* fix: packagedb: remove reverse dependencies correctly when removing a package

* fix: info command sets repository correctly to packagedb
* fix: use -mx=9 options for pylzma, implement that by passing keyword args down to pylzma. 64mb dictionary size 64 fastBytes BT4, we can't implement the wonderful BCJ2
This commit is contained in:
Eray Özkural
2006-05-11 15:06:09 +00:00
parent 77b3690450
commit b1a6893d7f
5 changed files with 39 additions and 38 deletions
+2 -6
View File
@@ -258,13 +258,11 @@ def info_file(package_fn):
def info_name(package_name, installed=False): def info_name(package_name, installed=False):
"""fetch package information for a package""" """fetch package information for a package"""
if ctx.packagedb.has_package(package_name, pisi.itembyrepodb.all):
if installed: if installed:
package = ctx.packagedb.get_package(package_name, pisi.itembyrepodb.installed) package = ctx.packagedb.get_package(package_name, pisi.itembyrepodb.installed)
else: else:
package, repo = ctx.packagedb.get_package_repo(package_name) package, repo = ctx.packagedb.get_package_repo(package_name, pisi.itembyrepodb.repos)
if repo==pisi.itembyrepodb.installed: repostr = repo
raise Error(_('Package %s not found') % package_name)
from pisi.metadata import MetaData from pisi.metadata import MetaData
metadata = MetaData() metadata = MetaData()
@@ -281,8 +279,6 @@ def info_name(package_name, installed=False):
else: else:
files = None files = None
return metadata, files return metadata, files
else:
raise Error(_('Package %s not found') % package_name)
def search_package_names(query): def search_package_names(query):
r = set() r = set()
+4 -1
View File
@@ -134,7 +134,10 @@ class ArchiveZip(ArchiveBase):
else: else:
method = ctx.get_option('compression_method') method = ctx.get_option('compression_method')
if not method: if not method:
self.zip_obj.write(file_name, arc_name, zipfileext.ZIP_LZMA_BOGUS) method = 'lzma'
if method == 'lzma':
self.zip_obj.write(file_name, arc_name, zipfileext.ZIP_LZMA_BOGUS,
dictionary = 26, fastBytes = 64)
else: else:
self.zip_obj.write(file_name, arc_name, self.comp_method[method]) self.zip_obj.write(file_name, arc_name, self.comp_method[method])
+6 -4
View File
@@ -675,7 +675,7 @@ Usage: info <package1> <package2> ... <packagen>
ctx.ui.info(_('[inst] '), noln=True) ctx.ui.info(_('[inst] '), noln=True)
else: else:
ctx.ui.info(_('Installed package:')) ctx.ui.info(_('Installed package:'))
self.print_pkginfo(metadata, files) self.print_pkginfo(metadata, files,pisi.itembyrepodb.installed)
if ctx.packagedb.has_package(arg): if ctx.packagedb.has_package(arg):
metadata, files = pisi.api.info_name(arg, False) metadata, files = pisi.api.info_name(arg, False)
@@ -683,9 +683,9 @@ Usage: info <package1> <package2> ... <packagen>
ctx.ui.info(_('[repo] '), noln=True) ctx.ui.info(_('[repo] '), noln=True)
else: else:
ctx.ui.info(_('Package found in repository:')) ctx.ui.info(_('Package found in repository:'))
self.print_pkginfo(metadata, files) self.print_pkginfo(metadata, files, pisi.itembyrepodb.repos)
def print_pkginfo(self, metadata, files): def print_pkginfo(self, metadata, files, repo = None):
import os.path import os.path
if not ctx.get_option('long'): if not ctx.get_option('long'):
@@ -693,7 +693,9 @@ Usage: info <package1> <package2> ... <packagen>
ctx.ui.info('%15s - %s' % (pkg.name, unicode(pkg.summary))) ctx.ui.info('%15s - %s' % (pkg.name, unicode(pkg.summary)))
else: else:
ctx.ui.info(unicode(metadata.package)) ctx.ui.info(unicode(metadata.package))
revdeps = [x[0] for x in ctx.packagedb.get_rev_deps(metadata.package.name)] if repo:
revdeps = [x[0] for x in
ctx.packagedb.get_rev_deps(metadata.package.name, repo)]
print _('Reverse Dependencies:'), util.strlist(revdeps) print _('Reverse Dependencies:'), util.strlist(revdeps)
if self.options.files or self.options.files_path: if self.options.files or self.options.files_path:
if files: if files:
+6 -1
View File
@@ -117,8 +117,13 @@ class PackageDB(object):
def proc(txn): def proc(txn):
package_info = self.d.get_item(name, repo, txn=txn) package_info = self.d.get_item(name, repo, txn=txn)
self.d.remove_item(name, repo, txn=txn) self.d.remove_item(name, repo, txn=txn)
for dep in package_info.runtimeDependencies():
dep_name = str(dep.package)
if self.dr.has_key(dep_name, repo, txn):
revdep = self.dr.get_item(dep_name, repo, txn)
revdep = filter(lambda (n,d):n!=name, revdep)
self.dr.add_item(dep_name, revdep, repo, txn)
if self.dr.has_key(name, repo, txn=txn): if self.dr.has_key(name, repo, txn=txn):
self.dr.remove_item(name, repo, txn=txn) self.dr.remove_item(name, repo, txn=txn)
ctx.componentdb.remove_package(package_info.partOf, package_info.name, repo, txn) ctx.componentdb.remove_package(package_info.partOf, package_info.name, repo, txn)
self.d.txn_proc(proc, txn) self.d.txn_proc(proc, txn)
+2 -7
View File
@@ -192,7 +192,7 @@ class ZipFileExt(ZipFile):
raise RuntimeError, \ raise RuntimeError, \
"Compression requires the (missing) pylzma module" "Compression requires the (missing) pylzma module"
def write(self, filename, arcname=None, compress_type=None): def write(self, filename, arcname=None, compress_type=None, **kwargs):
"""Put the bytes from filename into the archive under the name """Put the bytes from filename into the archive under the name
arcname.""" arcname."""
st = os.stat(filename) st = os.stat(filename)
@@ -253,7 +253,7 @@ class ZipFileExt(ZipFile):
buf = fp.read() buf = fp.read()
file_size = len(buf) file_size = len(buf)
CRC = binascii.crc32(buf, CRC) CRC = binascii.crc32(buf, CRC)
compressed = pylzma.compress(buf, eos=1) compressed = pylzma.compress(buf, **kwargs)
self.fp.write(compressed) self.fp.write(compressed)
zinfo.compress_size = len(compressed) zinfo.compress_size = len(compressed)
@@ -284,11 +284,6 @@ class ZipFileExt(ZipFile):
raise RuntimeError, \ raise RuntimeError, \
"De-compression requires the (missing) zlib module" "De-compression requires the (missing) zlib module"
return DeflatedZipFileEntry(self.fp, zinfo.compress_size) return DeflatedZipFileEntry(self.fp, zinfo.compress_size)
## elif zinfo.compress_type == ZIP_BZIP2:
## if not bzip2:
## raise RuntimeError, \
## "De-compression requires the (missing) bzip2 module"
## return LZMAFileEntry(self.fp, zinfo.compress_size)
elif zinfo.compress_type == ZIP_LZMA_BOGUS: elif zinfo.compress_type == ZIP_LZMA_BOGUS:
if not pylzma: if not pylzma:
raise RuntimeError, \ raise RuntimeError, \