GRMLBASE/98-clean-chroot: avoid warning messages with resolvconf <1.80 master
authorMichael Prokop <mika@grml.org>
Fri, 29 May 2020 12:57:56 +0000 (14:57 +0200)
committerMichael Prokop <mika@grml.org>
Fri, 29 May 2020 13:02:45 +0000 (15:02 +0200)
In commit acf12d4123bd68f we got rid of /etc/resolvconf/run, and while
resolvconf >=1.80 no longer uses /etc/resolvconf/run, older
versions of resolvconf still use it in their libc update hook script. :-/

So while it really works e.g. on Debian/buster (as documented in
commit acf12d4123bd68f) with resolvconf v1.79, there's an ugly:

| /etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /etc/resolvconf/run/resolv.conf" for resolvconf versions

message when invoking "dhclient". Try to avoid this.

Related to https://github.com/grml/grml/issues/142

etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot

index f293e91..a00ebd6 100755 (executable)
@@ -189,7 +189,20 @@ else
   echo "Setting up resolvconf"
   rm -f "${target}"/etc/resolvconf/resolv.conf.d/original
   rm -f "${target}"/etc/resolv.conf
-  ln -s /run/resolvconf/resolv.conf "${target}"/etc/resolv.conf
+
+  # avoid "/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a
+  # symbolic link to /etc/resolvconf/run/resolv.conf" for resolvconf versions
+  # before 1.80
+  RESOLVCONF_VERSION=$($ROOTCMD dpkg-query -W -f='${Version}\n' resolvconf || true)
+  echo "-> Identified resolvconf version '${RESOLVCONF_VERSION}'"
+  if dpkg --compare-versions "${RESOLVCONF_VERSION}" lt 1.80 ; then
+    echo "-> Installing resolvconf symlink for versions <1.80"
+    ln -s /etc/resolvconf/run/resolv.conf "${target}"/etc/resolv.conf
+  else
+    echo "-> Installing resolvconf symlink for versions >=1.80"
+    ln -s /run/resolvconf/resolv.conf "${target}"/etc/resolv.conf
+  fi
+
 fi
 
 # make sure we don't leak any mdadm configurations