Package: ftp.debian.org Severity: wishlist Tags: patch Hi,
I have written two patches to make dak auto-decruft tpu similar to the auto-decruft of experimental. Thanks, ~Niels
>From 51c6331b860059100c016c26d38d9d935dc2bb81 Mon Sep 17 00:00:00 2001 From: Niels Thykier <ni...@thykier.net> Date: Sun, 30 Apr 2017 14:03:33 +0000 Subject: [PATCH 1/2] dak auto-decruft: Support decrufting equal versions for NVIX decrufts Signed-off-by: Niels Thykier <ni...@thykier.net> --- dak/auto_decruft.py | 20 +++++++++++++++----- daklib/cruft.py | 12 ++++++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/dak/auto_decruft.py b/dak/auto_decruft.py index 66479a47fd..571fc9b765 100644 --- a/dak/auto_decruft.py +++ b/dak/auto_decruft.py @@ -59,6 +59,8 @@ Automatic removal of common kinds of cruft unstable) --if-newer-version-in-rm-msg RMMSG use RMMSG in the removal message (e.g. "NVIU") + --decruft-equal-versions use with --if-newer-version-in to also decruft versions + that are identical in both suites. """ sys.exit(exit_code) @@ -374,7 +376,7 @@ def sources2removals(source_list, suite_id, session): return to_remove -def decruft_newer_version_in(othersuite, suite_name, suite_id, rm_msg, session, dryrun): +def decruft_newer_version_in(othersuite, suite_name, suite_id, rm_msg, session, dryrun, decruft_equal_versions): """Compute removals items given a list of names of source packages @type othersuite: str @@ -394,8 +396,11 @@ def decruft_newer_version_in(othersuite, suite_name, suite_id, rm_msg, session, @type dryrun: bool @param dryrun: If True, just print the actions rather than actually doing them + + @type decruft_equal_versions: bool + @param decruft_equal_versions: If True, use >= instead of > for finding decruftable packages. """ - nvi_list = [x[0] for x in newer_version(othersuite, suite_name, session)] + nvi_list = [x[0] for x in newer_version(othersuite, suite_name, session, include_equal=decruft_equal_versions)] if nvi_list: message = "[auto-cruft] %s" % rm_msg if dryrun: @@ -416,8 +421,10 @@ def main (): ('s',"suite","Auto-Decruft::Options::Suite","HasArg"), # The "\0" seems to be the only way to disable short options. ("\0",'if-newer-version-in',"Auto-Decruft::Options::OtherSuite", "HasArg"), - ("\0",'if-newer-version-in-rm-msg',"Auto-Decruft::Options::OtherSuiteRMMsg", "HasArg")] - for i in ["help", "Dry-Run", "Debug", "OtherSuite", "OtherSuiteRMMsg"]: + ("\0",'if-newer-version-in-rm-msg',"Auto-Decruft::Options::OtherSuiteRMMsg", "HasArg"), + ("\0",'decruft-equal-versions',"Auto-Decruft::Options::OtherSuiteDecruftEqual") + ] + for i in ["help", "Dry-Run", "Debug", "OtherSuite", "OtherSuiteRMMsg", "OtherSuiteDecruftEqual"]: if not cnf.has_key("Auto-Decruft::Options::%s" % (i)): cnf["Auto-Decruft::Options::%s" % (i)] = "" @@ -431,10 +438,13 @@ def main (): debug = False dryrun = False + decruft_equal_versions = False if Options["Dry-Run"]: dryrun = True if Options["Debug"]: debug = True + if Options["OtherSuiteDecruftEqual"]: + decruft_equal_versions = True if Options["OtherSuite"] and not Options["OtherSuiteRMMsg"]: utils.fubar("--if-newer-version-in requires --if-newer-version-in-rm-msg") @@ -452,7 +462,7 @@ def main (): if Options["OtherSuite"]: osuite = get_suite(Options["OtherSuite"].lower(), session).suite_name - decruft_newer_version_in(osuite, suite_name, suite_id, Options["OtherSuiteRMMsg"], session, dryrun) + decruft_newer_version_in(osuite, suite_name, suite_id, Options["OtherSuiteRMMsg"], session, dryrun, decruft_equal_versions) if not dryrun: session.commit() diff --git a/daklib/cruft.py b/daklib/cruft.py index 05666ceba2..942e40cade 100644 --- a/daklib/cruft.py +++ b/daklib/cruft.py @@ -26,7 +26,7 @@ from daklib.dbconn import * from sqlalchemy import func from sqlalchemy.orm import object_session -def newer_version(lowersuite_name, highersuite_name, session): +def newer_version(lowersuite_name, highersuite_name, session, include_equal=False): ''' Finds newer versions in lowersuite_name than in highersuite_name. Returns a list of tuples (source, higherversion, lowerversion) where higherversion is @@ -42,9 +42,13 @@ def newer_version(lowersuite_name, highersuite_name, session): list = [] for (source, higherversion) in query: - lowerversion = session.query(func.max(DBSource.version)). \ - filter_by(source = source).filter(DBSource.version > higherversion). \ - with_parent(lowersuite).group_by(DBSource.source).scalar() + q = session.query(func.max(DBSource.version)). \ + filter_by(source = source) + if include_equal: + q = q.filter(DBSource.version >= higherversion) + else: + q = q.filter(DBSource.version > higherversion) + lowerversion = q.with_parent(lowersuite).group_by(DBSource.source).scalar() if lowerversion is not None: list.append((source, higherversion, lowerversion)) -- 2.11.0
>From bdedf8b74c9af119d8385669168599df4cfc7f79 Mon Sep 17 00:00:00 2001 From: Niels Thykier <ni...@thykier.net> Date: Sun, 30 Apr 2017 14:22:50 +0000 Subject: [PATCH 2/2] dinstall: Auto-decruft tpu Signed-off-by: Niels Thykier <ni...@thykier.net> --- config/debian/dinstall.functions | 1 + 1 file changed, 1 insertion(+) diff --git a/config/debian/dinstall.functions b/config/debian/dinstall.functions index 06fa01932a..3c4b8c31b1 100755 --- a/config/debian/dinstall.functions +++ b/config/debian/dinstall.functions @@ -157,6 +157,7 @@ function autocruft() { log "Check for obsolete binary packages" dak auto-decruft -s unstable dak auto-decruft -s experimental --if-newer-version-in unstable --if-newer-version-in-rm-msg "NVIU" + dak auto-decruft -s testing-proposed-updates --if-newer-version-in testing --if-newer-version-in-rm-msg "NVIT" --decruft-equal-versions } function fingerprints() { -- 2.11.0