From owner-dev-commits-src-branches@freebsd.org Thu Jul 8 05:13:29 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9845C662EB9; Thu, 8 Jul 2021 05:13:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GL4FP2vYxz58T4; Thu, 8 Jul 2021 05:13:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C3FF1AFE1; Thu, 8 Jul 2021 05:13:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1685DTXF083957; Thu, 8 Jul 2021 05:13:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1685DTrK083956; Thu, 8 Jul 2021 05:13:29 GMT (envelope-from git) Date: Thu, 8 Jul 2021 05:13:29 GMT Message-Id: <202107080513.1685DTrK083956@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 27e18c06f08b - stable/11 - mergemaster: handle symbolic links during update. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 27e18c06f08b413cd6d90922971194ae65921805 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2021 05:13:29 -0000 The branch stable/11 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=27e18c06f08b413cd6d90922971194ae65921805 commit 27e18c06f08b413cd6d90922971194ae65921805 Author: Warner Losh AuthorDate: 2020-11-18 19:22:24 +0000 Commit: Warner Losh CommitDate: 2021-07-08 05:13:18 +0000 mergemaster: handle symbolic links during update. /etc/os-release is now a symbolic link to a generated file. Make mergemaster cope with symbolic links generically. I'm no longer a big mergemaster user, so this has only been lightly tested by me, though Kimura-san has ran it through its paces. Submitted by: Yasushiro KIMURA-san PR: 242212 MFC After: 2 weeks (cherry picked from commit 30a56f9ef72705f2f3646ce4330cbc20675a465e) --- usr.sbin/mergemaster/mergemaster.sh | 118 +++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh index 086ee11db0f6..fdccf81802ea 100755 --- a/usr.sbin/mergemaster/mergemaster.sh +++ b/usr.sbin/mergemaster/mergemaster.sh @@ -1072,6 +1072,7 @@ for COMPFILE in `find . | sort` ; do fi done +# Compare regular files for COMPFILE in `find . -type f | sort`; do # First, check to see if the file exists in DESTDIR. If not, the @@ -1161,6 +1162,119 @@ for COMPFILE in `find . -type f | sort`; do fi # Yes, the file still remains to be checked done # This is for the for way up there at the beginning of the comparison +ask_answer_for_symbolic_link () { + HANDLE_COMPSYMLINK='' + while true; do + echo " Use 'd' to delete the temporary ${COMPSYMLINK}" + echo " Use 'i' to install the temporary ${COMPSYMLINK}" + echo '' + echo " Default is to leave the temporary symbolic link to deal with by hand" + echo '' + echo -n "How should I deal with this? [Leave it for later] " + read HANDLE_COMPSYMLINK + case ${HANDLE_COMPSYMLINK} in + ''|[dDiI]) + break + ;; + *) + echo "invalid choice: ${HANDLE_COMPSYMLINK}" + echo '' + HANDLE_COMPSYMLINK='' + ;; + esac + done +} + +install_symbolic_link () { + rm -f ${DESTDIR}${COMPSYMLINK#.} > /dev/null 2>&1 + if [ -L ${DESTDIR}${COMPSYMLINK#.} ]; then + return 1 + fi + cp -a ${COMPSYMLINK} ${DESTDIR}${COMPSYMLINK#.} > /dev/null 2>&1 + if [ ! -L ${DESTDIR}${COMPSYMLINK#.} ]; then + return 1 + fi + return 0 +} + +handle_symbolic_link () { + case ${HANDLE_COMPSYMLINK} in + [dD]) + rm ${COMPSYMLINK} + echo '' + echo " *** Deleting ${COMPSYMLINK}" + echo '' + return 1 + ;; + [iI]) + echo '' + if install_symbolic_link; then + rm ${COMPSYMLINK} + echo " *** ${COMPSYMLINK} installed successfully" + return 2 + else + echo " *** Problem installing ${COMPSYMLINK}, it will remain to merge by hand" + return 3 + fi + echo '' + ;; + '') + echo '' + echo " *** ${COMPSYMLINK} will remain for your consideration" + echo '' + return 0 + ;; + esac +} + +# Compare symblic links +for COMPSYMLINK in `find . -type l | sort`; do + if [ ! -L "${DESTDIR}${COMPSYMLINK#.}" ]; then + if [ -n "${AUTO_RUN}" -a -z "${AUTO_INSTALL}" ]; then + echo " *** ${COMPSYMLINK} will remain for your consideration" + continue + else + echo '' + echo " *** There is no installed version of ${COMPSYMLINK}" + echo '' + if [ -n "${AUTO_INSTALL}" ]; then + HANDLE_COMPSYMLINK="i" + else + ask_answer_for_symbolic_link + fi + handle_symbolic_link + if [ -n "${AUTO_INSTALL}" -a $? -eq 2 ]; then + AUTO_INSTALLED_FILES="${AUTO_INSTALLED_FILES} ${DESTDIR}${COMPSYMLINK#.} +" + fi + fi + elif [ $(readlink ${COMPSYMLINK}) = $(readlink ${DESTDIR}${COMPSYMLINK#.}) ]; then + echo " *** Temp ${COMPSYMLINK} and installed are the same, deleting" + rm ${COMPSYMLINK} + else + if [ -n "${AUTO_RUN}" -a -z "${AUTO_UPGRADE}" ]; then + echo " *** ${COMPSYMLINK} will remain for your consideration" + continue + else + echo '' + echo " *** Target of temp symbolic link is differnt from that of installed one" + echo " Temp (${COMPSYMLINK}): $(readlink ${COMPSYMLINK})" + echo " Installed (${DESTDIR}${COMPSYMLINK#.})): $(readlink ${DESTDIR}${COMPSYMLINK#.})" + echo '' + if [ -n "${AUTO_UPGRADE}" ]; then + HANDLE_COMPSYMLINK="i" + else + ask_answer_for_symbolic_link + fi + handle_symbolic_link + if [ -n "${AUTO_UPGRADE}" -a $? -eq 2 ]; then + AUTO_UPGRADED_FILES="${AUTO_UPGRADED_FILES} ${DESTDIR}${COMPSYMLINK#.} +" + fi + fi + fi +done + echo '' echo "*** Comparison complete" @@ -1172,10 +1286,10 @@ fi echo '' -TEST_FOR_FILES=`find ${TEMPROOT} -type f -size +0 2>/dev/null` +TEST_FOR_FILES=`find ${TEMPROOT} -type f -size +0 -or -type l 2>/dev/null` if [ -n "${TEST_FOR_FILES}" ]; then echo "*** Files that remain for you to merge by hand:" - find "${TEMPROOT}" -type f -size +0 | sort + find "${TEMPROOT}" -type f -size +0 -or -type l | sort echo '' case "${AUTO_RUN}" in