diff options
author | Paul Sokolovsky <paul.sokolovsky@linaro.org> | 2012-01-06 17:32:16 +0200 |
---|---|---|
committer | Paul Sokolovsky <paul.sokolovsky@linaro.org> | 2012-01-06 17:32:16 +0200 |
commit | b3fb0fa8fc8da5d05fa86060defdd621cd9a3b3d (patch) | |
tree | 3adf0afeddcaca7bb7348d93c208390c5621ca63 /node | |
parent | 1134ff2f3226e7fcfdc0f75261a443c2a04b5dce (diff) |
Allow to specify ramdisk size for a build with RAMDISK_SIZE build config var.
This was a bit tricky, as ramdisk mounting happens with root privs, and we don't
want to evaluate potentially arbitrary code in a build config with root privs.
So, set up as simple sudo sandox to query that var.
Diffstat (limited to 'node')
-rwxr-xr-x | node/build | 47 |
1 files changed, 34 insertions, 13 deletions
@@ -7,9 +7,25 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html ############################################################################### +# +# $1 = mirror service host +# $2 = build CONFIG, base64-encoded +# set -xe +# We need ramdisk size when executing under root, but still don't want +# to evaluate build config (== arbitrary code) as such. +function get_ramdisk_size () { + sudo -E -H -u jenkins-build bash -es "$1" <<\EOF + export CONFIGURATION="$(echo "$1" | base64 -id)" + set -a + eval "$CONFIGURATION" + set +a + echo $RAMDISK_SIZE +EOF +} + BUILD_SCRIPT_ROOT=$(readlink -f "$(dirname "${0}")/../build-scripts") # Stopgap measure to cleanup environment on instances reused for different jobs @@ -20,19 +36,24 @@ umount build || true rm -rf build mkdir build -# XXX mounting build/out on a tmpfs is probably a bit android specific... -mem_total=`cat /proc/meminfo | grep MemTotal | sed -s 's/[^0-9]*\([0-9]*\) kB/\1/'` -if [ "$mem_total" -gt 15680064 ] -then - echo using 11.75G tmpfs for build - mount -t tmpfs -o size=11750M tmpfs build -elif [ "$mem_total" -gt 10485760 ] -then - echo using 11.75G tmpfs for build/out - mkdir build/out - mount -t tmpfs -o size=11750M tmpfs build/out -else - mkdir build/out +ramdisk_size=$(get_ramdisk_size $2) + +# Put build/* on a ramdisk to speed up build +if [ -z "$ramdisk_size" -o "$ramdisk_size" -gt 0 ]; then + mem_total=`cat /proc/meminfo | grep MemTotal | sed -s 's/[^0-9]*\([0-9]*\) kB/\1/'` + if [ "$mem_total" -gt 15680064 ]; then + ramisk_size=${ramdisk_size:-11750M} + echo "Using $ramdisk_size tmpfs for build" + mount -t tmpfs -o size=$ramdisk_size tmpfs build + elif [ "$mem_total" -gt 10485760 ]; then + # XXX mounting build/out on a tmpfs is probably a bit android specific... + ramisk_size=${ramdisk_size:-11750M} + echo "Using $ramdisk_size tmpfs for build/out" + mkdir build/out + mount -t tmpfs -o size=$ramdisk_size tmpfs build/out + else + mkdir build/out + fi fi chown jenkins-build:nogroup build |