From 97d94019946b7b1c0d80020bb0776694fb02f5b8 Mon Sep 17 00:00:00 2001 From: Marcel Telka <marcel@telka.sk> Date: Tue, 02 Apr 2024 08:08:00 +0200 Subject: [PATCH] Add domdf_python_tools Python project --- Vagrantfile | 115 +++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 74 insertions(+), 41 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 6c19113..81c80ed 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -12,60 +12,93 @@ # # Copyright 2016 Adam Stevko. All rights reserved. +# Copyright 2017 Michal Nowak +# Copyright 2021 David Stes # Vagrant.configure("2") do |config| - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "openindiana/hipster" + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "openindiana/hipster" - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - config.vm.box_check_update = true + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + config.vm.box_check_update = true - # Unless OpenIndiana is better supported in vagrant, we have to use this - # workaround. The problem is with vagrant creating folder as root:root, - # but rsync connects as vagrant and fails to write. - config.vm.synced_folder ".", "/vagrant", type: "rsync", - rsync__args: ["--verbose", "--archive", "-z", "--copy-links"], - rsync__rsync_path: "pfexec rsync", owner: "vagrant", group: "vagrant" + # Unless OpenIndiana is better supported in vagrant, we have to use this + # workaround. The problem with vagrant is that it creates folder as root:root, + # but rsync connects as vagrant and thus fails to write. + config.vm.synced_folder ".", "/vagrant", type: "rsync", + rsync__args: ["--verbose", "--archive", "-zz", "--copy-links"], + rsync__rsync_path: "pfexec rsync", owner: "vagrant", group: "vagrant" - # Autoconfigure resources for development VM. The snippet is taken from - # https://stefanwrobel.com/how-to-make-vagrant-performance-not-suck. - # We allocate 1/4 of available system memory and CPU core count of the host - # to the VM, so performance does not suck. - config.vm.provider "virtualbox" do |v| + # Autoconfigure resources for development VM. The snippet is taken from + # https://stefanwrobel.com/how-to-make-vagrant-performance-not-suck. + # We allocate 1/4 of available system memory and CPU core count of the host + # to the VM, so performance does not suck. host = RbConfig::CONFIG['host_os'] - # Give VM 1/4 system memory and CPU core count - if host =~ /darwin/ - # sysctl returns Bytes and we need to convert to MB - mem = `sysctl -n hw.memsize`.to_i / 1024 - cpus = `sysctl -n hw.ncpu`.to_i / 4 + # Get memory size and CPU cores amount + if host =~ /solaris/ + mem = `/usr/sbin/prtconf|grep Memory|cut -f3 -d' '`.to_i * 1024 * 1024 + cpus = `/usr/sbin/psrinfo|wc -l`.to_i + elsif host =~ /darwin/ + # sysctl returns Bytes + mem = `sysctl -n hw.memsize`.to_i + cpus = `sysctl -n hw.ncpu`.to_i elsif host =~ /linux/ - # meminfo shows KB and we need to convert to MB - mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 - cpus = `grep -c Processor /proc/cpuinfo`.to_i / 4 + # meminfo shows size in kB; convert to Bytes + mem = `awk '/MemTotal/ {print $2}' /proc/meminfo`.to_i * 1024 + cpus = `getconf _NPROCESSORS_ONLN`.to_i elsif host =~ /mswin|mingw|cygwin/ - # Windows code via https://github.com/rdsubhas/vagrant-faster - mem = `wmic computersystem Get TotalPhysicalMemory`.split[1].to_i / 1024 - cpus = 2 + # Windows code via https://github.com/rdsubhas/vagrant-faster + mem = `wmic computersystem Get TotalPhysicalMemory`.split[1].to_i + cpus = `echo %NUMBER_OF_PROCESSORS%`.to_i + else + puts "Unsupported operating system" + exit end - mem = mem / 1024 / 4 + # Give VM 1/4 system memory as well as CPU core count + mem /= 1024 ** 2 * 4 + cpus /= 4 - v.customize ["modifyvm", :id, "--memory", mem] - v.customize ["modifyvm", :id, "--cpus", cpus] - end + config.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--memory", mem] + v.customize ["modifyvm", :id, "--cpus", cpus] - # Once vagrant is able to chown files on OpenIndiana, chown line should be - # removed from this part. - config.vm.provision "shell", inline: <<-SHELL - pfexec chown -R vagrant:vagrant /vagrant - pfexec pkg install build-essential + v.customize ["storagectl", :id, "--name", "SATA Controller", "--hostiocache", "on"] + # Enable following line, if oi-userland directory is on non-rotational + # drive (e.g. SSD). (This could be automated, but with all those storage + # technologies (LVM, partitions, ...) on all three operationg systems, + # it's actually error prone to detect it automatically.) macOS has it + # enabled by default as recent Macs have SSD anyway. + if host =~ /darwin/ + v.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 0, "--nonrotational", "on"] + else + #v.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 0, "--nonrotational", "on"] + end + # Should we ever support `--discard` option, we need to switch to VDI + # virtual disk format first. + #v.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 0, "--discard", "on"] + config.vm.synced_folder ".", "/vagrant_mounted" + end - cd /vagrant && gmake setup - echo "VM ready, happy contributing!" - SHELL + config.vm.provider :libvirt do |libvirt| + libvirt.memory = mem + libvirt.cpus = cpus + end + + # Once vagrant is able to chown files on OpenIndiana, chown line should be + # removed from this part. + config.vm.provision "shell", inline: <<-SHELL + pfexec chown -R vagrant:vagrant /vagrant + pfexec pkg install build-essential + + cd /vagrant && gmake setup + pfexec pkg set-publisher --non-sticky -g file:///vagrant/i386/repo userland + pfexec pkg set-publisher --non-sticky openindiana.org + echo "VM is ready, happy contributing!" + SHELL end -- Gitblit v1.9.3