aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2009-04-30 21:52:45 +0000
committerfuzzyray <fuzzyray@gentoo.org>2009-04-30 21:52:45 +0000
commit86eaf5e03289e45a95514b4f6011157972016e9d (patch)
treec16903693f2030c7b01b346b29b265dc1a473888 /src/pkg-clean
parentFix has_key() deprecation message. (Bug #232797) (diff)
downloadgentoolkit-0.2.4.tar.gz
gentoolkit-0.2.4.tar.bz2
gentoolkit-0.2.4.zip
Tagging the gentoolkit-0.2.4 releasegentoolkit-0.2.4
svn path=/tags/gentoolkit-0.2.4/; revision=564
Diffstat (limited to 'src/pkg-clean')
-rw-r--r--src/pkg-clean/AUTHORS5
-rw-r--r--src/pkg-clean/ChangeLog0
-rw-r--r--src/pkg-clean/README0
-rw-r--r--src/pkg-clean/pkg-clean99
-rw-r--r--src/pkg-clean/pkg-clean.120
5 files changed, 124 insertions, 0 deletions
diff --git a/src/pkg-clean/AUTHORS b/src/pkg-clean/AUTHORS
new file mode 100644
index 0000000..f126a36
--- /dev/null
+++ b/src/pkg-clean/AUTHORS
@@ -0,0 +1,5 @@
+Maintainer:
+Karl Trygve Kalleberg <karltk@gentoo.org>
+
+Authors:
+Leo Lipelis <aeoo@gentoo.org> (original author)
diff --git a/src/pkg-clean/ChangeLog b/src/pkg-clean/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/pkg-clean/ChangeLog
diff --git a/src/pkg-clean/README b/src/pkg-clean/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/pkg-clean/README
diff --git a/src/pkg-clean/pkg-clean b/src/pkg-clean/pkg-clean
new file mode 100644
index 0000000..abe0159
--- /dev/null
+++ b/src/pkg-clean/pkg-clean
@@ -0,0 +1,99 @@
+#!/usr/bin/python
+# Copyright 1999-2003 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+# $Header$
+# Author: Leo Lipelis <aeoo@gentoo.org>
+# Author: Karl Trygve Kalleberg <karltk@gentoo.org>
+
+import commands
+import re
+import sys
+import time
+import os
+
+# constants for package tuples that are stored in pkg_hash
+PKG_TIME = 0 # number of seconds for ctime function
+PKG = 1 # package full path as accepted by ebuild
+PKG_NAME = 2 # package name as accepted by emerge
+
+(status, pkg_files) = commands.getstatusoutput(
+ "find /var/db/pkg -iname '*.ebuild' -printf '%T@ %p\n' | sort -n")
+
+pkg_file_list = pkg_files.splitlines()
+
+pkg_hash = {}
+for time_pkg_pair in pkg_file_list:
+ (pkg_time, pkg) = time_pkg_pair.split()
+ pkg_time = int(pkg_time)
+ # This covers developer trees with not-accepted categories
+ tmp_name = re.match(r'/var/db/pkg/(.*/.*)/.*', pkg)
+ if not tmp_name: continue
+ pkg_name = tmp_name.group(1)
+ tmp_core = re.match(r'(.*)-\d.*', pkg_name)
+ if not tmp_core: continue
+ pkg_core = tmp_core.group(1)
+ if pkg_hash.has_key(pkg_core):
+ pkg_hash[pkg_core].append((pkg_time, pkg, pkg_name))
+ else:
+ pkg_hash[pkg_core] = [(pkg_time, pkg, pkg_name)]
+
+total_len = len(pkg_hash.keys())
+curpkg = 0
+tmpname = os.tmpnam()
+assume_yes = 0
+
+if len(sys.argv) > 1:
+ if sys.argv[1] in ["-y", "--yes"]:
+ assume_yes = 1
+ elif sys.argv[1] in ["-h", "--help"]:
+ print """pkg-clean [options]
+
+-y, --yes Don't ask for individual confirmation before unmerging; assume yes.
+"""
+ sys.exit(0)
+
+for pkg_core in pkg_hash.keys():
+ print "Examining %s:" % (pkg_core)
+ if len(pkg_hash[pkg_core]) < 2:
+ continue
+ unmerged_indexes = []
+
+ curpkg += 1
+ choices = ""
+ idx = 1
+ for pkg_tuple in pkg_hash[pkg_core]:
+ choices += " %d \"%s %s\" 0" % \
+ (idx, time.ctime(pkg_tuple[PKG_TIME]),
+ pkg_tuple[PKG_NAME])
+ idx += 1
+
+ params = "dialog --separate-output --backtitle \"pkg-clean processing package %d of %d\" " % ( curpkg, total_len)
+ params += "--checklist \"Select which package(s) to unmerge\" 20 70 12" + choices
+ res = os.system(params + " 2> " + tmpname)
+ if res:
+ sys.exit(0)
+
+ ins = open(tmpname)
+ for j in ins.readlines():
+ idx = int(j)
+ if idx == 0:
+ break
+
+ full_path = pkg_hash[pkg_core][idx-1][PKG]
+ ebuild = full_path.replace("/var/db/pkg/", "")
+
+ if not assume_yes:
+ params = "dialog --backtitle \"" + ebuild + "\" " + \
+ "--yesno \"Are you sure you want to unmerge " + ebuild + " ?\" 20 70"
+ res = os.system(params)
+ else:
+ res = 0
+
+ if res == 0:
+ (status, unmerge_out) = commands.getstatusoutput(
+ "ebuild %s unmerge" % (full_path))
+ print unmerge_out
+ time.sleep(2)
+ if status != 0:
+ sys.exit(status)
+ ins.close()
diff --git a/src/pkg-clean/pkg-clean.1 b/src/pkg-clean/pkg-clean.1
new file mode 100644
index 0000000..7a295f3
--- /dev/null
+++ b/src/pkg-clean/pkg-clean.1
@@ -0,0 +1,20 @@
+.TH pkg\-clean "1" "Nov 2003" "gentoolkit"
+.SH NAME
+pkg\-clean \- Gentoo: Clean obsolete packages
+.SH SYNOPSIS
+.B pkg\-clean
+.SH BUGS
+This tool is obsolete, as of gentoolkit 0.2.0.
+Use 'emerge clean' or 'emerge depclean' (with caution; read the man page)
+instead.
+
+.SH SEE ALSO
+.BR emerge(1)
+.br
+.BR /usr/sbin/pkg\-clean
+
+.SH AUTHORS
+This informative man page was written by Karl Trygve Kalleberg
+<karltk@gentoo.org> and expanded by Katerina Barone\-Adesi
+<katerinab@gmail.com>.
+