repo build order calculator, you have to disable cdom impl to make this work fast atm
This commit is contained in:
+4
-2
@@ -145,8 +145,10 @@ class ArchiveZip(ArchiveBase):
|
|||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
||||||
def unpack_file_cond(self, pred, target_dir, archive_root = ''):
|
def unpack_file_cond(self, pred, target_dir, archive_root = ''):
|
||||||
"""Unpack/Extract a file according to predicate function filename ->
|
"""Unpack/Extract files according to predicate function
|
||||||
bool"""
|
pred: filename -> bool
|
||||||
|
unpacks stuff into target_dir and only extracts files
|
||||||
|
from archive_root, treating it as the archive root"""
|
||||||
zip_obj = self.zip_obj
|
zip_obj = self.zip_obj
|
||||||
for info in zip_obj.infolist():
|
for info in zip_obj.infolist():
|
||||||
if pred(info.filename): # check if condition holds
|
if pred(info.filename): # check if condition holds
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ const = pisi.constants.Constants()
|
|||||||
|
|
||||||
config = None
|
config = None
|
||||||
|
|
||||||
|
use_mdom = False
|
||||||
|
|
||||||
def get_option(opt):
|
def get_option(opt):
|
||||||
return config and config.get_option(opt)
|
return config and config.get_option(opt)
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -16,9 +16,12 @@ try:
|
|||||||
from xmlextpiks import *
|
from xmlextpiks import *
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
|
gibidi
|
||||||
|
if pisi.context.use_mdom:
|
||||||
|
raise Error('zibidi')
|
||||||
from xmlextcdom import *
|
from xmlextcdom import *
|
||||||
except:
|
except:
|
||||||
raise Error('cannot find 4suite implementation')
|
#raise Error('cannot find 4suite implementation')
|
||||||
print 'xmlext: cDomlette/piksemel implementation cannot be loaded, falling back to minidom'
|
print 'xmlext: cDomlette/piksemel implementation cannot be loaded, falling back to minidom'
|
||||||
from xmlextmdom import *
|
from xmlextmdom import *
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,20 @@
|
|||||||
#
|
#
|
||||||
# Authors: Eray Ozkural <eray@uludag.org.tr>
|
# Authors: Eray Ozkural <eray@uludag.org.tr>
|
||||||
|
|
||||||
|
import pisi.context
|
||||||
|
|
||||||
try:
|
try:
|
||||||
horagata # comment out to disable piks
|
horagata # comment out to disable piks
|
||||||
#from xmlfilepiks import *
|
#from xmlfilepiks import *
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
|
zibidi
|
||||||
|
if pisi.context.use_mdom:
|
||||||
|
raise Error('zibidi')
|
||||||
from xmlfilecdom import *
|
from xmlfilecdom import *
|
||||||
except:
|
except:
|
||||||
raise Error('cannot find 4suite implementation')
|
#raise Error('cannot find 4suite implementation')
|
||||||
print 'xmlext: cDomlette/piksemel implementation cannot be loaded, falling back to minidom'
|
print 'xmlext: cDomlette/piksemel implementation cannot be loaded, falling back to minidom'
|
||||||
from xmlfilemdom import *
|
from xmlfilemdom import *
|
||||||
|
|
||||||
|
print 'gumburdop'
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import codecs
|
|||||||
|
|
||||||
import pisi
|
import pisi
|
||||||
from pisi.pxml.xmlextcdom import *
|
from pisi.pxml.xmlextcdom import *
|
||||||
|
from pisi.file import File
|
||||||
|
|
||||||
class Error(pisi.Error):
|
class Error(pisi.Error):
|
||||||
"named this way because the class if mostly used with an import *"
|
"named this way because the class if mostly used with an import *"
|
||||||
@@ -59,9 +60,12 @@ class XmlFile(object):
|
|||||||
"""returns root document element"""
|
"""returns root document element"""
|
||||||
return self.doc.documentElement
|
return self.doc.documentElement
|
||||||
|
|
||||||
def readxml(self, fileName):
|
def readxml(self, uri, tmpDir = '/tmp'):
|
||||||
|
uri = File.make_uri(uri)
|
||||||
|
localpath = File.download(uri, tmpDir)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.doc = mdom.parse(fileName)
|
self.doc = mdom.parse(localpath)
|
||||||
except ExpatError, inst:
|
except ExpatError, inst:
|
||||||
raise Error(_("File '%s' has invalid XML: %s\n") % (fileName,
|
raise Error(_("File '%s' has invalid XML: %s\n") % (fileName,
|
||||||
str(inst)))
|
str(inst)))
|
||||||
|
|||||||
Executable
+79
@@ -0,0 +1,79 @@
|
|||||||
|
#! /usr/bin/python
|
||||||
|
# a simple tool to list stuff in source repository
|
||||||
|
# author: exa
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
sys.path.insert(0, '.')
|
||||||
|
|
||||||
|
import pisi.context as ctx
|
||||||
|
ctx.usemdom = True
|
||||||
|
print 'hobarey'
|
||||||
|
import pisi
|
||||||
|
import pisi.api
|
||||||
|
import pisi.config
|
||||||
|
import pisi.specfile as specfile
|
||||||
|
import pisi.util
|
||||||
|
from pisi.graph import Digraph
|
||||||
|
|
||||||
|
options = pisi.config.Options()
|
||||||
|
if len(sys.argv) > 2:
|
||||||
|
options.destdir=sys.argv[2]
|
||||||
|
else:
|
||||||
|
options.destdir = '/'
|
||||||
|
pisi.api.init(database=False, options=options)
|
||||||
|
repo_uri = sys.argv[1]
|
||||||
|
|
||||||
|
specfiles = []
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(repo_uri):
|
||||||
|
for fn in files:
|
||||||
|
if fn == 'pspec.xml':
|
||||||
|
#ctx.ui.info(_('Adding %s to package index') % fn)
|
||||||
|
sf = specfile.SpecFile()
|
||||||
|
sf.read(pisi.util.join_path(root, fn))
|
||||||
|
sf.check()
|
||||||
|
print 'read %s: %s' % (sf.source.name, sf.source.version)
|
||||||
|
|
||||||
|
specfiles.append(sf)
|
||||||
|
|
||||||
|
#print specfiles
|
||||||
|
|
||||||
|
def plan_build(specfiles):
|
||||||
|
# try to construct a pisi graph of packages to
|
||||||
|
# install / reinstall
|
||||||
|
|
||||||
|
G_f = Digraph()
|
||||||
|
#pgraph.PGraph(packagedb) # construct G_f
|
||||||
|
|
||||||
|
pkgtosrc = {}
|
||||||
|
|
||||||
|
for sf in specfiles:
|
||||||
|
for pkg in sf.packages:
|
||||||
|
pkgtosrc[str(pkg.name)] = str(sf.source.name)
|
||||||
|
|
||||||
|
# find the "install closure" graph of G_f by package
|
||||||
|
# set A using packagedb
|
||||||
|
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])
|
||||||
|
|
||||||
|
if ctx.config.get_option('debug'):
|
||||||
|
G_f.write_graphviz(sys.stdout)
|
||||||
|
order = G_f.topological_sort()
|
||||||
|
order.reverse()
|
||||||
|
return G_f, order
|
||||||
|
|
||||||
|
G_f, order = plan_build(specfiles)
|
||||||
|
|
||||||
|
print order
|
||||||
|
pisi.api.finalize()
|
||||||
@@ -27,6 +27,6 @@ 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 '%s: %s' % (sf.source.name, sf.source.version)
|
print 'read %s: %s' % (sf.source.name, sf.source.version)
|
||||||
|
|
||||||
pisi.api.finalize()
|
pisi.api.finalize()
|
||||||
|
|||||||
Reference in New Issue
Block a user