Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 14666 - auto update feature for etc-update
Summary: auto update feature for etc-update
Status: RESOLVED DUPLICATE of bug 4709
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Nicholas Jones (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-28 03:43 UTC by Jeff Kowing
Modified: 2011-10-30 22:38 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Added auto update feature. (etc-update,17.15 KB, text/plain)
2003-01-28 03:48 UTC, Jeff Kowing
Details
Removed comments so script will actually replace the /etc files. (etc-update.new,17.14 KB, text/plain)
2003-01-31 12:01 UTC, Jeff Kowing
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Kowing 2003-01-28 03:43:06 UTC
FWIW: I've made some additions to the etc-update script so that it will auto
update config files that have never been modified by the user.  The
modifications borrow from Naan Yaar's script at 
http://forums.gentoo.org/viewtopic.php?t=13390
which was mentioned to me in this thread:
http://article.gmane.org/gmane.linux.gentoo.devel/6726

I just noticed that there are some excellent folks working on a python
replacement of etc-update at http://bugs.gentoo.org/show_bug.cgi?id=14079.

Anyways, here is a snippet of comments from the top of the modified etc-update
script that explains how it works.  

 #!/bin/bash
# Copyright 2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU Public License v2
# Author Brandon Low <lostlogic@gentoo.org>
#
# Previous version (from which I've borrowed a few bits) by:
# Jochem Kossen <j.kossen@home.nl>
# Leo Lipelis <aeoo@gentoo.org>
# Karl Trygve Kalleberg <karltk@gentoo.org>
#
# ---- auto update feature ----
# Jeff Kowing <jkowing@ghg.net>: I borrowed lots from
# Naan Yaar (see his script at http://forums.gentoo.org/viewtopic.php?t=13390)
#
# Auto update works as follows:
#
# It saves the original md5sums of configuration files as found in the
# /var/db/pkg directory.  After an update, a ._cfg* file will
# automatically replace its corresponding config file if that config
# file was never modified.  This is determined by comparing the config
# file with the saved original md5sums.
#
# Here is a typical procedure for using the auto update feature:
#
# 1. Create and keep safe a CONFIG.md5sum file which contains all the
#    config file md5sums, by typing:
#    # etc-update md5sum -f CONFIG.md5sum
#
# 2. Now do your big emerge, e.g.:
#    # emerge -u world 
#
# 3. Afterwards, see what config files will be automatically updated.
#    # etc-update auto -f CONFIG.md5sum --dry-run
#
# 4. If things look okay, then do it: 
#    # etc-update auto -f CONFIG.md5sum
#
# 5. Be sure to save your new md5sum's before the next big emerge.
#    # etc-update md5sum -f CONFIG.md5sum
#

$ etc-update -h

Usage: 

   etc-update 
   etc-update auto [-f <file>] [--dry-run]
   etc-update md5sum [-f <file>]
   etc-update [-h | --help]

Details:

   etc-update 

      With no arguments, etc-update will perform an interactive update of
      your configuration files.

   etc-update auto [-f <file>] [--dry-run]

      -f <file>        Name of the md5sum file.  
                       Default is CONFIG.md5sum

      --dry-run        Don't do the replacement.

      Use this command AFTER a big emerge.  It will automatically
      replace config files with their ._cfg* counterparts.  Only the
      configuration files that have not been modified will be
      automatically replaced.  To determine which configuration files
      have been modified, you must have saved a md5sum file that was
      generated BEFORE the big emerge.  To do so, use the 
      'etc-update md5sum' command described below.

   etc-update md5sum [-f <file>] 

      -f <file>        Name of the md5sum file. 
                       Default is CONFIG.md5sum

      Use this command BEFORE a big emerge.  It will output a md5sum
      file of the configuration files at the time they were installed.
      You should save the output before doing a big emerge.  You will
      need it to run the 'etc-update auto' command.

Exiting: Done.
Comment 1 Jeff Kowing 2003-01-28 03:48:50 UTC
Created attachment 7705 [details]
Added auto update feature.

The modifications are based upon a /usr/sbin/etc-update from portage-2.0.46-r9.

Be careful using this very minimally tested script!
Comment 2 Maurizio Disimino 2003-01-29 11:41:55 UTC
Great! I like it.
Thanks

Maurizio
Comment 3 TGL 2003-01-30 16:24:13 UTC
Hi,

I've tested this script and it really works great. That's really nice to see this feature implemented. I think the next step is to simplify the usage of the script. Here is how I see it:
 - CONFIG.md5 should have a standard location (maybe somewhere in /var/db/portage)
 - 'etc-update' should do the following three steps: "auto", then "interactive", and then "md5" (where "interactive" is the current default behavior). I think that  this way, if someone always use etc-update when needed, then CONFIG.md5 will always be in an up-to-date state, at least if he does all the updates at the same time. Maybe there should be a confirmation asked for the "md5" step if some ._cfg files remain when the user leaves the interactive step.
 - some "auto-only", "interactive-only" and "md5-only" options could be added to override then previously described 3 in 1 behavior.

What do you think about this 2 cents ?
Comment 4 Jeff Kowing 2003-01-31 12:01:14 UTC
Created attachment 7784 [details]
Removed comments so script will actually replace the /etc files.

Drats.	I forgot to remove some comments that prevented the script from
actually replacing the config file with its ._cfg* counterpart. Sorry about
that.
Comment 5 Jeff Kowing 2003-01-31 12:50:48 UTC
Yes.  I think your 2 cents http://bugs.gentoo.org/show_bug.cgi?id=14666#c3 is worth more than that!  That all sounds good to me.  Alain (alain@gentoo.org) has also educated me some on the existence of a /var/cache/edb/config database and Alain has great ideas about saving the original config files for later smart merging.  I believe Alain and others are working on eventual replacements for etc-update that are more integrated into the portage/emerge system.  But until then, it is pretty easy to hack some more on etc-update.  The problem, as always, is finding the time to do it! 

By the way, I just used etc-update to auto update about 52 config files after a emerge -u world.  Everything seems to have gone okay.

-jeff
Comment 6 Sean E Russell 2003-02-06 21:22:27 UTC
You totally rock. 
 
I was just about to my own version of this (same heuristic -- md5sums to detect 
changes), but decided to read GWN first... and voila. 
 
I was also toying with the idea of trying to detect when the only thing that has 
changed is comments -- this seems to constitute a large number of et-see changes.  
But this should solve the vast majority of trivial conf updates. 
Comment 7 SpanKY gentoo-dev 2003-02-25 15:38:31 UTC
bug 4709 has a patch for portage so that it is done automagically 

*** This bug has been marked as a duplicate of 4709 ***