From 624717e546b0c65ce6a17ecc3a8f291945acdc7a Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Jul 26 2016 07:52:09 +0000 Subject: [PATCH 1/3] skip multiarch tests if gcc -m32 won't work It turns out to be too difficult to get the necessary packages (glibc-devel.i686 and libgcc.i686) installed when building RPMs in Koji, so in that case let's just skip the multiarch tests. --- diff --git a/rpmfluff.py b/rpmfluff.py index cab4dda..688e64a 100644 --- a/rpmfluff.py +++ b/rpmfluff.py @@ -475,6 +475,11 @@ def get_expected_arch(): expectedArch = get_expected_arch() +def can_compile_m32(): + # 64-bit hosts can compile 32-bit binaries by using -m32, but only if the + # necessary bits are installed (they are often not). + return os.path.exists('/usr/include/gnu/stubs-32.h') and os.path.exists('/lib/libgcc_s.so.1') + class Trigger: def __init__(self, event, triggerConds, script, program=None): """For documentation on RPM triggers, see @@ -1695,8 +1700,8 @@ class TestSimpleRpmBuild(unittest.TestCase): "/usr/bin/perl")) self.rpmbuild.make() - @unittest.skipIf(expectedArch != 'x86_64', - 'host arch is not x86_64') + @unittest.skipIf(expectedArch != 'x86_64' or not can_compile_m32(), + 'host arch is not x86_64 or 32-bit support is missing') def test_multiarch_compilation(self): """Ensure that building on multiple archs works as expected""" self.rpmbuild.buildArchs = ['i386', 'x86_64'] @@ -1844,8 +1849,8 @@ class YumRepoBuildTests(unittest.TestCase): self.assert_is_file(os.path.join(repo.repoDir, 'test-package-devel-0.1-1.%s.rpm' % expectedArch)) self.assert_is_file(os.path.join(repo.repoDir, 'test-package-python-0.1-1.%s.rpm' % expectedArch)) - @unittest.skipIf(expectedArch != 'x86_64' or not shutil.which("createrepo_c"), - 'host arch is not x86_64 or createrepo_c not found in PATH') + @unittest.skipIf(expectedArch != 'x86_64' or not can_compile_m32() or not shutil.which("createrepo_c"), + 'host arch is not x86_64 or 32-bit support is missing or createrepo_c not found in PATH') def test_multiple_arches(self): package = SimpleRpmBuild('test-multilib-package', '0.1', '1', ['i386', 'x86_64']) repo = YumRepoBuild([package]) From 93142e7e75ece19bcb55feac67edbc3d4812ac95 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Jul 26 2016 08:06:54 +0000 Subject: [PATCH 2/3] handle %{__isa_bits} being undefined It seems to be undefined on armhfp builds in Fedora Koji, at least. --- diff --git a/rpmfluff.py b/rpmfluff.py index 688e64a..16fe97b 100644 --- a/rpmfluff.py +++ b/rpmfluff.py @@ -1107,7 +1107,7 @@ class SimpleRpmBuild(RpmBuild): subpackageSuffix=None): """Add a simple source file to the sources, build it, and install it somewhere, using the given compilation flags""" sourceId = self.add_source(SourceFile(sourceFileName, sourceContent)) - self.section_build += "%if %{__isa_bits} == 32\n%define mopt -m32\n%endif\n" + self.section_build += "%if 0%{?__isa_bits} == 32\n%define mopt -m32\n%endif\n" self.section_build += "gcc %%{?mopt} %s %s\n"%(compileFlags, sourceFileName) if createParentDirs: self.create_parent_dirs(installPath) From ac36d4a4fded80b456e81b00f223519964cef70a Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Jul 26 2016 08:06:54 +0000 Subject: [PATCH 3/3] add some missing BuildRequires This lets the tests all pass in %check. Fixes #7. --- diff --git a/python-rpmfluff.spec b/python-rpmfluff.spec index 2a45291..834bbfd 100644 --- a/python-rpmfluff.spec +++ b/python-rpmfluff.spec @@ -25,6 +25,7 @@ such as rpm and yum. Summary: %{summary} %{?python_provide:%python_provide python2-%{modname}} BuildRequires: python2-devel +BuildRequires: rpm-python Requires: rpm-build Requires: createrepo_c @@ -36,6 +37,7 @@ Python 2 version. Summary: %{summary} %{?python_provide:%python_provide python3-%{modname}} BuildRequires: python3-devel +BuildRequires: rpm-python3 Requires: rpm-build Requires: createrepo_c @@ -55,9 +57,8 @@ Python 3 version. %py3_install %check -# Ignore errors as for now due to https://pagure.io/rpmfluff/issue/7 -python2 %{modname}.py || : -python3 %{modname}.py || : +python2 %{modname}.py +python3 %{modname}.py %files -n python2-%{modname} %license LICENSE