* pgraph: herhangi bir packagedb interface'ine sahip database'le calis
* fix: #366, bagimlilik cizgesini install_pkg_files icinde hesapla * beta-upgrade'de de repo1 adli repo'yu kullan, daha once INVALID olarak isaretledigim bug'i da cozer boylece, arada elle komut girmek gerekmez. * asagida dosyalarin siralanmasi isi gosteriliyor nebula:pisi$ pisi-cli list-repo nebula:pisi$ pisi-cli --yes-all --ignore-comar remove unzip ['unzip'] processing unzip checking zip processing zip digraph G { unzip[ unzip(5.50,1) ]; zip[ zip(2.3,1) ]; zip -- unzip; } ['zip', 'unzip'] Removing package zip. Removing package unzip. nebula:pisi$ pisi-cli --yes-all --ignore-comar install zip-2.3-1.pisi unzip-5.50-1.pisi A = ['zip-2.3-1.pisi', 'unzip-5.50-1.pisi'] ['unzip', 'zip'] Name: unzip Summary: Unzipper for pkzip-compressed files Description: Unzipper for pkzip-compressed files Name: zip Summary: Info ZIP (encryption support) Description: Info ZIP (encryption support) checking unzip digraph G { unzip[ unzip(5.50,1) ]; zip[ zip(2.3,1) ]; zip -- unzip; } ['unzip', 'zip'] Installing unzip, version 5.50, release 1, build 0 Extracting files, Storing files.xml, metadata.xml. Installing zip, version 2.3, release 1, build 0 Extracting files, Storing files.xml, metadata.xml.
This commit is contained in:
+11
-12
@@ -10,29 +10,28 @@
|
||||
|
||||
# PISI package relation graph that represents the state of packagedb
|
||||
|
||||
import packagedb
|
||||
from sourcedb import sourcedb
|
||||
from graph import *
|
||||
|
||||
# Cache the results from packagedb queries in a graph
|
||||
|
||||
class PGraph(digraph):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, packagedb):
|
||||
super(PGraph, self).__init__()
|
||||
self.packagedb = packagedb
|
||||
|
||||
def add_package(self, pkg):
|
||||
pkg1 = packagedb.get_package(pkg)
|
||||
pkg1 = self.packagedb.get_package(pkg)
|
||||
self.add_vertex(str(pkg), (pkg1.version, pkg1.release))
|
||||
|
||||
def add_plain_dep(self, pkg1name, pkg2name):
|
||||
pkg1data = None
|
||||
if not pkg1name in self.vertices():
|
||||
pkg1 = packagedb.get_package(pkg1name)
|
||||
pkg1 = self.packagedb.get_package(pkg1name)
|
||||
pkg1data = (pkg1.version, pkg1.release)
|
||||
pkg2data = None
|
||||
if not pkg2name in self.vertices():
|
||||
pkg2 = packagedb.get_package(pkg2name)
|
||||
pkg2 = self.packagedb.get_package(pkg2name)
|
||||
pkg2data = (pkg2.version, pkg2.release)
|
||||
self.add_edge(str(pkg1name), str(pkg2name), ('d', None),
|
||||
pkg1data, pkg2data )
|
||||
@@ -40,11 +39,11 @@ class PGraph(digraph):
|
||||
def add_dep(self, pkg, depinfo):
|
||||
pkg1data = None
|
||||
if not pkg in self.vertices():
|
||||
pkg1 = packagedb.get_package(pkg)
|
||||
pkg1 = self.packagedb.get_package(pkg)
|
||||
pkg1data = (pkg1.version, pkg1.release)
|
||||
pkg2data = None
|
||||
if not depinfo.package in self.vertices():
|
||||
pkg2 = packagedb.get_package(depinfo.package)
|
||||
pkg2 = self.packagedb.get_package(depinfo.package)
|
||||
pkg2data = (pkg2.version, pkg2.release)
|
||||
self.add_edge(str(pkg), str(depinfo.package), ('d', depinfo),
|
||||
pkg1data, pkg2data )
|
||||
@@ -52,11 +51,11 @@ class PGraph(digraph):
|
||||
def add_rev_dep(self, depinfo, pkg):
|
||||
pkg1data = None
|
||||
if not pkg in self.vertices():
|
||||
pkg1 = packagedb.get_package(depinfo.package)
|
||||
pkg1 = self.packagedb.get_package(depinfo.package)
|
||||
pkg1data = (pkg1.version, pkg1.release)
|
||||
pkg2data = None
|
||||
if not depinfo.package in self.vertices():
|
||||
pkg2 = packagedb.get_package(pkg)
|
||||
pkg2 = self.packagedb.get_package(pkg)
|
||||
pkg2data = (pkg2.version, pkg2.release)
|
||||
self.add_edge(str(depinfo.package), str(pkg), ('d', depinfo),
|
||||
pkg1data, pkg2data )
|
||||
@@ -64,11 +63,11 @@ class PGraph(digraph):
|
||||
def add_conflict(self, pkg, conflinfo):
|
||||
pkg1data = None
|
||||
if not pkg in self.vertices():
|
||||
pkg1 = packagedb.get_package(pkg)
|
||||
pkg1 = self.packagedb.get_package(pkg)
|
||||
pkg1data = (pkg1.version, pkg1.release)
|
||||
pkg2data = None
|
||||
if not pkg in self.vertices():
|
||||
pkg2 = packagedb.get_package(conflinfo.package)
|
||||
pkg2 = self.packagedb.get_package(conflinfo.package)
|
||||
pkg2data = (pkg2.version, pkg2.release)
|
||||
|
||||
self.add_biedge(str(pkg), str(conflinfo.package), ('c', conflinfo)
|
||||
|
||||
+63
-10
@@ -30,6 +30,9 @@ from pisi.repodb import repodb
|
||||
from pisi.installdb import installdb
|
||||
from pisi.index import Index
|
||||
|
||||
class Error:
|
||||
pass
|
||||
|
||||
def install(packages):
|
||||
"""install a list of packages (either files/urls, or names)"""
|
||||
|
||||
@@ -56,13 +59,13 @@ def install(packages):
|
||||
# ui.error("Error: %s\n" % e)
|
||||
|
||||
|
||||
def install_pkg_files(packages):
|
||||
def install_pkg_files(package_URIs):
|
||||
"""install a number of pisi package files"""
|
||||
from package import Package
|
||||
|
||||
ui.debug('A = %s\n' % str(packages))
|
||||
ui.debug('A = %s\n' % str(package_URIs))
|
||||
|
||||
for x in packages:
|
||||
for x in package_URIs:
|
||||
if not x.endswith(const.package_prefix):
|
||||
ui.error('Mixing file names and package names not supported YET.\n')
|
||||
return False
|
||||
@@ -70,10 +73,13 @@ def install_pkg_files(packages):
|
||||
# read the package information into memory first
|
||||
# regardless of which distribution they come from
|
||||
d_t = {}
|
||||
for x in packages:
|
||||
dfn = {}
|
||||
for x in package_URIs:
|
||||
package = Package(x)
|
||||
package.read()
|
||||
d_t[package.metadata.package.name] = package.metadata.package
|
||||
name = str(package.metadata.package.name)
|
||||
d_t[name] = package.metadata.package
|
||||
dfn[name] = x
|
||||
|
||||
def satisfiesDep(dep):
|
||||
return dependency.installedSatisfiesDep(dep) \
|
||||
@@ -99,8 +105,55 @@ def install_pkg_files(packages):
|
||||
(not extra_packages):
|
||||
#FIXME: Construct a dependency graph for files
|
||||
# and install in rev. topological order
|
||||
for x in packages:
|
||||
operations.install_single_file(x)
|
||||
|
||||
class PackageDB:
|
||||
def __init__(self):
|
||||
self.d = d_t
|
||||
|
||||
def get_package(self, key):
|
||||
return d_t[str(key)]
|
||||
|
||||
packagedb = PackageDB()
|
||||
|
||||
A = d_t.keys()
|
||||
|
||||
if len(A)==0:
|
||||
ui.info('No packages to install.\n')
|
||||
return True
|
||||
|
||||
# try to construct a pisi graph of packages to
|
||||
# install / reinstall
|
||||
|
||||
G_f = pgraph.PGraph(packagedb) # construct G_f
|
||||
|
||||
# find the "install closure" graph of G_f by package
|
||||
# set A using packagedb
|
||||
print A
|
||||
for x in A:
|
||||
G_f.add_package(x)
|
||||
B = A
|
||||
#state = {}
|
||||
while len(B) > 0:
|
||||
Bp = set()
|
||||
for x in B:
|
||||
pkg = packagedb.get_package(x)
|
||||
print pkg
|
||||
for dep in pkg.runtimeDeps:
|
||||
print 'checking ', dep
|
||||
if dependency.dictSatisfiesDep(d_t, dep):
|
||||
if not dep.package in G_f.vertices():
|
||||
Bp.add(str(dep.package))
|
||||
G_f.add_dep(x, dep)
|
||||
B = Bp
|
||||
G_f.write_graphviz(sys.stdout)
|
||||
order = G_f.topological_sort()
|
||||
order.reverse()
|
||||
print order
|
||||
|
||||
for x in order:
|
||||
operations.install_single_file(dfn[x])
|
||||
else:
|
||||
raise Error('External dependencies not satisfied')
|
||||
|
||||
return True # everything went OK.
|
||||
|
||||
@@ -118,7 +171,7 @@ def install_pkg_names(A):
|
||||
# try to construct a pisi graph of packages to
|
||||
# install / reinstall
|
||||
|
||||
G_f = pgraph.PGraph() # construct G_f
|
||||
G_f = pgraph.PGraph(packagedb) # construct G_f
|
||||
|
||||
# find the "install closure" graph of G_f by package
|
||||
# set A using packagedb
|
||||
@@ -187,7 +240,7 @@ def upgrade_pkg_names(A):
|
||||
# try to construct a pisi graph of packages to
|
||||
# install / reinstall
|
||||
|
||||
G_f = pgraph.PGraph() # construct G_f
|
||||
G_f = pgraph.PGraph(packagedb) # construct G_f
|
||||
|
||||
# find the "install closure" graph of G_f by package
|
||||
# set A using packagedb
|
||||
@@ -243,7 +296,7 @@ def remove(A):
|
||||
# try to construct a pisi graph of packages to
|
||||
# install / reinstall
|
||||
|
||||
G_f = pgraph.PGraph() # construct G_f
|
||||
G_f = pgraph.PGraph(packagedb) # construct G_f
|
||||
|
||||
# find the "install closure" graph of G_f by package
|
||||
# set A using packagedb
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
pwd
|
||||
PATH=$PATH:.
|
||||
set -x -e
|
||||
pisi-cli --ignore-comar remove unzip
|
||||
pisi-cli build tests/zip/pspec.xml tests/unzip/pspec.xml
|
||||
pisi-cli index .
|
||||
pisi-cli add-repo repo1 pisi-index.xml
|
||||
|
||||
@@ -12,10 +12,10 @@ cd myrepo
|
||||
../pisi-cli build ../tests/zip2/pspec.xml ../tests/unzip2/pspec.xml
|
||||
cd ..
|
||||
pisi-cli index myrepo
|
||||
pisi-cli remove-repo myrepo
|
||||
pisi-cli add-repo myrepo pisi-index.xml
|
||||
pisi-cli remove-repo repo1
|
||||
pisi-cli add-repo repo1 pisi-index.xml
|
||||
pisi-cli list-repo
|
||||
pisi-cli update-repo myrepo
|
||||
pisi-cli update-repo repo1
|
||||
pisi-cli list-available
|
||||
pisi-cli --ignore-comar upgrade zip
|
||||
pisi-cli list-installed
|
||||
|
||||
Reference in New Issue
Block a user