comparison bin/updatetreepkg.py @ 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
children 757e5504f46a
comparison
equal deleted inserted replaced
143:ddd141e09e8f 144:dd54ef8a9244
1 #! /usr/bin/python2.4
2 # Copyright (C) 2007, 2008 by Intevation GmbH
3 # Authors:
4 # Bernhard Herzog <bh@intevation.de>
5 #
6 # This program is free software under the GPL (>=v2)
7 # Read the file COPYING coming with the software for details.
8
9 """Script to help update a tree packager installation to the current
10 version. The script updates the information stored in the filesystem
11 for the individual revisions in the following ways:
12
13 - Rename the build log from build.log to log/build_log.txt
14
15 - Rename the build log from build_log.txt to log/build_log.txt
16 """
17
18 import os
19
20 import treepkgcmd
21 from treepkg.options import create_parser
22 from treepkg.packager import create_package_track, PackagerGroup
23 from treepkg.readconfig import read_config
24
25 def rename_file(old_name, new_name, dry_run):
26 if os.path.exists(old_name):
27 new_dir = os.path.dirname(new_name)
28 if not os.path.isdir(new_dir):
29 print "mkdir %s" % (new_dir,)
30 if not dry_run:
31 os.mkdir(new_dir)
32 print "mv %s %s" % (old_name, new_name)
33 if not dry_run:
34 os.rename(old_name, new_name)
35
36 def update_treepkg(config_file, dry_run):
37 treepkg_opts, packager_opts = read_config(config_file)
38 for opts in packager_opts:
39 opts["handle_dependencies"] = False
40 group = PackagerGroup([create_package_track(**opts)
41 for opts in packager_opts],
42 **treepkg_opts)
43 for track in group.get_package_tracks():
44 for revision in track.get_revisions():
45 # Originally, the build logs were called build.log and were
46 # in the base directory of a revision
47 rename_file(os.path.join(revision.base_dir, "build.log"),
48 revision.build_log, dry_run)
49 # for a while, the build logs were called build_log.txt but
50 # still were in the base directory
51 rename_file(os.path.join(revision.base_dir, "build_log.txt"),
52 revision.build_log, dry_run)
53
54 def parse_commandline():
55 parser = create_parser()
56 parser.set_defaults(dry_run=False)
57 parser.add_option("-n", "--dry-run", action="store_true",
58 help="Do not actually change anything")
59 return parser.parse_args()
60
61
62 def main():
63 options, args = parse_commandline()
64 update_treepkg(options.config_file, options.dry_run)
65
66 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)