Bug 252132 - mergemaster: needs to cope with empty $FreeBSD$ tags or /etc files must have $FreeBSD: number$
Summary: mergemaster: needs to cope with empty $FreeBSD$ tags or /etc files must have ...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-25 21:32 UTC by Trond.Endrestol
Modified: 2021-02-12 03:37 UTC (History)
7 users (show)

See Also:


Attachments
id_tools.tar.gz (1.32 KB, application/gzip)
2021-02-12 03:37 UTC, Katsuyuki Miyoshi
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Trond.Endrestol 2020-12-25 21:32:06 UTC
The $FreeBSD$ keyword is empty after the conversion to Git. Now, mergemaster(8) has nothing to compare other than actual file content.

Previously, users of "mergemaster -Fp" and "mergemaster -Fi" only merged files when the $FreeBSD$ keyword differed. Now, we find ourselves constantly merging files we have modified such as /etc/master.passwd and /etc/group.

Please fix mergemaster(8) or consider assigning values to the $FreeBSD$ keyword for files belonging in /etc. Maybe it can be as simple as "$FreeBSD: number$" where "number" must be incremented before running "git commit".

Finally, maybe it's time we all moved to etcupdate(8). Please advise the community.
Comment 1 Anton Saietskii 2021-01-04 14:16:16 UTC
Yep, mergemaster became almost completely useless without keywords. This should be considered as POLA violation.
Comment 2 Marek Zarychta 2021-01-04 23:12:50 UTC
(In reply to Anton Saietskii from comment #1)

No worries. I was told that mergemaster(8) is on its way out, but
$FreeBSD$ IDs can be regenerated in the local Git repository with clean/smudge filters. With them applied, "mergemaster -UFi" still works fine and also the administrator is able to better track the updates.

More info on configuring the filters can be found here:
https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes
Comment 3 Katsuyuki Miyoshi 2021-02-12 03:37:25 UTC
Created attachment 222381 [details]
id_tools.tar.gz

This is my personal solution.

My solution is to replace "$FreeBSD$" with "$FreeBSD: MD5 $".
(MD5 is the MD5 checksum of the source file.)

"$FreeBSD: MD5 $" is not the original "$FreeBSD$" format, but it is useful enough for mergemaster.

I'm happy with these. However, I don't know if these are enough for everyone who does various tasks. And, I don't even know what will happen to "$FreeBSD$" in the future.

I hope that a better response will be made.

Here are the steps:

===========================================================================
[Provides 3 files]
 replace_id.sh: This is a script that replaces "$FreeBSD ... $" in files installed by "make distribution" with "$FreeBSD: MD5 $".

 src_id.sh: This is a git filter script.

 post-commit: This is a git hook script.

----------------------------------------------------------------------
[0] Start with the mergemaster completed by the traditional way.
 It doesn't matter if you use a subversion repository, a git repository, or any revision of the source files. 

----------------------------------------------------------------------
[1-1] Backup the files installed by "make distribution" (That is, /etc/*, /root/*, and /boot/device.hints)
 It's not mandatory to do this, but I recommend that you back up your /etc, /root, /boot/device.hints files so that you can restore them in case of an accident.

[1-2] # sh replace_id.sh
   Make sure the SOURCEDIR and DESTDIR in replace_id.sh are correct and run replace_id.sh.

With the above, "$FreeBSD ... $" in files installed by "make distribution" will be replaced with "$FreeBSD: MD5 $". Make sure those files are not corrupted.

----------------------------------------------------------------------
[2-1] Now let /usr/src be the new git repository.

[2-2] Install "src_id.sh" in the appropriate directory in the ${PATH}. (ex: /usr/local/bin/src_id.sh)

And, in the git repository:

[2-3] # git config filter.src_id.smudge 'src_id.sh add'
[2-4] # git config filter.src_id.clean 'src_id.sh del'
[2-5] # echo '* filter=src_id' >> .git/info/attributes
[2-6] (After checking that your post-commit file doesn't exist in .git/hooks)
      # /bin/cp post-commit .git/hooks

[2-7] # git ls-files -z | /usr/bin/xargs -0 /bin/rm -f
[2-8] # git checkout -f

From now on, even if you update the source files, mergemaster will work fine.
----------------------------------------------------------------------
[Notes]
When you first run mergemaster after the above work, you will be asked to merge the following four files.

/etc/mail/freebsd.cf
/etc/mail/freebsd.submit.cf
/etc/mail/sendmail.cf
/etc/mail/submit.cf

For these, please merge at that time.
(This is because replace_id.sh doesn't support cases for those files.)
===========================================================================

That's all. Thanks.