提交 d11ecb68 编写于 作者: I Ivo De Decker

Add option to remove outdated binaries

This adds an option to dak rm to remove only the binaries that were built from
an outdated version of the specified source package.
上级 cd948b39
...@@ -81,6 +81,8 @@ Remove PACKAGE(s) from suite(s). ...@@ -81,6 +81,8 @@ Remove PACKAGE(s) from suite(s).
-h, --help show this help and exit -h, --help show this help and exit
-m, --reason=MSG reason for removal -m, --reason=MSG reason for removal
-n, --no-action don't do anything -n, --no-action don't do anything
-o, --outdated remove binaries from the specified source package
that were built from previous source versions
-p, --partial don't affect override files -p, --partial don't affect override files
-R, --rdep-check check reverse dependencies -R, --rdep-check check reverse dependencies
-s, --suite=SUITE act on this suite -s, --suite=SUITE act on this suite
...@@ -138,6 +140,7 @@ def main(): ...@@ -138,6 +140,7 @@ def main():
('R', "rdep-check", "Rm::Options::Rdep-Check"), ('R', "rdep-check", "Rm::Options::Rdep-Check"),
('m', "reason", "Rm::Options::Reason", "HasArg"), # Hysterical raisins; -m is old-dinstall option for rejection reason ('m', "reason", "Rm::Options::Reason", "HasArg"), # Hysterical raisins; -m is old-dinstall option for rejection reason
('n', "no-action", "Rm::Options::No-Action"), ('n', "no-action", "Rm::Options::No-Action"),
('o', "outdated", "Rm::Options::Outdated"),
('p', "partial", "Rm::Options::Partial"), ('p', "partial", "Rm::Options::Partial"),
('s', "suite", "Rm::Options::Suite", "HasArg"), ('s', "suite", "Rm::Options::Suite", "HasArg"),
('S', "source-only", "Rm::Options::Source-Only"), ('S', "source-only", "Rm::Options::Source-Only"),
...@@ -145,7 +148,7 @@ def main(): ...@@ -145,7 +148,7 @@ def main():
for i in ['NoArchAllRdeps', for i in ['NoArchAllRdeps',
"architecture", "binary", "binary-only", "carbon-copy", "component", "architecture", "binary", "binary-only", "carbon-copy", "component",
"done", "help", "no-action", "partial", "rdep-check", "reason", "done", "help", "no-action", "outdated", "partial", "rdep-check", "reason",
"source-only", "Do-Close"]: "source-only", "Do-Close"]:
key = "Rm::Options::%s" % (i) key = "Rm::Options::%s" % (i)
if key not in cnf: if key not in cnf:
...@@ -166,15 +169,18 @@ def main(): ...@@ -166,15 +169,18 @@ def main():
utils.fubar("need at least one package name as an argument.") utils.fubar("need at least one package name as an argument.")
if Options["Architecture"] and Options["Source-Only"]: if Options["Architecture"] and Options["Source-Only"]:
utils.fubar("can't use -a/--architecture and -S/--source-only options simultaneously.") utils.fubar("can't use -a/--architecture and -S/--source-only options simultaneously.")
if ((Options["Binary"] and Options["Source-Only"]) actions = [Options["Binary"], Options["Binary-Only"], Options["Source-Only"], Options["Outdated"]]
or (Options["Binary"] and Options["Binary-Only"]) nr_actions = len([act for act in actions if act])
or (Options["Binary-Only"] and Options["Source-Only"])): if nr_actions > 1:
utils.fubar("Only one of -b/--binary, -B/--binary-only and -S/--source-only can be used.") utils.fubar("Only one of -b/--binary, -B/--binary-only, -o/--outdated and -S/--source-only can be used.")
if "Carbon-Copy" not in Options and "Done" not in Options: if "Carbon-Copy" not in Options and "Done" not in Options:
utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.") utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.")
if Options["Architecture"] and not Options["Partial"]: if Options["Architecture"] and not Options["Partial"]:
utils.warn("-a/--architecture implies -p/--partial.") utils.warn("-a/--architecture implies -p/--partial.")
Options["Partial"] = "true" Options["Partial"] = "true"
if Options["Outdated"] and not Options["Partial"]:
utils.warn("-o/--outdated implies -p/--partial.")
Options["Partial"] = "true"
if Options["Do-Close"] and not Options["Done"]: if Options["Do-Close"] and not Options["Done"]:
utils.fubar("No.") utils.fubar("No.")
if (Options["Do-Close"] if (Options["Do-Close"]
...@@ -236,7 +242,26 @@ def main(): ...@@ -236,7 +242,26 @@ def main():
# XXX: TODO: This all needs converting to use placeholders or the object # XXX: TODO: This all needs converting to use placeholders or the object
# API. It's an SQL injection dream at the moment # API. It's an SQL injection dream at the moment
if Options["Binary"]: if Options["Outdated"]:
# Remove binary packages that were built from an outdated version of
# the specified source package
q = session.execute("""
SELECT b.package, b.version, a.arch_string, b.id, b.maintainer, s.source
FROM binaries b
JOIN source s ON s.id = b.source
JOIN bin_associations ba ON ba.bin = b.id
JOIN architecture a ON a.id = b.architecture
JOIN suite su ON su.id = ba.suite
JOIN files f ON f.id = b.file
JOIN files_archive_map af ON af.file_id = f.id AND af.archive_id = su.archive_id
JOIN component c ON c.id = af.component_id
JOIN newest_source on s.source = newest_source.source AND su.id = newest_source.suite
WHERE
s.version < newest_source.version
%s %s %s %s
""" % (con_packages, con_suites, con_components, con_architectures))
to_remove.extend(q)
elif Options["Binary"]:
# Removal by binary package name # Removal by binary package name
q = session.execute(""" q = session.execute("""
SELECT b.package, b.version, a.arch_string, b.id, b.maintainer, s.source SELECT b.package, b.version, a.arch_string, b.id, b.maintainer, s.source
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册