From 03f33debafe262ca249cf8e75dbdfd9aa5f2282e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 18 Mar 2011 17:24:42 +0100 Subject: [PATCH] Add "type" property to all packages. --- pakfire/packages/__init__.py | 2 +- pakfire/packages/base.py | 6 ++++-- pakfire/packages/binary.py | 2 -- pakfire/packages/source.py | 4 +--- pakfire/packages/virtual.py | 2 -- pakfire/repository/index.py | 5 +++++ 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pakfire/packages/__init__.py b/pakfire/packages/__init__.py index 440e874bb..0983ed47a 100644 --- a/pakfire/packages/__init__.py +++ b/pakfire/packages/__init__.py @@ -8,4 +8,4 @@ from virtual import VirtualPackage from listing import PackageListing from make import Makefile -from packager import Packager +from packager import BinaryPackager diff --git a/pakfire/packages/base.py b/pakfire/packages/base.py index 81dd58013..3d6bf4ed2 100644 --- a/pakfire/packages/base.py +++ b/pakfire/packages/base.py @@ -11,8 +11,6 @@ import pakfire.depsolve from pakfire.i18n import _ class Package(object): - type = None # either "bin", "src" or "virt" - def __init__(self, pakfire, repo=None): self.pakfire = pakfire self._repo = repo @@ -211,6 +209,10 @@ class Package(object): def arch(self): raise NotImplementedError + @property + def type(self): + return self.metadata.get("TYPE", "unknown") + @property def maintainer(self): return self.metadata.get("PKG_MAINTAINER") diff --git a/pakfire/packages/binary.py b/pakfire/packages/binary.py index efff2a756..3ce9ef5c3 100644 --- a/pakfire/packages/binary.py +++ b/pakfire/packages/binary.py @@ -5,8 +5,6 @@ import sys from file import FilePackage class BinaryPackage(FilePackage): - type = "bin" - @property def arch(self): return self.metadata.get("PKG_ARCH") diff --git a/pakfire/packages/source.py b/pakfire/packages/source.py index ad073ee88..1e53f5752 100644 --- a/pakfire/packages/source.py +++ b/pakfire/packages/source.py @@ -3,11 +3,9 @@ from file import FilePackage class SourcePackage(FilePackage): - type = "src" - @property def arch(self): - return self.type + return "src" def extract(self, path): pass diff --git a/pakfire/packages/virtual.py b/pakfire/packages/virtual.py index a18f55092..55fa4ee5f 100644 --- a/pakfire/packages/virtual.py +++ b/pakfire/packages/virtual.py @@ -6,8 +6,6 @@ from pakfire.constants import * class VirtualPackage(Package): - type = "virt" - def __init__(self, pakfire, data): self.pakfire = pakfire self._data = {} diff --git a/pakfire/repository/index.py b/pakfire/repository/index.py index ced0be908..f18c97d95 100644 --- a/pakfire/repository/index.py +++ b/pakfire/repository/index.py @@ -103,9 +103,14 @@ class DirectoryIndex(Index): package = packages.BinaryPackage(self.pakfire, self.repo, file) + if package.type == "source": + # Silently skip source packages. + continue + if not package.arch in (self.arch, "noarch"): logging.warning("Skipped package with wrong architecture: %s (%s)" \ % (package.filename, package.arch)) + print package.type continue self._packages.append(package) -- 2.47.3