From 5fa6e3e13c6ec421c174532e5cc4b1b4eb4aa822 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 6 Jul 2017 12:14:25 +1000 Subject: [PATCH] Add symlink test for resolv.conf restore We replace the base resolv.conf with an "outside" copy so that resolving works when we're in the chroot. Installing resolvconf package modifies the in-chroot resolv.conf to a symlink (to /var/run) which it wants maintained in the final image. We have the existing "immutable" check for a created resolv.conf file, but no eqivalent for a symlink. This adds a check to see if the resolv.conf is a symlink and leave it alone if it is, assuming it has been re-created in the chroot. I have tested this with ubuntu-minimal+resolvconf with dhcp-all-interfaces and the system seems to work with resolvconf working correctly. Change-Id: Idd5a26e9d55979bd951577d5b098ed4bfba91ad3 --- diskimage_builder/lib/img-functions | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/diskimage_builder/lib/img-functions b/diskimage_builder/lib/img-functions index 4fdf3011..d22c0d41 100644 --- a/diskimage_builder/lib/img-functions +++ b/diskimage_builder/lib/img-functions @@ -104,8 +104,15 @@ function run_d_in_target () { function finalise_base () { TARGET_ROOT=$TMP_MOUNT_PATH run_d cleanup - # If the file has been set immutable, we probably want to keep it - if lsattr $TMP_MOUNT_PATH/etc/resolv.conf | grep '^....i' >/dev/null ; then + # In create_base() we replaced/created the initial resolv.conf + # inside the image with a copy of the "outside" version so that + # resolving during the build will work. + # + # If that file has been replace with a symlink (resolvconf package + # can do this), or marked immutable, then don't restore the + # original version, just leave it alone. + if [ -L $TMP_MOUNT_PATH/etc/resolv.conf ] || \ + lsattr $TMP_MOUNT_PATH/etc/resolv.conf | grep '^....i' >/dev/null ; then # We're keeping the contents of resolv.conf set in the elements, # so remove the old saved file sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf.ORIG