Remove img-functions from ramdisk-image-create.

Ramdisk-image-create sources both img-functions and ramdisk-functions
causing duplicate functions. To correct this situation this patch
removes the import of img-functions from ramdisk-image-create.
It moves cleanup_dirs and run_d functions from img-functions to
common-functions to allow this.

fixes bug 1175427
Authored-by: Chris Krelle <nobodycam@gmail.com>

Change-Id: I971d019b0d92b06d9de661663b49c433e823ea42
This commit is contained in:
Chris Krelle 2013-05-06 09:11:49 -07:00
parent 7893e23435
commit 76d8d98a60
3 changed files with 20 additions and 20 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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