From owner-freebsd-current@FreeBSD.ORG Sun May 10 16:58:30 2009 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 837E1106564A; Sun, 10 May 2009 16:58:30 +0000 (UTC) (envelope-from jeremie@le-hen.org) Received: from smtp4-g21.free.fr (smtp4-g21.free.fr [212.27.42.4]) by mx1.freebsd.org (Postfix) with ESMTP id 7290A8FC15; Sun, 10 May 2009 16:58:22 +0000 (UTC) (envelope-from jeremie@le-hen.org) Received: from smtp4-g21.free.fr (localhost [127.0.0.1]) by smtp4-g21.free.fr (Postfix) with ESMTP id C0F2E4C813B; Sun, 10 May 2009 18:58:17 +0200 (CEST) Received: from endor.tataz.chchile.org (tataz.chchile.org [82.233.239.98]) by smtp4-g21.free.fr (Postfix) with ESMTP id DC3494C8176; Sun, 10 May 2009 18:58:14 +0200 (CEST) Received: from obiwan.tataz.chchile.org (obiwan.tataz.chchile.org [192.168.1.222]) by endor.tataz.chchile.org (Postfix) with ESMTP id 0F6A633E61; Sun, 10 May 2009 16:57:38 +0000 (UTC) Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000) id DCCDC5082A; Sun, 10 May 2009 18:57:37 +0200 (CEST) Date: Sun, 10 May 2009 18:57:37 +0200 From: Jeremie Le Hen To: dougb@FreeBSD.org Message-ID: <20090510165737.GB88857@obiwan.tataz.chchile.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="yrj/dFKFPuw6o+aM" Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Cc: freebsd-current@FreeBSD.org Subject: New mergemaster option -I, failsafe install files X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 May 2009 16:58:30 -0000 --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Doug, As you may guess from my multiple emails, I'm in the process of upgrading my jails :-). Since I have one jail per service, a very few number of configuration files are modified on each jail. As most of user of FreeBSD I think, I'm used to run "mergemaster -iU" to automate the process as much as possible. The problem with service jails (chapter 15.6.1 of the handbook) is that / is read-only mounted on all jails, /etc /var /root and a few other places being symlinks to /s, the private read-write space of each jail. Thus when mergemaster tries to update /boot/devices.hints it fails and abort. Therefore I've implemented a new -I option that does the same thing as -i except that it will proceed on failure. At the end of the process, it will also show an informational message about files that could not be installed. This patch along with the fix I sent you a few hours ago allows to use mergemaster(8) in service jails flawlessly. Best regards, -- Jeremie Le Hen < jeremie at le-hen dot org >< ttz at chchile dot org > --yrj/dFKFPuw6o+aM Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="mergemaster-I.diff" Index: mergemaster.8 =================================================================== RCS file: /mnt/space/cvsroot/src/usr.sbin/mergemaster/mergemaster.8,v retrieving revision 1.41 diff -u -r1.41 mergemaster.8 --- mergemaster.8 23 Mar 2009 14:42:41 -0000 1.41 +++ mergemaster.8 10 May 2009 08:18:32 -0000 @@ -32,7 +32,7 @@ .Nd merge configuration files, et al during an upgrade .Sh SYNOPSIS .Nm -.Op Fl scrvahipFCPU +.Op Fl scrvahiIpFCPU .Op Fl m Ar /path/to/sources .Op Fl t Ar /path/to/temp/root .Op Fl d @@ -209,6 +209,9 @@ .It Fl i Automatically install any files that do not exist in the destination directory. +.It Fl I +Automatically install any files that do not exist in the +destination directory, but proceed on failure. .It Fl p Pre-buildworld mode. Compares only files known to be essential to the success of Index: mergemaster.sh =================================================================== RCS file: /mnt/space/cvsroot/src/usr.sbin/mergemaster/mergemaster.sh,v retrieving revision 1.69 diff -u -r1.69 mergemaster.sh --- mergemaster.sh 23 Mar 2009 14:42:41 -0000 1.69 +++ mergemaster.sh 10 May 2009 11:16:39 -0000 @@ -15,7 +15,7 @@ display_usage () { VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4` echo "mergemaster version ${VERSION_NUMBER}" - echo 'Usage: mergemaster [-scrvahipFCPU]' + echo 'Usage: mergemaster [-scrvahiIpFCPU]' echo ' [-m /path] [-t /path] [-d] [-u N] [-w N] [-A arch] [-D /path]' echo "Options:" echo " -s Strict comparison (diff every pair of files)" @@ -25,6 +25,7 @@ echo " -a Leave all files that differ to merge by hand" echo " -h Display more complete help" echo ' -i Automatically install files that do not exist in destination directory' + echo ' -I Automatically install files that do not exist in destination directory, but proceed on failure' echo ' -p Pre-buildworld mode, only compares crucial files' echo ' -F Install files that differ only by revision control Id ($FreeBSD)' echo ' -C Compare local rc.conf variables to the defaults' @@ -265,7 +266,7 @@ # Check the command line options # -while getopts ":ascrvhipCPm:t:du:w:D:A:FU" COMMAND_LINE_ARGUMENT ; do +while getopts ":ascrvhiIpCPm:t:du:w:D:A:FU" COMMAND_LINE_ARGUMENT ; do case "${COMMAND_LINE_ARGUMENT}" in A) ARCHSTRING='TARGET_ARCH='${OPTARG} @@ -303,6 +304,10 @@ i) AUTO_INSTALL=yes ;; + I) + AUTO_INSTALL=yes + AUTO_INSTALL_FAILSAFE=yes + ;; C) COMP_CONFS=yes ;; @@ -763,9 +768,17 @@ # Create directories as needed # install_error () { - echo "*** FATAL ERROR: Unable to install ${1} to ${2}" - echo '' - exit 1 + case "${AUTO_INSTALL_FAILSAFE}" in + '') + echo "*** FATAL ERROR: Unable to install ${1} to ${2}" + echo '' + exit 1 + ;; + *) + AUTO_FAILED_INSTALLED_FILES="${AUTO_FAILED_INSTALLED_FILES} $2/${1##*/} +" + ;; + esac } do_install_and_rm () { @@ -781,11 +794,14 @@ if [ ! -d "${3}/${2##*/}" ]; then if install -m ${1} ${2} ${3}; then unlink ${2} + return 0 else install_error ${2} ${3} + return 1 fi else install_error ${2} ${3} + return 1 fi } @@ -824,7 +840,7 @@ NEED_CAP_MKDB=yes ;; /etc/master.passwd) - do_install_and_rm 600 "${1}" "${DESTDIR}${INSTALL_DIR}" + do_install_and_rm 600 "${1}" "${DESTDIR}${INSTALL_DIR}" || return 1 NEED_PWD_MKDB=yes DONT_INSTALL=yes ;; @@ -1113,6 +1129,28 @@ ;; esac +case "${AUTO_FAILED_INSTALLED_FILES}" in +'') ;; +*) + case "${AUTO_RUN}" in + '') + ( + echo '*** You chose the automatic install option for files that did not' + echo ' exist on your system. The following could not be installed:' + echo "${AUTO_FAILED_INSTALLED_FILES}" + echo '' + ) | ${PAGER} + ;; + *) + echo '' + echo '*** You chose the automatic install option for files that did not' + echo ' exist on your system. The following could not be installed:' + echo "${AUTO_FAILED_INSTALLED_FILES}" + ;; + esac + ;; +esac + case "${AUTO_UPGRADED_FILES}" in '') ;; *) --yrj/dFKFPuw6o+aM--