From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eclean/
Date: Mon, 21 Aug 2023 05:16:20 +0000 (UTC) [thread overview]
Message-ID: <1692594978.a16d0d4fbfb4614832c4b682b41284a9050af29f.sam@gentoo> (raw)
commit: a16d0d4fbfb4614832c4b682b41284a9050af29f
Author: Siddhanth Rathod <xsiddhanthrathod <AT> gmail <DOT> com>
AuthorDate: Thu Mar 23 12:14:36 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Aug 21 05:16:18 2023 +0000
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=a16d0d4f
eclean-pkg: deal with invalid binpkgs
Changes required in portage -> https://github.com/gentoo/portage/pull/1016
Bug: https://bugs.gentoo.org/900224
Signed-off-by: Siddhanth Rathod <xsiddhanthrathod <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>
pym/gentoolkit/eclean/cli.py | 47 +++++++++++++++++++++++++++++++++++++----
pym/gentoolkit/eclean/output.py | 14 ++++++++++++
pym/gentoolkit/eclean/search.py | 9 ++++++--
3 files changed, 64 insertions(+), 6 deletions(-)
diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py
index fa94a55..40fc4f9 100644
--- a/pym/gentoolkit/eclean/cli.py
+++ b/pym/gentoolkit/eclean/cli.py
@@ -13,7 +13,6 @@ __version__ = "git"
__productname__ = "eclean"
__description__ = "A cleaning tool for Gentoo distfiles and binaries."
-
import os
import sys
import re
@@ -21,7 +20,7 @@ import time
import getopt
import portage
-from portage.output import white, yellow, turquoise, green
+from portage.output import white, yellow, turquoise, green, red
import gentoolkit.pprinter as pp
from gentoolkit.eclean.search import (
@@ -47,7 +46,7 @@ def printVersion():
print("Distributed under the terms of the GNU General Public License v2")
-def printUsage(_error=None, help=None):
+def printUsage(_error=None, help=None, unresolved_invalids=None):
"""Print help message. May also print partial help to stderr if an
error from {'options','actions'} is specified."""
@@ -63,10 +62,25 @@ def printUsage(_error=None, help=None):
"merged-distfiles-options",
"time",
"size",
+ "invalid_paths",
):
_error = None
if not _error and not help:
help = "all"
+ if _error == "invalid_paths":
+ print(
+ pp.error(
+ "eclean was not able to remove invalid binpkgs due to missing features in the currently installed portage"
+ ),
+ file=out,
+ )
+ print(
+ pp.error("Please remove the following binpkgs manually:"),
+ file=out,
+ )
+ for invalid in unresolved_invalids:
+ print(pp.error(invalid), file=out)
+ return
if _error == "time":
print(pp.error("Wrong time specification"), file=out)
print(
@@ -399,6 +413,8 @@ def parseArgs(options={}):
options["ignore-failure"] = True
elif o in ("-u", "--unique-use"):
options["unique-use"] = True
+ elif o in ("-N", "--skip-invalids"):
+ options["clean-invalids"] = False
else:
return_code = False
# sanity check of --deep only options:
@@ -458,6 +474,7 @@ def parseArgs(options={}):
options["changed-deps"] = False
options["ignore-failure"] = False
options["unique-use"] = False
+ options["clean-invalids"] = True
# if called by a well-named symlink, set the action accordingly:
action = None
# temp print line to ensure it is the svn/branch code running, etc..
@@ -527,7 +544,7 @@ def doAction(action, options, exclude={}, output=None):
if not options["quiet"]:
output.einfo("Building file list for " + action + " cleaning...")
if action == "packages":
- clean_me = findPackages(
+ clean_me, invalids = findPackages(
options,
exclude=exclude,
destructive=options["destructive"],
@@ -602,6 +619,28 @@ def doAction(action, options, exclude={}, output=None):
)
output.set_colors("deprecated")
output.list_pkgs(deprecated)
+ if invalids and options["clean-invalids"]:
+ if type(invalids) == list:
+ printUsage(_error="invalid_paths", unresolved_invalids=invalids)
+ sys.exit(1)
+ verb = "were"
+ if options["pretend"]:
+ verb = "would be"
+ if not options["quiet"]:
+ print()
+ print(
+ (
+ pp.emph(" The following ")
+ + red("invalid")
+ + pp.emph(" binpkgs were found")
+ )
+ )
+ output.set_colors("invalid")
+ output.list_pkgs(invalids)
+ clean_size = cleaner.clean_pkgs(invalids, pkgdir)
+ output.total("invalid", clean_size, len(invalids), verb, action)
+ else:
+ cleaner.clean_pkgs(invalids, pkgdir)
def main():
diff --git a/pym/gentoolkit/eclean/output.py b/pym/gentoolkit/eclean/output.py
index 62777b7..ebba499 100644
--- a/pym/gentoolkit/eclean/output.py
+++ b/pym/gentoolkit/eclean/output.py
@@ -39,6 +39,9 @@ class OutputControl:
self.pkg_color = cpv # green
self.numbers = number # turquoise
self.brace = blue
+ if mode == "invalid":
+ self.pkg_color = red
+ self.numbers = teal
elif mode == "deprecated":
self.pkg_color = yellow
self.numbers = teal # darkgreen
@@ -169,6 +172,17 @@ class OutputControl:
)
print(" ===========")
print(self.prettySize(size, True, red), message)
+ elif mode == "invalid":
+ message = (
+ red(str(num_files))
+ + " invalid binpkgs "
+ + verb
+ + " removed from the "
+ + action
+ + " directory"
+ )
+ print(" ===========")
+ print(self.prettySize(size, True, red), message)
elif mode == "deprecated":
message = (
"Total space from "
diff --git a/pym/gentoolkit/eclean/search.py b/pym/gentoolkit/eclean/search.py
index eb26ac8..a2ac0ce 100644
--- a/pym/gentoolkit/eclean/search.py
+++ b/pym/gentoolkit/eclean/search.py
@@ -517,9 +517,10 @@ def findPackages(
pkgdir: str = None,
port_dbapi=portage.db[portage.root]["porttree"].dbapi,
var_dbapi=portage.db[portage.root]["vartree"].dbapi,
-) -> dict[str, list[str]]:
+) -> tuple[dict[str, list[str]], dict[str, list[str]]]:
"""Find obsolete binary packages.
+ @param invalid_paths:
@param options: dict of options determined at runtime
@type options: dict
@param exclude: exclusion dict (as defined in the exclude.parseExcludeFile class)
@@ -638,8 +639,12 @@ def findPackages(
binpkg_path = bin_dbapi.bintree.getname(cpv)
dead_binpkgs.setdefault(cpv, []).append(binpkg_path)
+ try:
+ invalid_paths = bin_dbapi.bintree.invalid_paths
+ except AttributeError:
+ invalid_paths = bin_dbapi.bintree.invalids
- return dead_binpkgs
+ return dead_binpkgs, invalid_paths
# vim: set ts=4 sw=4 tw=79:
next reply other threads:[~2023-08-21 5:16 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-21 5:16 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-05-03 5:42 [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eclean/ Sam James
2024-05-03 5:40 Sam James
2024-05-03 5:40 Sam James
2024-05-03 5:40 Sam James
2024-05-03 5:11 Sam James
2024-02-18 2:19 Brian Dolbec
2024-02-18 2:19 Brian Dolbec
2024-01-19 7:03 Sam James
2024-01-19 6:15 Sam James
2024-01-12 19:16 Matt Turner
2023-12-03 7:51 Sam James
2023-10-08 3:28 Sam James
2023-10-08 3:28 Sam James
2023-09-29 7:20 Sam James
2023-08-24 19:52 Sam James
2023-08-22 20:54 Sam James
2023-08-22 20:52 Sam James
2023-08-22 20:50 Sam James
2023-08-22 20:50 Sam James
2023-08-22 20:35 Sam James
2023-08-21 5:16 Sam James
2022-07-11 7:17 Brian Dolbec
2022-07-09 22:45 Brian Dolbec
2022-07-09 21:46 Brian Dolbec
2022-06-01 10:25 Yixun Lan
2022-05-28 15:28 Yixun Lan
2022-02-09 10:48 Sam James
2020-06-09 17:29 Zac Medico
2020-03-12 16:51 Matt Turner
2020-03-12 16:51 Matt Turner
2020-01-03 4:31 Matt Turner
2019-12-05 16:51 Matt Turner
2019-12-05 16:51 Matt Turner
2019-09-13 23:34 Zac Medico
2017-12-12 5:51 Zac Medico
2016-07-03 6:29 Zac Medico
2016-07-01 6:19 Zac Medico
2016-06-24 21:40 Zac Medico
2016-06-24 21:36 Zac Medico
2016-06-23 20:01 Paul Varner
2015-10-19 21:33 Paul Varner
2015-10-15 21:39 Paul Varner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1692594978.a16d0d4fbfb4614832c4b682b41284a9050af29f.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox