Page MenuHomeFreeBSD

Add automated (non interactive) mode to etcupdate

Authored by kmoore on Jun 6 2018, 3:11 PM.


Group Reviewers

As apart of us using etcupdate in TrueOS with package base, we needed to add support for running etcupdate non-interactively. This new -a flag just defaults to keeping the old file in /etc when a conflict cannot be properly merged. In our use-case the user would then re-run etcupdate at some later point without the -a flag to deal with the conflicts by hand.

Test Plan

We're already using this in production in TrueOS, so far so good.

Diff Detail

rS FreeBSD src repository - subversion
Lint Skipped
Unit Tests Skipped
Build Status
Buildable 17041

Event Timeline

bcr added a subscriber: bcr.

OK from manpages, if you bump the .Dd upon commit.

This revision is now accepted and ready to land.Jun 6 2018, 3:35 PM

Just bumped the date on .Dd, thanks @bcr

This revision now requires review to proceed.Jun 6 2018, 5:01 PM

So I would perhaps try to make this more flexible and to more closely match the svn syntax (this is akin to 'svn resolve --accept working') by supporting 'etcupdate -a <mode>' where 'mode' is one of the prompt options (but not 'p', just 'mf' or 'tf' and possibly the 'mine-full' and 'theirs-full' aliases). In that case I would probably call the variable "resolve_mode" or some such (automated means different things to different people and I think it is too ambiguous to use here).

Also, as implemented this only affects 'etcupdate resolve' but not 'etcupdate' (the default command). The manpage and usage are incorrect, but I actually think it would be more useful to be able to specify this option for the default command, but that means changing the logic in merge_file() to consult the 'resolve_mode' and only call new_conflict if it does not specify a valid mode. (This means you could also specify 'resolve_mode=mf' in /etc/etcupdate.conf to change the default without having to alter the command line invocation for TrueOS if you wished and not having to call 'etcupdate resolve', just 'etcupdate' itself.)

Finally, there are some existing tests for etcupdate that test conflicts. It would be good to extend those to test that the new conflict modes work as well.

Also, one thing that may not be clear from the commit log: etcupdate already doesn't prompt for the "default" command. It is only "etcupdate resolve" that prompts the user. If you are currently only using '-a' with 'etcupdate' currently then this change isn't actually doing anything as it only changes the behavior of 'etcupdate resolve'. (One reason one might want a default resolve action though is that 'etcupdate' refuses to perform an update if there are previously-unresolved conflicts from an earlier run.)

I'm going to close this for now. With the incoming changes to package base this may become unnecessary moving forward. We'll maintain the local patch in TrueOS for the time being until we drop it there also.