diff --git a/pisi/install.py b/pisi/install.py index 7b7f8ee9..5b3ecc01 100644 --- a/pisi/install.py +++ b/pisi/install.py @@ -33,14 +33,20 @@ def install_package_file(package_fn): # check file system requirements # what to do if / is split into /usr, /var, etc.? - + # check conflicts # check dependencies + if not dependency.installable(metadata.packages[0].name): + raise InstallError("Package not installable") # unzip package in place + package.extract_dir_flat(ctx.destdir) # update databases # 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') diff --git a/pisi/installdb.py b/pisi/installdb.py index d198efcb..71d47c07 100644 --- a/pisi/installdb.py +++ b/pisi/installdb.py @@ -10,6 +10,7 @@ import util util.check_dir(ctx.db_dir()) d = shelve.open(ctx.db_dir() + '/install.bdb') +print 'installdb:', ctx.db_dir() + '/install.bdb' files_dir = ctx.archives_dir() + "/files" class InstallDBError(Exception): @@ -36,7 +37,7 @@ def get_version(pkg): (status, version, release) = d[pkg] return (version, release) -def is_removed(name): +def is_removed(pkg): if is_recorded(pkg): (status, version, release) = d[pkg] return status=='r' @@ -51,11 +52,13 @@ def install(pkg, version, release, files_xml): util.copy_file(files_xml, files_name(pkg, version, release)) def remove(pkg): - d[pkg] = 'r' + (status, version, release) = d[pkg] + d[pkg] = ('r', version, release) def purge(pkg): - (status, version, release) = d[pkg] - os.unlink(files_name(pkg, version, release)) - del d[pkg] + if d.has_key(pkg): + (status, version, release) = d[pkg] + os.unlink(files_name(pkg, version, release)) + del d[pkg] diff --git a/pisi/package.py b/pisi/package.py index 73e1e9a5..a04656b6 100644 --- a/pisi/package.py +++ b/pisi/package.py @@ -20,8 +20,14 @@ class Package: """extract file with path to 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): """extract PISI control files: metadata.xml, files.xml, action scripts, etc.""" diff --git a/pisi/specfile.py b/pisi/specfile.py index 93cd558d..726e0d1d 100644 --- a/pisi/specfile.py +++ b/pisi/specfile.py @@ -103,3 +103,8 @@ class MetaData(SpecFile): architecture = self.getNodeText("Source/Architecture") installSize = self.getNodeText("Source/InstallSize") + def verify(): + if len(packages) != 1: + return False + return True + diff --git a/tests/installdbtests.py b/tests/installdbtests.py index dca8a756..1ff3f13d 100644 --- a/tests/installdbtests.py +++ b/tests/installdbtests.py @@ -16,7 +16,7 @@ class InstallDBTestCase(unittest.TestCase): self.assert_(not installdb.is_installed('installtest')) def testInstall(self): - installdb.remove('installtest') + installdb.purge('installtest') installdb.install('installtest', '0.1', '2', './tests/sandbox/files.xml') f = installdb.files('installtest') a = f.readlines() @@ -28,8 +28,8 @@ class InstallDBTestCase(unittest.TestCase): self.assert_(installdb.is_installed('installtest')) installdb.remove('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 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)