diff --git a/diskimage_builder/elements/ubuntu-core/root.d/10-cache-ubuntu-image b/diskimage_builder/elements/ubuntu-core/root.d/10-cache-ubuntu-image index cd00ca2a9..9f16abfd6 100755 --- a/diskimage_builder/elements/ubuntu-core/root.d/10-cache-ubuntu-image +++ b/diskimage_builder/elements/ubuntu-core/root.d/10-cache-ubuntu-image @@ -29,7 +29,7 @@ DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://cdimage.ubuntu.com/ubuntu-core/relea BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-ubuntu-core-$numeric_release-core-$ARCH.tar.gz} SHA256SUMS=${SHA256SUMS:-$DIB_CLOUD_IMAGES/SHA256SUMS} CACHED_FILE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE -CACHED_FILE_LOCK=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE.lock +CACHED_FILE_LOCK=$DIB_LOCKFILES/$BASE_IMAGE_FILE.lock CACHED_SUMS=$DIB_IMAGE_CACHE/SHA256SUMS.ubuntu-core.$DIB_RELEASE.$ARCH function get_ubuntu_tarball() { diff --git a/diskimage_builder/elements/ubuntu/root.d/10-cache-ubuntu-tarball b/diskimage_builder/elements/ubuntu/root.d/10-cache-ubuntu-tarball index a6ece7680..41241a5b5 100755 --- a/diskimage_builder/elements/ubuntu/root.d/10-cache-ubuntu-tarball +++ b/diskimage_builder/elements/ubuntu/root.d/10-cache-ubuntu-tarball @@ -17,7 +17,7 @@ DIB_RELEASE=${DIB_RELEASE:-trusty} BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$DIB_RELEASE-server-cloudimg-$ARCH-root.tar.gz} SHA256SUMS=${SHA256SUMS:-https://${DIB_CLOUD_IMAGES##http?(s)://}/$DIB_RELEASE/current/SHA256SUMS} CACHED_FILE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE -CACHED_FILE_LOCK=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE.lock +CACHED_FILE_LOCK=$DIB_LOCKFILES/$BASE_IMAGE_FILE.lock CACHED_SUMS=$DIB_IMAGE_CACHE/SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH function get_ubuntu_tarball() { diff --git a/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot b/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot index d2a3a8a6e..027a58425 100755 --- a/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot +++ b/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot @@ -201,14 +201,14 @@ function _install_pkg_manager { --installroot $TARGET_ROOT \ install $@ ${_lang_pack} ${_extra_pkgs} && rc=$? || rc=$? - # We modified the base system - make sure we clean up always! - rm $HOME/.rpmmacros.dib.lock + # Note we've modified the base system's .rpmmacros. Ensure we + # clean it up *always* # sed makes it easy to remove last line, but not last n lines... sed -i '$ d' $HOME/.rpmmacros; sed -i '$ d' $HOME/.rpmmacros; if [ $rc != 0 ]; then die "Initial yum install to chroot failed! Can not continue." fi - ) 9>$HOME/.rpmmacros.dib.lock + ) 9>$DIB_LOCKFILES/.rpmmacros.dib.lock # Set gpg path back because subsequent actions will take place in # the chroot diff --git a/diskimage_builder/lib/disk-image-create b/diskimage_builder/lib/disk-image-create index 70b1db7aa..24eb62ddf 100644 --- a/diskimage_builder/lib/disk-image-create +++ b/diskimage_builder/lib/disk-image-create @@ -166,9 +166,16 @@ done export DIB_DEBUG_TRACE +# TODO: namespace this under ~/.cache/dib/ for consistency export DIB_IMAGE_CACHE=${DIB_IMAGE_CACHE:-~/.cache/image-create} mkdir -p $DIB_IMAGE_CACHE +# We have a couple of critical sections (touching parts of the host +# system or download images to common cache) that we use flock around. +# Use this directory for lockfiles. +export DIB_LOCKFILES=${DIB_LOCKFILES:-~/.cache/dib/lockfiles} +mkdir -p $DIB_LOCKFILES + if [ "$CLEAR_ENV" = "1" -a "$HOME" != "" ]; then echo "Re-execing to clear environment." echo "(note this will prevent much of the local_config element from working)"