changeset 144:dd54ef8a9244

New file. Script to update an existing treepkg installation to the filesystem layout of the current version
author Bernhard Herzog <bh@intevation.de>
date Mon, 02 Jun 2008 17:44:19 +0000
parents ddd141e09e8f
children 123e9a5f31fa
files bin/updatetreepkg.py
diffstat 1 files changed, 66 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/updatetreepkg.py	Mon Jun 02 17:44:19 2008 +0000
@@ -0,0 +1,66 @@
+#! /usr/bin/python2.4
+# Copyright (C) 2007, 2008 by Intevation GmbH
+# Authors:
+# Bernhard Herzog <bh@intevation.de>
+#
+# This program is free software under the GPL (>=v2)
+# Read the file COPYING coming with the software for details.
+
+"""Script to help update a tree packager installation to the current
+version.  The script updates the information stored in the filesystem
+for the individual revisions in the following ways:
+
+ - Rename the build log from build.log to log/build_log.txt
+
+ - Rename the build log from build_log.txt to log/build_log.txt
+"""
+
+import os
+
+import treepkgcmd
+from treepkg.options import create_parser
+from treepkg.packager import create_package_track, PackagerGroup
+from treepkg.readconfig import read_config
+
+def rename_file(old_name, new_name, dry_run):
+    if os.path.exists(old_name):
+        new_dir = os.path.dirname(new_name)
+        if not os.path.isdir(new_dir):
+            print "mkdir %s" % (new_dir,)
+            if not dry_run:
+                os.mkdir(new_dir)
+        print "mv %s %s" % (old_name, new_name)
+        if not dry_run:
+            os.rename(old_name, new_name)
+
+def update_treepkg(config_file, dry_run):
+    treepkg_opts, packager_opts = read_config(config_file)
+    for opts in packager_opts:
+        opts["handle_dependencies"] = False
+    group = PackagerGroup([create_package_track(**opts)
+                           for opts in packager_opts],
+                          **treepkg_opts)
+    for track in group.get_package_tracks():
+        for revision in track.get_revisions():
+            # Originally, the build logs were called build.log and were
+            # in the base directory of a revision
+            rename_file(os.path.join(revision.base_dir, "build.log"),
+                        revision.build_log, dry_run)
+            # for a while, the build logs were called build_log.txt but
+            # still were in the base directory
+            rename_file(os.path.join(revision.base_dir, "build_log.txt"),
+                        revision.build_log, dry_run)
+
+def parse_commandline():
+    parser = create_parser()
+    parser.set_defaults(dry_run=False)
+    parser.add_option("-n", "--dry-run", action="store_true",
+                      help="Do not actually change anything")
+    return parser.parse_args()
+
+
+def main():
+    options, args = parse_commandline()
+    update_treepkg(options.config_file, options.dry_run)
+
+main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)