2635.5.1
by Brendan Donegan
support: add manage_release script |
1 |
#!/usr/bin/python
|
2 |
# This file is part of Checkbox.
|
|
3 |
#
|
|
4 |
# Copyright 2014 Canonical Ltd.
|
|
5 |
# Written by:
|
|
6 |
# Brendan Donegan <brendan.donegan@canonical.com>
|
|
7 |
#
|
|
8 |
# Checkbox is free software: you can redistribute it and/or modify
|
|
9 |
# it under the terms of the GNU General Public License version 3,
|
|
10 |
# as published by the Free Software Foundation.
|
|
11 |
||
12 |
#
|
|
13 |
# Checkbox is distributed in the hope that it will be useful,
|
|
14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 |
# GNU General Public License for more details.
|
|
17 |
#
|
|
18 |
# You should have received a copy of the GNU General Public License
|
|
19 |
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
|
|
20 |
||
21 |
# Manage release of Checkbox packages
|
|
22 |
# ===================================
|
|
23 |
from __future__ import absolute_import, print_function |
|
24 |
||
25 |
import sys |
|
26 |
||
27 |
from argparse import ArgumentParser |
|
28 |
from launchpadlib.launchpad import Launchpad |
|
29 |
from lazr.restfulclient.errors import BadRequest |
|
30 |
||
31 |
COPY_PACKAGES = ['checkbox', 'checkbox-certification', 'fwts'] |
|
32 |
COPY_SERIES = ['precise', 'quantal', 'raring', 'saucy', 'trusty'] |
|
33 |
||
34 |
||
35 |
def _get_distro_series(distro): |
|
36 |
# For now just get from precise forward but later on this
|
|
37 |
# could be made more intelligent
|
|
38 |
distro_series = [] |
|
39 |
for series in COPY_SERIES: |
|
40 |
try: |
|
41 |
distro_series.append(distro.getSeries(name_or_version=series)) |
|
42 |
except BadRequest: |
|
43 |
raise SystemExit("Unable to get info on series '{}' from " |
|
44 |
"Launchpad - make sure this is a valid "
|
|
45 |
"series name.".format(series)) |
|
46 |
return distro_series |
|
47 |
||
48 |
||
49 |
def publish(args): |
|
50 |
lp = Launchpad.login_with(sys.argv[0], 'production') |
|
51 |
# Get all the series we want to publish for
|
|
52 |
ubuntu = lp.distributions['ubuntu'] |
|
53 |
distro_series = _get_distro_series(ubuntu) |
|
54 |
# Get the testing PPA and the stable PPA to copy packages
|
|
55 |
testing_ppa = lp.people['checkbox-dev'].getPPAByName(name='testing') |
|
56 |
stable_ppa = (lp.people['hardware-certification'] |
|
57 |
.getPPAByName(name='public')) |
|
58 |
||
59 |
packages = (COPY_PACKAGES if not args.package else args.package) |
|
60 |
for package in packages: |
|
61 |
for series in distro_series: |
|
62 |
source_package = testing_ppa.getPublishedSources( |
|
63 |
source_name=package, |
|
64 |
distro_series=series) |
|
65 |
if source_package: |
|
66 |
src = source_package[0] |
|
67 |
try: |
|
68 |
stable_ppa.syncSource(from_archive=testing_ppa.self_link, |
|
69 |
include_binaries=True, |
|
70 |
source_name=src.source_package_name, |
|
71 |
to_pocket='Release', |
|
72 |
version=src.source_package_version) |
|
73 |
except BadRequest as error: |
|
74 |
raise SystemExit("Copy failed because {}".format(error)) |
|
75 |
print("Copied {} version {} to stable PPA.".format( |
|
76 |
src.source_package_name, |
|
77 |
src.source_package_version)) |
|
78 |
else: |
|
79 |
print("{} not published in testing PPA.".format(package)) |
|
80 |
||
81 |
||
82 |
def main(): |
|
83 |
parser = ArgumentParser("Tool for managing the release of packages, " |
|
84 |
"to the terms of the Canonical Hardware "
|
|
85 |
"Certification team.") |
|
86 |
subparsers = parser.add_subparsers() |
|
87 |
publish_parser = subparsers.add_parser('publish', help='Publish release') |
|
88 |
publish_parser.set_defaults(func=publish) |
|
89 |
publish_parser.add_argument('-p', '--package', |
|
90 |
action='append', |
|
91 |
help='Package to copy from testing to stable') |
|
92 |
||
93 |
args = parser.parse_args() |
|
94 |
return args.func(args) |
|
95 |
||
96 |
if __name__ == "__main__": |
|
97 |
sys.exit(main()) |