From 7b34681d95fc7ec0cafe6d9105f51787f6fd7eca Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Jun 06 2024 17:51:44 +0000 Subject: Correct source flattening for RPM 4.19.90+ (#2290735) RPM 4.19.90 (4.20 alpha 1) introduced per-build directories, which adds one more level to the build directory nesting that this is trying to flatten out. I can't think of a command that will work with both RPM versions, and I can't find a way to get RPM to tell us more directly whether this feature is present (it seems like the macros used are sufficiently internal that you can't `rpm --eval` them), so I can't see a better way to handle this than a rather awkward version check, unfortunately. Signed-off-by: Adam Williamson --- diff --git a/roles/standard-test-source/tasks/main.yml b/roles/standard-test-source/tasks/main.yml index 11af880..5e2ad17 100644 --- a/roles/standard-test-source/tasks/main.yml +++ b/roles/standard-test-source/tasks/main.yml @@ -33,6 +33,13 @@ - '!all' delegate_facts: True + - name: Check if RPM version is 4.19.90 or higher + # https://stackoverflow.com/questions/4023830 + shell: printf "4.19.90\n$(rpm -q --queryformat='%{VERSION}\n' rpm)\n" | sort -C -V + # rc 1 means "version is lower than 4.19.90" + # rc 0 means "version is 4.19.90 or higher" + register: rpm_vercheck + - name: Check if required packages are installed on the system command: rpm -q {{ item }} ignore_errors: True @@ -92,10 +99,22 @@ "_sourcedir {{tenv_workdir}}/" --define "_builddir {{srcdir}}" when: not fetch_only -- name: Flatten sources +- name: Flatten sources (RPM < 4.19.90) shell: | shopt -s dotglob mv {{ srcdir }}/*/* {{ srcdir }} when: - flatten - not fetch_only + - "rpm_vercheck.rc != 0" + +# https://bugzilla.redhat.com/show_bug.cgi?id=2290735 +# https://github.com/rpm-software-management/rpm/pull/2885 +- name: Flatten sources (RPM >= 4.19.90) + shell: | + shopt -s dotglob + mv {{ srcdir }}/*/*/* {{ srcdir }} + when: + - flatten + - not fetch_only + - "rpm_vercheck.rc == 0"