From bb8a9f73941947c683544627afd49e3e8ab52d2d Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Fri, 8 Mar 2024 16:43:30 -0800 Subject: [PATCH 01/11] ubuntu-build: support --batch with no package names to retry all --- ubuntu-build | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/ubuntu-build b/ubuntu-build index acbf140..17946fa 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -112,7 +112,7 @@ def main(): help=f"Affect only 'architecture' (can be used several times)." f" Valid architectures are: {', '.join(valid_archs)}.", ) - parser.add_argument("packages", metavar="package", nargs="+", help=argparse.SUPPRESS) + parser.add_argument("packages", metavar="package", nargs="*", help=argparse.SUPPRESS) # Parse our options. args = parser.parse_args() @@ -275,6 +275,51 @@ def main(): "You don't have the permissions to rescore builds. Ignoring your rescore request." ) + if not args.packages: + series = Distribution("ubuntu").getSeries(release) + for build in series.getBuildRecords( + build_state='Failed to build', pocket=pocket + ): + 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 + can_retry = args.retry and me.canUploadPackage( + ubuntu_archive, series, build.source_package_name, + build.current_source_publication.component_name + ) + 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 + ) + + if can_retry: + Logger.info("Retrying build of %s on %s...", + build.source_package_name, build.arch_tag) + build.retry() + else: + Logger.info("Cannot retry build of %s on %s.", + build.source_package_name, build.arch_tag) + if args.priority and can_rescore: + Logger.info(pkg.rescoreBuilds(archs, args.priority)) + + Logger.info("") + sys.exit(0) + + for pkg in args.packages: try: pkg = ubuntu_archive.getSourcePackage(pkg, release, pocket) From 42f8e5c0d2735b29611828ac51af6c0bf5016ee3 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Fri, 8 Mar 2024 18:38:59 -0800 Subject: [PATCH 02/11] ubuntu-build: in batch mode, print a count of packages retried --- ubuntu-build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ubuntu-build b/ubuntu-build index 17946fa..fbf7397 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -276,6 +276,8 @@ def main(): ) if not args.packages: + retry_count = 0 + series = Distribution("ubuntu").getSeries(release) for build in series.getBuildRecords( build_state='Failed to build', pocket=pocket @@ -309,6 +311,7 @@ def main(): if can_retry: Logger.info("Retrying build of %s on %s...", build.source_package_name, build.arch_tag) + retry_count += 1 build.retry() else: Logger.info("Cannot retry build of %s on %s.", @@ -317,6 +320,7 @@ def main(): Logger.info(pkg.rescoreBuilds(archs, args.priority)) Logger.info("") + Logger.info("%d package builds retried", retry_count) sys.exit(0) From f01502bda272131b40319b407090baefd0d6f829 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Fri, 8 Mar 2024 18:53:16 -0800 Subject: [PATCH 03/11] ubuntu-build: make the --arch option top-level This gets rid of the fugly --arch2 option --- ubuntu-build | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/ubuntu-build b/ubuntu-build index fbf7397..c83ead6 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -65,12 +65,7 @@ def main(): # Prepare our option parser. parser = argparse.ArgumentParser(usage=usage) - # Retry options - retry_rescore_options = parser.add_argument_group( - "Retry and rescore options", - "These options may only be used with the 'retry' and 'rescore' operations.", - ) - retry_rescore_options.add_argument( + parser.add_argument( "-a", "--arch", action="append", @@ -105,13 +100,6 @@ def main(): type=int, help="Rescore builds to .", ) - batch_options.add_argument( - "--arch2", - action="append", - dest="architecture", - help=f"Affect only 'architecture' (can be used several times)." - f" Valid architectures are: {', '.join(valid_archs)}.", - ) parser.add_argument("packages", metavar="package", nargs="*", help=argparse.SUPPRESS) # Parse our options. From 691c1381dbbac02105c2dfe9aea14c7ee65c8996 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Sun, 10 Mar 2024 01:45:20 -0800 Subject: [PATCH 04/11] ubuntu-build: support retrying builds in other states that failed-to-build --- ubuntu-build | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ubuntu-build b/ubuntu-build index c83ead6..5fba28e 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -100,6 +100,11 @@ def main(): type=int, help="Rescore builds to .", ) + batch_options.add_argument( + "--state", action="store", dest="state", + help="Act on builds that are in the specified state (default: Failed to build)", + ) + parser.add_argument("packages", metavar="package", nargs="*", help=argparse.SUPPRESS) # Parse our options. @@ -266,9 +271,11 @@ def main(): if not args.packages: retry_count = 0 + if not args.state: + args.state='Failed to build' series = Distribution("ubuntu").getSeries(release) for build in series.getBuildRecords( - build_state='Failed to build', pocket=pocket + build_state=args.state, pocket=pocket ): if build.arch_tag not in archs: continue From 688202a7cf43fac30e4557524baec4c8abfb5a23 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Sun, 10 Mar 2024 13:35:56 -0700 Subject: [PATCH 05/11] ubuntu-build: update copyright --- ubuntu-build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ubuntu-build b/ubuntu-build index 5fba28e..87e3d39 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -2,11 +2,12 @@ # # ubuntu-build - command line interface for Launchpad buildd operations. # -# Copyright (C) 2007 Canonical Ltd. +# Copyright (C) 2007-2024 Canonical Ltd. # Authors: # - Martin Pitt # - Jonathan Davies # - Michael Bienia +# - Steve Langasek # # 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 From 0bef4d7352d03854a196ffa722ca4402a228319e Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Sun, 10 Mar 2024 13:36:30 -0700 Subject: [PATCH 06/11] ubuntu-build: fix licensing. Canonical licensing policy has never been GPLv3+, only GPLv3. --- ubuntu-build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ubuntu-build b/ubuntu-build index 87e3d39..d5dc350 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -11,8 +11,7 @@ # # 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of From 010af53d7c95fc8803229d39124aaef2ba2418d0 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Sun, 10 Mar 2024 14:35:47 -0700 Subject: [PATCH 07/11] Add a -A archive option to act on ppas as well. This results in a major refactor of the code to use launchpadlib directly instead of the ubuntutools.lp.lpapicache module in ubuntu-dev-tools which is idiosyncratic and does not expose the full launchpad API. Easier to rewrite to use the standard library. --- ubuntu-build | 212 +++++++++++++++++++++++------------ ubuntutools/lp/lpapicache.py | 45 -------- 2 files changed, 142 insertions(+), 115 deletions(-) diff --git a/ubuntu-build b/ubuntu-build index d5dc350..69d0086 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -29,19 +29,52 @@ import argparse import sys from launchpadlib.credentials import TokenAuthorizationException +from launchpadlib.launchpad import Launchpad +import lazr.restfulclient.errors from ubuntutools import getLogger -from ubuntutools.lp.lpapicache import Distribution, Launchpad, PersonTeam -from ubuntutools.lp.udtexceptions import ( - PackageNotFoundException, - PocketDoesNotExistError, - SeriesNotFoundException, -) +from ubuntutools.lp.udtexceptions import PocketDoesNotExistError from ubuntutools.misc import split_release_pocket Logger = getLogger() +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: + if build.rescore(score): + res.append(f" {arch}: done") + else: + res.append(f" {arch}: failed") + 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}" + + def main(): # Usage. usage = "%(prog)s \n\n" @@ -74,6 +107,9 @@ def main(): f"include: {', '.join(valid_archs)}.", ) + parser.add_argument("-A", "--archive", help="operate on ARCHIVE", + default="ubuntu") + # Batch processing options batch_options = parser.add_argument_group( "Batch processing", @@ -102,7 +138,7 @@ def main(): ) batch_options.add_argument( "--state", action="store", dest="state", - help="Act on builds that are in the specified state (default: Failed to build)", + help="Act on builds that are in the specified state", ) parser.add_argument("packages", metavar="package", nargs="*", help=argparse.SUPPRESS) @@ -110,14 +146,25 @@ def main(): # Parse our options. args = parser.parse_args() - try: - # Will fail here if we have no credentials, bail out - Launchpad.login() - except TokenAuthorizationException: - sys.exit(1) - me = PersonTeam.me + launchpad = Launchpad.login_with("ubuntu-dev-tools", "production", + version="devel") + me = launchpad.me - if not args.batch: + is_buildd_admin = any(t.name == "launchpad-buildd-admins" \ + for t in me.super_teams) + + ubuntu = launchpad.distributions['ubuntu'] + + if args.batch: + release = args.series + if not release: + release = ubuntu.getDevelopmentSeries().name + "-proposed" + try: + (release, pocket) = split_release_pocket(release) + except PocketDoesNotExistError as error: + Logger.error(error) + sys.exit(1) + else: # Check we have the correct number of arguments. if len(args.packages) < 3: parser.error("Incorrect number of arguments.") @@ -130,6 +177,14 @@ def main(): parser.print_help() sys.exit(1) + 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: # Check our operation. if operation not in ("rescore", "retry", "status"): Logger.error("Invalid operation: %s.", operation) @@ -153,33 +208,35 @@ def main(): Logger.error(error) sys.exit(1) - ubuntu_archive = Distribution("ubuntu").getArchive() # Get list of published sources for package in question. try: - sources = ubuntu_archive.getSourcePackage(package, release, pocket) - distroseries = Distribution("ubuntu").getSeries(release) - except (SeriesNotFoundException, PackageNotFoundException) as error: - Logger.error(error) + sources = archive.getPublishedSources( + distro_series=distroseries, + pocket=pocket, + source_name=package, + status='Published')[0] + except IndexError as error: + Logger.error("No publication found for package %s", package) sys.exit(1) # Get list of builds for that package. builds = sources.getBuilds() # Find out the version and component in given release. - version = sources.getVersion() - component = sources.getComponent() + version = sources.source_package_version + component = sources.component_name # Operations that are remaining may only be done by Ubuntu developers # (retry) or buildd admins (rescore). Check if the proper permissions # are in place. if operation == "rescore": - necessary_privs = me.isLpTeamMember("launchpad-buildd-admins") + necessary_privs = is_buildd_admin if operation == "retry": - necessary_privs = me.canUploadPackage( - ubuntu_archive, - distroseries, - sources.getPackageName(), - sources.getComponent(), - pocket=pocket, + necessary_privs = archive.checkUpload( + component=sources.getComponent(), + distroseries=distroseries, + person=launchpad.me, + pocket=pocket, + sourcepackagename=sources.getPackageName(), ) if operation in ("rescore", "retry") and not necessary_privs: @@ -245,24 +302,8 @@ def main(): # filter out duplicate and invalid architectures archs.intersection_update(valid_archs) - release = args.series - if not release: - release = Distribution("ubuntu").getDevelopmentSeries().name + "-proposed" - try: - (release, pocket) = split_release_pocket(release) - except PocketDoesNotExistError as error: - Logger.error(error) - sys.exit(1) - - ubuntu_archive = Distribution("ubuntu").getArchive() - try: - distroseries = Distribution("ubuntu").getSeries(release) - except SeriesNotFoundException as error: - Logger.error(error) - sys.exit(1) - # Check permisions (part 1): Rescoring can only be done by buildd admins - can_rescore = args.priority and me.isLpTeamMember("launchpad-buildd-admins") + can_rescore = args.priority and is_buildd_admin if args.priority and not can_rescore: Logger.error( "You don't have the permissions to rescore builds. Ignoring your rescore request." @@ -272,11 +313,27 @@ def main(): retry_count = 0 if not args.state: - args.state='Failed to build' - series = Distribution("ubuntu").getSeries(release) - for build in series.getBuildRecords( - build_state=args.state, pocket=pocket - ): + 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: if build.arch_tag not in archs: continue if not build.current_source_publication: @@ -284,9 +341,12 @@ def main(): # fixme: refactor # Check permissions (part 2): check upload permissions for the # source package - can_retry = args.retry and me.canUploadPackage( - ubuntu_archive, series, build.source_package_name, - build.current_source_publication.component_name + 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, ) if args.retry and not can_retry: Logger.error( @@ -303,57 +363,69 @@ def main(): build.source_package_version ) - if can_retry: + if args.retry: Logger.info("Retrying build of %s on %s...", build.source_package_name, build.arch_tag) retry_count += 1 build.retry() - else: - Logger.info("Cannot retry build of %s on %s.", - build.source_package_name, build.arch_tag) + if args.priority and can_rescore: - Logger.info(pkg.rescoreBuilds(archs, args.priority)) + if build.can_be_rescored: + build.rescore(score=args.priority) + else: + Logger.info("Cannot rescore build of %s on %s.", + build.source_package_name, build.arch_tag) Logger.info("") - Logger.info("%d package builds retried", retry_count) + if args.retry: + Logger.info("%d package builds retried", retry_count) sys.exit(0) for pkg in args.packages: try: - pkg = ubuntu_archive.getSourcePackage(pkg, release, pocket) - except PackageNotFoundException as error: - Logger.error(error) + pkg = archive.getPublishedSources( + distro_series=distroseries, + pocket=pocket, + source_name=pkg, + status='Published')[0] + except IndexError as error: + Logger.error("No publication found for package %s", pkg) continue # Check permissions (part 2): check upload permissions for the source # package - can_retry = args.retry and me.canUploadPackage( - ubuntu_archive, distroseries, pkg.getPackageName(), pkg.getComponent() + can_retry = args.retry and archive.checkUpload( + component=pkg.component_name, + distroseries=distroseries, + person=launchpad.me, + pocket=pocket, + sourcepackagename=pkg.source_package_name, ) if args.retry and not can_retry: Logger.error( "You don't have the permissions to retry the " "build of '%s'. Ignoring your request.", - pkg.getPackageName(), + pkg.source_package_name, ) Logger.info( "The source version for '%s' in '%s' (%s) is: %s", - pkg.getPackageName(), + pkg.source_package_name, release, pocket, - pkg.getVersion(), + pkg.source_package_version, ) - Logger.info(pkg.getBuildStates(archs)) + Logger.info(getBuildStates(pkg, archs)) if can_retry: - Logger.info(pkg.retryBuilds(archs)) + Logger.info(retryBuilds(pkg, archs)) if args.priority and can_rescore: - Logger.info(pkg.rescoreBuilds(archs, args.priority)) + Logger.info(rescoreBuilds(pkg, archs, args.priority)) Logger.info("") if __name__ == "__main__": main() + diff --git a/ubuntutools/lp/lpapicache.py b/ubuntutools/lp/lpapicache.py index 589b332..1404809 100644 --- a/ubuntutools/lp/lpapicache.py +++ b/ubuntutools/lp/lpapicache.py @@ -1097,51 +1097,6 @@ class SourcePackagePublishingHistory(BaseWrapper): for build in builds: self._builds[build.arch_tag] = Build(build) - def getBuildStates(self, archs): - res = [] - - if not self._builds: - self._fetch_builds() - - for arch in archs: - build = self._builds.get(arch) - if build: - res.append(f" {build}") - msg = "\n".join(res) - return f"Build state(s) for '{self.getPackageName()}':\n{msg}" - - def rescoreBuilds(self, archs, score): - res = [] - - if not self._builds: - self._fetch_builds() - - for arch in archs: - build = self._builds.get(arch) - if build: - if build.rescore(score): - res.append(f" {arch}: done") - else: - res.append(f" {arch}: failed") - msg = "\n".join(res) - return f"Rescoring builds of '{self.getPackageName()}' to {score}:\n{msg}" - - def retryBuilds(self, archs): - res = [] - - if not self._builds: - self._fetch_builds() - - for arch in archs: - build = self._builds.get(arch) - if build: - if build.retry(): - res.append(f" {arch}: done") - else: - res.append(f" {arch}: failed") - msg = "\n".join(res) - return f"Retrying builds of '{self.getPackageName()}':\n{msg}" - class BinaryPackagePublishingHistory(BaseWrapper): """ From 9e710a3d66fa9af406100941e8a90f7805ecb54a Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Sun, 10 Mar 2024 15:46:22 -0700 Subject: [PATCH 08/11] Always use exact match when looking for source packages by name --- ubuntu-build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ubuntu-build b/ubuntu-build index 69d0086..dd903a4 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -212,6 +212,7 @@ def main(): try: sources = archive.getPublishedSources( distro_series=distroseries, + exact_match=True, pocket=pocket, source_name=package, status='Published')[0] @@ -386,6 +387,7 @@ def main(): try: pkg = archive.getPublishedSources( distro_series=distroseries, + exact_match=True, pocket=pocket, source_name=pkg, status='Published')[0] From d5faa9b13301743cb12413bbe46fddba87553eec Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Sun, 10 Mar 2024 15:48:16 -0700 Subject: [PATCH 09/11] Proper handling of getDevelopmentSeries() --- ubuntu-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubuntu-build b/ubuntu-build index dd903a4..6bda9fd 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -158,7 +158,7 @@ def main(): if args.batch: release = args.series if not release: - release = ubuntu.getDevelopmentSeries().name + "-proposed" + release = ubuntu.getDevelopmentSeries()[0].name + "-proposed" try: (release, pocket) = split_release_pocket(release) except PocketDoesNotExistError as error: From 07d3158ade6235761b8ee4a5992dbb73299e74ba Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Sun, 10 Mar 2024 16:51:15 -0700 Subject: [PATCH 10/11] Don't do expensive check of group membership on rescore, just handle exceptions This could do with some further refactoring, but will probably postpone that until a decision is made about dropping the non-batch mode --- ubuntu-build | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/ubuntu-build b/ubuntu-build index 6bda9fd..2efacf3 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -54,10 +54,21 @@ def rescoreBuilds(pkg, archs, score): for build in pkg.getBuilds(): arch = build.arch_tag if arch in archs: - if build.rescore(score): + if not build.can_be_rescored: + continue + try: + build.rescore(score=score) res.append(f" {arch}: done") - else: + 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) res.append(f" {arch}: failed") + msg = "\n".join(res) return f"Rescoring builds of '{pkg.source_package_name}' to {score}:\n{msg}" @@ -150,9 +161,6 @@ def main(): version="devel") me = launchpad.me - is_buildd_admin = any(t.name == "launchpad-buildd-admins" \ - for t in me.super_teams) - ubuntu = launchpad.distributions['ubuntu'] if args.batch: @@ -229,8 +237,6 @@ def main(): # Operations that are remaining may only be done by Ubuntu developers # (retry) or buildd admins (rescore). Check if the proper permissions # are in place. - if operation == "rescore": - necessary_privs = is_buildd_admin if operation == "retry": necessary_privs = archive.checkUpload( component=sources.getComponent(), @@ -240,7 +246,7 @@ def main(): sourcepackagename=sources.getPackageName(), ) - if operation in ("rescore", "retry") and not necessary_privs: + if operation == "retry" and not necessary_privs: Logger.error( "You cannot perform the %s operation on a %s package as you" " do not have the permissions to do this action.", @@ -274,7 +280,13 @@ def main(): # FIXME: make priority an option priority = 5000 Logger.info("Rescoring build %s to %d...", build.arch_tag, priority) - build.rescore(score=priority) + 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 else: Logger.info("Cannot rescore build on %s.", build.arch_tag) if operation == "retry": @@ -303,15 +315,9 @@ def main(): # filter out duplicate and invalid architectures archs.intersection_update(valid_archs) - # Check permisions (part 1): Rescoring can only be done by buildd admins - can_rescore = args.priority and is_buildd_admin - if args.priority and not can_rescore: - Logger.error( - "You don't have the permissions to rescore builds. Ignoring your rescore request." - ) - if not args.packages: retry_count = 0 + can_rescore = True if not args.state: if args.retry: @@ -372,9 +378,15 @@ def main(): if args.priority and can_rescore: if build.can_be_rescored: - build.rescore(score=args.priority) - else: - Logger.info("Cannot rescore build of %s on %s.", + 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.", build.source_package_name, build.arch_tag) Logger.info("") @@ -422,7 +434,7 @@ def main(): Logger.info(getBuildStates(pkg, archs)) if can_retry: Logger.info(retryBuilds(pkg, archs)) - if args.priority and can_rescore: + if args.priority: Logger.info(rescoreBuilds(pkg, archs, args.priority)) Logger.info("") From c92fa6502f0d9dc2485e5d93a66ae0c7ea91c5ed Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Sun, 10 Mar 2024 20:52:05 -0700 Subject: [PATCH 11/11] ubuntu-build: Handling of proposed vs release pocket default for ppas --- ubuntu-build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ubuntu-build b/ubuntu-build index 2efacf3..88ec52f 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -166,7 +166,11 @@ def main(): if args.batch: release = args.series if not release: - release = ubuntu.getDevelopmentSeries()[0].name + "-proposed" + # 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" try: (release, pocket) = split_release_pocket(release) except PocketDoesNotExistError as error: