HomeFreeBSD

freebsd-update: Fix merging already-updated files

Description

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,

  1. 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)

Details

Provenance
cpercivaAuthored on May 5 2023, 3:00 AM
gordonCommitted on Sep 6 2023, 4:56 PM
Reviewer
delphij
Differential Revision
D39973: freebsd-update: Fix merging already-updated files
Parents
rG4341433a673f: Add UPDATING entries and bump version
Branches
Unknown
Tags
Unknown