コード例 #1
0
ファイル: headerSource.py プロジェクト: T-D-Oe/spacewalk
    def populate(self, header, size, checksum_type, checksum, path=None, org_id=None,
        header_start=None, header_end=None, channels=[]):

        # XXX is seems to me that this is the place that 'source_rpm' is getting
        # set
        for f in self.keys():
            field = f
            if self.tagMap.has_key(f):
                field = self.tagMap[f]
                if not field:
                    # Unsupported
                    continue

            # get the db field value from the header
            val = header[field]
            if f == 'build_time':
                if type(val) in (IntType, LongType):
                    # A UNIX timestamp
                    val = gmtime(val)
	    if f == 'payload_size':
                # workaround for older rpms where signed
                # attributes go negative for size > 2G
                if val < 0:
                    val = long(val) + 2 ** 32
            elif val:
                # Convert to strings
                if isinstance(val, unicode):
                    val = to_string(val)
                else:
                    val = str(val)
            elif val == []:
                val = None
            self[f] = val

        self['package_size'] = size
        self['checksum_type'] = checksum_type
        self['checksum'] = checksum
        self['checksums'] = {checksum_type:checksum}
        self['path'] = path
        self['org_id'] = org_id
        self['header_start'] = header_start
        self['header_end'] = header_end
        self['last_modified'] = localtime(time.time())
        if 'sigmd5' in self:
           if self['sigmd5']:
               self['sigchecksum_type'] = 'md5'
               self['sigchecksum'] = self['sigmd5']
           del(self['sigmd5'])

        # Fix some of the information up
        vendor = self['vendor']
        if vendor is None:
            self['vendor'] = 'Red Hat, Inc.'
        payloadFormat = self['payload_format']
        if payloadFormat is None:
            self['payload_format'] = 'cpio'
        if self['payload_size'] is None:
            self['payload_size'] = 0
        return self
コード例 #2
0
ファイル: headerSource.py プロジェクト: usairman82/spacewalk
 def populate(self, hash):
     ChangeLog.populate(self, hash)
     # Fix the time
     tm = self['mtime']
     if type(tm) in (IntType, LongType):
         # A UNIX timestamp
         self['mtime'] = localtime(tm)
     if type(self['filedigest']) == StringType:
         self['checksum'] = self['filedigest']
         del (self['filedigest'])
コード例 #3
0
ファイル: headerSource.py プロジェクト: m47ik/uyuni
 def populate(self, hash):
     ChangeLog.populate(self, hash)
     # Fix the time
     tm = self['mtime']
     if type(tm) in (IntType, LongType):
         # A UNIX timestamp
         self['mtime'] = localtime(tm)
     if type(self['filedigest']) == StringType:
         self['checksum'] = self['filedigest']
         del(self['filedigest'])
コード例 #4
0
ファイル: headerSource.py プロジェクト: usairman82/spacewalk
 def populate(self, hash):
     ChangeLog.populate(self, hash)
     # Fix the time
     tm = self['time']
     if type(tm) in (IntType, LongType):
         # A UNIX timestamp
         self['time'] = localtime(tm)
     # In changelog, data is either in UTF-8, or in any other
     # undetermined encoding. Assume ISO-Latin-1 if not UTF-8.
     for i in ('text', 'name'):
         try:
             self[i] = UnicodeType(self[i], "utf-8")
         except UnicodeDecodeError:
             self[i] = UnicodeType(self[i], "iso-8859-1")
コード例 #5
0
ファイル: headerSource.py プロジェクト: m47ik/uyuni
 def populate(self, hash):
     ChangeLog.populate(self, hash)
     # Fix the time
     tm = self['time']
     if type(tm) in (IntType, LongType):
         # A UNIX timestamp
         self['time'] = localtime(tm)
     # In changelog, data is either in UTF-8, or in any other
     # undetermined encoding. Assume ISO-Latin-1 if not UTF-8.
     for i in ('text', 'name'):
         try:
             self[i] = UnicodeType(self[i], "utf-8")
         except UnicodeDecodeError:
             self[i] = UnicodeType(self[i], "iso-8859-1")
コード例 #6
0
ファイル: debPackage.py プロジェクト: lpramuk/spacewalk
    def __init__(self, header, size, checksum_type, checksum, path=None, org_id=None,
            channels=[]):

        headerSource.rpmBinaryPackage.__init__(self)

        self.tagMap = headerSource.rpmBinaryPackage.tagMap.copy()

        # Remove already-mapped tags
        self._already_mapped = [
            'rpm_version', 'payload_size', 'payload_format',
            'package_group', 'build_time', 'build_host'
        ]

        for t in self._already_mapped:
            if self.tagMap.has_key(t):
                del self.tagMap[t]

        # XXX is seems to me that this is the place that 'source_rpm' is getting
        # set
        for f in self.keys():
            field = f
            if self.tagMap.has_key(f):
                field = self.tagMap[f]
                if not field:
                    # Unsupported
                    continue

            # get the db field value from the header
            val = header[field]
            if f == 'build_time':
                if val is not None and isinstance(val, IntType):
                    # A UNIX timestamp
                    val = gmtime(val)
            elif val:
                # Convert to strings
                if isinstance(val, unicode):
                    val = to_string(val)
                else:
                    val = str(val)
            elif val == []:
                val = None
            self[f] = val

        self['package_size'] = size
        self['checksum_type'] = checksum_type
        self['checksum'] = checksum
        self['path'] = path
        self['org_id'] = org_id
        self['header_start'] = None
        self['header_end'] = None
        self['last_modified'] = localtime(time.time())
        if self['sigmd5']:
            self['sigchecksum_type'] = 'md5'
            self['sigchecksum'] = self['sigmd5']
        del(self['sigmd5'])

        # Fix some of the information up
        vendor = self['vendor']
        if vendor is None:
            self['vendor'] = 'Debian'
        payloadFormat = self['payload_format']
        if payloadFormat is None:
            self['payload_format'] = 'ar'
        if self['payload_size'] is None:
            self['payload_size'] = 0

        # Populate file information
        self._populateFiles(header)
        # Populate dependency information
        self._populateDependencyInformation(header)
        # Populate changelogs
        self._populateChangeLog(header)
        # Channels
        self._populateChannels(channels)

        self['source_rpm'] = None

        group = self.get('package_group', '')
        if group == '' or group is None:
            self['package_group'] = 'NoGroup'
コード例 #7
0
ファイル: debPackage.py プロジェクト: pombredanne/spacewalk-1
    def __init__(self, header, size, checksum_type, checksum, path=None, org_id=None, channels=[]):

        headerSource.rpmBinaryPackage.__init__(self)

        self.tagMap = headerSource.rpmBinaryPackage.tagMap.copy()

        # Remove already-mapped tags
        self._already_mapped = [
            "rpm_version",
            "payload_size",
            "payload_format",
            "package_group",
            "build_time",
            "build_host",
        ]

        for t in self._already_mapped:
            if self.tagMap.has_key(t):
                del self.tagMap[t]

        # XXX is seems to me that this is the place that 'source_rpm' is getting
        # set
        for f in self.keys():
            field = f
            if self.tagMap.has_key(f):
                field = self.tagMap[f]
                if not field:
                    # Unsupported
                    continue

            # get the db field value from the header
            val = header[field]
            if f == "build_time":
                if val is not None and isinstance(val, IntType):
                    # A UNIX timestamp
                    val = gmtime(val)
            elif val:
                # Convert to strings
                if isinstance(val, unicode):
                    val = unicode.encode(val, "utf-8")
                else:
                    val = str(val)
            elif val == []:
                val = None
            self[f] = val

        self["package_size"] = size
        self["checksum_type"] = checksum_type
        self["checksum"] = checksum
        self["path"] = path
        self["org_id"] = org_id
        self["header_start"] = None
        self["header_end"] = None
        self["last_modified"] = localtime(time.time())
        if self["sigmd5"]:
            self["sigchecksum_type"] = "md5"
            self["sigchecksum"] = self["sigmd5"]
        del (self["sigmd5"])

        # Fix some of the information up
        vendor = self["vendor"]
        if vendor is None:
            self["vendor"] = "Debian"
        payloadFormat = self["payload_format"]
        if payloadFormat is None:
            self["payload_format"] = "ar"
        if self["payload_size"] is None:
            self["payload_size"] = 0

        # Populate file information
        self._populateFiles(header)
        # Populate dependency information
        self._populateDependencyInformation(header)
        # Populate changelogs
        self._populateChangeLog(header)
        # Channels
        self._populateChannels(channels)

        self["source_rpm"] = None

        group = self.get("package_group", "")
        if group == "" or group is None:
            self["package_group"] = "NoGroup"
コード例 #8
0
ファイル: headerSource.py プロジェクト: usairman82/spacewalk
    def populate(self,
                 header,
                 size,
                 checksum_type,
                 checksum,
                 path=None,
                 org_id=None,
                 header_start=None,
                 header_end=None,
                 channels=[]):

        # XXX is seems to me that this is the place that 'source_rpm' is getting
        # set
        for f in self.keys():
            field = f
            if f in self.tagMap:
                field = self.tagMap[f]
                if not field:
                    # Unsupported
                    continue

            # get the db field value from the header
            val = header[field]
            if f == 'build_time':
                if type(val) in (IntType, LongType):
                    # A UNIX timestamp without timezone => UTC timezone
                    val = gmtime(val)
            if f == 'payload_size':
                if val is None:
                    # use longarchivesize header field for rpms with archive > 4GB
                    if ('longarchivesize'
                            in header) and (header['longarchivesize'] > 0):
                        val = header['longarchivesize']
                elif val < 0:
                    # workaround for older rpms where signed
                    # attributes go negative for size > 2G
                    val = LongType(val) + 2**32
            elif val:
                # Convert to strings
                if isinstance(val, UnicodeType):
                    val = to_string(val)
                else:
                    val = str(val)
            elif val == []:
                val = None
            self[f] = val

        self['repo_type'] = 'yum'
        self['package_size'] = size
        self['checksum_type'] = checksum_type
        self['checksum'] = checksum
        self['checksums'] = {checksum_type: checksum}
        self['path'] = path
        self['org_id'] = org_id
        self['header_start'] = header_start
        self['header_end'] = header_end
        self['last_modified'] = localtime(time.time())
        if 'sigmd5' in self:
            if self['sigmd5']:
                self['sigchecksum_type'] = 'md5'
                self['sigchecksum'] = self['sigmd5']
            del (self['sigmd5'])

        # Fix some of the information up
        vendor = self['vendor']
        if vendor is None:
            self['vendor'] = 'Red Hat, Inc.'
        payloadFormat = self['payload_format']
        if payloadFormat is None:
            self['payload_format'] = 'cpio'
        if self['payload_size'] is None:
            self['payload_size'] = 0
        return self