-
Notifications
You must be signed in to change notification settings - Fork 7
/
find-unapplied-patches
executable file
·46 lines (33 loc) · 1.31 KB
/
find-unapplied-patches
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import pisi
def get_pspecs(path):
return os.popen("find %s -name 'pspec.xml'" % path).read().strip().split("\n")
def get_files(path):
if os.path.exists("%s/files" % path):
return [l.strip().split(path+'/')[-1] for l in os.popen("find %s/files -type f" % path).readlines() \
if "/.svn" not in l]
else:
return []
if __name__ == "__main__":
# Recursively traverse along a given directory to find
# unapplied patches to the packages.
if len(sys.argv) < 2:
print "Usage: %s <directory>" % sys.argv[0]
sys.exit(1)
dir = sys.argv[1]
for pspec in get_pspecs(dir):
spec = pisi.specfile.SpecFile(pspec)
spec_dir = os.path.dirname(pspec)
# Find applied patches from pspec
patches = ["files/%s" % p.filename for p in spec.source.patches]
# Append possible additional files too
patches.extend(["files/%s" % _p.filename for _p in sum([p.additionalFiles for p in spec.packages], [])])
# Find actual files in files/ (.svn excluded)
files = get_files(spec_dir)
# Print the results if any
results = ["%s/%s" % (spec_dir, p) for p in set(files).difference(patches)]
if results:
print "\n".join(results)