Add a release argument to grim-reaper

main
Simon Quigley 3 weeks ago
parent 86f5d81d63
commit 02ee48bfd3

@ -158,4 +158,4 @@ done < candidates;
rm candidates; rm candidates;
echo "Run the grim reaper..." echo "Run the grim reaper..."
./grim-reaper ./grim-reaper $RELEASE

@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
import argparse
from concurrent.futures import ThreadPoolExecutor, as_completed from concurrent.futures import ThreadPoolExecutor, as_completed
from datetime import datetime, timedelta from datetime import datetime, timedelta
from launchpadlib.launchpad import Launchpad from launchpadlib.launchpad import Launchpad
@ -28,11 +29,16 @@ def print_log(string):
time_elapsed = now - old_now time_elapsed = now - old_now
print(f"[{now}] (took {time_elapsed}) {string}") print(f"[{now}] (took {time_elapsed}) {string}")
parser = argparse.ArgumentParser()
parser.add_argument("release")
args = parser.parse_args()
print(f"[{now}] Logging into Launchpad...") print(f"[{now}] Logging into Launchpad...")
launchpad = Launchpad.login_with("grim-reaper", "production", version="devel") launchpad = Launchpad.login_with("grim-reaper", "production", version="devel")
print_log("Logged in. Initializing repositories...") print_log("Logged in. Initializing repositories...")
ubuntu = launchpad.distributions["ubuntu"] ubuntu = launchpad.distributions["ubuntu"]
series = ubuntu.getSeries(name_or_version=args.release)
lubuntu_ci = launchpad.people["lubuntu-ci"] lubuntu_ci = launchpad.people["lubuntu-ci"]
regular = lubuntu_ci.getPPAByName(distribution=ubuntu, name="unstable-ci") regular = lubuntu_ci.getPPAByName(distribution=ubuntu, name="unstable-ci")
proposed = lubuntu_ci.getPPAByName(distribution=ubuntu, name="unstable-ci-proposed") 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?!?!?!?!!!") print_log("IS THAT THE GRIM REAPER?!?!?!?!!!")
# Fetch packages once # Fetch packages once
two_weeks_ago = datetime.now() - timedelta(days=14) packages = []
packages = [proposed.getPublishedSources(status="Superseded"), regular.getPublishedSources(status="Superseded")] for repository in [proposed, regular]:
total_removals = sum(len(packageset) for packageset in packages) 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}") print_log(f"Total packages to remove: {total_removals}")
current_package = 1 current_package = 1
current_percentage = 0 current_percentage = 0
for packageset in packages: for repository in packages:
for pkg in packageset: for pkg in repository:
# Cancel all running builds for the package: # Cancel all running builds for the package
for build in pkg.getBuilds(): for build in pkg.getBuilds():
if build.buildstate in ["Currently building", "Needs building"]: if build.buildstate in ["Currently building", "Needs building"]:
# Only cancel the build if we can # Only cancel the build if we can

Loading…
Cancel
Save