2018-10-25 20:55:20 +02:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
2019-06-26 21:20:21 +02:00
|
|
|
Vagrant.require_version ">= 2.2.0"
|
|
|
|
|
2019-05-20 19:26:11 +02:00
|
|
|
module OS
|
|
|
|
def OS.windows?
|
|
|
|
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def OS.mac?
|
|
|
|
(/darwin/ =~ RUBY_PLATFORM) != nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def OS.unix?
|
|
|
|
!OS.windows?
|
|
|
|
end
|
|
|
|
|
|
|
|
def OS.linux?
|
|
|
|
OS.unix? and not OS.mac?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-25 20:55:20 +02:00
|
|
|
# Vagrant file for setting up a build environment for Proton.
|
2019-05-20 19:26:11 +02:00
|
|
|
if OS.linux?
|
|
|
|
cpus = `nproc`.to_i
|
|
|
|
# meminfo shows KB and we need to convert to MB
|
|
|
|
memory = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 2
|
|
|
|
elsif OS.mac?
|
|
|
|
cpus = `sysctl -n hw.physicalcpu`.to_i
|
|
|
|
# sysctl shows bytes and we need to convert to MB
|
|
|
|
memory = `sysctl hw.memsize | sed -e 's/hw.memsize: //'`.to_i / 1024 / 1024 / 2
|
|
|
|
else
|
|
|
|
cpus = 1
|
|
|
|
memory = 1024
|
|
|
|
puts "Vagrant launched from unsupported platform."
|
|
|
|
end
|
|
|
|
puts "Platform: " + cpus.to_s + " CPUs, " + memory.to_s + " MB memory"
|
2018-10-25 20:55:20 +02:00
|
|
|
|
|
|
|
Vagrant.configure(2) do |config|
|
2019-05-07 21:01:31 +02:00
|
|
|
#libvirt doesn't have a decent synced folder, so we have to use vagrant-sshfs.
|
|
|
|
#This is not needed for virtualbox, but I couldn't find a way to use a
|
|
|
|
#different synced folder type per provider, so we always use it.
|
|
|
|
config.vagrant.plugins = "vagrant-sshfs"
|
|
|
|
|
2018-10-25 20:55:20 +02:00
|
|
|
config.vm.box = "generic/debian9"
|
|
|
|
|
2018-11-02 18:36:24 +01:00
|
|
|
config.vm.provider "virtualbox" do |v|
|
2019-05-20 19:26:11 +02:00
|
|
|
v.cpus = cpus
|
|
|
|
v.memory = memory
|
2018-11-02 18:36:24 +01:00
|
|
|
end
|
2018-10-25 20:55:20 +02:00
|
|
|
|
2019-05-07 21:01:31 +02:00
|
|
|
config.vm.provider "libvirt" do |v|
|
2019-05-20 19:26:11 +02:00
|
|
|
v.cpus = cpus
|
|
|
|
v.memory = memory
|
2019-05-07 21:01:31 +02:00
|
|
|
v.random_hostname = true
|
|
|
|
v.default_prefix = ENV['USER'].to_s.dup.concat('_').concat(File.basename(Dir.pwd))
|
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.synced_folder "./vagrant_share/", "/vagrant/", create: true, type: "sshfs", sshfs_opts_append: "-o cache=no"
|
|
|
|
config.vm.synced_folder ".", "/home/vagrant/proton", id: "proton", type: "rsync", rsync__exclude: ["vagrant_share"]
|
2018-10-25 20:55:20 +02:00
|
|
|
|
2018-12-05 18:21:36 +01:00
|
|
|
#this is where the VM is initialized on first setup
|
2018-10-25 20:55:20 +02:00
|
|
|
config.vm.provision "shell", privileged: "true", inline: <<-SHELL
|
2018-12-05 18:21:36 +01:00
|
|
|
#install docker and steam-runtime dependencies
|
2018-10-25 20:55:20 +02:00
|
|
|
dpkg --add-architecture i386
|
|
|
|
apt-get update
|
|
|
|
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
|
2018-11-19 20:08:55 +01:00
|
|
|
|
2018-10-25 20:55:20 +02:00
|
|
|
#add winehq repo
|
2019-01-02 14:51:56 +01:00
|
|
|
curl -fsSL https://dl.winehq.org/wine-builds/winehq.key | apt-key add -
|
2018-10-25 20:55:20 +02:00
|
|
|
echo 'deb http://dl.winehq.org/wine-builds/debian stretch main' > /etc/apt/sources.list.d/winehq.list
|
2018-11-19 20:08:55 +01:00
|
|
|
|
2018-10-25 20:55:20 +02:00
|
|
|
#add docker repo
|
|
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
|
|
|
|
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable"
|
2018-11-19 20:08:55 +01:00
|
|
|
|
2018-12-05 18:21:36 +01:00
|
|
|
#add backports
|
|
|
|
echo 'deb http://ftp.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/backports.list
|
|
|
|
|
2018-11-19 20:08:55 +01:00
|
|
|
#install host build-time dependencies
|
2018-10-25 20:55:20 +02:00
|
|
|
apt-get update
|
2019-06-03 19:47:31 +02:00
|
|
|
apt-get install -y gpgv2 gnupg2 g++ g++-6-multilib git docker-ce fontforge-nox python-debian schroot
|
2018-10-25 20:55:20 +02:00
|
|
|
apt-get -y -t stretch-backports install meson
|
2018-11-19 20:08:55 +01:00
|
|
|
|
2018-12-05 18:21:36 +01:00
|
|
|
#winehq-devel is installed to pull in dependencies to run Wine
|
|
|
|
apt-get install -y --install-recommends winehq-devel
|
|
|
|
|
2018-11-19 20:08:55 +01:00
|
|
|
#remove system Wine installation to ensure no accidental leakage
|
|
|
|
apt-get remove -y winehq-devel
|
|
|
|
|
|
|
|
#allow vagrant user to run docker
|
2018-10-25 20:55:20 +02:00
|
|
|
adduser vagrant docker
|
2019-06-03 19:47:31 +02:00
|
|
|
|
2019-06-24 20:51:54 +02:00
|
|
|
if ! schroot -i -c proton_crosscc >/dev/null 2>&1; then
|
2019-06-05 18:23:59 +02:00
|
|
|
#download build of recent mingw-w64 with dwarf2 exceptions enabled
|
2019-06-24 20:51:54 +02:00
|
|
|
wget --progress=dot -O /root/proton_crosscc.tar.xz 'http://repo.steampowered.com/proton_mingw/proton_mingw-9.1-1.tar.xz'
|
|
|
|
unxz -T0 /root/proton_crosscc.tar.xz
|
|
|
|
mkdir -p /srv/chroot/proton_crosscc/
|
|
|
|
tar -xf /root/proton_crosscc.tar -C /srv/chroot/proton_crosscc/
|
|
|
|
|
|
|
|
#install proton_crosscc schroot
|
|
|
|
cat > /etc/schroot/chroot.d/proton_crosscc <<EOF
|
|
|
|
[proton_crosscc]
|
2019-06-03 19:47:31 +02:00
|
|
|
description=Special mingw-w64 for building DXVK
|
|
|
|
type=directory
|
2019-06-24 20:51:54 +02:00
|
|
|
directory=/srv/chroot/proton_crosscc/
|
2019-06-03 19:47:31 +02:00
|
|
|
users=vagrant
|
|
|
|
personality=linux
|
|
|
|
preserve-environment=true
|
|
|
|
EOF
|
2019-06-05 18:23:59 +02:00
|
|
|
fi
|
2018-10-25 20:55:20 +02:00
|
|
|
SHELL
|
|
|
|
|
|
|
|
config.vm.provision "shell", privileged: "true", inline: <<-SHELL
|
|
|
|
# unprivileged shell still runs as root for some reason
|
2018-12-05 18:21:36 +01:00
|
|
|
|
|
|
|
# the script below will set up the steam-runtime docker containers
|
2018-10-25 20:55:20 +02:00
|
|
|
sudo -u vagrant /home/vagrant/proton/vagrant-user-setup.sh
|
|
|
|
SHELL
|
|
|
|
end
|