Move functions to common-functions for reuse.

Change-Id: I12a5687d94df678d7f7e8c0b075ee4aba1082156
This commit is contained in:
Robert Collins 2013-06-20 16:47:22 +12:00 committed by Chris Jones
parent 0b1ff7d4b0
commit a969be49a2
4 changed files with 43 additions and 42 deletions

View File

@ -87,7 +87,7 @@ TMP_MOUNT_PATH=$TMP_BUILD_DIR/mnt
echo "working in $TMP_MOUNT_PATH"
create_base
create_ramdisk_base
populate_lib
populate_busybox
populate_init

View File

@ -187,3 +187,44 @@ function arg_to_elements() {
echo "Expanded element dependencies to: $IMAGE_ELEMENT"
}
function create_base () {
mkdir $TMP_BUILD_DIR/mnt
export TMP_MOUNT_PATH=$TMP_BUILD_DIR/mnt
# Copy data in to the root.
TARGET_ROOT=$TMP_MOUNT_PATH run_d root
if [ -z "$(ls $TMP_MOUNT_PATH | grep -v lost+found)" ] ; then
# Nothing copied in, use Ubuntu.
echo "Adding ubuntu element as / had no contents"
IMAGE_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $IMAGE_ELEMENT ubuntu)
generate_hooks
echo "Now building: $IMAGE_ELEMENT"
TARGET_ROOT=$TMP_MOUNT_PATH run_d root
fi
# Configure Image
# Setup resolv.conf so we can chroot to install some packages
if [ -L $TMP_MOUNT_PATH/etc/resolv.conf ] || [ -f $TMP_MOUNT_PATH/etc/resolv.conf ] ; then
sudo mv $TMP_MOUNT_PATH/etc/resolv.conf $TMP_MOUNT_PATH/etc/resolv.conf.ORIG
fi
# Recreate resolv.conf
sudo touch $TMP_MOUNT_PATH/etc/resolv.conf
sudo chmod 777 $TMP_MOUNT_PATH/etc/resolv.conf
# use system configured resolv.conf if available to support internal proxy resolving
if [ -e /etc/resolv.conf ]
then
cat /etc/resolv.conf > $TMP_MOUNT_PATH/etc/resolv.conf
else
echo nameserver 8.8.8.8 > $TMP_MOUNT_PATH/etc/resolv.conf
fi
mount_proc_dev_sys
}
function mount_proc_dev_sys () {
# supporting kernel file systems
sudo mount -t proc none $TMP_MOUNT_PATH/proc
sudo mount --bind /dev $TMP_MOUNT_PATH/dev
sudo mount -t sysfs none $TMP_MOUNT_PATH/sys
}

View File

@ -53,46 +53,6 @@ function ensure_sudo () {
sudo echo "Ensuring sudo is available"
}
function create_base () {
mkdir $TMP_BUILD_DIR/mnt
export TMP_MOUNT_PATH=$TMP_BUILD_DIR/mnt
# Copy data in to the root.
TARGET_ROOT=$TMP_MOUNT_PATH run_d root
if [ -z "$(ls $TMP_MOUNT_PATH | grep -v lost+found)" ] ; then
# Nothing copied in, use Ubuntu.
echo "Adding ubuntu element as / had no contents"
IMAGE_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $IMAGE_ELEMENT ubuntu)
generate_hooks
echo "Now building: $IMAGE_ELEMENT"
TARGET_ROOT=$TMP_MOUNT_PATH run_d root
fi
# Configure Image
# Setup resolv.conf so we can chroot to install some packages
if [ -L $TMP_MOUNT_PATH/etc/resolv.conf ] || [ -f $TMP_MOUNT_PATH/etc/resolv.conf ] ; then
sudo mv $TMP_MOUNT_PATH/etc/resolv.conf $TMP_MOUNT_PATH/etc/resolv.conf.ORIG
fi
# Recreate resolv.conf
sudo touch $TMP_MOUNT_PATH/etc/resolv.conf
sudo chmod 777 $TMP_MOUNT_PATH/etc/resolv.conf
# use system configured resolv.conf if available to support internal proxy resolving
if [ -e /etc/resolv.conf ]
then
cat /etc/resolv.conf > $TMP_MOUNT_PATH/etc/resolv.conf
else
echo nameserver 8.8.8.8 > $TMP_MOUNT_PATH/etc/resolv.conf
fi
mount_proc_dev_sys
}
function mount_proc_dev_sys () {
# supporting kernel file systems
sudo mount -t proc none $TMP_MOUNT_PATH/proc
sudo mount --bind /dev $TMP_MOUNT_PATH/dev
sudo mount -t sysfs none $TMP_MOUNT_PATH/sys
}
# Helper function to run a command inside the chroot
function run_in_target () {
# Force the inclusion of /usr/local/bin in PATH, this is needed for some

View File

@ -56,7 +56,7 @@ function ensure_binaries() {
export BINARY_DEPS
}
function create_base () {
function create_ramdisk_base () {
echo "Creating base system"
mkdir -p "$TMP_MOUNT_PATH/bin"