Mercurial > treepkg
view bin/publishpackages.py @ 441:eadcb1bb54e2
Merged revisions 388-399 via svnmerge from
svn+ssh://svn.wald.intevation.org/treepkg/branches/treepkg-status
........
r388 | bricks | 2010-07-28 10:38:50 +0200 (Mi, 28 Jul 2010) | 3 lines
fix if statement
upload hook should be called if it's not empty
........
r389 | bricks | 2010-07-28 13:38:00 +0200 (Mi, 28 Jul 2010) | 2 lines
only rsync specified architectures from cachedir to publishdir
........
r390 | bricks | 2010-07-29 14:07:57 +0200 (Do, 29 Jul 2010) | 2 lines
introduced after_copy_hook and made rsync upload to publishdir optional
........
r391 | bricks | 2010-07-29 15:43:39 +0200 (Do, 29 Jul 2010) | 3 lines
publish package must be default to get original behaviour
be more verbose at publishing
........
r392 | bricks | 2010-07-29 16:50:53 +0200 (Do, 29 Jul 2010) | 2 lines
fix handling of showing only successfull builds together with num packages
........
r393 | bricks | 2010-07-29 16:52:42 +0200 (Do, 29 Jul 2010) | 2 lines
fixed typo
........
r394 | bricks | 2010-07-29 16:59:10 +0200 (Do, 29 Jul 2010) | 2 lines
fixed another typo
........
r395 | bricks | 2010-07-29 18:05:54 +0200 (Do, 29 Jul 2010) | 3 lines
fixed another typo
treepkg is really slow with many revisions
........
r396 | bricks | 2010-08-02 12:41:55 +0200 (Mo, 02 Aug 2010) | 2 lines
fixed typos
........
r397 | bricks | 2010-08-02 17:36:12 +0200 (Mo, 02 Aug 2010) | 3 lines
be more error prone in listing different files
not checking if a dir exists caused several errors if a build wasn't successful
........
r398 | bricks | 2010-08-05 18:21:47 +0200 (Do, 05 Aug 2010) | 2 lines
review changes
........
r399 | bricks | 2010-08-06 13:06:08 +0200 (Fr, 06 Aug 2010) | 4 lines
cleanup modules
fix test_info testcases
added testcases for remove_trailingslashes and expand_filename
........
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Fri, 06 Aug 2010 13:41:54 +0000 |
parents | 383d23c6bfde 8e0c81870e5e |
children | bccd69dedbe5 |
line wrap: on
line source
#! /usr/bin/python # Copyright (C) 2007, 2008, 2009 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. """Publishes selected packages created by treepkg""" import sys import os import shutil import shlex from optparse import OptionParser from ConfigParser import SafeConfigParser import treepkgcmd from treepkg.readconfig import read_config_section, convert_bool from treepkg.run import call, capture_output from treepkg.cmdexpand import cmdexpand from treepkg.util import ensure_directory, listdir_abs, \ remove_trailing_slashes, expand_filename from treepkg.publish import prefix_for_remote_command, copy_to_publishdir config_desc = ["distribution", "section", "num_newest", "build_user", "build_host", "build_listpackages", "publish_user", "publish_host", ("after_upload_hook", shlex.split), ("publish_remove_old_packages", convert_bool), ("publish_dir", remove_trailing_slashes), ("cachedir", lambda s: expand_filename(remove_trailing_slashes(s)))] def read_config(filename): parser = SafeConfigParser() parser.read([filename]) return read_config_section(parser, "publishpackages", config_desc) def parse_commandline(): parser = OptionParser() parser.set_defaults(config_file=os.path.join(treepkgcmd.topdir, "publishpackages.cfg"), quiet=False) parser.add_option("--config-file", help=("The configuration file." " Default is publishpackages.cfg")) parser.add_option("--revision", help=("The revision whose files are to be published." " If not given, the latest revision is used" " The value may be given as REV-RULESREV to specify" " both the main source revision and the revision of" " the packaging rules")) parser.add_option("--dist", help=("The debian distribution name to use on" " the publishing system")) parser.add_option("--section", help=("The debian distribution section name to use on" " the publishing system")) parser.add_option("--track", help=("The package track whose files are to be" " published. If not given, files of all tracks" " will be published")) parser.add_option("--quiet", action="store_true", help=("Do not print progress meters or other" " informational output")) return parser.parse_args() def copy_to_cache(variables, track, revision, arch, quiet): listpackages_vars = variables.copy() if arch == "source": listpackages_vars["pkgtype"] = "--source" else: listpackages_vars["pkgtype"] = "--binary" if track: listpackages_vars["track"] = ["--track", track] else: listpackages_vars["track"] = [] if revision: listpackages_vars["revision"] = ["--revision", revision] else: listpackages_vars["revision"] = [] runremote = prefix_for_remote_command(variables["build_user"], variables["build_host"]) files = capture_output(cmdexpand("@runremote $build_listpackages" " @track @revision $pkgtype" " --newest=$num_newest", runremote=runremote, **listpackages_vars)).splitlines() # scp the packages to the cache dir cachedir = variables["cachedir"] shutil.rmtree(cachedir, ignore_errors=True) ensure_directory(cachedir) if files: if variables["build_host"]: userhost = "%(build_user)s@%(build_host)s:" % variables files = [userhost + filename for filename in files] scp_flags = [] if quiet: scp_flags.append("-q") call(cmdexpand("scp -p @scp_flags @files $cachedir/", files=files, scp_flags=scp_flags, **variables)) def publish_packages_arch(variables, track, revision, dist, section, arch, quiet): copy_to_cache(variables, track, revision, arch, quiet) copy_to_publishdir(variables, dist, section, arch, quiet) def publish_packages(config_filename, track, revision, dist, section, quiet): config = read_config(config_filename) if dist is None: dist = config["distribution"] if section is None: section = config["section"] for arch in ["binary-i386", "source"]: publish_packages_arch(config, track, revision, dist, section, arch, quiet) # update apt archive if config["after_upload_hook"]: call(config["after_upload_hook"]) def main(): options, args = parse_commandline() publish_packages(options.config_file, options.track, options.revision, options.dist, options.section, options.quiet) main()