2019-09-04 17:20:40 -03:00
|
|
|
#!/usr/bin/python3
|
2010-12-03 00:06:43 +01:00
|
|
|
#
|
2009-11-30 23:01:47 +01:00
|
|
|
# ubuntu-build - command line interface for Launchpad buildd operations.
|
2008-08-11 21:48:40 +01:00
|
|
|
#
|
2024-03-10 13:35:56 -07:00
|
|
|
# Copyright (C) 2007-2024 Canonical Ltd.
|
2008-08-13 22:39:02 +01:00
|
|
|
# Authors:
|
|
|
|
# - Martin Pitt <martin.pitt@canonical.com>
|
2008-12-29 18:45:57 +00:00
|
|
|
# - Jonathan Davies <jpds@ubuntu.com>
|
2009-07-29 14:49:06 +02:00
|
|
|
# - Michael Bienia <geser@ubuntu.com>
|
2024-03-10 13:35:56 -07:00
|
|
|
# - Steve Langasek <steve.langasek@canonical.com>
|
2008-08-11 21:48:40 +01:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2024-03-10 13:36:30 -07:00
|
|
|
# the Free Software Foundation, version 3 of the License.
|
2008-08-11 21:48:40 +01:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2023-01-30 23:10:31 +01:00
|
|
|
# pylint: disable=invalid-name
|
|
|
|
# pylint: enable=invalid-name
|
|
|
|
|
2023-01-31 13:33:18 +01:00
|
|
|
import argparse
|
2008-08-11 21:48:40 +01:00
|
|
|
import sys
|
2023-01-30 21:28:47 +01:00
|
|
|
|
|
|
|
from launchpadlib.credentials import TokenAuthorizationException
|
2024-03-10 14:35:47 -07:00
|
|
|
from launchpadlib.launchpad import Launchpad
|
|
|
|
import lazr.restfulclient.errors
|
2023-01-30 21:28:47 +01:00
|
|
|
|
|
|
|
from ubuntutools import getLogger
|
2024-03-10 14:35:47 -07:00
|
|
|
from ubuntutools.lp.udtexceptions import PocketDoesNotExistError
|
2010-12-27 22:33:01 +01:00
|
|
|
from ubuntutools.misc import split_release_pocket
|
2008-08-11 21:48:40 +01:00
|
|
|
|
2021-02-01 18:26:13 -05:00
|
|
|
Logger = getLogger()
|
2018-10-12 18:54:07 -04:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2024-03-10 14:35:47 -07:00
|
|
|
def getBuildStates(pkg, archs):
|
|
|
|
res = []
|
|
|
|
|
|
|
|
for build in pkg.getBuilds():
|
|
|
|
if build.arch_tag in archs:
|
|
|
|
res.append(f" {build.arch_tag}: {build.buildstate}")
|
|
|
|
msg = "\n".join(res)
|
|
|
|
return f"Build state(s) for '{pkg.source_package_name}':\n{msg}"
|
|
|
|
|
|
|
|
def rescoreBuilds(pkg, archs, score):
|
|
|
|
res = []
|
|
|
|
|
|
|
|
for build in pkg.getBuilds():
|
|
|
|
arch = build.arch_tag
|
|
|
|
if arch in archs:
|
2024-03-10 16:51:15 -07:00
|
|
|
if not build.can_be_rescored:
|
|
|
|
continue
|
|
|
|
try:
|
|
|
|
build.rescore(score=score)
|
2024-03-10 14:35:47 -07:00
|
|
|
res.append(f" {arch}: done")
|
2024-03-10 16:51:15 -07:00
|
|
|
except lazr.restfulclient.errors.Unauthorized:
|
|
|
|
Logger.error(
|
|
|
|
"You don't have the permissions to rescore builds. Ignoring your rescore request."
|
|
|
|
)
|
|
|
|
return None
|
|
|
|
except lazr.restfulclient.errors.BadRequest:
|
|
|
|
Logger.info("Cannot rescore build of %s on %s.",
|
|
|
|
build.source_package_name, arch)
|
2024-03-10 14:35:47 -07:00
|
|
|
res.append(f" {arch}: failed")
|
2024-03-10 16:51:15 -07:00
|
|
|
|
2024-03-10 14:35:47 -07:00
|
|
|
msg = "\n".join(res)
|
|
|
|
return f"Rescoring builds of '{pkg.source_package_name}' to {score}:\n{msg}"
|
|
|
|
|
|
|
|
def retryBuilds(pkg, archs):
|
|
|
|
res = []
|
|
|
|
for build in pkg.getBuilds():
|
|
|
|
arch = build.arch_tag
|
|
|
|
if arch in archs:
|
|
|
|
try:
|
|
|
|
build.retry()
|
|
|
|
res.append(f" {arch}: done")
|
|
|
|
except lazr.restfulclient.errors.BadRequest:
|
|
|
|
res.append(f" {arch}: failed")
|
|
|
|
msg = "\n".join(res)
|
|
|
|
return f"Retrying builds of '{pkg.source_package_name}':\n{msg}"
|
|
|
|
|
|
|
|
|
2010-12-27 19:55:48 +01:00
|
|
|
def main():
|
|
|
|
# Usage.
|
2023-01-31 13:33:18 +01:00
|
|
|
usage = "%(prog)s <srcpackage> <release> <operation>\n\n"
|
2010-12-27 19:55:48 +01:00
|
|
|
usage += "Where operation may be one of: rescore, retry, or status.\n"
|
|
|
|
usage += "Only Launchpad Buildd Admins may rescore package builds."
|
|
|
|
|
|
|
|
# Valid architectures.
|
2023-01-30 19:45:36 +01:00
|
|
|
valid_archs = set(
|
|
|
|
[
|
|
|
|
"armhf",
|
|
|
|
"arm64",
|
|
|
|
"amd64",
|
|
|
|
"i386",
|
|
|
|
"powerpc",
|
|
|
|
"ppc64el",
|
|
|
|
"riscv64",
|
|
|
|
"s390x",
|
|
|
|
]
|
|
|
|
)
|
2010-12-27 19:55:48 +01:00
|
|
|
|
|
|
|
# Prepare our option parser.
|
2023-01-31 13:33:18 +01:00
|
|
|
parser = argparse.ArgumentParser(usage=usage)
|
2010-12-27 19:55:48 +01:00
|
|
|
|
2024-03-08 18:53:16 -08:00
|
|
|
parser.add_argument(
|
2023-01-30 19:45:36 +01:00
|
|
|
"-a",
|
|
|
|
"--arch",
|
|
|
|
action="append",
|
|
|
|
dest="architecture",
|
2023-01-31 19:32:58 +01:00
|
|
|
help=f"Rebuild or rescore a specific architecture. Valid architectures "
|
|
|
|
f"include: {', '.join(valid_archs)}.",
|
2023-01-30 19:45:36 +01:00
|
|
|
)
|
2010-12-27 19:55:48 +01:00
|
|
|
|
2024-03-10 14:35:47 -07:00
|
|
|
parser.add_argument("-A", "--archive", help="operate on ARCHIVE",
|
|
|
|
default="ubuntu")
|
|
|
|
|
2010-12-27 19:55:48 +01:00
|
|
|
# Batch processing options
|
2023-01-31 13:33:18 +01:00
|
|
|
batch_options = parser.add_argument_group(
|
2023-01-30 19:45:36 +01:00
|
|
|
"Batch processing",
|
|
|
|
"These options and parameter ordering is only "
|
|
|
|
"available in --batch mode.\nUsage: "
|
|
|
|
"ubuntu-build --batch [options] <package>...",
|
|
|
|
)
|
2023-01-31 13:33:18 +01:00
|
|
|
batch_options.add_argument(
|
|
|
|
"--batch", action="store_true", dest="batch", help="Enable batch mode"
|
2023-01-30 19:45:36 +01:00
|
|
|
)
|
2023-01-31 13:33:18 +01:00
|
|
|
batch_options.add_argument(
|
2023-01-30 19:45:36 +01:00
|
|
|
"--series",
|
|
|
|
action="store",
|
|
|
|
dest="series",
|
|
|
|
help="Selects the Ubuntu series to operate on (default: current development series)",
|
|
|
|
)
|
2023-01-31 13:33:18 +01:00
|
|
|
batch_options.add_argument(
|
|
|
|
"--retry", action="store_true", dest="retry", help="Retry builds (give-back)."
|
2023-01-30 19:45:36 +01:00
|
|
|
)
|
2023-01-31 13:33:18 +01:00
|
|
|
batch_options.add_argument(
|
2023-01-30 19:45:36 +01:00
|
|
|
"--rescore",
|
|
|
|
action="store",
|
|
|
|
dest="priority",
|
2023-01-31 13:33:18 +01:00
|
|
|
type=int,
|
2023-01-30 19:45:36 +01:00
|
|
|
help="Rescore builds to <priority>.",
|
|
|
|
)
|
2024-03-10 01:45:20 -08:00
|
|
|
batch_options.add_argument(
|
|
|
|
"--state", action="store", dest="state",
|
2024-03-10 14:35:47 -07:00
|
|
|
help="Act on builds that are in the specified state",
|
2024-03-10 01:45:20 -08:00
|
|
|
)
|
|
|
|
|
2024-03-08 16:43:30 -08:00
|
|
|
parser.add_argument("packages", metavar="package", nargs="*", help=argparse.SUPPRESS)
|
2010-12-27 19:55:48 +01:00
|
|
|
|
|
|
|
# Parse our options.
|
2023-01-31 13:33:18 +01:00
|
|
|
args = parser.parse_args()
|
2010-12-22 23:04:29 +02:00
|
|
|
|
2024-03-10 14:35:47 -07:00
|
|
|
launchpad = Launchpad.login_with("ubuntu-dev-tools", "production",
|
|
|
|
version="devel")
|
|
|
|
me = launchpad.me
|
2023-07-07 19:23:41 +02:00
|
|
|
|
2024-03-10 14:35:47 -07:00
|
|
|
ubuntu = launchpad.distributions['ubuntu']
|
|
|
|
|
|
|
|
if args.batch:
|
|
|
|
release = args.series
|
|
|
|
if not release:
|
2024-03-10 20:52:05 -07:00
|
|
|
# ppas don't have a proposed pocket so just use the release pocket;
|
|
|
|
# but for the main archive we default to -proposed
|
|
|
|
release = ubuntu.getDevelopmentSeries()[0].name
|
|
|
|
if args.archive == 'ubuntu':
|
|
|
|
release = release + "-proposed"
|
2024-03-10 14:35:47 -07:00
|
|
|
try:
|
|
|
|
(release, pocket) = split_release_pocket(release)
|
|
|
|
except PocketDoesNotExistError as error:
|
|
|
|
Logger.error(error)
|
|
|
|
sys.exit(1)
|
|
|
|
else:
|
2010-12-27 19:55:48 +01:00
|
|
|
# Check we have the correct number of arguments.
|
2023-01-31 13:33:18 +01:00
|
|
|
if len(args.packages) < 3:
|
|
|
|
parser.error("Incorrect number of arguments.")
|
2010-12-27 19:55:48 +01:00
|
|
|
|
|
|
|
try:
|
2023-01-31 13:33:18 +01:00
|
|
|
package = str(args.packages[0]).lower()
|
|
|
|
release = str(args.packages[1]).lower()
|
|
|
|
operation = str(args.packages[2]).lower()
|
2010-12-27 19:55:48 +01:00
|
|
|
except IndexError:
|
2023-01-31 13:33:18 +01:00
|
|
|
parser.print_help()
|
2010-12-27 19:55:48 +01:00
|
|
|
sys.exit(1)
|
2010-12-22 23:04:29 +02:00
|
|
|
|
2024-03-10 14:35:47 -07:00
|
|
|
archive = launchpad.archives.getByReference(reference=args.archive)
|
|
|
|
try:
|
|
|
|
distroseries = ubuntu.getSeries(name_or_version=release)
|
|
|
|
except lazr.restfulclient.errors.NotFound as error:
|
|
|
|
Logger.error(error)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if not args.batch:
|
2010-12-27 19:55:48 +01:00
|
|
|
# Check our operation.
|
2023-01-30 23:10:31 +01:00
|
|
|
if operation not in ("rescore", "retry", "status"):
|
2023-01-31 11:13:07 +01:00
|
|
|
Logger.error("Invalid operation: %s.", operation)
|
2010-12-22 23:04:29 +02:00
|
|
|
sys.exit(1)
|
2010-12-27 19:55:48 +01:00
|
|
|
|
|
|
|
# If the user has specified an architecture to build, we only wish to
|
|
|
|
# rebuild it and nothing else.
|
2023-01-31 13:33:18 +01:00
|
|
|
if args.architecture:
|
|
|
|
if args.architecture[0] not in valid_archs:
|
|
|
|
Logger.error("Invalid architecture specified: %s.", args.architecture[0])
|
2010-12-27 19:55:48 +01:00
|
|
|
sys.exit(1)
|
|
|
|
else:
|
|
|
|
one_arch = True
|
2010-12-22 23:04:29 +02:00
|
|
|
else:
|
2010-12-27 19:55:48 +01:00
|
|
|
one_arch = False
|
|
|
|
|
|
|
|
# split release and pocket
|
|
|
|
try:
|
2010-12-27 22:33:01 +01:00
|
|
|
(release, pocket) = split_release_pocket(release)
|
2019-09-04 17:20:40 -03:00
|
|
|
except PocketDoesNotExistError as error:
|
2018-10-12 18:54:07 -04:00
|
|
|
Logger.error(error)
|
2010-12-27 19:55:48 +01:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# Get list of published sources for package in question.
|
|
|
|
try:
|
2024-03-10 14:35:47 -07:00
|
|
|
sources = archive.getPublishedSources(
|
|
|
|
distro_series=distroseries,
|
2024-03-10 15:46:22 -07:00
|
|
|
exact_match=True,
|
2024-03-10 14:35:47 -07:00
|
|
|
pocket=pocket,
|
|
|
|
source_name=package,
|
|
|
|
status='Published')[0]
|
|
|
|
except IndexError as error:
|
|
|
|
Logger.error("No publication found for package %s", package)
|
2010-12-27 19:55:48 +01:00
|
|
|
sys.exit(1)
|
|
|
|
# Get list of builds for that package.
|
|
|
|
builds = sources.getBuilds()
|
|
|
|
|
|
|
|
# Find out the version and component in given release.
|
2024-03-10 14:35:47 -07:00
|
|
|
version = sources.source_package_version
|
|
|
|
component = sources.component_name
|
2010-12-27 19:55:48 +01:00
|
|
|
|
|
|
|
# Operations that are remaining may only be done by Ubuntu developers
|
|
|
|
# (retry) or buildd admins (rescore). Check if the proper permissions
|
|
|
|
# are in place.
|
2023-01-30 23:10:31 +01:00
|
|
|
if operation == "retry":
|
2024-03-10 14:35:47 -07:00
|
|
|
necessary_privs = archive.checkUpload(
|
|
|
|
component=sources.getComponent(),
|
|
|
|
distroseries=distroseries,
|
|
|
|
person=launchpad.me,
|
|
|
|
pocket=pocket,
|
|
|
|
sourcepackagename=sources.getPackageName(),
|
2023-01-30 19:45:36 +01:00
|
|
|
)
|
|
|
|
|
2024-03-10 16:51:15 -07:00
|
|
|
if operation == "retry" and not necessary_privs:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error(
|
2023-01-31 11:13:07 +01:00
|
|
|
"You cannot perform the %s operation on a %s package as you"
|
|
|
|
" do not have the permissions to do this action.",
|
|
|
|
operation,
|
|
|
|
component,
|
2023-01-30 19:45:36 +01:00
|
|
|
)
|
2010-12-27 19:55:48 +01:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# Output details.
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.info(
|
2023-01-31 11:13:07 +01:00
|
|
|
"The source version for '%s' in %s (%s) is at %s.",
|
|
|
|
package,
|
|
|
|
release.capitalize(),
|
|
|
|
component,
|
|
|
|
version,
|
2023-01-30 19:45:36 +01:00
|
|
|
)
|
2010-12-27 19:55:48 +01:00
|
|
|
|
2018-10-12 18:54:07 -04:00
|
|
|
Logger.info("Current build status for this package:")
|
2010-12-27 19:55:48 +01:00
|
|
|
|
|
|
|
# Output list of arches for package and their status.
|
|
|
|
done = False
|
|
|
|
for build in builds:
|
2023-01-31 13:33:18 +01:00
|
|
|
if one_arch and build.arch_tag != args.architecture[0]:
|
2010-12-27 19:55:48 +01:00
|
|
|
# Skip this architecture.
|
|
|
|
continue
|
|
|
|
|
|
|
|
done = True
|
2023-01-31 11:13:07 +01:00
|
|
|
Logger.info("%s: %s.", build.arch_tag, build.buildstate)
|
2023-01-30 23:10:31 +01:00
|
|
|
if operation == "rescore":
|
2010-12-27 19:55:48 +01:00
|
|
|
if build.can_be_rescored:
|
|
|
|
# FIXME: make priority an option
|
|
|
|
priority = 5000
|
2023-01-31 11:13:07 +01:00
|
|
|
Logger.info("Rescoring build %s to %d...", build.arch_tag, priority)
|
2024-03-10 16:51:15 -07:00
|
|
|
try:
|
|
|
|
build.rescore(score=priority)
|
|
|
|
except lazr.restfulclient.errors.Unauthorized:
|
|
|
|
Logger.error(
|
|
|
|
"You don't have the permissions to rescore builds. Ignoring your rescore request."
|
|
|
|
)
|
|
|
|
break
|
2010-12-27 19:55:48 +01:00
|
|
|
else:
|
2023-01-31 11:13:07 +01:00
|
|
|
Logger.info("Cannot rescore build on %s.", build.arch_tag)
|
2023-01-30 23:10:31 +01:00
|
|
|
if operation == "retry":
|
2010-12-27 19:55:48 +01:00
|
|
|
if build.can_be_retried:
|
2023-01-31 11:13:07 +01:00
|
|
|
Logger.info("Retrying build on %s...", build.arch_tag)
|
2010-12-27 19:55:48 +01:00
|
|
|
build.retry()
|
|
|
|
else:
|
2023-01-31 11:13:07 +01:00
|
|
|
Logger.info("Cannot retry build on %s.", build.arch_tag)
|
2010-12-27 19:55:48 +01:00
|
|
|
|
|
|
|
# We are done
|
|
|
|
if done:
|
|
|
|
sys.exit(0)
|
|
|
|
|
2023-01-31 11:13:07 +01:00
|
|
|
Logger.info("No builds for '%s' found in the %s release", package, release.capitalize())
|
2018-10-12 18:54:07 -04:00
|
|
|
Logger.info("It may have been built in a former release.")
|
2010-12-27 19:55:48 +01:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
# Batch mode
|
|
|
|
|
2023-01-31 13:33:18 +01:00
|
|
|
if not args.architecture:
|
2010-12-27 19:55:48 +01:00
|
|
|
# no specific architectures specified, assume all valid ones
|
|
|
|
archs = valid_archs
|
2010-12-22 23:04:29 +02:00
|
|
|
else:
|
2023-01-31 13:33:18 +01:00
|
|
|
archs = set(args.architecture)
|
2010-12-27 19:55:48 +01:00
|
|
|
|
|
|
|
# filter out duplicate and invalid architectures
|
|
|
|
archs.intersection_update(valid_archs)
|
2010-12-22 23:04:29 +02:00
|
|
|
|
2024-03-08 16:43:30 -08:00
|
|
|
if not args.packages:
|
2024-03-08 18:38:59 -08:00
|
|
|
retry_count = 0
|
2024-03-10 16:51:15 -07:00
|
|
|
can_rescore = True
|
2024-03-08 18:38:59 -08:00
|
|
|
|
2024-03-10 01:45:20 -08:00
|
|
|
if not args.state:
|
2024-03-10 14:35:47 -07:00
|
|
|
if args.retry:
|
|
|
|
args.state='Failed to build'
|
|
|
|
elif args.priority:
|
|
|
|
args.state='Needs building'
|
|
|
|
# there is no equivalent to series.getBuildRecords() for a ppa.
|
|
|
|
# however, we don't want to have to traverse all build records for
|
|
|
|
# all series when working on the main archive, so we use
|
|
|
|
# series.getBuildRecords() for ubuntu and handle ppas separately
|
|
|
|
series = ubuntu.getSeries(name_or_version=release)
|
|
|
|
if args.archive == 'ubuntu':
|
|
|
|
builds = series.getBuildRecords(build_state=args.state,
|
|
|
|
pocket=pocket)
|
|
|
|
else:
|
|
|
|
builds = []
|
|
|
|
for build in archive.getBuildRecords(build_state=args.state,
|
|
|
|
pocket=pocket):
|
|
|
|
if not build.current_source_publication:
|
|
|
|
continue
|
|
|
|
if build.current_source_publication.distro_series==series:
|
|
|
|
builds.append(build)
|
|
|
|
for build in builds:
|
2024-03-08 16:43:30 -08:00
|
|
|
if build.arch_tag not in archs:
|
|
|
|
continue
|
|
|
|
if not build.current_source_publication:
|
|
|
|
continue
|
|
|
|
# fixme: refactor
|
|
|
|
# Check permissions (part 2): check upload permissions for the
|
|
|
|
# source package
|
2024-03-10 14:35:47 -07:00
|
|
|
can_retry = args.retry and archive.checkUpload(
|
|
|
|
component=build.current_source_publication.component_name,
|
|
|
|
distroseries=series,
|
|
|
|
person=launchpad.me,
|
|
|
|
pocket=pocket,
|
|
|
|
sourcepackagename=build.source_package_name,
|
2024-03-08 16:43:30 -08:00
|
|
|
)
|
|
|
|
if args.retry and not can_retry:
|
|
|
|
Logger.error(
|
|
|
|
"You don't have the permissions to retry the "
|
|
|
|
"build of '%s', skipping.",
|
|
|
|
build.source_package_name
|
|
|
|
)
|
|
|
|
continue
|
|
|
|
Logger.info(
|
|
|
|
"The source version for '%s' in '%s' (%s) is: %s",
|
|
|
|
build.source_package_name,
|
|
|
|
release,
|
|
|
|
pocket,
|
|
|
|
build.source_package_version
|
|
|
|
)
|
|
|
|
|
2024-03-12 11:52:32 -07:00
|
|
|
if args.retry and build.can_be_retried:
|
2024-03-08 16:43:30 -08:00
|
|
|
Logger.info("Retrying build of %s on %s...",
|
|
|
|
build.source_package_name, build.arch_tag)
|
|
|
|
build.retry()
|
2024-03-12 11:52:32 -07:00
|
|
|
retry_count += 1
|
2024-03-10 14:35:47 -07:00
|
|
|
|
2024-03-08 16:43:30 -08:00
|
|
|
if args.priority and can_rescore:
|
2024-03-10 14:35:47 -07:00
|
|
|
if build.can_be_rescored:
|
2024-03-10 16:51:15 -07:00
|
|
|
try:
|
|
|
|
build.rescore(score=args.priority)
|
|
|
|
except lazr.restfulclient.errors.Unauthorized:
|
|
|
|
Logger.error(
|
|
|
|
"You don't have the permissions to rescore builds. Ignoring your rescore request."
|
|
|
|
)
|
|
|
|
can_rescore = False
|
|
|
|
except lazr.restfulclient.errors.BadRequest:
|
|
|
|
Logger.info("Cannot rescore build of %s on %s.",
|
2024-03-10 14:35:47 -07:00
|
|
|
build.source_package_name, build.arch_tag)
|
2024-03-08 16:43:30 -08:00
|
|
|
|
|
|
|
Logger.info("")
|
2024-03-10 14:35:47 -07:00
|
|
|
if args.retry:
|
|
|
|
Logger.info("%d package builds retried", retry_count)
|
2024-03-08 16:43:30 -08:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
2023-01-31 13:33:18 +01:00
|
|
|
for pkg in args.packages:
|
2010-12-27 19:55:48 +01:00
|
|
|
try:
|
2024-03-10 14:35:47 -07:00
|
|
|
pkg = archive.getPublishedSources(
|
|
|
|
distro_series=distroseries,
|
2024-03-10 15:46:22 -07:00
|
|
|
exact_match=True,
|
2024-03-10 14:35:47 -07:00
|
|
|
pocket=pocket,
|
|
|
|
source_name=pkg,
|
|
|
|
status='Published')[0]
|
|
|
|
except IndexError as error:
|
|
|
|
Logger.error("No publication found for package %s", pkg)
|
2010-12-22 23:04:29 +02:00
|
|
|
continue
|
|
|
|
|
2010-12-27 19:55:48 +01:00
|
|
|
# Check permissions (part 2): check upload permissions for the source
|
|
|
|
# package
|
2024-03-10 14:35:47 -07:00
|
|
|
can_retry = args.retry and archive.checkUpload(
|
|
|
|
component=pkg.component_name,
|
|
|
|
distroseries=distroseries,
|
|
|
|
person=launchpad.me,
|
|
|
|
pocket=pocket,
|
|
|
|
sourcepackagename=pkg.source_package_name,
|
2023-01-30 19:45:36 +01:00
|
|
|
)
|
2023-01-31 13:33:18 +01:00
|
|
|
if args.retry and not can_retry:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error(
|
|
|
|
"You don't have the permissions to retry the "
|
2023-01-31 11:13:07 +01:00
|
|
|
"build of '%s'. Ignoring your request.",
|
2024-03-10 14:35:47 -07:00
|
|
|
pkg.source_package_name,
|
2023-01-30 19:45:36 +01:00
|
|
|
)
|
2010-12-27 19:55:48 +01:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.info(
|
2023-01-31 11:13:07 +01:00
|
|
|
"The source version for '%s' in '%s' (%s) is: %s",
|
2024-03-10 14:35:47 -07:00
|
|
|
pkg.source_package_name,
|
2023-01-31 11:13:07 +01:00
|
|
|
release,
|
|
|
|
pocket,
|
2024-03-10 14:35:47 -07:00
|
|
|
pkg.source_package_version,
|
2023-01-30 19:45:36 +01:00
|
|
|
)
|
2010-12-27 19:55:48 +01:00
|
|
|
|
2024-03-10 14:35:47 -07:00
|
|
|
Logger.info(getBuildStates(pkg, archs))
|
2010-12-27 19:55:48 +01:00
|
|
|
if can_retry:
|
2024-03-10 14:35:47 -07:00
|
|
|
Logger.info(retryBuilds(pkg, archs))
|
2024-03-10 16:51:15 -07:00
|
|
|
if args.priority:
|
2024-03-10 14:35:47 -07:00
|
|
|
Logger.info(rescoreBuilds(pkg, archs, args.priority))
|
2010-12-27 19:55:48 +01:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.info("")
|
2010-12-27 19:55:48 +01:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
if __name__ == "__main__":
|
2010-12-27 19:55:48 +01:00
|
|
|
main()
|
2024-03-10 14:35:47 -07:00
|
|
|
|