bh@89: #! /usr/bin/python2.4 bh@89: # Copyright (C) 2007 by Intevation GmbH bh@89: # Authors: bh@89: # Bernhard Herzog bh@89: # bh@89: # This program is free software under the GPL (>=v2) bh@89: # Read the file COPYING coming with the software for details. bh@89: bh@89: """List the absolute filenames of packages created by treepkg""" bh@89: bh@89: import sys bh@89: bh@89: import treepkgcmd bh@89: from treepkg.options import create_parser bh@89: from treepkg.report import get_packager_group bh@89: bh@89: def parse_commandline(): bh@89: parser = create_parser() bh@89: parser.set_defaults(binary=False, source=False) bh@89: parser.add_option("--revision", type="int", bh@89: help=("The revision whose files are to be listed." bh@89: " If not given, the latest revision is used")) bh@89: parser.add_option("--track", bh@89: help=("The package track whose files are to be listed")) bh@89: parser.add_option("--source", action="store_true", bh@89: help=("List source packages")) bh@89: parser.add_option("--binary", action="store_true", bh@89: help=("List binary packages")) bh@89: return parser.parse_args() bh@89: bh@89: bh@89: def list_track_packages(track, revision, source, binary): bh@89: revisions = track.get_revisions() bh@89: if not revisions: bh@89: print >>sys.stderr, "No revisions have been packaged" bh@89: sys.exit(1) bh@89: bh@89: if revision is None: bh@89: revpkg = revisions[-1] bh@89: else: bh@89: for revpkg in revisions: bh@89: if revpkg.revision == revision: bh@89: break bh@89: else: bh@89: revpkg = None bh@89: bh@89: if revpkg is not None: bh@89: if source: bh@89: for filename in revpkg.list_source_files(): bh@89: print filename bh@89: if binary: bh@89: for filename in revpkg.list_binary_files(): bh@89: print filename bh@89: else: bh@89: print >>sys.stderr, "No revision", repr(revision) bh@89: sys.exit(1) bh@89: bh@89: def list_packages(config_file, trackname, revision, source, binary): bh@89: group = get_packager_group(config_file) bh@89: for track in group.get_package_tracks(): bh@89: if track.name == trackname: bh@89: list_track_packages(track, revision, source, binary) bh@89: break bh@89: else: bh@89: print >>sys.stderr, "no track named", trackname bh@89: sys.exit(1) bh@89: bh@89: def main(): bh@89: options, args = parse_commandline() bh@89: list_packages(options.config_file, options.track, options.revision, bh@89: source=options.source, binary=options.binary) bh@89: bh@89: main()