From: Einar Karttunen <ekarttun@cs.Helsinki.FI>
To: gentoo-dev@cvs.gentoo.org
Subject: Re: [gentoo-dev] A script to help in updating configuration files
Date: Thu Sep 6 09:45:02 2001 [thread overview]
Message-ID: <20010906184434.A3635@cs.helsinki.fi> (raw)
In-Reply-To: <20010906084149.C24055@cvs.gentoo.org>; from drobbins@gentoo.org on Thu, Sep 06, 2001 at 08:41:49AM -0600
[-- Attachment #1: Type: text/plain, Size: 610 bytes --]
On Thu, Sep 06, 2001 at 08:41:49AM -0600, Daniel Robbins wrote:
> On Thu, Sep 06, 2001 at 01:39:11PM +0300, Einar Karttunen wrote:
> > Hello
> >
> > The script is very simple, but I hope it
> > will help someone...
> >
> > - Einar Karttunen
>
> Neat! I'll try it out and probably use it as a base for our config
> management update system. Thank you very much and please continue
> working on it and posting updates when you have made significant
> improvements to the previous version.
I added some more functionality to it so it can be used
better. It even has a minimal help :-)
- Einar Karttunen
[-- Attachment #2: etc-update --]
[-- Type: text/plain, Size: 1345 bytes --]
#!/usr/bin/env spython
# Einar Karttunen 9.6.2001 <ekarttun@cs.helsinki.fi>
# this file must be distributed under GNU GPL
# version 0.02
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)
def diff(old, new):
print "new: "+new+" old: "+old
os.system("diff -Bbs "+new+" "+old)
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
diff(file, bare)
while 1:
r = raw_input("overwrite old "+bare+" with new? [?drNy] ").lower()
if r == 'y':
os.system('mv -fv '+file+' '+bare)
elif r== 'd':
os.remove(file)
elif r== 'r':
diff(file, bare)
continue
elif r== '?':
print """
? display this help
d delete the NEW file
r print the diff another time
N do nothing (the deault)
y replace old with new
remember you can use CTRL-Z to suspend and inspect the situation more closely
"""
continue
break
else:
print "error in 'find'"
next prev parent reply other threads:[~2001-09-06 15:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2001-09-06 10:00 ` Daniel Robbins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010906184434.A3635@cs.helsinki.fi \
--to=ekarttun@cs.helsinki.fi \
--cc=gentoo-dev@cvs.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox