1 |
On Tue, 25 Mar 2003 20:34:38 +0000 |
2 |
Chris Bainbridge <C.J.Bainbridge@×××××.uk> wrote: |
3 |
|
4 |
> On Tuesday 25 March 2003 18:55, DJ Cozatt wrote: |
5 |
> > I won't repost the thread but I liked this idea and wondered it if could |
6 |
> > also be extended to remove old pkg's in PKGDIR set when usindg buildpkg |
7 |
> > in /etc/make.conf Would yield a more general housecleaning app |
8 |
> > |
9 |
> > bus_drivr |
10 |
> > |
11 |
> > -- |
12 |
> > gentoo-dev@g.o mailing list |
13 |
> |
14 |
> Heres my binary packages cleaning script. Its very simplistic but does the |
15 |
> job. |
16 |
> |
17 |
> #!/usr/bin/python |
18 |
> |
19 |
> import os |
20 |
> import stat |
21 |
> import string |
22 |
> |
23 |
> def samename(s0,s1): |
24 |
> i=0 |
25 |
> for x in s0: |
26 |
> if x in string.digits: |
27 |
> break |
28 |
> i+=1 |
29 |
> # same for s1 |
30 |
> j=0 |
31 |
> for x in s0: |
32 |
> if x in string.digits: |
33 |
> break |
34 |
> j+=1 |
35 |
> return s0[:i]==s1[:j] |
36 |
> |
37 |
> dirs=['All'] |
38 |
> removed=[] |
39 |
> for dir in dirs: |
40 |
> print 'Searching files' |
41 |
> os.chdir('/usr/portage/packages/'+dir) |
42 |
> list=os.listdir('.') |
43 |
> list.sort() |
44 |
> current=list[0] |
45 |
> for x in list[1:]: |
46 |
> if samename(current,x): |
47 |
> time0=os.stat(current)[stat.ST_CTIME] |
48 |
> time1=os.stat(x)[stat.ST_CTIME] |
49 |
> if time0<time1: |
50 |
> removed.append(current) |
51 |
> os.remove(current) |
52 |
> current=x |
53 |
> else: |
54 |
> removed.append(x) |
55 |
> os.remove(x) |
56 |
> else: |
57 |
> current=x |
58 |
> |
59 |
> print 'Removed',removed |
60 |
> |
61 |
> print 'Searching for broken symlinks' |
62 |
> removed=[] |
63 |
> dirs=os.listdir('/usr/portage/packages/') |
64 |
> for dir in dirs: |
65 |
> os.chdir('/usr/portage/packages/'+dir) |
66 |
> list=os.listdir('.') |
67 |
> for f in list: |
68 |
> try: |
69 |
> os.stat(f) |
70 |
> except: |
71 |
> if os.path.islink(f): |
72 |
> removed.append(f) |
73 |
> os.remove(f) |
74 |
> |
75 |
> print 'Removed',removed |
76 |
> |
77 |
> |
78 |
> |
79 |
> -- |
80 |
> gentoo-dev@g.o mailing list |
81 |
> |
82 |
|
83 |
Thank you :) |
84 |
|
85 |
-- |
86 |
gentoo-dev@g.o mailing list |