From nobody Tue May 09 23:30:48 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 4QGDtJ3DbCz49gxH; Tue, 9 May 2023 23:30:48 +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 4QGDtJ2fw3z3lVr; Tue, 9 May 2023 23:30:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683675048; 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=Er8DarG2VkObAQv+aLCLK52xGN3kFqk/rfZKziZb28o=; b=Nox1Aa3D1ovHW53f/3oqQ48XqLbWc6RQBY3HRyQOtUVmzo/i4TL3vjq7XhubPY8mNoaM0o VvyuYcbKdtRjambM0r/TpOGjcpTomqkfiwZe7+5BDQrqAbM8UvGiUva5hYMSGv3JryzKAj cP3XBgLgMbcWUCPZ5l9t5O4cZ8xfDYO3Ub+WxNRStGBHWvSMGqBHIfL6+8P9RVxlq8HePz Ow15gpJuegsN0syPoZxsOC/Sa2btPE9R7YT2Qzqf3xPEQtyT6qU407f3le7WvEy3JhJQry MxQ1bl3bLLGwprLigSWwakNhE90gsPAmLgHdoYOW575mgOK2TrJXj5LJ0PgtsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683675048; 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=Er8DarG2VkObAQv+aLCLK52xGN3kFqk/rfZKziZb28o=; b=Y937eBB5EOyYCLH4A/mErpHxycYOfZqKIaKwc6TQgz7IWMPjH2K7H2hAeKuFgmHRaK6Pxc jhU/b5Agn9xIQpLEBj4Zahe97nubXdKJ4iN/haoPhNjrWgCBXZ5BghnmuiwNr+DuGy266H 9uDBhtMqPngElTiA0LlmWvP5EV4cSj8e589ZCS+QbCxLHtjVZ7Lizh9rs0K29JIO6dQD4f S6CMct5Mx83BOxQwBn3UbrkY7xHfZUM8Gdgoajye9q0zDveQe9oL8vAYZ+M+7i2qcWkZIh FQerDLqbLekQKzU/YLKboZlllCpxvNdtKyjgS43C7OXAhMc3F8OPiixUVOJx7w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683675048; a=rsa-sha256; cv=none; b=I5FSn82td01nWNlriWVZOZWyf/c4+fdC2XgYD5OV4zjpDPewKfCCP5sv3vdRO+Xs3iAWa5 OBiKHzSoGUwagbmAsoikSAl58DfzKgjO61u84Wncltxc6DyF138eUmS4k5tczBWdg8BJsJ fu6yXxNofQBQHDagrAXqaf0H+HsgwUgJsW05NsnUE+LNJuQ/xhIscDIpNv/2yqUtmnGQv9 ZgNVAqa9EQ+ENHRCgJ8csoI8bSXd25BW00uYbKBAD88t9hdLJA5pwlhjNN+qZx1J0rGg9X q3ZPktaeDufzNWFVHBkjeCPArmhM1pFIK/58GwOd6DUyZn/xsTNq6RUG6aQ8Yw== 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 4QGDtJ1kQWzn24; Tue, 9 May 2023 23:30:48 +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 349NUmkR014378; Tue, 9 May 2023 23:30:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 349NUmsX014377; Tue, 9 May 2023 23:30:48 GMT (envelope-from git) Date: Tue, 9 May 2023 23:30:48 GMT Message-Id: <202305092330.349NUmsX014377@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: c55b7e522629 - main - freebsd-update: Fix merging already-updated 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: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c55b7e522629cb78adeb54bd9964304481d55eab Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=c55b7e522629cb78adeb54bd9964304481d55eab commit c55b7e522629cb78adeb54bd9964304481d55eab Author: Colin Percival AuthorDate: 2023-05-05 03:00:58 +0000 Commit: Colin Percival CommitDate: 2023-05-09 23:28:09 +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 MFC after: 7 days X-EN-Candidate: yes Differential Revision: https://reviews.freebsd.org/D39973 --- 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 03eefee75bbd..cbc153fc1af2 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