diff --git a/Makefile-tests.am b/Makefile-tests.am index 19762cd5..21e8dac3 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -7,36 +7,47 @@ AM_TESTS_ENVIRONMENT = \ commondir=$(abs_top_srcdir)/tests/common CLEANFILES += \ - tests/common/compose/yum/empty \ tests/common/compose/yum/repodata/repomd.xml \ tests/common/compose/test-repo.repo \ tests/common/compose/yum/repodata/*.bz2 \ tests/common/compose/yum/repodata/*.gz \ $(NULL) -# Needed by the compose test -tests/common/compose/yum/empty: tests/common/compose/yum/empty.c - $(CC) -nostdlib $< -o $@ +testpackages = \ + tests/common/compose/yum/x86_64/empty-1.0-1.x86_64.rpm \ + tests/common/compose/yum/x86_64/foo-1.0-1.x86_64.rpm \ + $(NULL) -tests/common/compose/yum/repodata/repomd.xml: tests/common/compose/yum/empty tests/common/compose/yum/empty.spec +# Create a rule for each testpkg with their respective spec file as dep. +# The static pattern feature is almost a fit for this, but does not allow string +# substitutions and wildcards in the patterns to allow rpm-filename --> +# spec-filename without also encoding the arch, release, and rev. +define testpkgbuild_template = +$(1): tests/common/compose/yum/$(2).spec (cd tests/common/compose/yum && \ - rpmbuild \ - --define "_sourcedir $(abs_top_srcdir)/tests/common/compose/yum" \ - --define "_specdir $(abs_top_srcdir)/tests/common/compose/yum" \ - --define "_builddir $(abs_top_srcdir)/tests/common/compose/yum" \ - --define "_srcrpmdir $(abs_top_srcdir)/tests/common/compose/yum" \ - --define "_rpmdir $(abs_top_srcdir)/tests/common/compose/yum" \ - --define "_buildrootdir $(abs_top_srcdir)/tests/common/compose/yum/.build" \ - -ba empty.spec && \ - rm *.src.rpm && \ - createrepo_c --no-database $(abs_top_srcdir)/tests/common/compose/yum/) + rm -rf .build && \ + rpmbuild -ba $$$$(basename $$<) \ + --define "_sourcedir $$$$PWD" \ + --define "_specdir $$$$PWD" \ + --define "_builddir $$$$PWD/.build" \ + --define "_srcrpmdir $$$$PWD" \ + --define "_rpmdir $$$$PWD" \ + --define "_buildrootdir $$$$PWD" && \ + rm -rf .build && \ + rm -f *.src.rpm) +endef + +$(foreach pkg,$(testpackages),$(eval $(call testpkgbuild_template,$(pkg),$(shell basename $(pkg) | cut -d- -f1)))) + +tests/common/compose/yum/repodata/repomd.xml: $(testpackages) + (cd tests/common/compose/yum && \ + createrepo_c --no-database $$PWD) tests/common/compose/test-repo.repo: tests/common/compose/test-repo.repo.in tests/common/compose/yum/repodata/repomd.xml cat $< | sed -e "s|%WHERE%|$(abs_top_srcdir)|" > $@ CLEANFILES += \ tests/common/compose/test-repo-local.repo \ - tests/common/compose/yum/empty-1.0-1.src.rpm \ $(NULL) tests_check_jsonutil_CPPFLAGS = -I $(srcdir)/src/libpriv diff --git a/tests/common/compose/yum/empty.c b/tests/common/compose/yum/empty.c deleted file mode 100644 index f2e1ebbc..00000000 --- a/tests/common/compose/yum/empty.c +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- - * - * Copyright (C) 2015 Red Hat Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2 of the licence or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -int -_start () -{ - __asm__ __volatile__ ("mov $1, %eax"); - __asm__ __volatile__ ("mov $0, %ebx\n"); - __asm__ __volatile__ ("int $0x80\n"); -} diff --git a/tests/common/compose/yum/empty.spec b/tests/common/compose/yum/empty.spec index 7284fc01..34a84fce 100644 --- a/tests/common/compose/yum/empty.spec +++ b/tests/common/compose/yum/empty.spec @@ -10,7 +10,6 @@ License: GPL+ Group: Development/Tools URL: http://foo.bar.com BuildArch: x86_64 -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root %description %{summary} @@ -18,6 +17,16 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root %prep %build +cat > empty.c << EOF +int +_start () +{ + __asm__ __volatile__ ("mov \$1, %eax"); + __asm__ __volatile__ ("mov \$0, %ebx\n"); + __asm__ __volatile__ ("int \$0x80\n"); +} +EOF +cc -nostdlib empty.c -o empty %install mkdir -p %{buildroot}/boot @@ -58,5 +67,3 @@ rm -rf %{buildroot} %changelog * Tue Mar 17 2015 Giuseppe Scrivano 1.0-1 - First Build - -EOF diff --git a/tests/common/compose/yum/foo.spec b/tests/common/compose/yum/foo.spec new file mode 100644 index 00000000..d7b420aa --- /dev/null +++ b/tests/common/compose/yum/foo.spec @@ -0,0 +1,34 @@ +Summary: Awesome utility that allows convenient foobing +Name: foo +Version: 1.0 +Release: 1 +License: GPL+ +Group: Development/Tools +URL: http://foo.bar.com +BuildArch: x86_64 + +%description +%{summary} + +%prep + +%build +cat > foo << EOF +#!/bin/sh +echo "Happy foobing!" +EOF +chmod a+x foo + +%install +mkdir -p %{buildroot}/usr/bin +install foo %{buildroot}/usr/bin + +%clean +rm -rf %{buildroot} + +%files +/usr/bin/foo + +%changelog +* Tue Jun 21 2016 Jonathan Lebon 1.0-1 +- First Build