Last active
September 26, 2015 01:18
-
-
Save simon-engledew/1016273 to your computer and use it in GitHub Desktop.
Create a virtual build environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function chroot_jail { | |
TEMP="/tmp/$$.$(date +%s)" | |
mkdir "$TEMP" | |
sudo unionfs "$1=RW:/=RO" "$TEMP" -o allow_other -o dev -o cow | |
trap "sudo fusermount -u \"$TEMP\" && rm -r \"$TEMP\"" INT TERM EXIT | |
sudo chroot "$TEMP" /bin/bash -c "$(cat)" | |
} | |
chroot_jail out <<__CHROOT__ | |
__CHROOT__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function chroot_jail { | |
MOUNTS=$(printf ",%s" "${@:2}" "/") | |
MOUNTS="$1$MOUNTS" | |
TEMP="/tmp/$$.$(date +%s)" | |
mkdir "$TEMP" | |
sudo mhddfs "$MOUNTS" "$TEMP" -o allow_other -o dev | |
trap "sudo fusermount -u \"$TEMP\" && rm -r \"$TEMP\"" INT TERM EXIT | |
sudo chroot "$TEMP" /bin/bash -c "$(cat)" | |
} | |
chroot_jail output readonly <<__CHROOT__ | |
rvm install 1.9.2 | |
rvm use 1.9.2 | |
rvm gem install bundler-1.0.13.gem --no-rdoc --no-ri | |
__CHROOT__ | |
tar --file "rvm.tar" --create --preserve-permissions --directory output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment