989
by Colin Watson
bootstrap-package: new tool to bootstrap a single package using injected build-dependencies |
1 |
#! /usr/bin/python
|
2 |
||
3 |
# Copyright (C) 2016 Canonical Ltd.
|
|
4 |
# Author: Colin Watson <cjwatson@ubuntu.com>
|
|
5 |
||
6 |
# This program is free software: you can redistribute it and/or modify
|
|
7 |
# it under the terms of the GNU General Public License as published by
|
|
8 |
# the Free Software Foundation; version 3 of the License.
|
|
9 |
#
|
|
10 |
# This program is distributed in the hope that it will be useful,
|
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
# GNU General Public License for more details.
|
|
14 |
#
|
|
15 |
# You should have received a copy of the GNU General Public License
|
|
16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
||
18 |
"""Bootstrap a package build using injected build-dependencies."""
|
|
19 |
||
20 |
from __future__ import print_function |
|
21 |
import sys |
|
22 |
||
23 |
from optparse import ( |
|
24 |
OptionParser, |
|
25 |
SUPPRESS_HELP, |
|
26 |
)
|
|
27 |
||
28 |
from launchpadlib.launchpad import Launchpad |
|
29 |
||
30 |
import lputils |
|
31 |
||
32 |
||
33 |
def bootstrap_package(options, package): |
|
34 |
source = lputils.find_latest_published_source(options, package) |
|
35 |
arch_tags = [a.architecture_tag for a in options.architectures] |
|
36 |
for build in source.getBuilds(): |
|
37 |
if build.arch_tag in arch_tags: |
|
999
by Colin Watson
bootstrap-package: allow bootstrapping builds that are still "Needs building" |
38 |
if (build.buildstate != "Needs building" and |
39 |
not build.can_be_retried): |
|
989
by Colin Watson
bootstrap-package: new tool to bootstrap a single package using injected build-dependencies |
40 |
print("%s cannot be retried" % build.web_link, file=sys.stderr) |
41 |
elif options.dry_run: |
|
42 |
print("Would bootstrap %s" % build.web_link) |
|
43 |
else: |
|
44 |
print("Bootstrapping %s" % build.web_link) |
|
45 |
build.external_dependencies = ( |
|
1120
by Colin Watson
bootstrap-package: set [trusted=yes] for bootstrap archive |
46 |
"deb [trusted=yes] "
|
47 |
"http://archive-team.internal/bootstrap/%s %s main" % |
|
989
by Colin Watson
bootstrap-package: new tool to bootstrap a single package using injected build-dependencies |
48 |
(build.arch_tag, source.distro_series.name)) |
49 |
build.lp_save() |
|
50 |
build.retry() |
|
51 |
||
52 |
||
53 |
def bootstrap_packages(options, packages): |
|
54 |
for package in packages: |
|
55 |
bootstrap_package(options, package) |
|
56 |
||
57 |
||
58 |
def main(): |
|
59 |
parser = OptionParser( |
|
60 |
usage="usage: %prog [options] package [...]", |
|
61 |
epilog=lputils.ARCHIVE_REFERENCE_DESCRIPTION) |
|
62 |
parser.add_option( |
|
63 |
"-l", "--launchpad", dest="launchpad_instance", default="production") |
|
64 |
parser.add_option( |
|
65 |
"-n", "--dry-run", default=False, action="store_true", |
|
66 |
help="only show what would be done") |
|
67 |
parser.add_option("-A", "--archive", help="bootstrap in ARCHIVE") |
|
68 |
parser.add_option( |
|
69 |
"-s", "--suite", metavar="SUITE", help="bootstrap in SUITE") |
|
70 |
parser.add_option( |
|
71 |
"-a", "--architecture", dest="architectures", action="append", |
|
72 |
metavar="ARCHITECTURE", |
|
73 |
help="architecture tag (may be given multiple times)") |
|
74 |
parser.add_option( |
|
75 |
"-d", "--distribution", default="ubuntu", help=SUPPRESS_HELP) |
|
76 |
parser.add_option( |
|
77 |
"-e", "--version", |
|
78 |
metavar="VERSION", help="package version (default: current version)") |
|
79 |
||
80 |
options, args = parser.parse_args() |
|
81 |
||
82 |
options.launchpad = Launchpad.login_with( |
|
83 |
"bootstrap-package", options.launchpad_instance, version="devel") |
|
84 |
lputils.setup_location(options, default_pocket="Proposed") |
|
85 |
||
86 |
if not args: |
|
87 |
parser.error("You must specify some packages to bootstrap.") |
|
88 |
||
89 |
bootstrap_packages(options, args) |
|
90 |
||
91 |
||
92 |
if __name__ == "__main__": |
|
93 |
main() |