backend/spacewalk/common/rhn_rpm.py | 94 +++---------------------------------
1 file changed, 8 insertions(+), 86 deletions(-)
New commits:
commit 24cc5c97c2441d823d82f096948f1c8325be6166
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Feb 24 10:29:55 2011 +0100
RPMTransaction is dead after RPMReadOnlyTransaction removal
diff --git a/backend/spacewalk/common/rhn_rpm.py b/backend/spacewalk/common/rhn_rpm.py
index a749795..ed602fe 100644
--- a/backend/spacewalk/common/rhn_rpm.py
+++ b/backend/spacewalk/common/rhn_rpm.py
@@ -55,58 +55,6 @@ PGPHASHALGO = {
class InvalidPackageError(Exception):
pass
-class RPMTransaction:
- """ wrapper/proxy class for rpm.Transaction so we can instrument it, etc easily """
- read_only = 0
- def __init__(self):
- self.ts = rpm.TransactionSet()
- self.tsflags = []
-
- def getMethod(self, method):
- # in theory, we can override this with
- # profile/etc info
- return getattr(self.ts, method)
-
- def pushVSFlags(self, flags):
- """ push method, so we don't lose the previous set value, and we can potentially debug a bit easier """
- self.tsflags.append(flags)
- self.ts.setVSFlags(self.tsflags[-1])
-
- def popVSFlags(self):
- """ pop method, so we don't lose the previous set value, and we can potentially debug a bit easier """
- del self.tsflags[-1]
- self.ts.setVSFlags(self.tsflags[-1])
-
- def addInstall(self, arg1, arg2, mode):
- """Install a package"""
- hdr = arg1.hdr
- return self.ts.addInstall(hdr, arg2, mode)
-
- def addErase(self, arg1):
- """Erase a package"""
- hdr = arg1.hdr
- return self.ts.addErase(hdr)
-
- def check(self):
- """Check dependencies"""
- return self.ts.check()
-
- def setFlags(self, flag):
- """Set transaction flags"""
- return self.ts.setFlags(flag)
-
- def setProbFilter(self, flag):
- """Set problem flags"""
- return self.ts.setProbFilter(flag)
-
- def run(self, callback, user_data):
- return self.ts.run(callback, user_data)
-
- def hdrFromFdno(self, fd):
- return self.ts.hdrFromFdno(fd)
-
-
-
class RPM_Header:
"Wrapper class for an rpm header - we need to store a flag is_source"
def __init__(self, hdr, is_source=None):
commit c1dda0f09ffbd33efd234327f9eb9bfbbaa4cdfc
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Feb 24 10:27:21 2011 +0100
SharedStateTransaction is dead after RPMReadOnlyTransaction removal
diff --git a/backend/spacewalk/common/rhn_rpm.py b/backend/spacewalk/common/rhn_rpm.py
index 7039b11..a749795 100644
--- a/backend/spacewalk/common/rhn_rpm.py
+++ b/backend/spacewalk/common/rhn_rpm.py
@@ -107,12 +107,6 @@ class RPMTransaction:
-class SharedStateTransaction:
- _shared_state = {}
-
- def __init__(self):
- self.__dict__ = self._shared_state
-
class RPM_Header:
"Wrapper class for an rpm header - we need to store a flag is_source"
def __init__(self, hdr, is_source=None):
commit 0692677ae6a4707101b396f6d9e915c574e922d3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Feb 24 10:25:13 2011 +0100
RPMReadOnlyTransaction() is dead after get_package_header() change
diff --git a/backend/spacewalk/common/rhn_rpm.py b/backend/spacewalk/common/rhn_rpm.py
index f65d8d1..7039b11 100644
--- a/backend/spacewalk/common/rhn_rpm.py
+++ b/backend/spacewalk/common/rhn_rpm.py
@@ -113,15 +113,6 @@ class SharedStateTransaction:
def __init__(self):
self.__dict__ = self._shared_state
-class RPMReadOnlyTransaction(SharedStateTransaction, RPMTransaction):
- read_only = 1
- def __init__(self):
- SharedStateTransaction.__init__(self)
- if not hasattr(self, 'ts'):
- RPMTransaction.__init__(self)
- # FIXME: replace with macro defination
- self.pushVSFlags(8)
-
class RPM_Header:
"Wrapper class for an rpm header - we need to store a flag is_source"
def __init__(self, hdr, is_source=None):
commit ea16c79e86f35a66a1f9628ed0ab33547f6212f3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Mar 2 23:38:49 2011 +0100
removed rpm.readHeaderFromFD(), it brokes signatures
mim: why can't we use rpm.readHeaderFromFD()?
Panu: it's "legal" to read the headers like that - they are just two
headers next two each other on the disk
Panu: however you can't actually access the signature header data from python
Panu: ...unless you go the ts.hdrFromFdno() route which merges the
signature header into tags that the python bindings can understand and work on
diff --git a/backend/spacewalk/common/rhn_rpm.py b/backend/spacewalk/common/rhn_rpm.py
index 86d89c7..f65d8d1 100644
--- a/backend/spacewalk/common/rhn_rpm.py
+++ b/backend/spacewalk/common/rhn_rpm.py
@@ -239,11 +239,13 @@ def get_header_struct_size(package_file):
return header_size
+SHARED_TS=None
def get_package_header(filename=None, file=None, fd=None):
""" Loads the package header from a file / stream / file descriptor
Raises rpm.error if an error is found, or InvalidPacageError if package is
busted
"""
+ global SHARED_TS
# XXX Deal with exceptions better
if (filename is None and file is None and fd is None):
raise ValueError, "No parameters passed"
@@ -262,25 +264,12 @@ def get_package_header(filename=None, file=None, fd=None):
else:
file_desc = f.fileno()
-# FIXME:
- if None:
- pass
-# - readHeaderFromFD() doesn't set hdr['archivesize'] which makes payload_size = 0
-# for all imported packages
-# - this code was introduced as a fix of bz 487621; if it re-appears then uncomment
-# and try to fix missing hdr['archivesize'] another way
-# #if hasattr(rpm, 'readHeaderFromFD'):
-#
-# header_start, header_end = \
-# get_header_byte_range(os.fdopen(os.dup(file_desc)))
-# os.lseek(file_desc, header_start, 0)
-# hdr, offset = rpm.readHeaderFromFD(file_desc)
- else:
- # RHEL-4 and older, do the old way
- ts = RPMReadOnlyTransaction()
- ts.pushVSFlags(~(rpm.RPMVSF_NOMD5 | rpm.RPMVSF_NEEDPAYLOAD))
- hdr = ts.hdrFromFdno(file_desc)
- ts.popVSFlags()
+ # don't try to use rpm.readHeaderFromFD() here, it brokes signatures
+ # see commit message
+ if not SHARED_TS:
+ SHARED_TS = rpm.ts()
+ SHARED_TS.setVSFlags(-1)
+ hdr = SHARED_TS.hdrFromFdno(file_desc)
if hdr is None:
raise InvalidPackageError
is_source = hdr[rpm.RPMTAG_SOURCEPACKAGE]