Skip to content

Commit cbf9053

Browse files
author
aydemir
committed
qt5 circle dep
1 parent bf71265 commit cbf9053

File tree

8 files changed

+196
-9
lines changed

8 files changed

+196
-9
lines changed

circledep-finder

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
#!/usr/bin/python
2+
#
3+
# -*- coding: utf-8 -*-
4+
#
5+
# Copyright (C) 2008, TUBITAK/UEKAE
6+
#
7+
# This program is free software; you can redistribute it and/or modify it under
8+
# the terms of the GNU General Public License as published by the Free
9+
# Software Foundation; either version 2 of the License, or (at your option)
10+
# any later version.
11+
#
12+
# Please read the COPYING file.
13+
#
14+
15+
import sys
16+
import multiprocessing
17+
18+
import urllib2
19+
import bz2
20+
import lzma
21+
22+
import piksemel
23+
24+
import pisi
25+
import pisi.dependency as dependency
26+
from pisi.graph import CycleException
27+
28+
29+
class SourceDB:
30+
def __init__(self, index):
31+
32+
self.__source_nodes = {}
33+
self.__pkgstosrc = {}
34+
35+
doc = piksemel.parseString(index)
36+
self.__source_nodes, self.__pkgstosrc = self.__generate_sources(doc)
37+
38+
def __generate_sources(self, doc):
39+
sources = {}
40+
pkgstosrc = {}
41+
42+
for spec in doc.tags("SpecFile"):
43+
src_name = spec.getTag("Source").getTagData("Name")
44+
sources[src_name] = spec.toString()
45+
for package in spec.tags("Package"):
46+
pkgstosrc[package.getTagData("Name")] = src_name
47+
48+
return sources, pkgstosrc
49+
50+
def has_spec(self, name):
51+
return self.__source_nodes.has_key(name)
52+
53+
def get_spec(self, name):
54+
src = self.__source_nodes[name]
55+
spec = pisi.specfile.SpecFile()
56+
spec.parse(src)
57+
return spec
58+
59+
def list_specs(self):
60+
return self.__source_nodes.keys()
61+
62+
def pkgtosrc(self, name):
63+
return self.__pkgstosrc[name]
64+
65+
def find_circle(sourcedb, A):
66+
67+
G_f = pisi.graph.Digraph()
68+
69+
def get_spec(name):
70+
if sourcedb.has_spec(name):
71+
return sourcedb.get_spec(name)
72+
else:
73+
raise Exception('Cannot find source package: %s' % name)
74+
75+
def get_src(name):
76+
return get_spec(name).source
77+
78+
def add_src(src):
79+
if not str(src.name) in G_f.vertices():
80+
G_f.add_vertex(str(src.name), (src.version, src.release))
81+
82+
def pkgtosrc(pkg):
83+
try:
84+
tmp = sourcedb.pkgtosrc(pkg)
85+
except KeyError, e:
86+
# this is a bad hack but after we hit a problem we need to continue
87+
tmp = "e3"
88+
print "---> borks in ", e
89+
90+
return tmp
91+
92+
B = A
93+
94+
install_list = set()
95+
96+
while len(B) > 0:
97+
Bp = set()
98+
for x in B:
99+
sf = get_spec(x)
100+
src = sf.source
101+
add_src(src)
102+
103+
# add dependencies
104+
105+
def process_dep(dep):
106+
srcdep = pkgtosrc(dep.package)
107+
if not srcdep in G_f.vertices():
108+
Bp.add(srcdep)
109+
add_src(get_src(srcdep))
110+
if not src.name == srcdep: # firefox - firefox-devel thing
111+
G_f.add_edge(src.name, srcdep)
112+
113+
for builddep in src.buildDependencies:
114+
process_dep(builddep)
115+
116+
for pkg in sf.packages:
117+
for rtdep in pkg.packageDependencies:
118+
process_dep(rtdep)
119+
B = Bp
120+
121+
try:
122+
order_build = G_f.topological_sort()
123+
order_build.reverse()
124+
except CycleException, cycle:
125+
return str(cycle)
126+
127+
return ""
128+
129+
def getIndex(uri):
130+
try:
131+
if "://" in uri:
132+
rawdata = urllib2.urlopen(uri).read()
133+
else:
134+
rawdata = open(uri, "r").read()
135+
except IOError:
136+
print "could not fetch %s" % uri
137+
return None
138+
139+
if uri.endswith("bz2"):
140+
data = bz2.decompress(rawdata)
141+
elif uri.endswith("xz") or uri.endswith("lzma"):
142+
data = lzma.decompress(rawdata)
143+
else:
144+
data = rawdata
145+
146+
return data
147+
148+
def processPackage(pkg, sourcesLength, counter):
149+
global sourcedb
150+
151+
sys.stdout.write("\r(%04d/%d) Calculating build dep of %s " % (counter, sourcesLength, pkg))
152+
sys.stdout.flush()
153+
154+
return find_circle(sourcedb, [pkg])
155+
156+
def updateStatus(circleResult):
157+
global cycles
158+
cycles.add(circleResult)
159+
160+
161+
if __name__ == "__main__":
162+
163+
if len(sys.argv) < 2:
164+
print "Usage: circlefinder.py <source repo pisi-index.xml file>"
165+
sys.exit(1)
166+
167+
rawIndex = getIndex(sys.argv[1])
168+
sourcedb = SourceDB(rawIndex)
169+
sources = sourcedb.list_specs()
170+
171+
sourcesLength = len(sources)
172+
counter = 0
173+
174+
global cycles
175+
cycles = set()
176+
177+
pool = multiprocessing.Pool()
178+
179+
for pkg in sources:
180+
counter += 1
181+
pool.apply_async(processPackage, (pkg, sourcesLength, counter), callback=updateStatus)
182+
183+
pool.close()
184+
pool.join()
185+
186+
if len(cycles):
187+
print
188+
for cycle in cycles:
189+
print cycle
190+
else:
191+
print "No circular dep found"
192+
193+

main/desktop/toolkit/qt5/qt5-declarative/pspec.xml

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
<RuntimeDependencies>
3131
<Dependency>qt5-base</Dependency>
3232
<Dependency>mesa</Dependency>
33-
<Dependency>qt5-xmlpatterns</Dependency>
3433
</RuntimeDependencies>
3534
</Package>
3635

main/desktop/toolkit/qt5/qt5-tools/pspec.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
<Name>qt5-tools</Name>
2424
<RuntimeDependencies>
2525
<Dependency>qt5-base</Dependency>
26-
<Dependency>qt5-declarative</Dependency>
27-
<Dependency>mesa</Dependency>
26+
<Dependency>mesa</Dependency>
2827
</RuntimeDependencies>
2928
<Files>
3029
<Path fileType="library">/usr/lib</Path>

main/desktop/toolkit/qt5/qt5-xmlpatterns/pspec.xml

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<Archive sha1sum="b25c2ec875fa1cbe0de20fd39bdd444c703540b4" type="tarxz">http://download.qt.io/official_releases/qt/5.4/5.4.1/submodules/qtxmlpatterns-opensource-src-5.4.1.tar.xz</Archive>
1515
<BuildDependencies>
1616
<Dependency>qt5-base-devel</Dependency>
17-
<Dependency>qt5-tools-devel</Dependency>
1817
</BuildDependencies>
1918
</Source>
2019

pisi-index.xml

-3
Original file line numberDiff line numberDiff line change
@@ -81596,7 +81596,6 @@ uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG compression
8159681596
<Name>qt5-tools</Name>
8159781597
<RuntimeDependencies>
8159881598
<Dependency>qt5-base</Dependency>
81599-
<Dependency>qt5-declarative</Dependency>
8160081599
<Dependency>mesa</Dependency>
8160181600
</RuntimeDependencies>
8160281601
<Files>
@@ -81756,7 +81755,6 @@ uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG compression
8175681755
<Archive type="tarxz" sha1sum="b25c2ec875fa1cbe0de20fd39bdd444c703540b4">http://download.qt.io/official_releases/qt/5.4/5.4.1/submodules/qtxmlpatterns-opensource-src-5.4.1.tar.xz</Archive>
8175781756
<BuildDependencies>
8175881757
<Dependency>qt5-base-devel</Dependency>
81759-
<Dependency>qt5-tools-devel</Dependency>
8176081758
</BuildDependencies>
8176181759
<SourceURI>main/desktop/toolkit/qt5/qt5-xmlpatterns/pspec.xml</SourceURI>
8176281760
</Source>
@@ -82365,7 +82363,6 @@ uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG compression
8236582363
<RuntimeDependencies>
8236682364
<Dependency>qt5-base</Dependency>
8236782365
<Dependency>mesa</Dependency>
82368-
<Dependency>qt5-xmlpatterns</Dependency>
8236982366
</RuntimeDependencies>
8237082367
<Files>
8237182368
<Path fileType="library">/usr/lib</Path>

pisi-index.xml.sha1sum

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b9e2b569cffc93d6451f01c95a6b3af342fdfb57
1+
1e4d047f86e01f21d448afd002e30f53a49d9d8e

pisi-index.xml.xz

4 Bytes
Binary file not shown.

pisi-index.xml.xz.sha1sum

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
364654e65f52060c04f7a06ee2bd8f5a9ca4e138
1+
e9d48f0b53d0682ad0dd24363356e48d8e6476de

0 commit comments

Comments
 (0)