forked from pisilinux/main
-
Notifications
You must be signed in to change notification settings - Fork 0
/
find-packages-not-compiled-in-farm
executable file
·119 lines (87 loc) · 2.9 KB
/
find-packages-not-compiled-in-farm
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# find which packages were not compiled in farm
# usage: scriptname svnindex pisiindex
#
import os
import sys
import urllib2
import bz2
import lzma
import piksemel
pisirepouri = "file:///home/ertugerata/Works/2.0-Beta.1/pisi-index.xml.xz"
svnrepouri = "https://github.com/ertugerata/main/raw/master/pisi-index.xml.xz"
def getIndex(uri):
try:
if "://" in uri:
rawdata = urllib2.urlopen(uri).read()
else:
rawdata = open(uri, "r").read()
except IOError:
print "could not fetch %s" % uri
return None
if uri.endswith("bz2"):
data = bz2.decompress(rawdata)
elif uri.endswith("xz") or uri.endswith("lzma"):
data = lzma.decompress(rawdata)
else:
data = rawdata
return data
def parseRepo(repoURI):
pkgdict = {}
rawData = getIndex(repoURI)
doc = piksemel.parseString(rawData)
hasSpecFile = doc.getTag("SpecFile")
if hasSpecFile:
for parent in doc.tags("SpecFile"):
pkgname = parent.getTag("Source").getTagData("Name")
srcname = pkgname
partof = parent.getTag("Source").getTagData("PartOf")
lastRelease = parent.getTag("History").tags("Update").next()
release = lastRelease.getAttribute("release")
pkgdict[srcname] = [partof, release]
else:
for parent in doc.tags("Package"):
pkgname = parent.getTagData("Name")
srcname = parent.getTag("Source").getTagData("Name")
partof = parent.getTagData("PartOf")
lastRelease = parent.getTag("History").tags("Update").next()
release = lastRelease.getAttribute("release")
pkgdict[srcname] = [partof, release]
return pkgdict
if __name__ == "__main__":
pkgmissing = []
pkgdifferent = []
if len(sys.argv) > 1:
svnrepouri = sys.argv[1]
if len(sys.argv) > 2:
pisirepouri = sys.argv[2]
print
print "* working on %s" % svnrepouri
svnrepo = parseRepo(svnrepouri)
print "* working on %s" % pisirepouri
pisirepo = parseRepo(pisirepouri)
pkglist = svnrepo.keys()
pkglist.sort()
for i in pkglist:
if not i in pisirepo:
partof = svnrepo[i][0]
pkgmissing.append("%s/%s" % (partof.replace(".", "/"), i))
elif svnrepo[i][1] != pisirepo[i][1]:
partof = svnrepo[i][0]
pkgdifferent.append("%s/%s" % (partof.replace(".", "/"), i))
pkgmissing.sort()
pkgdifferent.sort()
if len(pkgmissing):
print
print "* Packages missing in %s" % pisirepouri
for p in pkgmissing:
print " %s" % p
if len(pkgdifferent):
print
print "* Packages that needs compiling"
for p in pkgdifferent:
i = p.split("/")[-1]
print " %s (%s > %s)" % (p, svnrepo[i][1], pisirepo[i][1])
print