Merge "Move /tmp/ccache setup to base element"

This commit is contained in:
Jenkins 2013-10-11 08:57:06 +00:00 committed by Gerrit Code Review
commit 5907b2fa43
7 changed files with 31 additions and 10 deletions

View File

@ -10,3 +10,8 @@ Notes:
This may be as simple as having language-pack-XX installed in the
pre-install stage
* This element ensures /tmp/ccache will be available in the chroot
during the root, extra-data, pre-install, install and post-install
stages. /tmp/ccache is unavailable during block-device, finalise
and cleanup stages as it will have been automatically unmounted
by then.

View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
# As this is run in cleanup, it's already been automatically unmounted,
# so all we need to do here is remove the directory
sudo rmdir $TMP_MOUNT_PATH/tmp/ccache || true

View File

@ -1,4 +0,0 @@
#!/bin/bash
set -e
rmdir /tmp/ccache || true

15
elements/base/root.d/01-ccache Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e
# Don't do anything if already mounted (if disk-image-create is invoked with
# no elements specified, this hook actually fires twice, once during
# `run_d root` for the base element, then again when `run_d root` is called
# after automatically pulling in the Ubuntu element)
grep " $TMP_MOUNT_PATH/tmp/ccache" /proc/mounts && exit
DIB_CCACHE_DIR=${DIB_CCACHE_DIR:-$HOME/.cache/image-create/ccache}
mkdir -p $DIB_CCACHE_DIR
sudo mkdir -p $TMP_MOUNT_PATH/tmp/ccache
sudo mount --bind $DIB_CCACHE_DIR $TMP_MOUNT_PATH/tmp/ccache

View File

@ -241,8 +241,10 @@ function create_base () {
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.
if [ -z "$(ls $TMP_MOUNT_PATH | grep -v '^lost+found\|tmp$')" ] ; then
# Nothing copied in, use Ubuntu. Note the test above allows
# root.d elements to put things in /tmp, and still have the
# automatic Ubuntu behaviour.
echo "Adding ubuntu element as / had no contents"
IMAGE_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $IMAGE_ELEMENT ubuntu)
generate_hooks

View File

@ -20,4 +20,3 @@ FS_TYPE=${FS_TYPE:-ext4}
# Used to set the file extension only at this stage.
IMAGE_TYPE=${IMAGE_TYPE:-qcow2}
IMAGE_NAME=${IMAGE_NAME:-image}
DIB_CCACHE_DIR=${DIB_CCACHE_DIR:-~/.cache/image-create/ccache}

View File

@ -75,9 +75,6 @@ function run_d_in_target () {
sudo mkdir $TMP_MOUNT_PATH/tmp/in_target.d
sudo mount --bind ${TMP_HOOKS_PATH} $TMP_MOUNT_PATH/tmp/in_target.d
sudo mount -o remount,ro,bind ${TMP_HOOKS_PATH} $TMP_MOUNT_PATH/tmp/in_target.d
sudo mkdir -p $TMP_MOUNT_PATH/tmp/ccache
mkdir -p $DIB_CCACHE_DIR
sudo mount --bind $DIB_CCACHE_DIR $TMP_MOUNT_PATH/tmp/ccache
check_break before-$1 run_in_target bash
trap "check_break after-error run_in_target bash" ERR
run_in_target dib-run-parts /tmp/in_target.d/$1.d