Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 205 - nifty script to unmerge old ebuilds
Summary: nifty script to unmerge old ebuilds
Status: RESOLVED DUPLICATE of bug 278
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Geert Bevin
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-01-17 03:33 UTC by aeoo
Modified: 2011-10-30 22:19 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description aeoo 2002-01-17 03:33:52 UTC
Here is a script that will help you unmerge those old .ebuild's that are 
cluttering your system.  The script will sort them by date, from oldest to 
newest.

Pick a number of the ebuild to unmerge and hit enter.  Typing any non-number 
here will break the script because I am too sleepy and tired to finish it and 
make it nice.

To confirm unmerge, type "y" and hit enter.  Typing anything else will deny 
unmerge.

Have fun, and NO, there are no warranties, expressed or implied ;).
Comment 1 aeoo 2002-01-17 03:36:10 UTC
#!/usr/bin/python
# vim: set ts=4 sw=4:
# Copyright 2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# Author: Leo Lipelis

import commands as c
import re
import sys
import string
import time

# 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) = c.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 = string.atoi(pkg_time)
        pkg_name = re.match(r'/var/db/pkg/(.*/.*)/.*', pkg).group(1)
        pkg_core = re.match(r'(.*)-\d.*', pkg_name).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)]

for pkg_core in pkg_hash.keys():
        print "Examining %s:" % (pkg_core)
        if len(pkg_hash[pkg_core]) < 2:
                continue
        unmerged_indexes = []
        while 1:
                i = 0
                print "0) Continue"
                for pkg_tuple in pkg_hash[pkg_core]:
                        if i not in unmerged_indexes:
                                print "%d) %s %s" % (
                                                i+1,
                                                
time.ctime(pkg_tuple[PKG_TIME]),                                               
 pkg_tuple[PKG_NAME])
                        i = i + 1
                print "Unmerge: ",
                index = string.atoi(sys.stdin.readline())
                if index == 0:
                        break
                else:
                        index = index - 1
                ebuild = pkg_hash[pkg_core][index][PKG]
                print "Unmerge %s? " % (ebuild),
                confirmed = sys.stdin.readline()
                if confirmed == "y\n":
                        (status, unmerge_out) = c.getstatusoutput(
                                        "ebuild %s unmerge" % (ebuild))
                        print unmerge_out
                        if status != 0:
                                sys.exit(status)
                        unmerged_indexes.append(index)
                else:
                        print "continuing without unmerging..."

Comment 2 aeoo 2002-01-17 03:39:08 UTC
Bummer...looks like bugzilla chewed up my file and I can't attach it.

Get it from http://www.brainfreeze.org/pkg-update
Comment 3 Bruce A. Locke 2002-01-26 03:37:51 UTC
aeoo, I get a 404 on that link :(
Comment 4 Daniel Robbins (RETIRED) gentoo-dev 2002-01-28 12:43:18 UTC
I don't think we'll need this if we implement slots.
Comment 5 Geert Bevin 2002-01-31 14:57:06 UTC
The slot functionality will remove the need for such a script imho, therefor
marking aas duplicate

*** This bug has been marked as a duplicate of 278 ***