def _extract_drpm_data(drpm_filename): """ Extract a dict of information for a given DRPM. :param drpm_filename: full path to the package to analyze :type drpm_filename: str :return: dict of data about the package :rtype: dict """ drpm_data = dict() headers = rpm_parse.drpm_package_info(drpm_filename) try: # "handle" rpm-only drpms (without rpm header) rpm_headers = rpm_parse.package_headers(drpm_filename) except rpm.error: raise RPMOnlyDRPMsAreNotSupported(drpm_filename) drpm_data['signing_key'] = rpm_parse.package_signature(rpm_headers) drpm_data['arch'] = rpm_headers['arch'] old_nevr = old_name, old_epoch, old_version, old_release = rpm_parse.nevr( headers["old_nevr"]) new_nevr = new_name, new_epoch, new_version, new_release = rpm_parse.nevr( headers["nevr"]) drpm_data['sequence'] = headers["old_nevr"] + "-" + headers["seq"] drpm_data['epoch'] = str(new_epoch) drpm_data['oldepoch'] = str(old_epoch) drpm_data['version'] = str(new_version) drpm_data['oldversion'] = str(old_version) drpm_data['release'] = new_release drpm_data['oldrelease'] = old_release drpm_data['new_package'] = new_name drpm_data['size'] = os.stat(drpm_filename)[stat.ST_SIZE] old_evr = rpm_parse.nevr_to_evr(*old_nevr) new_evr = rpm_parse.nevr_to_evr(*new_nevr) drpm_data['filename'] = "drpms/%s-%s_%s.%s.drpm" % ( new_name, rpm_parse.evr_to_str(*old_evr), rpm_parse.evr_to_str(*new_evr), drpm_data['arch']) return _encode_as_utf8(drpm_data)
def _extract_drpm_data(drpm_filename): """ Extract a dict of information for a given DRPM. :param drpm_filename: full path to the package to analyze :type drpm_filename: str :return: dict of data about the package :rtype: dict """ drpm_data = dict() headers = rpm_parse.drpm_package_info(drpm_filename) try: # "handle" rpm-only drpms (without rpm header) rpm_headers = rpm_parse.package_headers(drpm_filename) except rpm.error: raise RPMOnlyDRPMsAreNotSupported(drpm_filename) drpm_data['signing_key'] = rpm_parse.package_signature(rpm_headers) drpm_data['arch'] = rpm_headers['arch'] old_nevr = old_name, old_epoch, old_version, old_release = rpm_parse.nevr(headers["old_nevr"]) new_nevr = new_name, new_epoch, new_version, new_release = rpm_parse.nevr(headers["nevr"]) drpm_data['sequence'] = headers["old_nevr"] + "-" + headers["seq"] drpm_data['epoch'] = str(new_epoch) drpm_data['oldepoch'] = str(old_epoch) drpm_data['version'] = str(new_version) drpm_data['oldversion'] = str(old_version) drpm_data['release'] = new_release drpm_data['oldrelease'] = old_release drpm_data['new_package'] = new_name drpm_data['size'] = os.stat(drpm_filename)[stat.ST_SIZE] old_evr = rpm_parse.nevr_to_evr(*old_nevr) new_evr = rpm_parse.nevr_to_evr(*new_nevr) drpm_data['filename'] = "drpms/%s-%s_%s.%s.drpm" % (new_name, rpm_parse.evr_to_str(*old_evr), rpm_parse.evr_to_str(*new_evr), drpm_data['arch']) return _encode_as_utf8(drpm_data)
def test_evr_with_epoch(self): """Test converting EVR tuple to string with epoch.""" evr = (3, "3.10", "4.fc3") self.assertEquals(rpm.evr_to_str(*evr), "3:3.10-4.fc3")