public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] A script to help in updating configuration files
@ 2001-09-06  4:40 Einar Karttunen
  2001-09-06  8:42 ` Daniel Robbins
  0 siblings, 1 reply; 4+ messages in thread
From: Einar Karttunen @ 2001-09-06  4:40 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 88 bytes --]

Hello

The script is very simple, but I hope it
will help someone...

- Einar Karttunen

[-- Attachment #2: etc-update --]
[-- Type: text/plain, Size: 902 bytes --]

#!/usr/bin/env spython

# Einar Karttunen 9.6.2001 <ekarttun@cs.helsinki.fi>
# this file must be distributed under GNU GPL

import os
import sys

if os.getuid()!=0:
	print "!!! etc-update must be run by root"
	sys.exit(1)

import commands
import portage
import string
import re

if not portage.settings["CONFIG_PROTECT"]:
	print "no CONFIG_PROTECTed directories"
	sys.exit(2)

req = re.compile('\._cfg\d\d\d\d_')
for d in string.split(portage.settings["CONFIG_PROTECT"]):
	if os.path.isdir(d):
		r = commands.getstatusoutput("find "+d+" -iname '._cfg????_*'")
		if r[0] == 0:
			for file in string.split(r[1]):
				path, bare = re.split(req,file)
				bare = path + bare
				print "new: "+file+" orig: "+bare
				os.system("diff -Bbs "+file+" "+bare)
				r = raw_input("overwrite old "+bare+" with new? [yN] ")
				if r == 'y':
					os.system('mv -fv '+file+' '+bare)
		else:
			print "error in 'find'"

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-09-06 15:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-06  4:40 [gentoo-dev] A script to help in updating configuration files Einar Karttunen
2001-09-06  8:42 ` Daniel Robbins
2001-09-06  9:45   ` Einar Karttunen
2001-09-06 10:00     ` Daniel Robbins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox