diff --git a/tests/Sanity/rpm-rebuild/main.fmf b/tests/Sanity/rpm-rebuild/main.fmf new file mode 100644 index 0000000..72fce8a --- /dev/null +++ b/tests/Sanity/rpm-rebuild/main.fmf @@ -0,0 +1,13 @@ +summary: rpmbuild package with rust +description: 'Ensure that rust does not break rpmbuild' +contact: + - Jesus Checa Hidalgo +component: + - rust +test: ./runtest.sh +framework: beakerlib +require+: + - rust + - rpm-build + - yum-utils +duration: 1h diff --git a/tests/Sanity/rpm-rebuild/ripgrep.fmf b/tests/Sanity/rpm-rebuild/ripgrep.fmf new file mode 100644 index 0000000..9cb533c --- /dev/null +++ b/tests/Sanity/rpm-rebuild/ripgrep.fmf @@ -0,0 +1,11 @@ +summary+: ": ripgrep" +require+: + - ripgrep +environment+: + PKG_TO_BUILD: "ripgrep" +duration: 15m + +adjust+: + # ripgrep is not part of RHEL + - when: distro != fedora + enabled: false diff --git a/tests/Sanity/rpm-rebuild/rpm-sequoia.fmf b/tests/Sanity/rpm-rebuild/rpm-sequoia.fmf new file mode 100644 index 0000000..d215dfb --- /dev/null +++ b/tests/Sanity/rpm-rebuild/rpm-sequoia.fmf @@ -0,0 +1,11 @@ +summary+: ": rpm-sequoia" +require+: + - rpm-sequoia +environment+: + PKG_TO_BUILD: "rpm-sequoia" +duration: 20m + +adjust+: + - when: distro < rhel-10, centos-stream-10 + enabled: false + because: "rpm-sequoia is available only in RHEL >= 10" diff --git a/tests/Sanity/rpm-rebuild/runtest.sh b/tests/Sanity/rpm-rebuild/runtest.sh new file mode 100755 index 0000000..475d2f9 --- /dev/null +++ b/tests/Sanity/rpm-rebuild/runtest.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="$(rpm -qf $(which rustc))" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE || rlDie "rustc not found. Aborting testcase..." + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + + if [[ "x" == "x${PKG_TO_BUILD}" ]]; then + rlLogError "No package was configured to build." + rlDie "The package must be passed over PKG_TO_BUILD environment variable." + fi + + rlPhaseEnd + + rlPhaseStart FAIL ${PKG_TO_BUILD}FetchSrcAndInstallBuildDeps + if ! rlCheckRpm $PKG_TO_BUILD; then + rlRun "yum install -y $PKG_TO_BUILD ${YUM_SWITCHES}" + rlAssertRpm $PKG_TO_BUILD + fi + rlFetchSrcForInstalled $PKG_TO_BUILD + rlRun SRPM=$(ls -1 *.src.rpm) + rlRun "rpm -ivh $SRPM" + rlRun SPECDIR="$(rpm -E '%{_specdir}')" + # Note about the spec file name: When packaging rust crates, the package + # is named rust-, as well as the spec file, but the rpm package + # (the one we use in dnf to install and query) is named as the crate, + # (without the "rust-" prefix). We have to take that into account to + # find the spec: + # https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/#_package_naming + rlRun "SPECNAME=$(rpm -ql $SRPM | grep .spec)" + + # Packages built with rust usually contains dynamic dependencies. + # builddep needs to be run from the srpm, not the spec file, to be able + # to generate them: + # https://fedoraproject.org/wiki/Changes/DynamicBuildRequires#rpmbuild + rlRun "yum-builddep -y ${SRPM} ${YUM_SWITCHES}" + rlPhaseEnd + + rlPhaseStartTest + set -o pipefail + rlRun "rpmbuild -bb ${SPECDIR}/${SPECNAME} |& tee ${SRPM}_rpmbuild.log" + rlFileSubmit "${SRPM}_rpmbuild.log" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd