When I emerged the new baselayout and was presented with 24 config files to update, I became a little bit tired of updating files that I have not modified since the emerge. I wrote a little script that will find these files by checking md5sums from ebuilds and then updates them automatically or one-by-one.

You can run this before running etc-update to save yourself some work.

NB.
1. This needs gentoolkit to work
2. You need to do this before the old package that installed the config file is cleaned (either through an emerge clean or autoclean)
3. Please make sure that copy/cut-and-paste to the script text file does not remove spaces or modify line-ends.

Code:

#!/bin/bash

# This script checks config files in directories with config files and
# checks whether their checksum matches known checksums in /var/db.
# If a checksum matches, the file has not been modified since the emerge
# and can be overwritten safely. These files are presented and queried
# for update individually or in one shot
#
# You can run this prior to running etc-update to save some work in updating
# files that you have not touched

When I emerged the new baselayout and was presented with 24 config files to update, I became a little bit tired of updating files that I have not modified since the emerge. I wrote a little script that will find these files by checking md5sums from ebuilds and then updates them automatically or one-by-one.

You can run this before running etc-update to save yourself some work.

I'll follow up with PM's and post the resolution to the forum since I don't want to clutter up the documentation thread.

[EDIT]PM exchanges determined that the cut-and-paste to a file changed the two spaces between \2 and \1 above into a single space, causing md5sum to fail. Adding warning to original post above regarding this.
Thanks, kirill[/EDIT]

I tryed your script, but i think that the new default behavior of emerge, to clean after emerging brook it.

Because it can removes the old CONTENT file containing the md5 checksum of a current file in /etc. So when i run you script he thinks that i modified the file because there is no CONTENT file containing his checksum.

Autoclean is on by default now. You can change this behavior by putting in this line in your /etc/make.conf file:

Code:

AUTOCLEAN="no"

NB. Portage seems to strongly recommend not doing this.

sebest wrote:

Hi.

I tryed your script, but i think that the new default behavior of emerge, to clean after emerging brook it.

Because it can removes the old CONTENT file containing the md5 checksum of a current file in /etc. So when i run you script he thinks that i modified the file because there is no CONTENT file containing his checksum.

Sorry. I haven't been around the forums a lot recently and have updated to the recent portage version only recently. I have attached the modified script below (it is a simple change that checks for qpkg explicitly rather than through pkglist).

Regards.

NB. Code has been updated in the first post to this thread itself and has been removed from this post.

Yama wrote:

This script served me flawlessly for quite some time (> 1 year), but now when I run it I receive the following error:

Code:

/usr/local/sbin/etc-autoupdate: line 29: /usr/lib/portage/bin/pkglist: No such file or directory
You need to emerge gentoolkit to run this

This started happening after upgrading my gentoolkit to the latest stable version (0.2.0_pre6). It seems that this version does not have the /usr/lib/portage/bin/pkglist file.

EDIT(Naan Yaar): Removed code and put in consolidated version in the first post.

Last edited by Naan Yaar on Sat Mar 13, 2004 4:56 am; edited 2 times in total

This script has served me well, it's a real time saver. However, awhile back I somehow got about 50 files in /usr/X11R6/lib/X11/xkb that needed updating, and I finally got around to looking at it. It seems that CONFIG_PROTECT is also present in /etc/profile.env which gets read when you source /etc/profile. So I played around a bit and changed the script so it sources /etc/profile too. This worked for what I needed so I thought I would share it. Use it at your own peril.

It prints a bunch of extra stuff, I sort of like it so I left it in. I suppose to be complete it should source /etc/make.conf too, but it doesn't seem to work right unless you add an empty CONFIG_PROTECT="" into /etc/make.conf.

I had noticed that it did not pick up files in .../xkb correctly, but did not investigate further. Thanks for your insight.

I have updated the script in the first post to this thread to reflect this fix.

Yak wrote:

This script has served me well, it's a real time saver. However, awhile back I somehow got about 50 files in /usr/X11R6/lib/X11/xkb that needed updating, and I finally got around to looking at it. It seems that CONFIG_PROTECT is also present in /etc/profile.env which gets read when you source /etc/profile. So I played around a bit and changed the script so it sources /etc/profile too. This worked for what I needed so I thought I would share it. Use it at your own peril.
...
It prints a bunch of extra stuff, I sort of like it so I left it in. I suppose to be complete it should source /etc/make.conf too, but it doesn't seem to work right unless you add an empty CONFIG_PROTECT="" into /etc/make.conf.