]>
Commit | Line | Data |
---|---|---|
7b2ce93a AM |
1 | #!/usr/bin/python |
2 | ||
3 | import subprocess | |
4 | import sys | |
5 | import os | |
8445e70f | 6 | import fnmatch |
7b2ce93a AM |
7 | |
8 | if len(sys.argv) != 2: | |
9 | print >> sys.stderr, "Usage: %s <spec>" % sys.argv[0] | |
10 | sys.exit(1) | |
11 | ||
12 | spec = sys.argv[1] | |
13 | ||
14 | if not os.path.isfile(spec): | |
15 | print >> sys.stderr, "%s: %s doesn't exist!" % (sys.argv[0], spec) | |
16 | sys.exit(1) | |
17 | ||
18 | dir = os.path.dirname(spec) | |
19 | if dir == '': | |
20 | dir = '.' | |
21 | ||
22 | p = subprocess.Popen(['rpm-specdump', spec], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
23 | (out, err) = p.communicate(None) | |
24 | p.wait() | |
e77c91c6 AM |
25 | if err: |
26 | print >> sys.stderr, "%s: %s" % (sys.argv[0], err) | |
27 | sys.exit(1) | |
7b2ce93a AM |
28 | |
29 | files = [] | |
30 | ||
31 | for l in out.split('\n'): | |
32 | data = l.split() | |
33 | if len(data) != 3 or data[0] != 's': | |
34 | continue | |
35 | file = os.path.basename(data[2]) | |
36 | files.append(file) | |
37 | ||
38 | obsolete = [] | |
39 | ||
8445e70f | 40 | def blacklisted(file): |
dd05fc46 | 41 | if file in [ '.', '..', 'CVS', '.cvsignore', 'dropin', 'md5', 'adapter', 'builder', |
82a3c8b3 | 42 | 'relup.sh', 'compile.sh', 'repackage.sh', 'rsync.sh', 'TODO', os.path.basename(spec) ]: |
8445e70f ER |
43 | return True |
44 | ||
45 | for pat in ['log.*', '.#*', '*~', '*.orig', '*.sw?']: | |
46 | if fnmatch.fnmatch(file, pat): | |
47 | return True | |
48 | ||
49 | return False | |
50 | ||
51 | for file in os.listdir(dir): | |
52 | file = os.path.basename(file) | |
53 | if blacklisted(file): | |
82a3c8b3 | 54 | continue |
8445e70f | 55 | |
7b2ce93a AM |
56 | if file not in files: |
57 | print "Obsolete file: %s" % file | |
58 | obsolete.append(file) | |
59 | ||
c7c88163 AM |
60 | if obsolete: |
61 | ||
62 | print "cvs rm -f %s" % " ".join(obsolete) | |
7998a6ff | 63 | print "cvs commit -m '- drop obsolete files' %s" % " ".join(obsolete) |