Beispiel #1
0
 def getHdr(self, pkg):
     hdr_name = "%s/hdr_%s" % (self.config.tempdir, pkg.getNEVRA())
     apkg = pyrpm.getRpmIOFactory(self.config, "file://%s" % hdr_name)
     try:
         apkg.write(pkg)
         apkg.close()
     except IOError:
         return None
     
     return hdr_name
Beispiel #2
0
    def save(self):
        name = "%s/%s" % (os.getcwd(), self["filename"])
        pkg = pyrpm.RpmPackage(self.config, "file://%s" % self["hdr"])
        pkg.read()
        apkg = pyrpm.getRpmIOFactory(name)
        try:
            apkg.write(pkg)
            apkg.close()
        except IOError:
            print "Could not write package header"
            return None
        pkg.close()

        target_fd = open(name, "ab")
#        print "tell=%d" % target_fd.tell()

        gz_cpio = gzipFile(self["cpio"])
        gz_cpio_size = os.stat(gz_cpio).st_size
        fd = open(gz_cpio, "rb")
        size = 0
        while size < gz_cpio_size:
            if gz_cpio_size - size > 65536:
                data = fd.read(65536)
            else:
                data = fd.read(gz_cpio_size - size)
#            if size == 0:
#                tmp_data = data[12:]
#                data = struct.pack("!cccccccccccc",
#                                   '\x1F', '\x8B', '\x08', '\x00',
#                                   '\x00', '\x00', '\x00', '\x00',
#                                   '\x00', '\x03', '\xD4', '\xBD')
#                data += tmp_data
            target_fd.write(data)
            size += len(data)
        fd.close()

        target_fd.close()