def test_parse_rpm_xmlish_can_parse_rhel(self): test_installed = self.get_test_loc('rpm_installed/distro-xmlish/rhel-rpms.xmlish') expected = self.get_test_loc('rpm_installed/distro-xmlish/rhel-rpms.xmlish-expected.json') packages = rpm_installed.parse_rpm_xmlish(test_installed, detect_licenses=True) result = [package.to_dict(_detailed=True) for package in packages] result = json.loads(json.dumps(result)) check_result_equals_expected_json(result, expected, regen=False)
def test_parse_rpm_xmlish(self): test_installed = self.get_test_loc('rpm_installed/xmlish/centos-5-rpms.xmlish') expected = self.get_test_loc('rpm_installed/xmlish/centos-5-rpms.xmlish-expected.json') packages = rpm_installed.parse_rpm_xmlish(test_installed) result = [package.to_dict(_detailed=True) for package in packages] result = json.loads(json.dumps(result)) check_result_equals_expected_json(result, expected, regen=False)
def parse(cls, location): # dump and parse the rpmdb to XMLish xmlish_loc = rpm_installed.collect_installed_rpmdb_xmlish_from_rpmdb_loc(location) package_data = rpm_installed.parse_rpm_xmlish( location=xmlish_loc, datasource_id=cls.datasource_id, package_type=cls.default_package_type, ) # TODO: package_data.namespace = cls.default_package_namespace return package_data
def get_installed_packages(root_dir, detect_licenses=False, **kwargs): """ Yield Package objects given a ``root_dir`` rootfs directory. """ # TODO: license and docs are typically at usr/share/doc/packages/<package name>/* and should be used # packages_doc_dir = os.path.join(root_dir, 'usr/share/doc/packages') # note that we also have file flags that can tell us which file is a license and doc. # dump the rpmdb to XMLish xmlish_loc = rpm_installed.collect_installed_rpmdb_xmlish_from_rootfs( root_dir) return rpm_installed.parse_rpm_xmlish(xmlish_loc, detect_licenses=detect_licenses)
def test_parse_rpm_xmlish_does_not_with_empty_or_missing_location(self): rpm_installed.parse_rpm_xmlish(None) rpm_installed.parse_rpm_xmlish('') rpm_installed.parse_rpm_xmlish('/foo/bar/does-not-exists')