Bug 286072 - etcupdate(8) fails to build "current" tree with read-only /usr/src
Summary: etcupdate(8) fails to build "current" tree with read-only /usr/src
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-13 08:40 UTC by Alastair Hogge
Modified: 2025-04-25 00:51 UTC (History)
7 users (show)

See Also:


Attachments
failed etcupdate(8) log (203.58 KB, text/plain)
2025-04-13 08:44 UTC, Alastair Hogge
no flags Details
proposed patch (1.26 KB, patch)
2025-04-14 17:15 UTC, Mark Johnston
no flags Details | Diff
proposed patch (1.09 KB, patch)
2025-04-14 17:19 UTC, Mark Johnston
no flags Details | Diff
successful etcupdate(8) log (488.23 KB, text/plain)
2025-04-15 11:12 UTC, Alastair Hogge
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alastair Hogge 2025-04-13 08:40:52 UTC

    
Comment 1 Alastair Hogge 2025-04-13 08:44:04 UTC
Created attachment 259520 [details]
failed etcupdate(8) log

The entire log from running etcupdate(8) post installkernel, and installworld.
Comment 2 Alastair Hogge 2025-04-13 12:03:11 UTC
Mailing list thread:
https://lists.freebsd.org/archives/freebsd-current/2025-April/007399.html
Comment 3 Mark Johnston freebsd_committer freebsd_triage 2025-04-14 15:27:10 UTC
So we're supposed to be staging nsswitch.conf in the object, but instead we're copying it elsewhere in the src tree: "cp -f /usr/src/lib/libc/net/nsswitch.conf /usr/src/lib/libc/nsswitch.conf".  From the build log there's an object under /var/db/etcupdate/etcupdate-JN3IPm7, so that seems surprising.
Comment 4 Mark Johnston freebsd_committer freebsd_triage 2025-04-14 17:03:31 UTC
Oh, this is because the buildetc target builds all with SUBDIR_OVERRIDE=etc... which was fine back when etc files lived in /usr/src/etc, but now doesn't really work now that they're scattered all over the tree. :(
Comment 5 Mark Johnston freebsd_committer freebsd_triage 2025-04-14 17:15:05 UTC
Created attachment 259552 [details]
proposed patch

If it's possible to test a patch, I'd appreciate you trying this one.
Comment 6 Mark Johnston freebsd_committer freebsd_triage 2025-04-14 17:19:40 UTC
Created attachment 259553 [details]
proposed patch

The previous patch was wrong, thanks to Kyle for pointing that out.
Comment 7 Alastair Hogge 2025-04-15 11:12:12 UTC
Created attachment 259580 [details]
successful etcupdate(8) log

successful etcupdate(8) log
Comment 8 Alastair Hogge 2025-04-15 11:14:57 UTC
(In reply to Mark Johnston from comment #5)
> If it's possible to test a patch, I'd appreciate you trying this one.

Yes! I updated one host so far, from 1016b3c344350fa5968f16852e5e4e388c51d817[1], to 168d873ae41fd8bd40555322a79c9f215cb4cb9c[2], and the etcupdate(8) process completed successfully. Thanks so much.

1: https://cgit.freebsd.org./src/commit/?id=1016b3c344350fa5968f16852e5e4e388c51d817
2: https://cgit.freebsd.org./src/commit/?id=168d873ae41fd8bd40555322a79c9f215cb4cb9c
Comment 9 commit-hook freebsd_committer freebsd_triage 2025-04-24 14:36:07 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f83ec40fca52e1e2319b5d4f770f8263378265d6

commit f83ec40fca52e1e2319b5d4f770f8263378265d6
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-04-24 14:32:41 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-04-24 14:32:41 +0000

    Makefile.inc1: Let the buildetc target run outside of etc

    Commit 49bc071f4088 ("nsswitch.conf: Avoid modification after
    installation") changes handling of nsswitch.conf such that we make a
    copy in the objdir during a build.  Historically, the in-tree
    nsswitch.conf lived under etc.

    The buildetc target and its copy set SUBDIR_OVERRIDE=etc when building
    the object tree, but I think this isn't right when conf files are
    scattered around the src tree.  If any of them require non-trivial
    processing, they'll get skipped during buildetc, and then some
    build-time commands may run during installetc.  In the linked PR, this
    fails because the src tree is mounted read-only and no objdir was
    created during buildetc.

    Remove the SUBDIR_OVERRIDE for the _obj target, and build the
    buildconfig target across the tree.

    PR:             286072
    Fixes:          49bc071f4088 ("nsswitch.conf: Avoid modification after installation")
    Reviewed by:    brooks, dim
    Tested by:      dim, Alastair Hogge <agh@riseup.net>
    Differential Revision:  https://reviews.freebsd.org/D49960

 Makefile.inc1 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 10 Alastair Hogge 2025-04-25 00:51:02 UTC
Legends, thanks so much.