* package'a yeni interface ekle (icindekileri kabak gibi cikarmak icin)
* install iskeletini file size disinda tamamla (nasil yapilacagi belli degil. caglar?) * installdb ve testlerini duzelt, ufak tefek hatalar vardi ahem *
This commit is contained in:
+7
-1
@@ -36,11 +36,17 @@ def install_package_file(package_fn):
|
|||||||
|
|
||||||
# check conflicts
|
# check conflicts
|
||||||
# check dependencies
|
# check dependencies
|
||||||
|
if not dependency.installable(metadata.packages[0].name):
|
||||||
|
raise InstallError("Package not installable")
|
||||||
|
|
||||||
# unzip package in place
|
# unzip package in place
|
||||||
|
package.extract_dir_flat(ctx.destdir)
|
||||||
|
|
||||||
# update databases
|
# update databases
|
||||||
|
|
||||||
# installdb
|
# installdb
|
||||||
installdb.install(spec.spec.install_dir() + '/files.xml')
|
installdb.install(metadata.packages[0].name,
|
||||||
|
metadata.source.version,
|
||||||
|
metadata.source.release,
|
||||||
|
ctx.install_dir() + '/files.xml')
|
||||||
|
|
||||||
|
|||||||
+8
-5
@@ -10,6 +10,7 @@ import util
|
|||||||
|
|
||||||
util.check_dir(ctx.db_dir())
|
util.check_dir(ctx.db_dir())
|
||||||
d = shelve.open(ctx.db_dir() + '/install.bdb')
|
d = shelve.open(ctx.db_dir() + '/install.bdb')
|
||||||
|
print 'installdb:', ctx.db_dir() + '/install.bdb'
|
||||||
files_dir = ctx.archives_dir() + "/files"
|
files_dir = ctx.archives_dir() + "/files"
|
||||||
|
|
||||||
class InstallDBError(Exception):
|
class InstallDBError(Exception):
|
||||||
@@ -36,7 +37,7 @@ def get_version(pkg):
|
|||||||
(status, version, release) = d[pkg]
|
(status, version, release) = d[pkg]
|
||||||
return (version, release)
|
return (version, release)
|
||||||
|
|
||||||
def is_removed(name):
|
def is_removed(pkg):
|
||||||
if is_recorded(pkg):
|
if is_recorded(pkg):
|
||||||
(status, version, release) = d[pkg]
|
(status, version, release) = d[pkg]
|
||||||
return status=='r'
|
return status=='r'
|
||||||
@@ -51,11 +52,13 @@ def install(pkg, version, release, files_xml):
|
|||||||
util.copy_file(files_xml, files_name(pkg, version, release))
|
util.copy_file(files_xml, files_name(pkg, version, release))
|
||||||
|
|
||||||
def remove(pkg):
|
def remove(pkg):
|
||||||
d[pkg] = 'r'
|
(status, version, release) = d[pkg]
|
||||||
|
d[pkg] = ('r', version, release)
|
||||||
|
|
||||||
def purge(pkg):
|
def purge(pkg):
|
||||||
(status, version, release) = d[pkg]
|
if d.has_key(pkg):
|
||||||
os.unlink(files_name(pkg, version, release))
|
(status, version, release) = d[pkg]
|
||||||
del d[pkg]
|
os.unlink(files_name(pkg, version, release))
|
||||||
|
del d[pkg]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -20,7 +20,13 @@ class Package:
|
|||||||
"""extract file with path to outdir"""
|
"""extract file with path to outdir"""
|
||||||
|
|
||||||
def extract_dir(self, dir, outdir):
|
def extract_dir(self, dir, outdir):
|
||||||
"""extract directory recursively"""
|
"""extract directory recursively, this function
|
||||||
|
copies the directory archiveroot/dir to outdir"""
|
||||||
|
|
||||||
|
def extract_dir_flat(self, dir, outdir):
|
||||||
|
"""extract directory recursively, this function
|
||||||
|
unpacks the *contents* of directory archiveroot/dir inside outdir
|
||||||
|
this is the function used by the installer"""
|
||||||
|
|
||||||
def extract_PISI_files(self, outdir):
|
def extract_PISI_files(self, outdir):
|
||||||
"""extract PISI control files: metadata.xml, files.xml,
|
"""extract PISI control files: metadata.xml, files.xml,
|
||||||
|
|||||||
@@ -103,3 +103,8 @@ class MetaData(SpecFile):
|
|||||||
architecture = self.getNodeText("Source/Architecture")
|
architecture = self.getNodeText("Source/Architecture")
|
||||||
installSize = self.getNodeText("Source/InstallSize")
|
installSize = self.getNodeText("Source/InstallSize")
|
||||||
|
|
||||||
|
def verify():
|
||||||
|
if len(packages) != 1:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class InstallDBTestCase(unittest.TestCase):
|
|||||||
self.assert_(not installdb.is_installed('installtest'))
|
self.assert_(not installdb.is_installed('installtest'))
|
||||||
|
|
||||||
def testInstall(self):
|
def testInstall(self):
|
||||||
installdb.remove('installtest')
|
installdb.purge('installtest')
|
||||||
installdb.install('installtest', '0.1', '2', './tests/sandbox/files.xml')
|
installdb.install('installtest', '0.1', '2', './tests/sandbox/files.xml')
|
||||||
f = installdb.files('installtest')
|
f = installdb.files('installtest')
|
||||||
a = f.readlines()
|
a = f.readlines()
|
||||||
@@ -28,8 +28,8 @@ class InstallDBTestCase(unittest.TestCase):
|
|||||||
self.assert_(installdb.is_installed('installtest'))
|
self.assert_(installdb.is_installed('installtest'))
|
||||||
installdb.remove('installtest')
|
installdb.remove('installtest')
|
||||||
self.assert_(installdb.is_removed('installtest'))
|
self.assert_(installdb.is_removed('installtest'))
|
||||||
installdb.purge('installtest', '0.1', '2')
|
installdb.purge('installtest')
|
||||||
self.assert_(not installdb.is_recorded('installtest'))
|
self.assert_(not installdb.is_recorded('installtest'))
|
||||||
self.assert_(not os.access(installdb.files_name('installtest'), os.F_OK))
|
self.assert_(not os.access(installdb.files_name('installtest', '0.1','2'), os.F_OK))
|
||||||
|
|
||||||
suite = unittest.makeSuite(InstallDBTestCase)
|
suite = unittest.makeSuite(InstallDBTestCase)
|
||||||
|
|||||||
Reference in New Issue
Block a user