]>
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() | |
e77c91c6 AM |
24 | if err: |
25 | print >> sys.stderr, "%s: %s" % (sys.argv[0], err) | |
26 | sys.exit(1) | |
7b2ce93a AM |
27 | |
28 | files = [] | |
29 | ||
30 | for l in out.split('\n'): | |
31 | data = l.split() | |
32 | if len(data) != 3 or data[0] != 's': | |
33 | continue | |
34 | file = os.path.basename(data[2]) | |
35 | files.append(file) | |
36 | ||
37 | obsolete = [] | |
38 | ||
39 | for file in os.listdir(dir): | |
40 | file = os.path.basename(file) | |
dd05fc46 AM |
41 | if file in [ '.', '..', 'CVS', '.cvsignore', 'dropin', 'md5', 'adapter', 'builder', |
42 | 'relup.sh', 'compile.sh', 'repackage.sh', 'TODO', os.path.basename(spec) ]: | |
7b2ce93a AM |
43 | continue |
44 | if file not in files: | |
45 | print "Obsolete file: %s" % file | |
46 | obsolete.append(file) | |
47 | ||
c7c88163 AM |
48 | if obsolete: |
49 | ||
50 | print "cvs rm -f %s" % " ".join(obsolete) | |
7998a6ff | 51 | print "cvs commit -m '- drop obsolete files' %s" % " ".join(obsolete) |
7b2ce93a AM |
52 | |
53 | ||
54 |