view bin/updatetreepkg.py @ 171:c0ea6cbb0fd2

Add "--debbuildopts -b" to "pbuilder build" command line to stop pbuilder from creating a source package. The .changes would otherwise contain references to that new source package instead of the one we passed to pbuilder. The checksums for the two source packages would be different so the .changes file would not match the source package that treepkg produces.
author Bernhard Herzog <bh@intevation.de>
date Mon, 23 Jun 2008 16:12:01 +0000
parents dd54ef8a9244
children 757e5504f46a
line wrap: on
line source
#! /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)