summaryrefslogtreecommitdiff
path: root/gbp
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-06-01 11:19:36 +0300
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-04-03 10:10:27 +0300
commit9a10f9fb64fd5c8004e91d57171a4c786adec425 (patch)
tree55fb9168ce830996dcfd25ac7778e519230a2df8 /gbp
parent81e04128c89038b0367b42af194f92eee7b60eec (diff)
downloadgit-buildpackage-9a10f9fb64fd5c8004e91d57171a4c786adec425.tar.gz
git-buildpackage-9a10f9fb64fd5c8004e91d57171a4c786adec425.tar.bz2
git-buildpackage-9a10f9fb64fd5c8004e91d57171a4c786adec425.zip
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 <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp')
-rw-r--r--gbp/rpm/__init__.py11
-rw-r--r--gbp/rpm/policy.py3
2 files changed, 12 insertions, 2 deletions
diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py
index c4468c3c..5fe2a9f9 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
@@ -32,7 +31,15 @@ from gbp.errors import GbpError
from gbp.git import GitRepositoryError
from gbp.patch_series import (PatchSeries, Patch)
import gbp.log
-from gbp.pkg import (PkgPolicy, UpstreamSource, compressor_opts, parse_archive_filename)
+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 650c06f5..b79de70d 100644
--- a/gbp/rpm/policy.py
+++ b/gbp/rpm/policy.py
@@ -27,6 +27,9 @@ rpm_version_chars = 'a-zA-Z\d.~+'
class RpmPkgPolicy(PkgPolicy):
"""Packaging policy for RPM"""
+ # Special rpmlib python module for GBP (only)
+ python_rpmlib_module_name = "rpmlibgbp"
+
# Do NOT use a plus '+' or a period '.' as a delimiter.
# Additionally, name must begin with an alphanumeric.
packagename_re = re.compile("^[a-zA-Z0-9][a-zA-Z0-9\-_]+$")