Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

apt upgrade merging modified files

231 views
Skip to first unread message

Michael Grant

unread,
Mar 25, 2021, 4:50:04 AM3/25/21
to
When I apt-update, sometimes I update something for which I modified a config file and I get this menu:

Configuration file '/etc/matrix-synapse/homeserver.yaml'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** homeserver.yaml (Y/I/N/O/D/Z) [default=N]

Sometimes, rarely, I get a 5th option offering to try to merge the
files. I don't know what causes the merge option to be available or
not.

If this is a file which I indeed modified, what I inevitably end up
doing is using the Z option, popping into a shell, then presents me 2
variables (without $ in front of them) which give me 2 files: current
and new.

So what I do is manually echo the two variables out (putting a $ in
front of them) and run emacs and emerge them together. This is fine,
it's usually pretty easy.

Is there some way I can at minimum add a 5th option to the above menu
to run emacs in emerge mode with those files as args? This would save
lazy me the steps of echoing the vars and starting emacs manually.

I run etckeeper, it would be really sweet if this was smart enough to
attempt a 3-way merge (merge with an ancestor file).

Michael Grant
signature.asc

Andrei POPESCU

unread,
Mar 25, 2021, 1:10:06 PM3/25/21
to
On Jo, 25 mar 21, 04:39:53, Michael Grant wrote:
> When I apt-update, sometimes I update something for which I modified a config file and I get this menu:
>
> Configuration file '/etc/matrix-synapse/homeserver.yaml'
> ==> Modified (by you or by a script) since installation.
> ==> Package distributor has shipped an updated version.
> What would you like to do about it ? Your options are:
> Y or I : install the package maintainer's version
> N or O : keep your currently-installed version
> D : show the differences between the versions
> Z : start a shell to examine the situation
> The default action is to keep your current version.
> *** homeserver.yaml (Y/I/N/O/D/Z) [default=N]

This is provided by dpkg.

> Sometimes, rarely, I get a 5th option offering to try to merge the
> files. I don't know what causes the merge option to be available or
> not.

The package is using ucf.

> If this is a file which I indeed modified, what I inevitably end up
> doing is using the Z option, popping into a shell, then presents me 2
> variables (without $ in front of them) which give me 2 files: current
> and new.
>
> So what I do is manually echo the two variables out (putting a $ in
> front of them) and run emacs and emerge them together. This is fine,
> it's usually pretty easy.

Hmm, with vim something like 'vimdiff $current $new' should work, there
is no need to echo the variables firsts, and I would be surprised if
emacs couldn't do something similar.

> Is there some way I can at minimum add a 5th option to the above menu
> to run emacs in emerge mode with those files as args? This would save
> lazy me the steps of echoing the vars and starting emacs manually.

That would have to be implemented in dpkg and ucf.

> I run etckeeper, it would be really sweet if this was smart enough to
> attempt a 3-way merge (merge with an ancestor file).

Recently more and more packages have been adding support for
conf.d-style directories. That way you can keep your local
customizations completely separate from the default configuration and
there is no prompt from dpkg or ucf.

Kind regards,
Andrei
--
http://wiki.debian.org/FAQsFromDebianUser
signature.asc

Sven Joachim

unread,
Mar 25, 2021, 1:30:05 PM3/25/21
to
On 2021-03-25 04:39 -0400, Michael Grant wrote:

> When I apt-update, sometimes I update something for which I modified a config file and I get this menu:
>
> Configuration file '/etc/matrix-synapse/homeserver.yaml'
> ==> Modified (by you or by a script) since installation.
> ==> Package distributor has shipped an updated version.
> What would you like to do about it ? Your options are:
> Y or I : install the package maintainer's version
> N or O : keep your currently-installed version
> D : show the differences between the versions
> Z : start a shell to examine the situation
> The default action is to keep your current version.
> *** homeserver.yaml (Y/I/N/O/D/Z) [default=N]

This prompt is coming from dpkg which notes that a conffile has been
changed. In Debian/dpkg jargon, a conffile is a configuration file that
is shipped in a package. The dpkg program keeps a checksum for each
conffile in its database and can therefore detect modifications, but it
does not track the content of conffiles.

> Sometimes, rarely, I get a 5th option offering to try to merge the
> files. I don't know what causes the merge option to be available or
> not.

These packages use a different mechanism for their configuration files
based on a program called ucf. The files are _not_ shipped in the
package, but created from a template in the maintainer scripts. Unlike
dpkg, ucf also stores the content of these files and is therefore able
to offer merge options.

> Is there some way I can at minimum add a 5th option to the above menu
> to run emacs in emerge mode with those files as args? This would save
> lazy me the steps of echoing the vars and starting emacs manually.
>
> I run etckeeper, it would be really sweet if this was smart enough to
> attempt a 3-way merge (merge with an ancestor file).

I am afraid this is not easily possible. Making dpkg's conffile prompt
smarter has been requested many times, but nothing has happened since
bug #32877[1] and its many siblings have been filed. Yes, that bug is
22 years old.

Cheers,
Sven


1. https://bugs.debian.org/32877

ellanios82

unread,
Mar 25, 2021, 2:10:05 PM3/25/21
to
 - could meld be a useful tool ? :

"meld/stable,stable 3.20.0-2 all
  graphical tool to diff and merge files"


....

 regards
0 new messages