]> git.pld-linux.org Git - packages/rpm-build-tools.git/commitdiff
- checks if some files are unused and can be cvs rmed
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Fri, 3 Jul 2009 06:27:56 +0000 (06:27 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    check-unused-files.py -> 1.1

check-unused-files.py [new file with mode: 0644]

diff --git a/check-unused-files.py b/check-unused-files.py
new file mode 100644 (file)
index 0000000..8547264
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+
+import subprocess
+import sys
+import os
+
+if len(sys.argv) != 2:
+    print >> sys.stderr, "Usage: %s <spec>" % sys.argv[0]
+    sys.exit(1)
+
+spec = sys.argv[1]
+
+if not os.path.isfile(spec):
+    print >> sys.stderr, "%s: %s doesn't exist!" % (sys.argv[0], spec)
+    sys.exit(1)
+
+dir = os.path.dirname(spec)
+if dir == '':
+    dir = '.'
+
+p = subprocess.Popen(['rpm-specdump', spec], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+(out, err) = p.communicate(None)
+p.wait()
+
+files = []
+
+for l in out.split('\n'):
+    data = l.split()
+    if len(data) != 3 or data[0] != 's':
+        continue
+    file = os.path.basename(data[2])
+    files.append(file)
+
+obsolete = []
+
+for file in os.listdir(dir):
+    file = os.path.basename(file)
+    if file in [ '.', '..', 'CVS', spec ]:
+        continue
+    if file not in files:
+        print "Obsolete file: %s" % file
+        obsolete.append(file)
+
+print
+print "cvs rm -f %s" % "".join(obsolete)
+
+
+
This page took 0.04547 seconds and 4 git commands to generate.