]>
Commit | Line | Data |
---|---|---|
7b2ce93a AM |
1 | #!/usr/bin/python |
2 | ||
3 | import subprocess | |
4 | import sys | |
5 | import os | |
6 | ||
7 | if len(sys.argv) != 2: | |
8 | print >> sys.stderr, "Usage: %s <spec>" % sys.argv[0] | |
9 | sys.exit(1) | |
10 | ||
11 | spec = sys.argv[1] | |
12 | ||
13 | if not os.path.isfile(spec): | |
14 | print >> sys.stderr, "%s: %s doesn't exist!" % (sys.argv[0], spec) | |
15 | sys.exit(1) | |
16 | ||
17 | dir = os.path.dirname(spec) | |
18 | if dir == '': | |
19 | dir = '.' | |
20 | ||
21 | p = subprocess.Popen(['rpm-specdump', spec], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
22 | (out, err) = p.communicate(None) | |
23 | p.wait() | |
24 | ||
25 | files = [] | |
26 | ||
27 | for l in out.split('\n'): | |
28 | data = l.split() | |
29 | if len(data) != 3 or data[0] != 's': | |
30 | continue | |
31 | file = os.path.basename(data[2]) | |
32 | files.append(file) | |
33 | ||
34 | obsolete = [] | |
35 | ||
36 | for file in os.listdir(dir): | |
37 | file = os.path.basename(file) | |
d9dbc940 | 38 | if file in [ '.', '..', 'CVS', '.cvsignore', 'dropin', 'md5', 'adapter', 'builder', 'relup.sh', 'compile.sh', 'repackage.sh', spec ]: |
7b2ce93a AM |
39 | continue |
40 | if file not in files: | |
41 | print "Obsolete file: %s" % file | |
42 | obsolete.append(file) | |
43 | ||
44 | ||
ca6c1ede | 45 | print "cvs rm -f %s" % " ".join(obsolete) |
7b2ce93a AM |
46 | |
47 | ||
48 |