From: James Bunton Date: Sat, 13 Feb 2016 00:18:21 +0000 (+1100) Subject: aptorphan/pacorphan: Support exclusions X-Git-Url: https://code.delx.au/monosys/commitdiff_plain/6ee0ccac0daa5635d1266af0d07299199b77fce2 aptorphan/pacorphan: Support exclusions --- diff --git a/scripts/aptorphan b/scripts/aptorphan index 0b1d783..0126a43 100755 --- a/scripts/aptorphan +++ b/scripts/aptorphan @@ -52,16 +52,24 @@ need_install_list = [] installed_pkg_list = [] explicit_pkg_list = [] -for filename in os.listdir(APTORPHAN_PATH): +for filename in sorted(os.listdir(APTORPHAN_PATH)): if filename.startswith("."): continue - filename = os.path.join(APTORPHAN_PATH, filename) - for pkg in codecs.open(filename, "r", "utf-8"): - pkg = strip_comment(pkg) - if pkg in keep_pkg_list: - print("# Duplicate entry: " + pkg) - if pkg: - keep_pkg_list.append(pkg.strip()) + full_filename = os.path.join(APTORPHAN_PATH, filename) + for pkg in codecs.open(full_filename, "r", "utf-8"): + pkg = strip_comment(pkg).strip() + if not pkg: + continue + if filename[0] != "~": + if pkg in keep_pkg_list: + print("# Duplicate entry:", pkg, "in file", filename) + continue + keep_pkg_list.append(pkg) + else: + if pkg not in keep_pkg_list: + print("# Redundant removal:", pkg, "in file", filename) + continue + keep_pkg_list.remove(pkg) for pkg in run(["aptitude", "search", "?or(~i!~aremove,~ainstall)", "-F", "%p"]): installed_pkg_list.append(pkg.strip()) diff --git a/scripts/pacorphan b/scripts/pacorphan index 39f90f0..a64a2ee 100755 --- a/scripts/pacorphan +++ b/scripts/pacorphan @@ -27,16 +27,24 @@ unneeded_pkg_list = [] installed_pkg_list = [] explicit_pkg_list = [] -for filename in os.listdir(PACORPHAN_PATH): +for filename in sorted(os.listdir(PACORPHAN_PATH)): if filename.startswith("."): continue - filename = os.path.join(PACORPHAN_PATH, filename) - for pkg in codecs.open(filename, "r", "utf-8"): - pkg = strip_comment(pkg) - if pkg in keep_pkg_list: - print("# Duplicate entry: " + pkg) - if pkg: - keep_pkg_list.append(pkg.strip()) + full_filename = os.path.join(PACORPHAN_PATH, filename) + for pkg in codecs.open(full_filename, "r", "utf-8"): + pkg = strip_comment(pkg).strip() + if not pkg: + continue + if filename[0] != "~": + if pkg in keep_pkg_list: + print("# Duplicate entry:", pkg, "in file", filename) + continue + keep_pkg_list.append(pkg) + else: + if pkg not in keep_pkg_list: + print("# Redundant removal:", pkg, "in file", filename) + continue + keep_pkg_list.remove(pkg) for pkg in run(["pacman", "-Qq"]): installed_pkg_list.append(pkg)