mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-11 17:54:06 +02:00
- add "fname" attribute to util.PackageError class
This commit is contained in:
@@ -23,18 +23,18 @@ class DebQuery(packagequery.PackageQuery):
|
|||||||
arfile.read()
|
arfile.read()
|
||||||
debbin = arfile.get_file('debian-binary')
|
debbin = arfile.get_file('debian-binary')
|
||||||
if debbin is None:
|
if debbin is None:
|
||||||
raise DebError('no debian binary')
|
raise DebError(self.__path, 'no debian binary')
|
||||||
if debbin.read() != '2.0\n':
|
if debbin.read() != '2.0\n':
|
||||||
raise DebError('invalid debian binary format')
|
raise DebError(self.__path, 'invalid debian binary format')
|
||||||
control = arfile.get_file('control.tar.gz')
|
control = arfile.get_file('control.tar.gz')
|
||||||
if control is None:
|
if control is None:
|
||||||
raise DebError('missing control.tar.gz')
|
raise DebError(self.__path, 'missing control.tar.gz')
|
||||||
# XXX: python24 relies on a name
|
# XXX: python24 relies on a name
|
||||||
tar = tarfile.open(name = 'control.tar.gz', fileobj = control)
|
tar = tarfile.open(name = 'control.tar.gz', fileobj = control)
|
||||||
try:
|
try:
|
||||||
control = tar.extractfile('./control')
|
control = tar.extractfile('./control')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise DebError('missing \'control\' file in control.tar.gz')
|
raise DebError(self.__path, 'missing \'control\' file in control.tar.gz')
|
||||||
self.__parse_control(control, all_tags, *extra_tags)
|
self.__parse_control(control, all_tags, *extra_tags)
|
||||||
|
|
||||||
def __parse_control(self, control, all_tags = False, *extra_tags):
|
def __parse_control(self, control, all_tags = False, *extra_tags):
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
class PackageError(Exception):
|
class PackageError(Exception):
|
||||||
"""base class for all package related errors"""
|
"""base class for all package related errors"""
|
||||||
def __init__(self, msg):
|
def __init__(self, fname, msg):
|
||||||
Exception.__init__(self)
|
Exception.__init__(self)
|
||||||
|
self.fname = fname
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
|
|
||||||
class PackageQueries(dict):
|
class PackageQueries(dict):
|
||||||
|
@@ -71,7 +71,7 @@ class RpmQuery(packagequery.PackageQuery):
|
|||||||
data = self.__file.read(RpmHeaderEntry.ENTRY_SIZE)
|
data = self.__file.read(RpmHeaderEntry.ENTRY_SIZE)
|
||||||
hdrmgc, reserved, il, dl = struct.unpack('!I3i', data)
|
hdrmgc, reserved, il, dl = struct.unpack('!I3i', data)
|
||||||
if self.HEADER_MAGIC != hdrmgc:
|
if self.HEADER_MAGIC != hdrmgc:
|
||||||
raise RpmHeaderError('invalid headermagic \'%s\'' % hdrmgc)
|
raise RpmHeaderError(self.__path, 'invalid headermagic \'%s\'' % hdrmgc)
|
||||||
# skip signature header for now
|
# skip signature header for now
|
||||||
size = il * RpmHeaderEntry.ENTRY_SIZE + dl
|
size = il * RpmHeaderEntry.ENTRY_SIZE + dl
|
||||||
# data is 8 byte aligned
|
# data is 8 byte aligned
|
||||||
@@ -81,7 +81,7 @@ class RpmQuery(packagequery.PackageQuery):
|
|||||||
hdrmgc, reserved, il, dl = struct.unpack('!I3i', data)
|
hdrmgc, reserved, il, dl = struct.unpack('!I3i', data)
|
||||||
self.header = RpmHeader(pad, dl)
|
self.header = RpmHeader(pad, dl)
|
||||||
if self.HEADER_MAGIC != hdrmgc:
|
if self.HEADER_MAGIC != hdrmgc:
|
||||||
raise RpmHeaderError('invalid headermagic \'%s\'' % hdrmgc)
|
raise RpmHeaderError(self.__path, 'invalid headermagic \'%s\'' % hdrmgc)
|
||||||
data = self.__file.read(il * RpmHeaderEntry.ENTRY_SIZE)
|
data = self.__file.read(il * RpmHeaderEntry.ENTRY_SIZE)
|
||||||
while len(data) > 0:
|
while len(data) > 0:
|
||||||
ei = struct.unpack('!4i', data[:RpmHeaderEntry.ENTRY_SIZE])
|
ei = struct.unpack('!4i', data[:RpmHeaderEntry.ENTRY_SIZE])
|
||||||
@@ -98,10 +98,10 @@ class RpmQuery(packagequery.PackageQuery):
|
|||||||
data = self.__file.read(self.LEAD_SIZE)
|
data = self.__file.read(self.LEAD_SIZE)
|
||||||
leadmgc, = struct.unpack('!I', data[:4])
|
leadmgc, = struct.unpack('!I', data[:4])
|
||||||
if leadmgc != self.LEAD_MAGIC:
|
if leadmgc != self.LEAD_MAGIC:
|
||||||
raise RpmError('invalid lead magic \'%s\'' % leadmgc)
|
raise RpmError(self.__path, 'invalid lead magic \'%s\'' % leadmgc)
|
||||||
sigtype, = struct.unpack('!h', data[78:80])
|
sigtype, = struct.unpack('!h', data[78:80])
|
||||||
if sigtype != self.HEADERSIG_TYPE:
|
if sigtype != self.HEADERSIG_TYPE:
|
||||||
raise RpmError('invalid header signature \'%s\'' % sigtype)
|
raise RpmError(self.__path, 'invalid header signature \'%s\'' % sigtype)
|
||||||
|
|
||||||
def __read_data(self, entry, data):
|
def __read_data(self, entry, data):
|
||||||
off = entry.offset
|
off = entry.offset
|
||||||
@@ -144,14 +144,14 @@ class RpmQuery(packagequery.PackageQuery):
|
|||||||
cnt += 1
|
cnt += 1
|
||||||
entry.data = entry.data[0]
|
entry.data = entry.data[0]
|
||||||
else:
|
else:
|
||||||
raise RpmHeaderError('unsupported tag type \'%d\' (tag: \'%s\'' % (entry.type, entry.tag))
|
raise RpmHeaderError(self.__path, 'unsupported tag type \'%d\' (tag: \'%s\'' % (entry.type, entry.tag))
|
||||||
|
|
||||||
def __reqprov(self, tag, flags, version):
|
def __reqprov(self, tag, flags, version):
|
||||||
pnames = self.header.gettag(tag).data
|
pnames = self.header.gettag(tag).data
|
||||||
pflags = self.header.gettag(flags).data
|
pflags = self.header.gettag(flags).data
|
||||||
pvers = self.header.gettag(version).data
|
pvers = self.header.gettag(version).data
|
||||||
if not (pnames and pflags and pvers):
|
if not (pnames and pflags and pvers):
|
||||||
raise RpmError('cannot get provides/requires, tags are missing')
|
raise RpmError(self.__path, 'cannot get provides/requires, tags are missing')
|
||||||
res = []
|
res = []
|
||||||
for name, flags, ver in zip(pnames, pflags, pvers):
|
for name, flags, ver in zip(pnames, pflags, pvers):
|
||||||
# RPMSENSE_SENSEMASK = 15 (see rpmlib.h) but ignore RPMSENSE_SERIAL (= 1 << 0) therefore use 14
|
# RPMSENSE_SENSEMASK = 15 (see rpmlib.h) but ignore RPMSENSE_SERIAL (= 1 << 0) therefore use 14
|
||||||
|
Reference in New Issue
Block a user