Gentoo Archives: gentoo-dev

From: Andy Arbon <gentoo@××××××××××××××.uk>
To: gentoo-user@g.o, gentoo-dev <gentoo-dev@g.o>
Subject: [gentoo-dev] Disk space && managing package binaries
Date: Mon, 24 Mar 2003 21:39:42
Message-Id: 3E7F7B1A.2050108@andrewarbon.co.uk
1 Hello,
2
3 Related to my recent question on gentoo-user regarding freeing up disk
4 space, I've just written a short bash script that helps tidying up the
5 binary packages that portage builds (see below).
6
7 All it does it take each file in the distfiles and packages directories
8 and use qpkg to see if the package that built/came from it is currently
9 installed. If it isn't then it's removed.
10
11 There are obviously shortcomings with this, but as a rough tool it
12 works. One problem is that if you have a package like rsync-1.2.3 and
13 rsync-1.2.3-r1 then rsync-1.2.3 won't get removed until the system gets
14 upgraded to rsync-1.2.4, as (AFAIK) there's no way to specify
15 end-of-string in a query to qpkg (am I wrong about this?)
16
17 At the moment it moves packages into a subdirectory ready to be removed
18 but doesn't actually remove them.
19
20 Any comments on this?
21
22 Cheers,
23
24 Andy
25
26 #!/bin/bash
27 # Clean out of date packages and distfiles out
28
29 PPATH="/usr/portage/packages/All"
30 DPATH="/usr/portage/distfiles"
31 FILELIST=`find $PPATH| sed -e \
32 's/.*\/\(.*\)\.\(tar.bz2$\|zip\|tar.gz$\|tbz2\|bz2\|gz\)$/\1/g' -e '1d'`
33
34 if [[ -z "$PPATH/../old" ]];
35 then mkdir "$PPATH/../old"
36 fi
37
38 for file in $FILELIST; do
39 echo -n "Testing $file "
40 if [[ ! `qpkg -I $file` ]];
41 then mv $PPATH/$file* $PPATH/../old/
42 echo "... removing";
43 else echo
44 fi
45 done
46
47 # Now we do the distfiles
48 FILELIST=`find $DPATH| sed -e \
49 's/.*\/\(.*\)\.\(tar.bz2$\|zip\|tar.gz$\|tbz2\|bz2\|gz\|exe\|wsz\|tgz\|patch\|bin\|tar.Z\)$/\1/g'
50 -e '1d'`
51
52 if [[ -z "$DPATH/../old" ]];
53 then mkdir "$DPATH/../old"
54 fi
55
56 for file in $FILELIST; do
57 echo -n "Testing $file "
58 if [[ ! `qpkg -I $file` ]];
59 then mv $DPATH/$file* $DPATH/../old/
60 echo "... removing";
61 else echo
62 fi
63 done
64
65
66 --
67 gentoo-dev@g.o mailing list