From nobody Wed Sep 6 17:37:30 2023 X-Original-To: dev-commits-src-branches@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 4RgqMG4qj8z4sQc4; Wed, 6 Sep 2023 17:37:30 +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 4RgqMG4Jk8z3dJB; Wed, 6 Sep 2023 17:37:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694021850; 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=4D1bbzu1VrJgJnQ7GtjY7ynDxvTFAeUyowcUrMfqhqk=; b=uVYhzFujdh8jjWlWCxyaHj/OXlIOhdizEwcs04AJSdxCJ+4JIKxDJoZ+bwZY1BVWJJIE2t W0KK0V03CyXLmfZGo3shDGTyi1+U1R+NRJvFhID40tTrLf6jXtGRD422dvOAoeKuCZG9WH ry6VhD9KIcNzlnRR8HN3T2hhIigzq6Zmah/xOxNzuwMeqC+9xtDTHYiTfg18AUsK/YAg6I LXxzrXg497n8XlxSUspb1C3nmrpP1kYq18KRvQBSdLFXJGTDjPQYSbZCL5QV78h/6BRz++ z+ciejX00W59s1gwUuJkMLi/dqjvSn2Gv7kgdIRe6HWi9XRF7sC/01ejBQpAeg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694021850; a=rsa-sha256; cv=none; b=OErBq3DSEr/Vo4Qz0JWPBzdkKT1GKJk518oAWlPiJxzpEmosm6uHv311hrPZdGiHdQpK0t VJg5wJOwWYlHLH4VidXVn7lQxwZKkBMA6wI7lQIRLc4qONMlipV6oG8Efj2S2satK7rZpx EY67Zv098SP2Xq07Os25Cnmn9Vcc1mIqCrmG3OYOPjbAFUdJPI07T38Sil0vEL894gXhJN IYmeKKUBKfoe2Yqivl/vcePK7RzYb9dK7xpAZTXm8uQHadOIgPIN7ZnFN7Dk084Am3Z1Tc g0FatYT0Inxx4vn+hmIwLq0kZyJ/UP1D9Aifi2Hr3ZVd1OX9i78bLvWRWouq8w== 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=1694021850; 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=4D1bbzu1VrJgJnQ7GtjY7ynDxvTFAeUyowcUrMfqhqk=; b=SrkzJNIgPpCeKyEOJE/FNrrS6uw1O+jbZakzoJleXqgTgw5wqxG0g3rgd6vJaVB6bDpwCl Mszpy4pBTTk9rtCX63J+1LUcTpzxtrWXBiHkfZh+DdC801w1CG6FZHBMTG6poozozekW9e dwR9eCJh6VGjiqH7x7ka1YNly3BqN3cCYsttNVw9DC/JtFPz78JxF3KaQWypoQXWftEdol qu8qjK+kyF39EtQtcc1VXSwX1F3rrqi4YX2vg9sK+tMrcBGxDPGsKE8oMXNrC2hjoPg5to DHndv0oewaO/2cy57JPiS+u+NagBl5SoqYM6OvMyYSAFtJzp6EjlbQjwqqRNEQ== 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 4RgqMG3NF6z9rt; Wed, 6 Sep 2023 17:37:30 +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 386HbUsf086345; Wed, 6 Sep 2023 17:37:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 386HbUCR086342; Wed, 6 Sep 2023 17:37:30 GMT (envelope-from git) Date: Wed, 6 Sep 2023 17:37:30 GMT Message-Id: <202309061737.386HbUCR086342@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 0b39d9de2e71 - releng/13.2 - freebsd-update: Fix merging already-updated files List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.2 X-Git-Reftype: branch X-Git-Commit: 0b39d9de2e7170c214b39f1aca42c11d6f7c13e9 Auto-Submitted: auto-generated The branch releng/13.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=0b39d9de2e7170c214b39f1aca42c11d6f7c13e9 commit 0b39d9de2e7170c214b39f1aca42c11d6f7c13e9 Author: Colin Percival AuthorDate: 2023-05-05 03:00:58 +0000 Commit: Gordon Tetlow CommitDate: 2023-09-06 16:56:24 +0000 freebsd-update: Fix merging already-updated files When performing an "upgrade" (moving between FreeBSD releases, as opposed to "update" which merely applies security/errata updates to the installed release) FreeBSD Update: 1. Generates a list of "files needing to be merged", namely those files which don't match the version installed in the "old" release and have paths matching the MergeChanges configuration directive (by default, /boot/device.hints and everything under /etc/). and later on, 2. Compares the currently-installed files to the versions in the "new" release, removing index entries for files which "don't need to be updated because they're not changing". Unfortunately if a file falls into both of these categories -- that is to say, if a file in /etc/ is the same as the version in the new release and not the same as the version in the old release -- the resulting "merge" step saw that the file was no longer listed as being part of the new release, resulting in the file being deleted. For the first 18 years of FreeBSD Update's existence, this never happened, since $FreeBSD$ tags resulted in "new release" files always being different from any files systems would already have installed. This commit fixes this behaviour by only placing a file into the "files needing to be merged" list if it does not match the version in the old release *or* the version in the new release. Reported by: des Reviewed by: delphij (earlier version), des, emaste Approved by: so Security: FreeBSD-EN-23:09.freebsd-update Differential Revision: https://reviews.freebsd.org/D39973 (cherry picked from commit c55b7e522629cb78adeb54bd9964304481d55eab) (cherry picked from commit 866e5c6b3ce7ca3e15a24180fa1a0dcbda7c4b0f) --- usr.sbin/freebsd-update/freebsd-update.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh index 4ef44d1ad000..4f779270926d 100644 --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -1677,11 +1677,12 @@ fetch_inspect_system () { echo "done." } -# For any paths matching ${MERGECHANGES}, compare $1 and $2 and find any -# files which differ; generate $3 containing these paths and the old hashes. +# For any paths matching ${MERGECHANGES}, compare $2 against $1 and $3 and +# find any files with values unique to $2; generate $4 containing these paths +# and their corresponding hashes from $1. fetch_filter_mergechanges () { # Pull out the paths and hashes of the files matching ${MERGECHANGES}. - for F in $1 $2; do + for F in $1 $2 $3; do for X in ${MERGECHANGES}; do grep -E "^${X}" ${F} done | @@ -1689,9 +1690,10 @@ fetch_filter_mergechanges () { sort > ${F}-values done - # Any line in $2-values which doesn't appear in $1-values and is a - # file means that we should list the path in $3. - comm -13 $1-values $2-values | + # Any line in $2-values which doesn't appear in $1-values or $3-values + # and is a file means that we should list the path in $3. + sort $1-values $3-values | + comm -13 - $2-values | fgrep '|f|' | cut -f 1 -d '|' > $2-paths @@ -1703,10 +1705,10 @@ fetch_filter_mergechanges () { while read X; do look "${X}|" $1-values | head -1 - done < $2-paths > $3 + done < $2-paths > $4 # Clean up - rm $1-values $2-values $2-paths + rm $1-values $2-values $3-values $2-paths } # For any paths matching ${UPDATEIFUNMODIFIED}, remove lines from $[123] @@ -2711,7 +2713,7 @@ upgrade_run () { # Based on ${MERGECHANGES}, generate a file tomerge-old with the # paths and hashes of old versions of files to merge. - fetch_filter_mergechanges INDEX-OLD INDEX-PRESENT tomerge-old + fetch_filter_mergechanges INDEX-OLD INDEX-PRESENT INDEX-NEW tomerge-old # Based on ${UPDATEIFUNMODIFIED}, remove lines from INDEX-* which # correspond to lines in INDEX-PRESENT with hashes not appearing