aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/etc-update')
-rw-r--r--src/etc-update/AUTHORS0
-rw-r--r--src/etc-update/ChangeLog0
-rw-r--r--src/etc-update/Makefile20
-rw-r--r--src/etc-update/README0
-rwxr-xr-xsrc/etc-update/etc-update165
-rw-r--r--src/etc-update/etc-update.112
6 files changed, 197 insertions, 0 deletions
diff --git a/src/etc-update/AUTHORS b/src/etc-update/AUTHORS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/etc-update/AUTHORS
diff --git a/src/etc-update/ChangeLog b/src/etc-update/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/etc-update/ChangeLog
diff --git a/src/etc-update/Makefile b/src/etc-update/Makefile
new file mode 100644
index 0000000..95838ad
--- /dev/null
+++ b/src/etc-update/Makefile
@@ -0,0 +1,20 @@
+# Copyright 2004 Karl Trygve Kalleberg <karltk@gentoo.org>
+# Copyright 2004 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+#
+# $Header$
+
+include ../../makedefs.mak
+
+all:
+ echo "PAPPLE (vb.) To do what babies do to soup with their spoons."
+
+dist:
+ mkdir -p ../../$(distdir)/src/etc-update
+ cp Makefile AUTHORS README TODO ChangeLog etc-update etc-update.1 ../../$(distdir)/src/etc-update/
+
+install:
+ install -m 0755 etc-update $(bindir)/
+ install -d $(docdir)/etc-update
+ install -m 0644 AUTHORS ChangeLog README $(docdir)/etc-update/
+ install -m 0644 etc-update.1 $(mandir)/
diff --git a/src/etc-update/README b/src/etc-update/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/etc-update/README
diff --git a/src/etc-update/etc-update b/src/etc-update/etc-update
new file mode 100755
index 0000000..f566dff
--- /dev/null
+++ b/src/etc-update/etc-update
@@ -0,0 +1,165 @@
+#! /usr/bin/python
+#
+# $Header$
+#
+# Distributed under the terms of the GNU General Public License v2
+# Copyright (c) 2003 Karl Trygve Kalleberg
+#
+# Based on previous versions, by
+# - Brandon Low <lostlogic@gentoo.org>
+# - Jochem Kossen <j.kossen@home.nl>
+# - Leo Lipelis <aeoo@gentoo.org>
+
+from dialog import Dialog
+import portage
+import time
+import re
+import os
+
+__author__ = "Karl Trygve Kalleberg"
+__email__ = "karltk@gentoo.org"
+__version__ = "0.2.0"
+__productname__ = "etc-update"
+__description__ = "Interactive config file updater"
+
+globals = portage.settings.configdict["globals"]
+
+for i in globals["CONFIG_PROTECT"].split():
+ print i
+
+# list all files in all CONFIG_PROTECT dirs
+# list them in the gui
+# one-by-one:
+# - is update to header only?
+# - is the original unmodified from the previous package? (not checkable - duh!)
+# -
+
+class Config:
+ pass
+
+def loadConfig():
+ cfg = Config()
+ globals = portage.settings.configdict["globals"]
+ cfg.config_protect = globals["CONFIG_PROTECT"].split()
+ return cfg
+
+def _recurseFiles(path):
+ files = []
+ if os.path.exists(path):
+ try:
+ tmpfiles = os.listdir(path)
+ for i in tmpfiles:
+ fn = path + "/" + i
+ if os.path.isdir(fn):
+ files += _recurseFiles(fn)
+ elif os.path.isfile(fn):
+ m = re.search("\._cfg...._",fn)
+ if m:
+ files.append(fn)
+ else:
+ print "What is this anyway?:", fn
+ except OSError:
+ pass
+ # print "Access denied:", path
+
+ return files
+
+def findAllFiles(dlg, config):
+ files = []
+ gauge = dlg.gauge(0,
+ "Processing CONFIG_PROTECT directories...",
+ 7,
+ 60,
+ "Gauge",
+ sleep=3)
+ num_dirs = len(config.config_protect)
+ for i in xrange(num_dirs):
+ rem = repr(num_dirs - i / num_dirs)
+ gauge.update(rem, "Directories remaining: %s" % rem)
+ files += _recurseFiles(config.config_protect[i])
+ return files
+
+def prettifyFiles(files):
+ rx = re.compile("\._cfg...._")
+ def strip_cfg(x):
+ """Remove ._cfg????_ part """
+ m = rx.search(x)
+ if m:
+ s,e = m.span(0)
+ return x[:s] + x[e:]
+ return x
+ return map(strip_cfg, files)
+
+def updateFile(dlg, original):
+
+ # Find candidates
+
+ dir = os.path.dirname(original)
+ filename = os.path.basename(original)
+ rx = re.compile("\._cfg...._" + filename)
+ cand = filter(lambda x: rx.search(x), os.listdir(dir))
+
+ if len(cand) > 1:
+
+ # Add mtimes
+ for i in xrange(len(cand)):
+ stamp = time.localtime(os.path.getmtime(dir + "/" + cand[i]))
+ tstr = time.strftime("%a, %d %b %Y %H:%M:%S", stamp)
+ cand[i] = cand[i] + " - " + tstr
+
+
+ # Show selection
+ replacement = dlg.menu("Files that need updating",
+ Dialog.AUTO_SIZE,
+ list = cand,
+ showHelp = False,
+ title="Checklist")
+
+ else:
+ replacement = cand[0]
+
+
+ # Display diff
+
+ dlg.yesno("Would you like to update \n" + \
+ "[" + original + "]with\n[" + dir + "/" + replacement + "] ?")
+
+def displayFiles(dlg, config, files):
+
+ pretty_files = prettifyFiles(files)
+
+ while 1:
+ result = dlg.menu("Files that need updating",
+ Dialog.AUTO_SIZE,
+ list = pretty_files,
+ showHelp = False,
+ title="Checklist")
+ if result == None:
+ if dlg.ERR_CANCEL:
+ break
+
+ updateFile(dlg, result)
+
+ if len(pretty_files):
+ print "!!! Warning: There are still files that require updating."
+
+
+def main():
+ dlg = Dialog("etc-update")
+# dlg = None
+
+ config = loadConfig()
+ files = findAllFiles(dlg, config)
+ displayFiles(dlg, config,files)
+
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ print "Operation aborted!"
+
+# TODO:
+# - option for automatically update untouched files
+# - show coloured diff
+# - proper progress bar
diff --git a/src/etc-update/etc-update.1 b/src/etc-update/etc-update.1
new file mode 100644
index 0000000..53477d8
--- /dev/null
+++ b/src/etc-update/etc-update.1
@@ -0,0 +1,12 @@
+.TH etc-update "1" "Nov 2003" "gentoolkit"
+.SH NAME
+etc-update \- Gentoo: Configuration Update Utility
+.SH SYNOPSIS
+.B etc-update
+.SH BUGS
+This tool does not yet have a man page. Feel free to submit a bug about it to
+http://bugs.gentoo.org
+.SH AUTHORS
+This informative man page was written by Karl Trygve Kalleberg
+<karltk@gentoo.org>.
+