public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Chris Gianelloni <wolf31o2@gentoo.org>
To: lafou@wanadoo.fr
Cc: Jason Wever <weeve@gentoo.org>, Gentoo-dev <gentoo-dev@gentoo.org>
Subject: Re: [gentoo-dev] New feature proposition (make.conf)
Date: 18 Aug 2003 08:38:45 -0400	[thread overview]
Message-ID: <1061210325.19236.252.camel@vertigo> (raw)
In-Reply-To: <1061121557.8012.15.camel@biproc>


[-- Attachment #1.1: Type: text/plain, Size: 978 bytes --]

On Sun, 2003-08-17 at 07:59, Philippe Lafoucrière wrote:
> > My thought is rather than remove the distfiles for the version you are
> > building, remove the distfiles for versions that have just been
> > uninstalled by clean or update (granted they aren't being used by the new
> > version as well). This way you only have the distfiles for what's
> > currently on your system.
> 
> I agree. I have a lot of files that should go to Trash in my distfiles.
> I have to remove them by hand. why keep
> 
> package_v1.0.tbz2
> package_v1.1.tbz2
> package_v1.2.tbz2
> package_v1.3.tbz2
> 
> where package_v1.3.tbz2 will only be used (not for packages with
> patches).

I don't remember where I got this, so I cannot give credit to the
person, but I find this is a great tool for removing distfiles for
packages you no longer have installed.

It is also in python, so portage integration could be a possibility.

-- 
Chris Gianelloni
Developer, Gentoo Linux

[-- Attachment #1.2: distclean.py --]
[-- Type: text/x-python, Size: 1771 bytes --]

#!/usr/bin/env python
# distclean.py - remove source files for Gentoo
# packages that are no longer installed
# Fredrik Arnerup (e97_far@e.kth.se), 2003
# Use with '-p' (pretend) flag to just get a list of files
# that would be removed
import sys, os, os.path, getopt, portage

opt_p = 0
try:
    if len(sys.argv) > 1:
        opt_p = getopt.getopt(sys.argv[1:], "p")[0][0][0] == '-p'
except getopt.GetoptError:
    pass

distdir = portage.config().environ()['DISTDIR']
print 'DISTDIR =', distdir
    
vartree = portage.db["/"]["vartree"]
packages = []
for name in vartree.getallnodes():
    packages.extend(vartree.dep_match(name))

files = {}
for package in packages:
    try:
        package_files = portage.portdb.aux_get(package, ['SRC_URI'])[0].split()
        package_files = [(url.split('/')[-1]) for url in package_files]
        for filename in package_files:
            files[filename] = 1
    except:
        print "Failed to get file list for", package

if not files:
    sys.exit("No package files found.  This can't be right.\n")

try:
    list = portage.listdir(distdir)
except os.OSError:
    sys.exit("Failed to read " + distdir)

size = 0; count = 0
for file in list:
    abs_file = distdir + '/' + file
    if (os.path.isfile(abs_file) and (not os.path.islink(abs_file)) 
        and (not file in files)):
        size += os.stat(abs_file).st_size
        count += 1
        if opt_p:
            print 'Would remove', abs_file
        else:
            try:
                os.remove(abs_file)
                print 'Removed', abs_file
            except OSError:
                print 'Failed to remove', abs_file


size /= 1024  ## KB
print "%i files, total size: %i KB" % (count, size)

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2003-08-18 12:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-17  9:45 [gentoo-dev] New feature proposition (make.conf) Philippe Lafoucrière
2003-08-17 11:06 ` Zack Gilburd
2003-08-17 11:17   ` Jason Wever
2003-08-17 11:59     ` Philippe Lafoucrière
2003-08-18 12:38       ` Chris Gianelloni [this message]
2003-08-18 18:51         ` Mike Frysinger
2003-08-18 19:23           ` Chris Gianelloni
2003-08-17 13:34     ` Dewet Diener
2003-08-21  4:44   ` Stewart Honsberger
2003-08-21  9:19     ` Chris Gianelloni
2003-08-21  9:43     ` Toby Dickenson
2003-08-28 16:06     ` Anders Eriksson
2003-08-28 16:25       ` Lisa Marie Seelye

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=1061210325.19236.252.camel@vertigo \
    --to=wolf31o2@gentoo.org \
    --cc=gentoo-dev@gentoo.org \
    --cc=lafou@wanadoo.fr \
    --cc=weeve@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