Merge "Build raw image in separate tmpfs"

This commit is contained in:
Jenkins 2014-05-08 23:15:27 +00:00 committed by Gerrit Code Review
commit dcb5494e04

View File

@ -28,15 +28,17 @@ function tmpfs_check() {
function mk_build_dir () { function mk_build_dir () {
TMP_BUILD_DIR=$(mktemp -t -d --tmpdir=${TMP_DIR:-/tmp} image.XXXXXXXX) TMP_BUILD_DIR=$(mktemp -t -d --tmpdir=${TMP_DIR:-/tmp} image.XXXXXXXX)
TMP_IMAGE_DIR=$(mktemp -t -d --tmpdir=${TMP_DIR:-/tmp} image.XXXXXXXX)
[ $? -eq 0 ] || die "Failed to create tmp directory" [ $? -eq 0 ] || die "Failed to create tmp directory"
export TMP_BUILD_DIR export TMP_BUILD_DIR
if tmpfs_check ; then if tmpfs_check ; then
sudo mount -t tmpfs tmpfs $TMP_BUILD_DIR sudo mount -t tmpfs tmpfs $TMP_BUILD_DIR
sudo mount -t tmpfs tmpfs $TMP_IMAGE_DIR
fi fi
sudo chown $(id -u):$(id -g) $TMP_BUILD_DIR sudo chown $(id -u):$(id -g) $TMP_BUILD_DIR $TMP_IMAGE_DIR
trap cleanup EXIT trap cleanup EXIT
echo Building in $TMP_BUILD_DIR echo Building in $TMP_BUILD_DIR
export TMP_IMAGE_PATH=$TMP_BUILD_DIR/image.raw export TMP_IMAGE_PATH=$TMP_IMAGE_DIR/image.raw
export TMP_HOOKS_PATH=$TMP_BUILD_DIR/hooks export TMP_HOOKS_PATH=$TMP_BUILD_DIR/hooks
} }
@ -190,8 +192,8 @@ function mount_qcow_image() {
function cleanup_dirs () { function cleanup_dirs () {
sudo rm -rf $TMP_BUILD_DIR/built sudo rm -rf $TMP_BUILD_DIR/built
sudo rm -rf $TMP_BUILD_DIR/mnt sudo rm -rf $TMP_BUILD_DIR/mnt
sudo umount -f $TMP_BUILD_DIR || true sudo umount -f $TMP_BUILD_DIR $TMP_IMAGE_DIR || true
rm -rf $TMP_BUILD_DIR rm -rf $TMP_BUILD_DIR $TMP_IMAGE_DIR
} }
# Run a directory of hooks outside the target. # Run a directory of hooks outside the target.