Move functions to common-functions for reuse.
Change-Id: I12a5687d94df678d7f7e8c0b075ee4aba1082156
This commit is contained in:
parent
0b1ff7d4b0
commit
a969be49a2
@ -87,7 +87,7 @@ TMP_MOUNT_PATH=$TMP_BUILD_DIR/mnt
|
|||||||
|
|
||||||
echo "working in $TMP_MOUNT_PATH"
|
echo "working in $TMP_MOUNT_PATH"
|
||||||
|
|
||||||
create_base
|
create_ramdisk_base
|
||||||
populate_lib
|
populate_lib
|
||||||
populate_busybox
|
populate_busybox
|
||||||
populate_init
|
populate_init
|
||||||
|
@ -187,3 +187,44 @@ function arg_to_elements() {
|
|||||||
|
|
||||||
echo "Expanded element dependencies to: $IMAGE_ELEMENT"
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -53,46 +53,6 @@ function ensure_sudo () {
|
|||||||
sudo echo "Ensuring sudo is available"
|
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
|
# Helper function to run a command inside the chroot
|
||||||
function run_in_target () {
|
function run_in_target () {
|
||||||
# Force the inclusion of /usr/local/bin in PATH, this is needed for some
|
# Force the inclusion of /usr/local/bin in PATH, this is needed for some
|
||||||
|
@ -56,7 +56,7 @@ function ensure_binaries() {
|
|||||||
export BINARY_DEPS
|
export BINARY_DEPS
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_base () {
|
function create_ramdisk_base () {
|
||||||
echo "Creating base system"
|
echo "Creating base system"
|
||||||
|
|
||||||
mkdir -p "$TMP_MOUNT_PATH/bin"
|
mkdir -p "$TMP_MOUNT_PATH/bin"
|
||||||
|
Loading…
Reference in New Issue
Block a user