tests: generate correct RPM name

Tests failed to run against Fedora 37 or newer cloud images because of
the following error,
    It's a image with multiple partitions, using last partition as main partition
    'xxx/tests/build/x86_64/kexec-tools-2.0.26-5.fc37.src.rpm' not found
    /dev/nbd0 disconnected
    make: *** [Makefile:73: xxx/tests/output/test-base-image] Error 1

This is because starting with Fedora 37, rpm changes its API,
    # Fedora >= 37
    $ rpm -q --specfile kexec-tools.spec
    kexec-tools-2.0.26-5.fc37.src
    # Fedora 36
    $ rpm -q --specfile kexec-tools.spec
    kexec-tools-2.0.26-5.fc36

The tests depends on rpm to generate correct RPM name. Fix this issue by
removing the trailing .src from the output of "rpm -q --specfile".

Reviewed-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Coiby Xu 2023-06-15 13:17:19 +08:00
parent 471c136481
commit 8f243d2ab1

View File

@ -30,7 +30,7 @@ RPMDEFINE = --define '_sourcedir $(REPO)'\
KEXEC_TOOLS_SRC = $(filter-out $(REPO)/tests,$(wildcard $(REPO)/*)) KEXEC_TOOLS_SRC = $(filter-out $(REPO)/tests,$(wildcard $(REPO)/*))
KEXEC_TOOLS_TEST_SRC = $(wildcard $(REPO)/tests/scripts/**/*) KEXEC_TOOLS_TEST_SRC = $(wildcard $(REPO)/tests/scripts/**/*)
KEXEC_TOOLS_NVR = $(shell rpm $(RPMDEFINE) -q --specfile $(REPO)/$(SPEC) 2>/dev/null | grep -m 1 .) KEXEC_TOOLS_NVR = $(shell rpm $(RPMDEFINE) -q --specfile $(REPO)/$(SPEC) 2>/dev/null | grep -m 1 . | sed -e 's#.src#.$(ARCH)#')
KEXEC_TOOLS_RPM = $(BUILD_ROOT)/$(ARCH)/$(KEXEC_TOOLS_NVR).rpm KEXEC_TOOLS_RPM = $(BUILD_ROOT)/$(ARCH)/$(KEXEC_TOOLS_NVR).rpm
all: $(TEST_ROOT)/output/test-base-image all: $(TEST_ROOT)/output/test-base-image