bh@144: #! /usr/bin/python2.4 bh@144: # Copyright (C) 2007, 2008 by Intevation GmbH bh@144: # Authors: bh@144: # Bernhard Herzog bh@144: # bh@144: # This program is free software under the GPL (>=v2) bh@144: # Read the file COPYING coming with the software for details. bh@144: bh@144: """Script to help update a tree packager installation to the current bh@144: version. The script updates the information stored in the filesystem bh@144: for the individual revisions in the following ways: bh@144: bh@144: - Rename the build log from build.log to log/build_log.txt bh@144: bh@144: - Rename the build log from build_log.txt to log/build_log.txt bh@144: """ bh@144: bh@144: import os bh@144: bh@144: import treepkgcmd bh@144: from treepkg.options import create_parser bh@144: from treepkg.packager import create_package_track, PackagerGroup bh@144: from treepkg.readconfig import read_config bh@144: bh@144: def rename_file(old_name, new_name, dry_run): bh@144: if os.path.exists(old_name): bh@144: new_dir = os.path.dirname(new_name) bh@144: if not os.path.isdir(new_dir): bh@144: print "mkdir %s" % (new_dir,) bh@144: if not dry_run: bh@144: os.mkdir(new_dir) bh@144: print "mv %s %s" % (old_name, new_name) bh@144: if not dry_run: bh@144: os.rename(old_name, new_name) bh@144: bh@144: def update_treepkg(config_file, dry_run): bh@144: treepkg_opts, packager_opts = read_config(config_file) bh@144: for opts in packager_opts: bh@144: opts["handle_dependencies"] = False bh@144: group = PackagerGroup([create_package_track(**opts) bh@144: for opts in packager_opts], bh@144: **treepkg_opts) bh@144: for track in group.get_package_tracks(): bh@144: for revision in track.get_revisions(): bh@144: # Originally, the build logs were called build.log and were bh@144: # in the base directory of a revision bh@144: rename_file(os.path.join(revision.base_dir, "build.log"), bh@144: revision.build_log, dry_run) bh@144: # for a while, the build logs were called build_log.txt but bh@144: # still were in the base directory bh@144: rename_file(os.path.join(revision.base_dir, "build_log.txt"), bh@144: revision.build_log, dry_run) bh@144: bh@144: def parse_commandline(): bh@144: parser = create_parser() bh@144: parser.set_defaults(dry_run=False) bh@144: parser.add_option("-n", "--dry-run", action="store_true", bh@144: help="Do not actually change anything") bh@144: return parser.parse_args() bh@144: bh@144: bh@144: def main(): bh@144: options, args = parse_commandline() bh@144: update_treepkg(options.config_file, options.dry_run) bh@144: bh@144: main()