* compute cycle for CycleException

* fix: build order thing: skip self arcs
* comment
This commit is contained in:
Eray Özkural
2005-12-14 21:39:07 +00:00
parent 425fb1482d
commit c466637af2
4 changed files with 44 additions and 19 deletions
+12 -4
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-3.8.dtd">
<!-- 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, -->
<Project version="3.8">
<ProgLanguage mixed="0">Python</ProgLanguage>
@@ -9,7 +9,7 @@
<Description>The package management software of Pardus distribution.
</Description>
<Author>PiSi Development Team</Author>
<Email></Email>
<EmaIl></EmaIl>
<Sources>
<Source>
<Dir>tools</Dir>
@@ -466,6 +466,14 @@
<Dir>pisi</Dir>
<Name>dbshelve.py</Name>
</Source>
<Source>
<Dir>tools</Dir>
<Name>calc-build-order.py</Name>
</Source>
<Source>
<Dir>tools</Dir>
<Name>repo-dep-resolver.py</Name>
</Source>
</Sources>
<Forms>
</Forms>
@@ -507,10 +515,10 @@
<VcsOtherData>{'standardLayout': 1}</VcsOtherData>
</Vcs>
<FiletypeAssociations>
<FiletypeAssociation pattern="*.py" type="SOURCES" />
<FiletypeAssociation pattern="*.ui.h" type="FORMS" />
<FiletypeAssociation pattern="*.idl" type="INTERFACES" />
<FiletypeAssociation pattern="*.ui" type="FORMS" />
<FiletypeAssociation pattern="*.idl" type="INTERFACES" />
<FiletypeAssociation pattern="*.py" type="SOURCES" />
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
</FiletypeAssociations>
</Project>
+15 -7
View File
@@ -12,18 +12,21 @@
# the most simple minded digraph class ever
# for python 2.3 compatibility
import sys
ver = sys.version_info
if ver[0] <= 2 and ver[1] < 4:
from sets import Set as set
import pisi
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
# not an error!
class CycleException(pisi.Exception):
pass
def __init__(self, cycle):
self.cycle = cycle
def __str__(self):
return _('encountered cycle %s') % self.cycle
class Digraph(object):
@@ -115,7 +118,12 @@ class Digraph(object):
self.p[v] = u
self.dfs_visit(v, finish_hook)
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)
if finish_hook:
finish_hook(u)
+1 -1
View File
@@ -75,7 +75,7 @@ setup(name="pisi",
# the below stuff is really nice but we already have a version
# 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__
+16 -7
View File
@@ -6,6 +6,10 @@ import sys
import os
sys.path.insert(0, '.')
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi.context as ctx
#ctx.usemdom = True
import pisi
@@ -13,7 +17,7 @@ import pisi.api
import pisi.config
import pisi.specfile as specfile
import pisi.util
from pisi.graph import Digraph
import pisi.graph
options = pisi.config.Options()
if len(sys.argv) > 2:
@@ -25,6 +29,7 @@ repo_uri = sys.argv[1]
specfiles = []
print "reading pspecfiles, just a moment"
for root, dirs, files in os.walk(repo_uri):
for fn in files:
if fn == 'pspec.xml':
@@ -32,14 +37,14 @@ for root, dirs, files in os.walk(repo_uri):
sf = specfile.SpecFile()
sf.read(pisi.util.join_path(root, fn))
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)
def plan_build(specfiles):
# try to construct a pisi graph of packages to
# install / reinstall
G_f = Digraph()
G_f = pisi.graph.Digraph()
pkgtosrc = {}
for sf in specfiles:
for pkg in sf.packages:
@@ -48,14 +53,15 @@ def plan_build(specfiles):
for x in specfiles:
#G_f.add_package(x)
src = x.source
print "adding vtx ", str(src.name)
if not str(src.name) in G_f.vertices():
G_f.add_vertex(str(src.name), (src.version, src.release))
for builddep in src.buildDependencies:
G_f.add_edge(str(src.name), str(builddep.package))
for pkg in x.packages:
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'):
G_f.write_graphviz(sys.stdout)
@@ -63,7 +69,10 @@ def plan_build(specfiles):
order.reverse()
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()