[Treepkg-commits] r69 - trunk/bin
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Jun 2 19:44:20 CEST 2008
Author: bh
Date: 2008-06-02 19:44:19 +0200 (Mon, 02 Jun 2008)
New Revision: 69
Added:
trunk/bin/updatetreepkg.py
Log:
New file. Script to update an existing treepkg installation to the
filesystem layout of the current version
Added: trunk/bin/updatetreepkg.py
===================================================================
--- trunk/bin/updatetreepkg.py 2008-06-02 17:43:22 UTC (rev 68)
+++ trunk/bin/updatetreepkg.py 2008-06-02 17:44:19 UTC (rev 69)
@@ -0,0 +1,66 @@
+#! /usr/bin/python2.4
+# Copyright (C) 2007, 2008 by Intevation GmbH
+# Authors:
+# Bernhard Herzog <bh at 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()
Property changes on: trunk/bin/updatetreepkg.py
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the Treepkg-commits
mailing list