Hi folks, I was quite happy to see Evgeni's patch for resolvconf-support in live-boot's git history, thanks!
Now I tried building a live-system with resolvconf and having an absolute symlink in includes.chroot for resolv.conf. This works around the install/remove logic of chroot_resolv.conf: - Without this the symlink installed by resolvconf in the chroot gets replaced by resolv.conf.orig when "chroot_resolv remove" runs. - This workaround has "chroot_resolv remove" "restore" replace the chroot's resolv.conf with the copy from includes.chroot, which works fine. However the build host - jessie, having resolvconf installed as well - ends up with a truncated resolv.conf after the build. I was able to track down the culprit to build/chroot_resolv:53 (git:debian-next) reading Truncate chroot/etc/resolv.conf.orig Possible solution*s* are attached (only one required). Personally I strongly prefer 0002, since it solves the underlying problem of files *outside* the build chroot getting modified. Thanks, Daniel
>From 2ce5d2917cc93622809e50060fdb7106d78bcc6c Mon Sep 17 00:00:00 2001 From: Daniel Reichelt <deb...@nachtgeist.net> Date: Tue, 21 Apr 2015 14:33:52 +0200 Subject: [PATCH 1/2] Don't truncate build host's resolv.conf if it's a symlink When resolvconf is to be included in the live image, the configtree requires to contain a symlink includes.chroot/etc/resolv.conf pointing to /etc/resolvconf/run/resolv.conf as a workaround for chroot_resolv's install/remove logic. However this falsly truncates the build host's resolv.conf --- scripts/build/chroot_resolv | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/build/chroot_resolv b/scripts/build/chroot_resolv index c976d61..0699139 100755 --- a/scripts/build/chroot_resolv +++ b/scripts/build/chroot_resolv @@ -50,7 +50,10 @@ case "${1}" in # # If you want to have a custom resolv.conf, please # overwrite it with normal local_includes mechanism. - Truncate chroot/etc/resolv.conf.orig + if [ ! -L chroot/etc/resolv.conf.orig ] + then + Truncate chroot/etc/resolv.conf.orig + fi elif [ -L chroot/etc/resolv.conf ] then # Move resolv.conf aside if it's a symlink (likely resolvconf) -- 2.1.4
>From a63b3df374021bdfbc8f72eff65eca1ab8b5728b Mon Sep 17 00:00:00 2001 From: Daniel Reichelt <deb...@nachtgeist.net> Date: Tue, 21 Apr 2015 14:46:36 +0200 Subject: [PATCH 2/2] Don't truncate files outside the build chroot The list of files passed to Truncate() might contain absolute symlinks pointing to files outside the chroot, which previously destroyed files on the build host. --- functions/chroot_resolv | 116 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 functions/chroot_resolv diff --git a/functions/chroot_resolv b/functions/chroot_resolv new file mode 100755 index 0000000..b165c3d --- /dev/null +++ b/functions/chroot_resolv @@ -0,0 +1,116 @@ +#!/bin/sh +echo "=======================" +ls -lisah /etc/resolv* +set -x + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <m...@daniel-baumann.ch> +## +## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING. +## This is free software, and you are welcome to redistribute it +## under certain conditions; see COPYING for details. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'manage /etc/resolv.conf')" +HELP="" +USAGE="${PROGRAM} {install|remove} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source +Set_defaults + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +case "${1}" in + install) + Echo_message "Configuring file /etc/resolv.conf" + + # Checking stage file + Check_stagefile .build/chroot_resolv + + # Checking lock file + Check_lockfile .lock + + # Creating lock file + Create_lockfile .lock + + if [ -e chroot/etc/resolv.conf ] + then + # Save resolv file or symlink + mv chroot/etc/resolv.conf chroot/etc/resolv.conf.orig + + # Also truncate it, otherwise we'll end up with the one + # created by debootstrap in the final image. + # + # If you want to have a custom resolv.conf, please + # overwrite it with normal local_includes mechanism. + if [ ! -L chroot/etc/resolv.conf.orig ] + then + Truncate chroot/etc/resolv.conf.orig + fi + elif [ -L chroot/etc/resolv.conf ] + then + # Move resolv.conf aside if it's a symlink (likely resolvconf) + mv chroot/etc/resolv.conf chroot/etc/resolv.conf.orig + fi + + if [ -f /etc/resolv.conf ] + then + # Copy resolv file + cp /etc/resolv.conf chroot/etc/resolv.conf + fi + + # Creating stage file + Create_stagefile .build/chroot_resolv + ;; + + remove) + Echo_message "Deconfiguring file /etc/resolv.conf" + + # Checking lock file + Check_lockfile .lock + + # Creating lock file + Create_lockfile .lock + + if [ -e config/includes.chroot/etc/resolv.conf ] + then + # Copying local resolv.conf + cp -a config/includes.chroot/etc/resolv.conf chroot/etc/resolv.conf + rm -f chroot/etc/resolv.conf.orig + elif [ -e chroot/etc/resolv.conf.orig ] || [ -L chroot/etc/resolv.conf.orig ] + then + # Restoring resolv file or symlink + mv chroot/etc/resolv.conf.orig chroot/etc/resolv.conf + else + # Truncating resolv file + Truncate chroot/etc/resolv.conf + fi + + # Clean up resolvconf's pollution + if [ -e chroot/etc/resolvconf/resolv.conf.d ] + then + rm -f chroot/etc/resolvconf/resolv.conf.d/original + rm -f chroot/etc/resolvconf/resolv.conf.d/tail + fi + + # Removing stage file + rm -f .build/chroot_resolv + ;; + + *) + Usage + ;; +esac +set -x +ls -lisah /etc/resolv* +echo "=======================" -- 2.1.4