diff --git a/bin/ramdisk-image-create b/bin/ramdisk-image-create index ea8f663c..62273472 100755 --- a/bin/ramdisk-image-create +++ b/bin/ramdisk-image-create @@ -56,7 +56,6 @@ for arg do RAMDISK_ELEMENT="$RAMDISK_ELEMENT $arg" ; done source $_LIB/ramdisk-defaults source $_LIB/common-functions -source $_LIB/img-functions source $_LIB/ramdisk-functions RAMDISK_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $RAMDISK_ELEMENT) diff --git a/lib/common-functions b/lib/common-functions index 9444f1d1..0343a0c1 100644 --- a/lib/common-functions +++ b/lib/common-functions @@ -141,3 +141,21 @@ function mount_qcow_image() { sudo mount ${NBD_DEV} $WORK_DIR fi } + +function cleanup_dirs () { + sudo rm -rf $TMP_BUILD_DIR/built + sudo rm -rf $TMP_BUILD_DIR/mnt + sudo umount $TMP_BUILD_DIR + rm -rf $TMP_BUILD_DIR +} + +# Run a directory of hooks outside the target. +function run_d() { + check_element + check_break before-$1 bash + if [ -d ${TMP_HOOKS_PATH}/$1.d ] ; then + run-parts ${TMP_HOOKS_PATH}/$1.d + fi + check_break after-$1 bash +} + diff --git a/lib/img-functions b/lib/img-functions index 3f1f3d96..557728ce 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -38,13 +38,6 @@ function cleanup () { cleanup_dirs } -function cleanup_dirs () { - sudo rm -rf $TMP_BUILD_DIR/built - sudo rm -rf $TMP_BUILD_DIR/mnt - sudo umount -f $TMP_BUILD_DIR || true - rm -rf $TMP_BUILD_DIR -} - function ensure_nbd () { NBD=`which qemu-nbd` || true if [ -z "$NBD" ]; then @@ -105,13 +98,13 @@ function mount_proc_dev_sys () { } # Helper function to run a command inside the chroot -function run_in_target() { +function run_in_target () { # -E to preserve http_proxy sudo -E chroot $TMP_MOUNT_PATH "$@" } # Helper function to run a directory of scripts inside the chroot -function run_d_in_target() { +function run_d_in_target () { check_element # If we can find a directory of hooks to run in the target filesystem, bind # mount it into the target and then execute run-parts in a chroot @@ -127,16 +120,6 @@ function run_d_in_target() { fi } -# Run a directory of hooks outside the target. -function run_d() { - check_element - check_break before-$1 bash - if [ -d ${TMP_HOOKS_PATH}/$1.d ] ; then - run-parts ${TMP_HOOKS_PATH}/$1.d - fi - check_break after-$1 bash -} - function prepare_first_boot () { check_break before-first-boot run_in_target bash if [ -d ${TMP_HOOKS_PATH}/first-boot.d ] ; then