Mercurial > treepkg
comparison bin/publishpackages.py @ 200:ce03e24f6d0f
publishpackages command: if --track is omitted, publish files of all tracks.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Wed, 20 Aug 2008 13:30:21 +0000 |
parents | 3caf4a5ecbf0 |
children | 55337021fe5b |
comparison
equal
deleted
inserted
replaced
199:24d119c27150 | 200:ce03e24f6d0f |
---|---|
1 #! /usr/bin/python2.4 | 1 #! /usr/bin/python2.4 |
2 # Copyright (C) 2007 by Intevation GmbH | 2 # Copyright (C) 2007, 2008 by Intevation GmbH |
3 # Authors: | 3 # Authors: |
4 # Bernhard Herzog <bh@intevation.de> | 4 # Bernhard Herzog <bh@intevation.de> |
5 # | 5 # |
6 # This program is free software under the GPL (>=v2) | 6 # This program is free software under the GPL (>=v2) |
7 # Read the file COPYING coming with the software for details. | 7 # Read the file COPYING coming with the software for details. |
57 parser.add_option("--section", | 57 parser.add_option("--section", |
58 help=("The debian distribution section name to use on" | 58 help=("The debian distribution section name to use on" |
59 " the publishing system")) | 59 " the publishing system")) |
60 parser.add_option("--track", | 60 parser.add_option("--track", |
61 help=("The package track whose files are to be" | 61 help=("The package track whose files are to be" |
62 " published")) | 62 " published. If not given, files of all tracks" |
63 " will be published")) | |
63 return parser.parse_args() | 64 return parser.parse_args() |
64 | 65 |
65 | 66 |
66 def publish_packages_arch(variables, track, revision, dist, section, arch): | 67 def publish_packages_arch(variables, track, revision, dist, section, arch): |
67 # create web-page on build host | 68 # create web-page on build host |
69 listpackages_vars = variables.copy() | |
70 | |
68 if arch == "source": | 71 if arch == "source": |
69 variables["pkgtype"] = "--source" | 72 listpackages_vars["pkgtype"] = "--source" |
70 else: | 73 else: |
71 variables["pkgtype"] = "--binary" | 74 listpackages_vars["pkgtype"] = "--binary" |
75 | |
76 if track: | |
77 listpackages_vars["track"] = ["--track", track] | |
78 else: | |
79 listpackages_vars["track"] = [] | |
80 | |
81 if revision: | |
82 listpackages_vars["revision"] = ["--revision", revision] | |
83 else: | |
84 listpackages_vars["revision"] = [] | |
72 | 85 |
73 files = capture_output(cmdexpand("ssh $build_user$@$build_host" | 86 files = capture_output(cmdexpand("ssh $build_user$@$build_host" |
74 " $build_listpackages" | 87 " $build_listpackages" |
75 " --track $track @revision $pkgtype", | 88 " @track @revision $pkgtype", |
76 **variables)).strip().split("\n") | 89 **listpackages_vars)).strip().split("\n") |
90 | |
77 # scp the packages to the cache dir | 91 # scp the packages to the cache dir |
78 cachedir = variables["cachedir"] | 92 cachedir = variables["cachedir"] |
79 shutil.rmtree(cachedir, ignore_errors=True) | 93 shutil.rmtree(cachedir, ignore_errors=True) |
80 ensure_directory(cachedir) | 94 ensure_directory(cachedir) |
81 userhost = "%(build_user)s@%(build_host)s:" % variables | 95 userhost = "%(build_user)s@%(build_host)s:" % variables |
94 | 108 |
95 | 109 |
96 def publish_packages(config_filename, track, revision, dist, section): | 110 def publish_packages(config_filename, track, revision, dist, section): |
97 config = read_config(config_filename) | 111 config = read_config(config_filename) |
98 | 112 |
99 variables = config.copy() | |
100 variables["track"] = track | |
101 if revision: | |
102 variables["revision"] = ["--revision", revision] | |
103 else: | |
104 variables["revision"] = [] | |
105 | |
106 for arch in ["binary-i386", "source"]: | 113 for arch in ["binary-i386", "source"]: |
107 publish_packages_arch(variables, track, revision, dist, section, arch) | 114 publish_packages_arch(config, track, revision, dist, section, arch) |
108 | 115 |
109 # update apt archive | 116 # update apt archive |
110 call(cmdexpand("ssh $publish_user$@$publish_host" | 117 call(cmdexpand("ssh $publish_user$@$publish_host" |
111 " $publish_apt_archive_update", | 118 " $publish_apt_archive_update", |
112 **variables)) | 119 **config)) |
113 | 120 |
114 def main(): | 121 def main(): |
115 options, args = parse_commandline() | 122 options, args = parse_commandline() |
116 for required_opt in ["track", "dist", "section"]: | 123 for required_opt in ["dist", "section"]: |
117 if getattr(options, required_opt) is None: | 124 if getattr(options, required_opt) is None: |
118 print >>sys.stderr, "The --%s option must be given" % required_opt | 125 print >>sys.stderr, "The --%s option must be given" % required_opt |
119 sys.exit(1) | 126 sys.exit(1) |
120 publish_packages(options.config_file, options.track, options.revision, | 127 publish_packages(options.config_file, options.track, options.revision, |
121 options.dist, options.section) | 128 options.dist, options.section) |