diff --git a/fetch-indexes b/fetch-indexes index 1a86750..39ad300 100755 --- a/fetch-indexes +++ b/fetch-indexes @@ -158,4 +158,4 @@ done < candidates; rm candidates; echo "Run the grim reaper..." -./grim-reaper +./grim-reaper $RELEASE diff --git a/grim-reaper b/grim-reaper index 375762f..cb97f21 100755 --- a/grim-reaper +++ b/grim-reaper @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import argparse from concurrent.futures import ThreadPoolExecutor, as_completed from datetime import datetime, timedelta from launchpadlib.launchpad import Launchpad @@ -28,11 +29,16 @@ def print_log(string): time_elapsed = now - old_now print(f"[{now}] (took {time_elapsed}) {string}") +parser = argparse.ArgumentParser() +parser.add_argument("release") +args = parser.parse_args() + print(f"[{now}] Logging into Launchpad...") launchpad = Launchpad.login_with("grim-reaper", "production", version="devel") print_log("Logged in. Initializing repositories...") ubuntu = launchpad.distributions["ubuntu"] +series = ubuntu.getSeries(name_or_version=args.release) lubuntu_ci = launchpad.people["lubuntu-ci"] regular = lubuntu_ci.getPPAByName(distribution=ubuntu, name="unstable-ci") proposed = lubuntu_ci.getPPAByName(distribution=ubuntu, name="unstable-ci-proposed") @@ -40,16 +46,17 @@ proposed = lubuntu_ci.getPPAByName(distribution=ubuntu, name="unstable-ci-propos print_log("IS THAT THE GRIM REAPER?!?!?!?!!!") # Fetch packages once -two_weeks_ago = datetime.now() - timedelta(days=14) -packages = [proposed.getPublishedSources(status="Superseded"), regular.getPublishedSources(status="Superseded")] -total_removals = sum(len(packageset) for packageset in packages) +packages = [] +for repository in [proposed, regular]: + packages.append(repository.getPublishedSources(status="Superseded", distro_series=series)) +total_removals = sum(len(repository) for repository in packages) print_log(f"Total packages to remove: {total_removals}") current_package = 1 current_percentage = 0 -for packageset in packages: - for pkg in packageset: - # Cancel all running builds for the package: +for repository in packages: + for pkg in repository: + # Cancel all running builds for the package for build in pkg.getBuilds(): if build.buildstate in ["Currently building", "Needs building"]: # Only cancel the build if we can