class Package(): @classmethod def from_url(cls, url): package_data = HTTPClient()._http_request(url=url, decode=None) return Package(raw_data=package_data) MODE_RAW_DATA = 0 MODE_FILE_PATH = 1 def __init__(self, raw_data=None): self.mode = None if raw_data is not None: self.data = raw_data self.mode = self.MODE_RAW_DATA self.fp = tempfile.NamedTemporaryFile() self.fp.write(raw_data) self.fp.seek(0) self.rpm = RPM(self.fp) def __enter__(self): return self def dependencies(self): cpio = self.rpm.gzip_file.read() content = cpio.read() return [] # yb = yum.YumBase() def __exit__(self, *excinfo): self.rpm.__exit__(*excinfo) if self.mode == self.MODE_RAW_DATA: self.fp.close()
def get_metadata(path): if os.path.isfile(path): rpmfile = RPM(file(os.path.abspath(path))) metadata = {rpmfile.name(): {'version': rpmfile[rpmdefs.RPMTAG_VERSION], 'path': os.path.abspath(path), 'arch': rpmfile[rpmdefs.RPMTAG_ARCH]} } return metadata else: return None
def get_metadata(path): if os.path.isfile(path): rpmfile = RPM(file(os.path.abspath(path))) metadata = { rpmfile.name(): { 'version': rpmfile[rpmdefs.RPMTAG_VERSION], 'path': os.path.abspath(path), 'arch': rpmfile[rpmdefs.RPMTAG_ARCH] } } return metadata else: return None
def channel_primary(name): rpm = RPM(file('skype-2.1.0.81-fc.i586.rpm')) p = [{ 'name': rpm[rpmdefs.RPMTAG_NAME], 'arch': rpm[rpmdefs.RPMTAG_ARCH], 'version': rpm[rpmdefs.RPMTAG_VERSION], 'release': rpm[rpmdefs.RPMTAG_RELEASE], 'epoch': rpm[rpmdefs.RPMTAG_SERIAL], 'summary': rpm[rpmdefs.RPMTAG_SUMMARY], 'description': rpm[rpmdefs.RPMTAG_DESCRIPTION], 'packager': rpm[rpmdefs.RPMTAG_PACKAGER], 'url': rpm[rpmdefs.RPMTAG_URL], 'time': { 'file': -1, 'build': rpm[rpmdefs.RPMTAG_BUILDTIME][0] }, 'arch1': rpm[rpmdefs.RPMTAG_ARCH], 'arch1': rpm[rpmdefs.RPMTAG_ARCH], 'arch1': rpm[rpmdefs.RPMTAG_ARCH], 'arch1': rpm[rpmdefs.RPMTAG_ARCH], 'arch1': rpm[rpmdefs.RPMTAG_ARCH], 'arch1': rpm[rpmdefs.RPMTAG_ARCH], 'arch1': rpm[rpmdefs.RPMTAG_ARCH], }] r = app.make_response(render_template('primary.xml', packages=p)) r.mimetype = 'text/xml' return r
def __init__(self, raw_data=None): self.mode = None if raw_data is not None: self.data = raw_data self.mode = self.MODE_RAW_DATA self.fp = tempfile.NamedTemporaryFile() self.fp.write(raw_data) self.fp.seek(0) self.rpm = RPM.load(self.fp)
def Get_Rpm_Package_info(self, FILELIST): global PACKAGES_DICT for FILE in FILELIST: try: if RPM_REGEX.match(FILE): FULL_FILENAME = DIR + '/' + FILE rpm = RPM(file(FULL_FILENAME)) if DEBUG > 0: print "==============" print "RPM Name: " + rpm.name() print "Package: " + rpm.package() print "Version: " + rpm[rpmdefs.RPMTAG_VERSION] print "Release: " + rpm[rpmdefs.RPMTAG_RELEASE] print "==============" if PACKAGES_DICT.has_key(rpm.name()): if PACKAGES_DICT[rpm.name()].has_key(rpm[rpmdefs.RPMTAG_VERSION]): PACKAGES_DICT[rpm.name()][rpm[rpmdefs.RPMTAG_VERSION]][rpm[rpmdefs.RPMTAG_RELEASE]] = FULL_FILENAME else: PACKAGES_DICT[rpm.name()][rpm[rpmdefs.RPMTAG_VERSION]] = {} PACKAGES_DICT[rpm.name()][rpm[rpmdefs.RPMTAG_VERSION]][rpm[rpmdefs.RPMTAG_RELEASE]] = FULL_FILENAME else: PACKAGES_DICT[rpm.name()] = {} PACKAGES_DICT[rpm.name()][rpm[rpmdefs.RPMTAG_VERSION]] = {} PACKAGES_DICT[rpm.name()][rpm[rpmdefs.RPMTAG_VERSION]][rpm[rpmdefs.RPMTAG_RELEASE]] = FULL_FILENAME except: pass return()
def upload(): status = 503 headers = [] curr_package = request.headers.get('X-Package-Name') rpm = RPM(file(unicode(curr_package))) rpm_data = parse_package_info(rpm) try: new_req_queue_element = '%s/%s' % (rpm_data['os_release'], rpm_data['os_arch']) dest_dirname = '%s/%s/Packages' % (app.settings['repo']['top_dir'], new_req_queue_element) shutil.move(curr_package, dest_dirname) src_filename = '%s/%s' % (dest_dirname, os.path.basename(curr_package)) dest_filename = '%s/%s' % (dest_dirname, rpm_data['filename']) shutil.move(src_filename, dest_filename) response = 'OK - Accessible as %s' % dest_filename status = 200 if new_req_queue_element not in req_queue: req_queue.append(new_req_queue_element) event_timeout.set() event_request.set() except BaseException as E: response = E.message return response, status, headers
def getPackageNameFromFile(package_name): try: rpm = RPM(file(package_name)) return rpm.filename() except Exception, _ex: return None
def setUp(self): self.rpm = RPM( BytesIO(open('tests/Eterm-0.9.3-5mdv2007.0.src.rpm', 'rb').read()))
def setUp(self): self.rpm = RPM(open('tests/Eterm-0.9.3-5mdv2007.0.src.rpm', 'rb'))
def setUp(self): self.rpm = RPM( StringIO(file('tests/Eterm-0.9.3-5mdv2007.0.src.rpm').read()))
def setUp(self): self.rpm = RPM(file('tests/Eterm-0.9.3-5mdv2007.0.src.rpm')) self.rpm = StringIO('')
def setUp(self): with open('tests/Eterm-0.9.3-5mdv2007.0.src.rpm', 'rb') as f: data = f.read() self.rpm = RPM(BytesIO(data))
def setUp(self): self.rpm = RPM(open('tests/compat-libcap1-1.10-7.el7.x86_64.rpm', 'rb'))