cmake-testsuite-sanity: fix for RPM 4.19.90 build dir change

See https://github.com/rpm-software-management/rpm/issues/3147
for the background. RPM 4.19.90 changed RPM's build directory
behavior; the tl;dr is that everything's one level deeper now.
This code was expecting something like:

/tmp/tmp.dheZFHDA0M/BUILD/cmake-3.31.10

but now we actually get something like:

/tmp/tmp.dheZFHDA0M/BUILD/cmake-3.31.10-build/cmake-3.31.10

this uses the trick from
https://github.com/rpm-software-management/rpm/issues/3147#issuecomment-2154192419
to figure out the base build directory and then go from there,
which *should* make this work on both older and newer RPM.

Without this fix, the tests are failing like this:

:: [ 21:03:33 ] :: [  BEGIN   ] :: Running 'CMakeDir='
:: [ 21:03:33 ] :: [   PASS   ] :: Command 'CMakeDir=' (Expected 0, got 0)
:: [ 21:03:33 ] :: [  BEGIN   ] :: Running 'cd /tmp/tmp.dheZFHDA0M/BUILD/'
:: [ 21:03:33 ] :: [   PASS   ] :: Command 'cd /tmp/tmp.dheZFHDA0M/BUILD/' (Expected 0, got 0)
:: [ 21:03:33 ] :: [  BEGIN   ] :: Running 'su -c './bootstrap &>/tmp/tmp.dheZFHDA0M/bootstrap.log' cmkbld'
:: [ 21:03:33 ] :: [   FAIL   ] :: Command 'su -c './bootstrap &>/tmp/tmp.dheZFHDA0M/bootstrap.log' cmkbld' (Expected 0, got 127)

you can see it doesn't get the directory right - it's trying
to run `./bootstrap` in `/tmp/tmp.dheZFHDA0M/BUILD/`, because
the attempt to discover `CMakeDir` failed and returned an
empty string. That's never going to work. See:
https://artifacts.dev.testing-farm.io/974c2a93-5d4c-4896-a48a-b2a54d2dd01d/

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2025-12-11 12:19:12 -08:00
commit 063d6e7fc9

View file

@ -57,8 +57,9 @@ rlJournalStart
rlRun "dnf builddep -y $TmpDir/SPECS/*.spec"
rlRun "su -c 'rpmbuild -D \"_topdir $TmpDir\" -bp $TmpDir/SPECS/*.spec &>$TmpDir/rpmbuild.log' $BUILD_USER"
rlRun "rlFileSubmit $TmpDir/rpmbuild.log"
rlRun "CMakeDir=`ls $TmpDir/BUILD | grep -E '^cmake-[0-9]+(\.[0-9]+)+(-rc[0-9]+)?$' | tail -n 1`"
rlRun "cd $TmpDir/BUILD/$CMakeDir"
rlRun "BuildDir=`rpmbuild -D \"_topdir $TmpDir\" -bc --short-circuit --define '__spec_build_pre echo %{_builddir}; exit 0' $TmpDir/SPECS/*.spec | tail -1`"
rlRun "CMakeDir=`ls $BuildDir | grep -E '^cmake-[0-9]+(\.[0-9]+)+(-rc[0-9]+)?$' | tail -n 1`"
rlRun "cd $BuildDir/$CMakeDir"
rlRun "su -c './bootstrap &>$TmpDir/bootstrap.log' $BUILD_USER"
rlRun "rlFileSubmit $TmpDir/bootstrap.log"
rlRun "ln -fs /usr/bin/cmake bin/cmake"