From 1b59091e2ac146792f0605304c4ff038c1e758b7 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 8 Oct 2011 14:22:25 +0200 Subject: [PATCH] Add package type information and supported arches to package metadata. --- python/pakfire/constants.py | 5 +++-- python/pakfire/packages/base.py | 11 ++++++++- python/pakfire/packages/file.py | 35 +++++++++++++++++++++++++++-- python/pakfire/packages/make.py | 9 ++++++-- python/pakfire/packages/packager.py | 5 +++++ 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/python/pakfire/constants.py b/python/pakfire/constants.py index af34ee6af..69d1960c8 100644 --- a/python/pakfire/constants.py +++ b/python/pakfire/constants.py @@ -57,9 +57,9 @@ METADATA_DOWNLOAD_PATH = "repodata" METADATA_DOWNLOAD_FILE = "repomd.json" METADATA_DATABASE_FILE = "packages.solv" -PACKAGE_FORMAT = 1 +PACKAGE_FORMAT = 2 # XXX implement this properly -PACKAGE_FORMATS_SUPPORTED = [0, 1] +PACKAGE_FORMATS_SUPPORTED = [0, 1, 2] PACKAGE_EXTENSION = "pfm" MAKEFILE_EXTENSION = "nm" @@ -122,6 +122,7 @@ package %(description)s end + type = %(type)s size = %(inst_size)d end diff --git a/python/pakfire/packages/base.py b/python/pakfire/packages/base.py index 0bb4f2156..96046392c 100644 --- a/python/pakfire/packages/base.py +++ b/python/pakfire/packages/base.py @@ -92,7 +92,16 @@ class Package(object): items = [ (_("Name"), self.name), - (_("Arch"), self.arch), + ] + + # Show supported arches if available. + if hasattr(self, "supported_arches") and not self.supported_arches == "all": + arch = "%s (%s)" % (self.arch, self.supported_arches) + else: + arch = self.arch + items.append((_("Arch"), arch)) + + items += [ (_("Version"), self.version), (_("Release"), self.release), ] diff --git a/python/pakfire/packages/file.py b/python/pakfire/packages/file.py index 43f40738e..925513617 100644 --- a/python/pakfire/packages/file.py +++ b/python/pakfire/packages/file.py @@ -454,7 +454,19 @@ class FilePackage(Package): Calculate the hash1 of this package. """ return util.calc_hash1(self.filename) - + + @property + def type(self): + if self.format >= 2: + type = self.lexer.package.get_ver("type") + elif self.format == 1: + type = self._type + else: + type = self.metadata.get("type") + + assert type, self + return type + @property def name(self): if self.format >= 1: @@ -685,10 +697,29 @@ class FilePackage(Package): class SourcePackage(FilePackage): - pass + _type = "source" + + @property + def arch(self): + return "src" + + @property + def supported_arches(self): + if self.format >= 2: + arches = self.lexer.package.get_var("arch", "all") + elif self.format == 1: + # Format 1 did not support "supported_arches", so we assume "all". + arches = "all" + else: + arches = self.metadata.get("PKG_SUPPORTED_ARCHES", "all") + + assert arches, self + return arches class BinaryPackage(FilePackage): + _type = "binary" + def get_scriptlet(self, type): a = self.open_archive() diff --git a/python/pakfire/packages/make.py b/python/pakfire/packages/make.py index ad82602cd..066d0ff0a 100644 --- a/python/pakfire/packages/make.py +++ b/python/pakfire/packages/make.py @@ -183,10 +183,15 @@ class Makefile(MakefileBase): @property def arch(self): + return "src" + + @property + def supported_arches(self): """ - This is only used to create the name of the source package. + These are the supported arches. Which means, packages of these + architectures can be built out of this source package. """ - return "src" + return self.lexer.get_var("sup_arches", "all") @property def packages(self): diff --git a/python/pakfire/packages/packager.py b/python/pakfire/packages/packager.py index 7ff97773b..9a4b658aa 100644 --- a/python/pakfire/packages/packager.py +++ b/python/pakfire/packages/packager.py @@ -200,6 +200,7 @@ class BinaryPackager(Packager): info.update({ "pakfire_version" : PAKFIRE_VERSION, "uuid" : uuid.uuid4(), + "type" : "binary", }) # Include distribution information. @@ -552,6 +553,7 @@ class SourcePackager(Packager): # Generic package information including Pakfire information. info.update({ "pakfire_version" : PAKFIRE_VERSION, + "type" : "source", }) # Include distribution information. @@ -580,6 +582,9 @@ class SourcePackager(Packager): "build_id" : uuid.uuid4(), }) + # Arches equals supported arches. + info["arch"] = self.pkg.supported_arches + # Set UUID # XXX replace this by the payload hash info.update({ -- 2.39.5