From nobody Sun Jan 07 21:25:53 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T7Vc14SqYz561gf; Sun, 7 Jan 2024 21:25:53 +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 4T7Vc12NPcz48sL; Sun, 7 Jan 2024 21:25:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704662753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2BwlHhqoUmq+FT+MbfdmiFq5nYTaMNJXYqKPnk2G0k4=; b=kTTW7MHjKzFutY+kA3kdUE8Qy0wsEkXnKLGlQhZp7M5f+kvf5Ua4IiMZjk3UuUnEsXVaB1 wtGKUGwOz1CCje3c3HVTbx4U4e0kkO/WAjWCMUEnDKPhTWo0JLkQgKh6y97/LlAv3jAQih b1CwKt6Wmp87keo4hn/YAwEh4JkBTXsJsCWDF8T8KEwK86iAZLN9tLOxLSq6hWleq8wZIy GqEm2mCocyV6f/lCGSobf6CEtfHgzrSh2HaxTRe6Fc5fZ07tkQS/M0byb4huSMEB0mhf5r 7gi4efagj5XTFLyjBix3exqSSvEyuLqB5yDXs+cFzHxApdl4QqUubjJav8YVLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704662753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2BwlHhqoUmq+FT+MbfdmiFq5nYTaMNJXYqKPnk2G0k4=; b=lVIle0l/3HGnYJv7FpIJLm3WpcG+O9uHY2kFwWDpqski6SiTnGQ0fajGqOZ3hA5t95gqSk mmp0+dUNR6VLvfVOp89sLsEa/qnYj9266zt76NNse01d2ACO6b9TguCUpYySfAyPp8zpCt 7VXOEtXpP0SxKWpBCqlN4cUmIScWkboALO3LLeWtnS6gKicVgCGt3QvmzkdoFXHBvuUWqi ycB8E19JU4EQqfVWDSV5IvZP80ZFHE3FOcyGR0muZBQfB7TWOui1C0ouZ8TtVncune5qj5 zfHkbd4H6zBDTIvhE1O6LVpOcFFOfI/NrbLp2e0cFvIXMGaXvc+3fTYE/AMJXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704662753; a=rsa-sha256; cv=none; b=k6IFqv6dnDCZOudKkiw6M1Pp0faSxVaUuKPWHbW5HWFDg6MFqvSX2K1iWxwRCnYctNqi6c x4jd4rthvxAQkkgIurl6rgnPJX6w9tTljS5qCqY13JWEopgBirY541sgK8ljWPS0u9RcD7 6yzosPDQEarXDI+Q9FxERK9hKw+FmpbjNeJPgFPMqwpYKQ1NmNaKqThjBfuNwp+LTJQM/s TDViKAcyz8b3K+wr0OXRH+I4CTexdDALXNvik0KaLCU1PaeVUvgziYrpSL0lhNe/AlL0or 13THXO+1RT/46feGA448aPlCz9NxxJXEJrumrpALgYLKl+4YCSbStGMWzjF3+w== 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 4T7Vc11PwCzgS3; Sun, 7 Jan 2024 21:25:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 407LPrxP084033; Sun, 7 Jan 2024 21:25:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 407LPriU084030; Sun, 7 Jan 2024 21:25:53 GMT (envelope-from git) Date: Sun, 7 Jan 2024 21:25:53 GMT Message-Id: <202401072125.407LPriU084030@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 01e31d1d875f - stable/13 - freebsd-update: handle directories changing to files List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 01e31d1d875f43a9d9c2d8f033409cbc7901c7ab Auto-Submitted: auto-generated The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=01e31d1d875f43a9d9c2d8f033409cbc7901c7ab commit 01e31d1d875f43a9d9c2d8f033409cbc7901c7ab Author: Ed Maste AuthorDate: 2023-09-12 02:59:30 +0000 Commit: Ed Maste CommitDate: 2024-01-07 20:41:48 +0000 freebsd-update: handle directories changing to files Further to f6d37c9ca13f ("freebsd-update: handle file -> directory on upgrade"), handle the reverse case of a directory changing to a file. We may not encounter this case on upgradess (before freebsd-update is retired) but it is needed to support rollback. PR: 273950 Reviewed by: dim Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41945 (cherry picked from commit c0f52443166ae7ecd512ab0350469d9c3648788c) (cherry picked from commit 1cf8528fec85a965baa5df2d8852166437af88a6) --- usr.sbin/freebsd-update/freebsd-update.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh index f5289e1cd9fc..7408ef1c6721 100644 --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -2899,6 +2899,15 @@ backup_kernel () { set +f } +# Check for and remove an existing directory that conflicts with the file or +# symlink that we are going to install. +dir_conflict () { + if [ -d "$1" ]; then + echo "Removing conflicting directory $1" + rm -rf -- "$1" + fi +} + # Install new files install_from_index () { # First pass: Do everything apart from setting file flags. We @@ -2919,6 +2928,7 @@ install_from_index () { -m ${PERM} ${BASEDIR}/${FPATH} ;; f) + dir_conflict "${BASEDIR}/${FPATH}" if [ -z "${LINK}" ]; then # Create a file, without setting flags. gunzip < files/${HASH}.gz > ${HASH} @@ -2931,6 +2941,7 @@ install_from_index () { fi ;; L) + dir_conflict "${BASEDIR}/${FPATH}" # Create a symlink ln -sfh ${HASH} ${BASEDIR}/${FPATH} ;; @@ -2967,10 +2978,14 @@ install_delete () { rmdir ${BASEDIR}/${FPATH} ;; f) - rm ${BASEDIR}/${FPATH} + if [ -f "${BASEDIR}/${FPATH}" ]; then + rm "${BASEDIR}/${FPATH}" + fi ;; L) - rm ${BASEDIR}/${FPATH} + if [ -L "${BASEDIR}/${FPATH}" ]; then + rm "${BASEDIR}/${FPATH}" + fi ;; esac done < killfiles