* unpack dir flat interface'i archivezip icin

* unicode sacmaligiyla ugras
* reduce default arg istiyor tabii
* bir takim ufak hatalar hala var
This commit is contained in:
Eray Özkural
2005-06-24 15:19:01 +00:00
parent 233c794672
commit 5ad2f1a2fe
5 changed files with 23 additions and 9 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ def main():
package_fn = args[0] package_fn = args[0]
try: try:
ui.info('* Installing ' + package_fn) ui.info('* Installing ' + package_fn + '\n')
pisi.install.install(package_fn) pisi.install.install(package_fn)
except pisi.install.InstallError, estr: except pisi.install.InstallError, estr:
print '*** An installation error has occured:' print '*** An installation error has occured:'
+3
View File
@@ -152,6 +152,9 @@ class ArchiveZip(ArchiveBase):
def unpack_dir(self, path, targetDir): def unpack_dir(self, path, targetDir):
self.unpack_file_cond(lambda f:util.subpath(path,f), targetDir) self.unpack_file_cond(lambda f:util.subpath(path,f), targetDir)
def unpack_dir_flat(self, path, targetDir):
self.unpack_file_cond(lambda f:util.subpath(path,f), targetDir, path)
def unpack(self, targetDir): def unpack(self, targetDir):
self.unpack_file_cond(lambda f: True, targetDir) self.unpack_file_cond(lambda f: True, targetDir)
self.close() self.close()
+8 -5
View File
@@ -26,7 +26,7 @@ def satisfiesInstallDeps(pkg):
deps = installDeps(pkg) deps = installDeps(pkg)
print 'installdeps = ', deps print 'installdeps = ', deps
return reduce(lambda x,y:x and y, return reduce(lambda x,y:x and y,
map(lambda x: satisfiesDep(pkg, x), deps)) map(lambda x: satisfiesDep(pkg, x), deps),True)
def runtimeDeps(pkg): def runtimeDeps(pkg):
return packagedb.get_package(pkg).runtimeDeps return packagedb.get_package(pkg).runtimeDeps
@@ -35,14 +35,17 @@ def satisfiesRuntimeDeps(pkg):
deps = runtimeDeps(pkg) deps = runtimeDeps(pkg)
print 'runtimedeps = ', deps print 'runtimedeps = ', deps
return reduce(lambda x,y:x and y, return reduce(lambda x,y:x and y,
map(lambda x: satisfiesDep(pkg, x), deps)) map(lambda x: satisfiesDep(pkg, x), deps),True)
def installable(pkg): def installable(pkg):
"""calculate if pkg is installable currently """calculate if pkg is installable currently
which means it has to satisfy both install and runtime dependencies""" which means it has to satisfy both install and runtime dependencies"""
if not packagedb.has_package(pkg): if not packagedb.has_package(pkg):
ui.info("package " + pkg + ui.info("package " + pkg + " is not present in the package database\n");
" is not installable due to lacking dependencies\n"); return False
elif not satisfiesRuntimeDeps(pkg) and satisfiesInstallDeps(pkg):
ui.info("package " + pkg + " does not satisfy dependencies\n");
return False return False
else: else:
return satisfiesRuntimeDeps(pkg) and satisfiesInstallDeps(pkg) return True
+2 -2
View File
@@ -25,7 +25,6 @@ def install(package_fn):
package = Package(package_fn, 'r') package = Package(package_fn, 'r')
# extract control files # extract control files
util.clean_dir(config.install_dir()) util.clean_dir(config.install_dir())
ui.info('extracting files\n')
package.extract_PISI_files(config.install_dir()) package.extract_PISI_files(config.install_dir())
# verify package # verify package
@@ -46,7 +45,8 @@ def install(package_fn):
raise InstallError("Package not installable") raise InstallError("Package not installable")
# unzip package in place # unzip package in place
package.extract_dir_flat(config.destdir) ui.info('Extracting files\n')
package.extract_dir_flat('install', config.destdir)
# update databases # update databases
+9 -1
View File
@@ -16,16 +16,19 @@ class InstallDBError(Exception):
pass pass
def files_name(pkg, version, release): def files_name(pkg, version, release):
return files_dir + '/' + pkg + '-' + version + '-' + release + '.xml' return str(files_dir + '/' + pkg + '-' + version + '-' + release + '.xml')
def files(pkg): def files(pkg):
pkg = str(pkg)
(status, version, release) = d[pkg] (status, version, release) = d[pkg]
return file(files_name(pkg,version,release)) return file(files_name(pkg,version,release))
def is_recorded(pkg): def is_recorded(pkg):
pkg = str(pkg)
return d.has_key(pkg) return d.has_key(pkg)
def is_installed(pkg): def is_installed(pkg):
pkg = str(pkg)
if is_recorded(pkg): if is_recorded(pkg):
(status, version, release) = d[pkg] (status, version, release) = d[pkg]
return status=='i' return status=='i'
@@ -33,10 +36,12 @@ def is_installed(pkg):
return False return False
def get_version(pkg): def get_version(pkg):
pkg = str(pkg)
(status, version, release) = d[pkg] (status, version, release) = d[pkg]
return (version, release) return (version, release)
def is_removed(pkg): def is_removed(pkg):
pkg = str(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'
@@ -45,16 +50,19 @@ def is_removed(pkg):
def install(pkg, version, release, files_xml): def install(pkg, version, release, files_xml):
"""install package with specific version and release""" """install package with specific version and release"""
pkg = str(pkg)
if is_installed(pkg): if is_installed(pkg):
raise InstallDBError("already installed") raise InstallDBError("already installed")
d[pkg] = ('i', version, release) d[pkg] = ('i', version, release)
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):
pkg = str(pkg)
(status, version, release) = d[pkg] (status, version, release) = d[pkg]
d[pkg] = ('r', version, release) d[pkg] = ('r', version, release)
def purge(pkg): def purge(pkg):
pkg = str(pkg)
if d.has_key(pkg): if d.has_key(pkg):
(status, version, release) = d[pkg] (status, version, release) = d[pkg]
f = files_name(pkg, version, release) f = files_name(pkg, version, release)