From: Markus Lehtonen Date: Fri, 1 Jun 2012 08:19:36 +0000 (+0300) Subject: rpm helpers: add support for gbp-specific rpmlib X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=89e46dfeffe73f0dba33f708e94f726d6b3991ec;p=tools%2Fgit-buildpackage.git rpm helpers: add support for gbp-specific rpmlib Adds support to use a special rpmlib, defined by rpm packaging policy. This makes it possible to use the target distro's rpmlib. That is, parse spec files for target distros (and architectures) incompatible with your host system. With the default RpmPkgPolicy, GBP tries to import "rpmlibgbp". Signed-off-by: Markus Lehtonen --- diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py index 81597da7..73934b66 100644 --- a/gbp/rpm/__init__.py +++ b/gbp/rpm/__init__.py @@ -22,7 +22,6 @@ import sys import os import re import tempfile -import rpm import glob import shutil as shutil from optparse import OptionParser @@ -35,6 +34,13 @@ import gbp.log from gbp.pkg import (UpstreamSource, compressor_opts, parse_archive_filename) from gbp.rpm.policy import RpmPkgPolicy +try: + # Try to load special RPM lib to be used for GBP (only) + rpm = __import__(RpmPkgPolicy.python_rpmlib_module_name) +except ImportError: + gbp.log.debug("Failed to import '%s' as rpm python module, using host's default rpm library instead" % RpmPkgPolicy.python_rpmlib_module_name) + import rpm + # define a large number to check the valid id of source file MAX_SOURCE_NUMBER = 99999 diff --git a/gbp/rpm/policy.py b/gbp/rpm/policy.py index 231f7ead..f73f1d92 100644 --- a/gbp/rpm/policy.py +++ b/gbp/rpm/policy.py @@ -22,6 +22,9 @@ from gbp.pkg import PkgPolicy, parse_archive_filename class RpmPkgPolicy(PkgPolicy): """Packaging policy for RPM""" + # Special rpmlib python module for GBP (only) + python_rpmlib_module_name = "rpmlibgbp" + alnum = 'a-zA-Z0-9' # Valid characters for RPM pkg name name_whitelist_chars = '._+%{}\-'