jenkins-setup-build-environment: auto-detect RAM/CPU specs

This lets this setup run on more basic hardware, like schweiger/vibi.
This commit is contained in:
Hans-Christoph Steiner 2019-11-18 18:13:37 +01:00
parent 499d65f292
commit 1f363a889d
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA
1 changed files with 15 additions and 3 deletions

View File

@ -55,15 +55,27 @@ mkdir $VAGRANT_HOME
rm -rf "$WORKSPACE"/../*/.testfiles
cd $WORKSPACE
memtotal=$(grep ^MemTotal: /proc/meminfo | awk '{print $2}')
if [ $memtotal -gt 8092876 ]; then
memory=8192
else
memory=$(((memtotal / 1024) - 1024))
fi
if [ `nproc` -le 6 ]; then
cpus=$((`nproc` - 1))
else
cpus=6
fi
cat <<EOF > $WORKSPACE/makebuildserver.config.py
debian_mirror = 'http://deb.debian.org/debian/'
boot_timeout = 1200
apt_package_cache = True
copy_caches_from_host = True
memory = 8192
cpus = 6
memory = $memory
cpus = $cpus
EOF
cd $WORKSPACE
./makebuildserver -vv --clean
if [ -z "`vagrant box list | egrep '^buildserver\s+\((libvirt|virtualbox), [0-9]+\)$'`" ]; then