Bug 260281

Summary: etcupdate: dry-run (-n) causes following actual run to skip changes
Product: Base System Reporter: Tomoaki AOKI <junchoon>
Component: miscAssignee: John Baldwin <jhb>
Status: Closed FIXED    
Severity: Affects Only Me CC: grahamperrin, jhb
Priority: --- Flags: jhb: mfc-stable13?
jhb: mfc-stable12?
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Tomoaki AOKI 2021-12-08 21:50:50 UTC
Doing `etcupdate -n` itself runs OK, but following `etcupdate -B` does
NOT do anything, hence nothing is actually updated.
The only workaround I have is NOT to try dry-run.

This would be caused by any commit done in april 2021 on main (MFC'ed to stable/13 in june 2021).
It would be because the same trees are used for dry-run and actual run.
(Not looked into the code. Just a thought.)

Maybe using dedicated trees (older one is copied from actual current
one, building current tree on dedicated place and delete them every
time the dry-run finishes) for dry-run would fix.

And copying /etc to some temporary place and applying changes to it,
copy back to /etc may be help for your issue, I think.
Comment 1 commit-hook freebsd_committer freebsd_triage 2022-05-25 21:03:18 UTC
A commit in branch main references this bug:

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

commit 431944fb5ffff5ad56e720b75b7beecdc4878e0e
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-05-25 21:02:51 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-25 21:02:51 +0000

    etcupdate: Don't rotate trees for a dry run.

    When performing a dry run, remove the temporary tree created rather
    than rotating the trees.  Rotating the trees meant that etcupdate
    thought the latest changes were already merged and would not merge
    them on the next real run.

    PR:             260281
    Reported by:    Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
    Fixes:          0611aec3cf3a etcupdate: Always extract to a temporary tree.
    MFC after:      1 week

 usr.sbin/etcupdate/etcupdate.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Comment 2 Tomoaki AOKI 2022-06-18 23:30:39 UTC
(In reply to commit-hook from comment #1)

Thanks!
Tried with several updates touching /etc on main and looks working fine.

After the trial on main, manually cherry picked to stable13 and confirmed also works fine. Not tested on other branches as I don't have working environment.

I'll close this once this is MFC'ed to stable13 and MFS'ed to releng13.
(Not sure stable12 and releng12 are affected or not.)

Sorry for the late answer as I had to confirm for multiple updates to be sure.
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-07-13 18:01:55 UTC
A commit in branch stable/13 references this bug:

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

commit 5d7b7a98e5ed56a33bdafbeb57c2e85e0ae0aab5
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-05-25 21:02:51 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-07-13 18:00:45 +0000

    etcupdate: Don't rotate trees for a dry run.

    When performing a dry run, remove the temporary tree created rather
    than rotating the trees.  Rotating the trees meant that etcupdate
    thought the latest changes were already merged and would not merge
    them on the next real run.

    PR:             260281
    Reported by:    Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
    Fixes:          0611aec3cf3a etcupdate: Always extract to a temporary tree.

    (cherry picked from commit 431944fb5ffff5ad56e720b75b7beecdc4878e0e)

 usr.sbin/etcupdate/etcupdate.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-07-13 18:01:57 UTC
A commit in branch stable/12 references this bug:

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

commit c4aa309d232cd1014e6eaae7043c29f8d45f5319
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-05-25 21:02:51 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-07-13 18:01:04 +0000

    etcupdate: Don't rotate trees for a dry run.

    When performing a dry run, remove the temporary tree created rather
    than rotating the trees.  Rotating the trees meant that etcupdate
    thought the latest changes were already merged and would not merge
    them on the next real run.

    PR:             260281
    Reported by:    Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
    Fixes:          0611aec3cf3a etcupdate: Always extract to a temporary tree.

    (cherry picked from commit 431944fb5ffff5ad56e720b75b7beecdc4878e0e)

 usr.sbin/etcupdate/etcupdate.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)