From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18762 invoked by uid 1002); 11 Nov 2002 20:38:53 -0000 Mailing-List: contact gentoo-dev-help@gentoo.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Received: (qmail 18753 invoked from network); 11 Nov 2002 20:38:53 -0000 Date: Mon, 11 Nov 2002 20:38:28 +0000 From: =?iso-8859-15?Q?Jos=E9?= Fonseca To: gentoo-dev@gentoo.org Message-ID: <20021111203828.GA10784@localhost.localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="fdj2RfSjLxBAspz7" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4i Subject: [gentoo-dev] Script to clean old files from /usr/portage/distfiles X-Archives-Salt: cff09830-6067-4034-a265-af3800a1dd63 X-Archives-Hash: 5294fdacc7decbd8e863c645e8f73098 --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit I never do `rm -f /usr/portage/distfiles'. I find very useful having the sources of the installed packages ihandy as it avoids downloading everything over andagain when updating to new releases of the same version, or when installing Gentoo on another system. But after some time that directory gets too fat and is too boring to eliminate the deprecated packages by hand so I've made a script to automate this. You can see it attached. I've started with a shell script, then python, then I've read qpkg.sh, ebuild.sh, portage.py and many others in the search of the easiest way to do this. In the end everything boiled down to 2 lines - the rest is just sintatic sugar! I hope you enjoy it. José Fonseca --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: attachment; filename=distfiles-clean Content-Transfer-Encoding: 8bit #!/bin/sh # # distfiles-clean # # Cleans unused files from Portage distfiles directory. # # José Fonseca PORTDIR=/usr/portage DISTDIR=$PORTDIR/distfiles CACHEDIR=$PORTDIR/metadata/cache PKGDBDIR=/var/db/pkg TMPFILE=`mktemp /tmp/$0.XXXXXX` find $PKGDBDIR -name '*.ebuild' | sed -n -e "s:^$PKGDBDIR/\([^/]*\)/\([^/]*\)/\([^/]*\)\.ebuild$:$CACHEDIR/\1/\3:p" | xargs -l sed -e '4!d;s/[[:space:]]\+/\n/g' | sed -n -e 's:^.*/::p' | sort -u > $TMPFILE ls -1 $DISTDIR | sort -m - $TMPFILE | uniq -u | sed -e "s:^:$DISTDIR/:" | xargs rm -f rm $TMPFILE --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii -- gentoo-dev@gentoo.org mailing list --fdj2RfSjLxBAspz7-- __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com