diff --git a/diskimage_builder/lib/common-functions b/diskimage_builder/lib/common-functions index a7f3666d..dd4efc74 100644 --- a/diskimage_builder/lib/common-functions +++ b/diskimage_builder/lib/common-functions @@ -342,7 +342,9 @@ function create_base () { # Save resolv.conf as created by the initial install. Note the # .ORIG file is an exported interface -- it may be modified and we # will copy it back in during finalisation of the image. - if [[ -e $TMP_MOUNT_PATH/etc/resolv.conf ]]; then + # Note that we use -L and -f to test here as test (and bash [[) + # return false with -e if the link target does not exist. + 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 diff --git a/diskimage_builder/lib/img-functions b/diskimage_builder/lib/img-functions index c861bdd5..d5f929cf 100644 --- a/diskimage_builder/lib/img-functions +++ b/diskimage_builder/lib/img-functions @@ -116,7 +116,9 @@ function finalise_base () { # Remove the resolv.conf we created and put the original (or # perhaps modified) version back. sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf - if [ -e $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ]; then + # Note that we use -L and -f to test here as test (and bash [[) + # return false with -e if the link target does not exist. + if [ -L $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] || [ -f $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] ; then sudo mv $TMP_MOUNT_PATH/etc/resolv.conf.ORIG $TMP_MOUNT_PATH/etc/resolv.conf fi fi