2018-10-25 21:55:20 +03:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
2019-06-26 22:20:21 +03:00
|
|
|
Vagrant.require_version ">= 2.2.0"
|
|
|
|
|
2019-05-20 20:26:11 +03: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 21:55:20 +03:00
|
|
|
# Vagrant file for setting up a build environment for Proton.
|
2019-05-20 20:26:11 +03: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
|
2020-04-21 15:59:47 +03:00
|
|
|
memory = [memory, 4096].max
|
2019-05-20 20:26:11 +03:00
|
|
|
puts "Platform: " + cpus.to_s + " CPUs, " + memory.to_s + " MB memory"
|
2018-10-25 21:55:20 +03:00
|
|
|
|
|
|
|
Vagrant.configure(2) do |config|
|
2019-05-07 22:01:31 +03: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-11-02 20:36:24 +03:00
|
|
|
config.vm.provider "virtualbox" do |v|
|
2020-03-28 02:29:11 +03:00
|
|
|
v.cpus = [cpus, 32].min # virtualbox limit is 32 cpus
|
2019-05-20 20:26:11 +03:00
|
|
|
v.memory = memory
|
2018-11-02 20:36:24 +03:00
|
|
|
end
|
2018-10-25 21:55:20 +03:00
|
|
|
|
2019-05-07 22:01:31 +03:00
|
|
|
config.vm.provider "libvirt" do |v|
|
2019-05-20 20:26:11 +03:00
|
|
|
v.cpus = cpus
|
|
|
|
v.memory = memory
|
2019-05-07 22:01:31 +03:00
|
|
|
v.random_hostname = true
|
|
|
|
v.default_prefix = ENV['USER'].to_s.dup.concat('_').concat(File.basename(Dir.pwd))
|
|
|
|
end
|
|
|
|
|
2019-10-04 16:16:29 +03:00
|
|
|
#deiban10-based build VM
|
|
|
|
config.vm.define "debian10", primary: true do |debian10|
|
2018-11-19 22:08:55 +03:00
|
|
|
|
2019-10-04 16:16:29 +03:00
|
|
|
debian10.vm.box = "generic/debian10"
|
2018-11-19 22:08:55 +03:00
|
|
|
|
2019-10-04 16:16:29 +03:00
|
|
|
debian10.vm.synced_folder "./vagrant_share/", "/vagrant/", create: true, type: "sshfs", sshfs_opts_append: "-o cache=no"
|
|
|
|
debian10.vm.synced_folder ".", "/home/vagrant/proton", id: "proton", type: "rsync", rsync__exclude: ["vagrant_share"]
|
2018-11-19 22:08:55 +03:00
|
|
|
|
2019-10-04 16:16:29 +03:00
|
|
|
debian10.vm.provision "shell", privileged: "true", inline: <<-SHELL
|
|
|
|
#install docker and steam-runtime dependencies
|
|
|
|
dpkg --add-architecture i386
|
|
|
|
apt-get update
|
|
|
|
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
|
2018-12-05 20:21:36 +03:00
|
|
|
|
2019-10-04 16:16:29 +03: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 buster stable"
|
2018-11-19 22:08:55 +03:00
|
|
|
|
2019-10-04 16:16:29 +03:00
|
|
|
#install host build-time dependencies
|
|
|
|
apt-get update
|
2020-08-17 18:06:22 +03:00
|
|
|
apt-get install -y ccache texinfo gpgv2 gnupg2 git docker-ce docker-ce-cli containerd.io \
|
2019-10-07 22:14:58 +03:00
|
|
|
fontforge-nox python-debian python-pip meson libmpc-dev libmpc-dev:i386 \
|
|
|
|
gcc g++ gcc-i686-linux-gnu g++-i686-linux-gnu binutils-i686-linux-gnu \
|
|
|
|
gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 \
|
|
|
|
g++-mingw-w64-i686 g++-mingw-w64-x86-64
|
|
|
|
|
|
|
|
update-alternatives --set x86_64-w64-mingw32-gcc `which x86_64-w64-mingw32-gcc-posix`
|
|
|
|
update-alternatives --set x86_64-w64-mingw32-g++ `which x86_64-w64-mingw32-g++-posix`
|
|
|
|
update-alternatives --set i686-w64-mingw32-gcc `which i686-w64-mingw32-gcc-posix`
|
|
|
|
update-alternatives --set i686-w64-mingw32-g++ `which i686-w64-mingw32-g++-posix`
|
2019-08-16 21:06:09 +03:00
|
|
|
|
2019-10-04 16:16:29 +03:00
|
|
|
#install adobe font devkit to build source san hans
|
|
|
|
pip install afdko
|
2018-12-05 20:21:36 +03:00
|
|
|
|
2019-10-04 16:16:29 +03:00
|
|
|
#allow vagrant user to run docker
|
|
|
|
adduser vagrant docker
|
2018-11-19 22:08:55 +03:00
|
|
|
|
2020-06-29 19:01:56 +03:00
|
|
|
#add steamrt docker
|
|
|
|
docker build -t "steam-proton-dev" -f "/home/vagrant/proton/steamrt/com.valvesoftware.SteamRuntime.Sdk-amd64,i386-soldier-sysroot.Dockerfile" /home/vagrant/proton/steamrt/
|
|
|
|
|
|
|
|
#allow user to run stuff in steamrt
|
|
|
|
sysctl kernel.unprivileged_userns_clone=1
|
|
|
|
mkdir -p /etc/sysctl.d/
|
|
|
|
echo kernel.unprivileged_userns_clone=1 > /etc/sysctl.d/docker_user.conf
|
|
|
|
|
2019-10-04 16:16:29 +03:00
|
|
|
# the script below will set up the steam-runtime docker containers
|
|
|
|
sudo -u vagrant /home/vagrant/proton/vagrant-user-setup.sh
|
2019-11-25 22:08:03 +03:00
|
|
|
|
|
|
|
#ensure we use only the mingw-w64 that we built
|
|
|
|
apt-get remove -y '*mingw-w64*'
|
2019-10-04 16:16:29 +03:00
|
|
|
SHELL
|
|
|
|
end
|
2018-10-25 21:55:20 +03:00
|
|
|
end
|