From nobody Wed Oct 18 14:54:00 2023 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 4S9YlD3fR3z4x7cw; Wed, 18 Oct 2023 14:54:00 +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 4S9YlD38fsz3bTM; Wed, 18 Oct 2023 14:54:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697640840; 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=3ErViBt9fAfp3gmouH3VTbuVTnvES2Sh9g5RfeByptw=; b=sIQNjXog7vB4CtfNzoS+3l9f3s5nYuDt/DOY56MhmNm+gPXr+6CQhiircDlumT0H9V2fgU b66tOJhPbtMy4cNG4FMjwkWrMXlM0FIYB52zzO7Pe+I8uo12fzMGLvdaVn/3a8c48QNEQW cY63be8BP+jKQBuRCvo3nISaIS66WqxFB8X7HmGj530d5CZEcQfSzntytL5tV20YKpl78e twGqW+3ss+wcFB0B7y06rvlpofnrBi8PNWPOz26XdqIwBlccCw9m9GgWN9djYrfi79NY3H wAhN6eWap02bPIx5UvzsSpID6joG/9hYZe4OwS+M26eglMg/UIBgPh58RnmmCQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697640840; a=rsa-sha256; cv=none; b=fSAc5EEKr9KadJlH9AyivYog3MUc1vJapsC0BZOXwqt2Rw+KnRQOPS8bjcspKqfynwUk9X Vx3PVqlvkTKgwLB0xOUeKisLS9LLVqw40vRFf5WWCYrLskgAqx8Zu+X/dDXuGXXEe280Hd 5ET7Fu7XLVbQWawXHgVy0r9GwcCwD8MeYazlyPDZx0nCZdXfy0wuKiTnVXkwraAieef9cU sooo0ADKE5eIYBjjJYxnIgYfcbhE1GpkOTekr2iv7429XTY31cOPIKr021fHpdEHoIn8I0 7hj7Bg7ObZk9bgwERGspED/ByDpP1oWrdsg4CiG6MkOqpr2jGgdRcGa+AqzcQQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697640840; 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=3ErViBt9fAfp3gmouH3VTbuVTnvES2Sh9g5RfeByptw=; b=dbmLIfPDh9EW/aP9Ic99CVruNNB/YmlFAsZQ30tiQWJ2j37QOcOcsd3eHtg/KwH1WpULhC /8HoTKH183Kd5Bgi6qsnk5CoFu32iNEwaLDj5DS2cEoW+r/CJb6B9CmHj/lo7DhGUewHet RRTLQnFI6QgOVrNtdTaGJ2CpWNEBXDr7Sm+800oLdpEY06wjHQJPEG+ZE94Kv5ilaUyhpk fGE/ICEjM32O+HO6BIYfrd2RGY+vzYz0facO//vdPqIUrPhKtbSoD0eyWvtRUrfbpmHY9C 2A1tY+5yDJbhFR/UqlTT9ewRB89pOAZcW2ImEdy8nM5sDM39C8wl+yIafzi8Ew== 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 4S9YlD2BbWz19jV; Wed, 18 Oct 2023 14:54:00 +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 39IEs0MM026439; Wed, 18 Oct 2023 14:54:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39IEs0sF026436; Wed, 18 Oct 2023 14:54:00 GMT (envelope-from git) Date: Wed, 18 Oct 2023 14:54:00 GMT Message-Id: <202310181454.39IEs0sF026436@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: c0f52443166a - main - 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/main X-Git-Reftype: branch X-Git-Commit: c0f52443166ae7ecd512ab0350469d9c3648788c Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=c0f52443166ae7ecd512ab0350469d9c3648788c commit c0f52443166ae7ecd512ab0350469d9c3648788c Author: Ed Maste AuthorDate: 2023-09-12 02:59:30 +0000 Commit: Ed Maste CommitDate: 2023-10-18 14:48:58 +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 --- 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 438e13a51154..30e78f9bffa2 100644 --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -2894,6 +2894,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 @@ -2914,6 +2923,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} @@ -2926,6 +2936,7 @@ install_from_index () { fi ;; L) + dir_conflict "${BASEDIR}/${FPATH}" # Create a symlink ln -sfh ${HASH} ${BASEDIR}/${FPATH} ;; @@ -2962,10 +2973,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