Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Sep 2003 15:36:30 -0600
From:      Mike Porter <mupi@mknet.org>
To:        Jason Andresen <jandrese@mitre.org>, "Jim C. Nasby" <jim@nasby.net>
Cc:        stable@freebsd.org
Subject:   Re: About mergemaster (Re: upgrading)
Message-ID:  <200309231536.36819.mupi@mknet.org>
In-Reply-To: <3F7080FD.2050505@mitre.org>
References:  <12829.1064235540@thrush.ravenbrook.com> <20030923170509.GA72668@nasby.net> <3F7080FD.2050505@mitre.org>

next in thread | previous in thread | raw e-mail | index | archive | help
=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 23 September 2003 11:21 am, Jason Andresen wrote:
> Jim C. Nasby wrote:
> > On Tue, Sep 23, 2003 at 09:25:10AM -0700, Doug White wrote:
> >>In 99% of cases, there is no CVS repo to compare against.
> >
> > Huh? What about the main FBSD CVS repository?
>
> Mergemaster is typically run in single user mode.  Unless you're running
> mergemaster on a CVS mirror, you're not going to be able to get at it.

That's why a simple hash of the file, which could be generated at install i=
s=20
probably the easiest way to go:

generate hash of the existing file, compare to the stored hash, if they are=
=20
the same, the file hasn't changed, install the new file (or prompt once for=
=20
confirmation, rather than requiring the user to page through all the diffs=
=20
for a file they don't really care about, but preserves the option of viewin=
g=20
the 'normal' mergemaster output....for example, /etc/defaults/rc.conf, whic=
h=20
should never be changed, but you may find that a setting that used to be on=
,=20
is now off (or vice versa) requiring a new line in /etc/rc.conf.).

This would handle the majority of cases. =20

However, as I have thought about this problem, a different solution present=
s=20
itself: a more sophisticated compare mechanism.

If, instead of simply comparing the 'installed' version of a file to the 'n=
ew'=20
version of a file, what if mergemaster could distinguish between changes to=
=20
the base file, and changes to 'defaults'.  For example, in my /etc/aliases,=
 I=20
have the line "root:  mupi"  As it stands, mergemaster always prompts me fo=
r=20
this file, because, of course, the original file reads "# root:   =20
me@my.domain".  However, I can't just choose (k)eep my installed version,=20
becuase there may be other changes to the aliases file, espcially if a new=
=20
user was created for some function, that user would typically point back to=
=20
root via the alias file, so there will be ahcnage there.  I also don't want=
=20
to just (i)nstall the new version, becuase then I would have to go back and=
=20
add that line back in.  Granted, it isn't bad, when I am only looking at on=
e=20
line, but what about, say /etc/passwd, where I could have to go in and chec=
k=20
each user?

A better method would be to compare the original /etc/aliases (before my ed=
it)=20
to the new /etc/aliases, and see of any changes have been made, and then=20
merge only changes from the original file back in to the installed file. =20
this would preserve my edits to /etc/aliases, while still allowing for any=
=20
new additions or removal of obsolete aliases.  The same approach would work=
=20
splendily with /etc/passwd, /etc/groups, /etc/printcap and /etc/hosts, whic=
h=20
are files we pretty much *know* are going to have been changed.  It should=
=20
work for most everything else, as well, and would preserve any local edits.=
 =20
The one scenario it would still break is if a change conflicts with an=20
existing line (for example, we add a new system user with the same uid as a=
n=20
existing user, or change the alias of root in /etc/aliases from=20
"me@my.domain" to "me@my.full.domain".  We'd want a detection mechnism for=
=20
that sort of thing ("does the line I am about to append to this file confli=
ct=20
with any existing lines?  If so, ask for confirmation before making the=20
change"  Done right, this would allow changes to comments as well, whether=
=20
just to correct a typo or to document new functionality.  Of course, this=20
comparison logic would be a devil to implement...it would be easy to simply=
=20
append the new lines to the bottom of the file, but you can't just blindly=
=20
delete lines from the installed file, without first checking if it is the=20
line we want to delete.  I don't know if diff/patch are smart enough to=20
handle this.  I think some experimentation is in order....

mike
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQE/cLzjY30jZzkECLcRAt/XAJ99n1BbjMkSkqp4qhJA5gnjKdnQBgCgtN94
vhQ8Bj1bvFRfPrYVmGfxo6U=3D
=3DwLiy
=2D----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200309231536.36819.mupi>