* compute cycle for CycleException
* fix: build order thing: skip self arcs * comment
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Project SYSTEM "Project-3.8.dtd">
|
<!DOCTYPE Project SYSTEM "Project-3.8.dtd">
|
||||||
<!-- Project file for project pisi -->
|
<!-- Project file for project pisi -->
|
||||||
<!-- Saved: 2005-12-08, 18:50:27 -->
|
<!-- Saved: 2005-12-14, 21:35:34 -->
|
||||||
<!-- Copyright (C) 2005 PiSi Development Team, -->
|
<!-- Copyright (C) 2005 PiSi Development Team, -->
|
||||||
<Project version="3.8">
|
<Project version="3.8">
|
||||||
<ProgLanguage mixed="0">Python</ProgLanguage>
|
<ProgLanguage mixed="0">Python</ProgLanguage>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<Description>The package management software of Pardus distribution.
|
<Description>The package management software of Pardus distribution.
|
||||||
</Description>
|
</Description>
|
||||||
<Author>PiSi Development Team</Author>
|
<Author>PiSi Development Team</Author>
|
||||||
<Email></Email>
|
<EmaIl></EmaIl>
|
||||||
<Sources>
|
<Sources>
|
||||||
<Source>
|
<Source>
|
||||||
<Dir>tools</Dir>
|
<Dir>tools</Dir>
|
||||||
@@ -466,6 +466,14 @@
|
|||||||
<Dir>pisi</Dir>
|
<Dir>pisi</Dir>
|
||||||
<Name>dbshelve.py</Name>
|
<Name>dbshelve.py</Name>
|
||||||
</Source>
|
</Source>
|
||||||
|
<Source>
|
||||||
|
<Dir>tools</Dir>
|
||||||
|
<Name>calc-build-order.py</Name>
|
||||||
|
</Source>
|
||||||
|
<Source>
|
||||||
|
<Dir>tools</Dir>
|
||||||
|
<Name>repo-dep-resolver.py</Name>
|
||||||
|
</Source>
|
||||||
</Sources>
|
</Sources>
|
||||||
<Forms>
|
<Forms>
|
||||||
</Forms>
|
</Forms>
|
||||||
@@ -507,10 +515,10 @@
|
|||||||
<VcsOtherData>{'standardLayout': 1}</VcsOtherData>
|
<VcsOtherData>{'standardLayout': 1}</VcsOtherData>
|
||||||
</Vcs>
|
</Vcs>
|
||||||
<FiletypeAssociations>
|
<FiletypeAssociations>
|
||||||
<FiletypeAssociation pattern="*.py" type="SOURCES" />
|
|
||||||
<FiletypeAssociation pattern="*.ui.h" type="FORMS" />
|
<FiletypeAssociation pattern="*.ui.h" type="FORMS" />
|
||||||
<FiletypeAssociation pattern="*.idl" type="INTERFACES" />
|
|
||||||
<FiletypeAssociation pattern="*.ui" type="FORMS" />
|
<FiletypeAssociation pattern="*.ui" type="FORMS" />
|
||||||
|
<FiletypeAssociation pattern="*.idl" type="INTERFACES" />
|
||||||
|
<FiletypeAssociation pattern="*.py" type="SOURCES" />
|
||||||
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
|
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
|
||||||
</FiletypeAssociations>
|
</FiletypeAssociations>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
+15
-7
@@ -12,18 +12,21 @@
|
|||||||
# the most simple minded digraph class ever
|
# the most simple minded digraph class ever
|
||||||
|
|
||||||
|
|
||||||
# for python 2.3 compatibility
|
|
||||||
import sys
|
import sys
|
||||||
ver = sys.version_info
|
|
||||||
if ver[0] <= 2 and ver[1] < 4:
|
|
||||||
from sets import Set as set
|
|
||||||
|
|
||||||
import pisi
|
import pisi
|
||||||
|
|
||||||
|
import gettext
|
||||||
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
|
_ = __trans.ugettext
|
||||||
|
|
||||||
# not an error!
|
# not an error!
|
||||||
|
|
||||||
class CycleException(pisi.Exception):
|
class CycleException(pisi.Exception):
|
||||||
pass
|
def __init__(self, cycle):
|
||||||
|
self.cycle = cycle
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return _('encountered cycle %s') % self.cycle
|
||||||
|
|
||||||
class Digraph(object):
|
class Digraph(object):
|
||||||
|
|
||||||
@@ -115,7 +118,12 @@ class Digraph(object):
|
|||||||
self.p[v] = u
|
self.p[v] = u
|
||||||
self.dfs_visit(v, finish_hook)
|
self.dfs_visit(v, finish_hook)
|
||||||
elif self.color[v] == 'g': # cycle detected
|
elif self.color[v] == 'g': # cycle detected
|
||||||
raise CycleException
|
cycle = [v, u]
|
||||||
|
while self.p[u]:
|
||||||
|
u = self.p[u]
|
||||||
|
cycle.append(u)
|
||||||
|
cycle.reverse()
|
||||||
|
raise CycleException(cycle)
|
||||||
self.color[u] = 'b' # mark black (completed)
|
self.color[u] = 'b' # mark black (completed)
|
||||||
if finish_hook:
|
if finish_hook:
|
||||||
finish_hook(u)
|
finish_hook(u)
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ setup(name="pisi",
|
|||||||
|
|
||||||
# the below stuff is really nice but we already have a version
|
# the below stuff is really nice but we already have a version
|
||||||
# we can use this stuff for svn snapshots in a separate
|
# we can use this stuff for svn snapshots in a separate
|
||||||
# script -- exa
|
# script, or with a parameter I don't know -- exa
|
||||||
|
|
||||||
PISI_VERSION = pisi.__version__
|
PISI_VERSION = pisi.__version__
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import sys
|
|||||||
import os
|
import os
|
||||||
sys.path.insert(0, '.')
|
sys.path.insert(0, '.')
|
||||||
|
|
||||||
|
import gettext
|
||||||
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
|
_ = __trans.ugettext
|
||||||
|
|
||||||
import pisi.context as ctx
|
import pisi.context as ctx
|
||||||
#ctx.usemdom = True
|
#ctx.usemdom = True
|
||||||
import pisi
|
import pisi
|
||||||
@@ -13,7 +17,7 @@ import pisi.api
|
|||||||
import pisi.config
|
import pisi.config
|
||||||
import pisi.specfile as specfile
|
import pisi.specfile as specfile
|
||||||
import pisi.util
|
import pisi.util
|
||||||
from pisi.graph import Digraph
|
import pisi.graph
|
||||||
|
|
||||||
options = pisi.config.Options()
|
options = pisi.config.Options()
|
||||||
if len(sys.argv) > 2:
|
if len(sys.argv) > 2:
|
||||||
@@ -25,6 +29,7 @@ repo_uri = sys.argv[1]
|
|||||||
|
|
||||||
specfiles = []
|
specfiles = []
|
||||||
|
|
||||||
|
print "reading pspecfiles, just a moment"
|
||||||
for root, dirs, files in os.walk(repo_uri):
|
for root, dirs, files in os.walk(repo_uri):
|
||||||
for fn in files:
|
for fn in files:
|
||||||
if fn == 'pspec.xml':
|
if fn == 'pspec.xml':
|
||||||
@@ -32,14 +37,14 @@ for root, dirs, files in os.walk(repo_uri):
|
|||||||
sf = specfile.SpecFile()
|
sf = specfile.SpecFile()
|
||||||
sf.read(pisi.util.join_path(root, fn))
|
sf.read(pisi.util.join_path(root, fn))
|
||||||
sf.check()
|
sf.check()
|
||||||
print 'read %s: %s' % (sf.source.name, sf.source.version)
|
#print 'read %s: %s' % (sf.source.name, sf.source.version)
|
||||||
specfiles.append(sf)
|
specfiles.append(sf)
|
||||||
|
|
||||||
def plan_build(specfiles):
|
def plan_build(specfiles):
|
||||||
# try to construct a pisi graph of packages to
|
# try to construct a pisi graph of packages to
|
||||||
# install / reinstall
|
# install / reinstall
|
||||||
|
|
||||||
G_f = Digraph()
|
G_f = pisi.graph.Digraph()
|
||||||
pkgtosrc = {}
|
pkgtosrc = {}
|
||||||
for sf in specfiles:
|
for sf in specfiles:
|
||||||
for pkg in sf.packages:
|
for pkg in sf.packages:
|
||||||
@@ -48,14 +53,15 @@ def plan_build(specfiles):
|
|||||||
for x in specfiles:
|
for x in specfiles:
|
||||||
#G_f.add_package(x)
|
#G_f.add_package(x)
|
||||||
src = x.source
|
src = x.source
|
||||||
print "adding vtx ", str(src.name)
|
|
||||||
if not str(src.name) in G_f.vertices():
|
if not str(src.name) in G_f.vertices():
|
||||||
G_f.add_vertex(str(src.name), (src.version, src.release))
|
G_f.add_vertex(str(src.name), (src.version, src.release))
|
||||||
for builddep in src.buildDependencies:
|
for builddep in src.buildDependencies:
|
||||||
G_f.add_edge(str(src.name), str(builddep.package))
|
G_f.add_edge(str(src.name), str(builddep.package))
|
||||||
for pkg in x.packages:
|
for pkg in x.packages:
|
||||||
for rtdep in pkg.packageDependencies:
|
for rtdep in pkg.packageDependencies:
|
||||||
G_f.add_edge(str(src.name), pkgtosrc[rtdep.package])
|
tsrc = pkgtosrc[rtdep.package]
|
||||||
|
if not src.name == tsrc: # firefox - firefox-devel thing
|
||||||
|
G_f.add_edge(src.name, tsrc )
|
||||||
|
|
||||||
if ctx.config.get_option('debug'):
|
if ctx.config.get_option('debug'):
|
||||||
G_f.write_graphviz(sys.stdout)
|
G_f.write_graphviz(sys.stdout)
|
||||||
@@ -63,7 +69,10 @@ def plan_build(specfiles):
|
|||||||
order.reverse()
|
order.reverse()
|
||||||
return G_f, order
|
return G_f, order
|
||||||
|
|
||||||
G_f, order = plan_build(specfiles)
|
try:
|
||||||
|
G_f, order = plan_build(specfiles)
|
||||||
|
print order
|
||||||
|
except pisi.graph.CycleException, e:
|
||||||
|
print e
|
||||||
|
|
||||||
print order
|
|
||||||
pisi.api.finalize()
|
pisi.api.finalize()
|
||||||
|
|||||||
Reference in New Issue
Block a user