From 1593be010021cde05d957cde7037d493da1362a4 Mon Sep 17 00:00:00 2001 From: Shreenidhi Shedi Date: Mon, 2 Dec 2024 11:35:06 +0530 Subject: [PATCH] No need to use %_topdir in specs, it is implicitly done setup-repo.sh: No need to pass `-r' to rpmbuild command, it was a wrong usage for our usecase Signed-off-by: Shreenidhi Shedi --- pytests/repo/setup-repo.sh | 24 +++++++++---------- pytests/repo/tdnf-bad-pre.spec | 9 +------ pytests/repo/tdnf-conflict-file0.spec | 5 ++-- pytests/repo/tdnf-conflict-file1.spec | 5 ++-- pytests/repo/tdnf-missing-dep.spec | 4 ++-- pytests/repo/tdnf-multi1.spec | 4 ++-- pytests/repo/tdnf-multi2.spec | 4 ++-- pytests/repo/tdnf-multi3.spec | 4 ++-- pytests/repo/tdnf-multi4.spec | 4 ++-- pytests/repo/tdnf-repoquery-base.spec | 5 ++-- pytests/repo/tdnf-repoquery-changelog.spec | 5 ++-- pytests/repo/tdnf-repoquery-deps.spec.in | 5 ++-- pytests/repo/tdnf-repoquery-queryformat.spec | 5 ++-- pytests/repo/tdnf-test-cleanreq-leaf1.spec | 4 ++-- pytests/repo/tdnf-test-cleanreq-leaf2.spec | 4 ++-- pytests/repo/tdnf-test-cleanreq-required.spec | 4 ++-- pytests/repo/tdnf-test-noarch.spec | 4 ++-- pytests/repo/tdnf-test-one.spec | 4 ++-- pytests/repo/tdnf-test-toolarge.spec | 6 ++--- pytests/repo/tdnf-verbose-scripts.spec | 6 ++--- 20 files changed, 56 insertions(+), 59 deletions(-) diff --git a/pytests/repo/setup-repo.sh b/pytests/repo/setup-repo.sh index 342fb155..2baabefd 100755 --- a/pytests/repo/setup-repo.sh +++ b/pytests/repo/setup-repo.sh @@ -8,22 +8,21 @@ # if [ $# -ne 2 ]; then - echo "Usage: $0 " + echo "Usage: $0 " >&2 exit 1 fi -function fix_dir_perms() -{ +function fix_dir_perms() { chmod 755 ${TEST_REPO_DIR} find ${TEST_REPO_DIR} -type d -exec chmod 0755 {} \; find ${TEST_REPO_DIR} -type f -exec chmod 0644 {} \; } ## used to check return code for each command. -function check_err { - rc=$? +function check_err() { + local rc=$? if [ $rc -ne 0 ]; then - echo $1 + echo "$1" >&2 exit $rc fi } @@ -37,7 +36,7 @@ fi REPO_SRC_DIR=$2 if [ ! -d ${REPO_SRC_DIR} ]; then - echo "specs dir does not exist" + echo "ERROR: specs dir does not exist" >&2 exit 1 fi @@ -58,7 +57,7 @@ mkdir -p -m 755 ${BUILD_PATH}/BUILD \ ${TEST_REPO_DIR}/yum.repos.d \ ${PUBLISH_PATH} \ ${PUBLISH_SRC_PATH} \ - ${PUBLISH_SHA512_PATH} \ + ${PUBLISH_SHA512_PATH} \ ${GNUPGHOME} #gpgkey data for unattended key generation @@ -90,12 +89,11 @@ for d in conflicts enhances obsoletes provides recommends requires suggests supp sed s/@@dep@@/$d/ < ${REPO_SRC_DIR}/tdnf-repoquery-deps.spec.in > ${BUILD_PATH}/SOURCES/tdnf-repoquery-$d.spec done -echo building packages +echo "Building packages" for spec in ${REPO_SRC_DIR}/*.spec ${BUILD_PATH}/SOURCES/*.spec ; do - echo "building ${spec}" - rpmbuild --define "_topdir ${BUILD_PATH}" \ - -r ${BUILD_PATH} -ba ${spec} 2>&1 - check_err "failed to build ${spec}" + echo "Building ${spec}" + rpmbuild --define "_topdir ${BUILD_PATH}" -ba ${spec} 2>&1 + check_err "ERROR: failed to build ${spec}" done rpmsign --addsign ${BUILD_PATH}/RPMS/*/*.rpm check_err "Failed to sign built packages." diff --git a/pytests/repo/tdnf-bad-pre.spec b/pytests/repo/tdnf-bad-pre.spec index 9cd4fc0f..15658323 100644 --- a/pytests/repo/tdnf-bad-pre.spec +++ b/pytests/repo/tdnf-bad-pre.spec @@ -19,19 +19,12 @@ Part of tdnf test spec. Test bad install scripts. %build %install -mkdir -p %_topdir/%buildroot/usr/bin -cat << EOF >> %_topdir/%buildroot/usr/bin/bad-pre.sh -#!/bin/sh -# dummy script. Return false because we are bad. -/bin/false -EOF %pre # fail intentionally -/bin/false +%{_bindir}/false %files -/usr/bin/bad-pre.sh %changelog * Fri Apr 2 2021 Oliver Kurth 1.0.0-1 diff --git a/pytests/repo/tdnf-conflict-file0.spec b/pytests/repo/tdnf-conflict-file0.spec index 57165db8..173d6633 100644 --- a/pytests/repo/tdnf-conflict-file0.spec +++ b/pytests/repo/tdnf-conflict-file0.spec @@ -16,9 +16,10 @@ Part of tdnf test spec. Two packages containing one identical file. %build %install -mkdir -p %_topdir/%buildroot/usr/lib/conflict +mkdir -p %{buildroot}/usr/lib/conflict # for a file conflict, cntents of the files need to differ -echo file0 > %_topdir/%buildroot/usr/lib/conflict/conflicting-file +echo file0 > %{buildroot}/usr/lib/conflict/conflicting-file + %files /usr/lib/conflict/conflicting-file diff --git a/pytests/repo/tdnf-conflict-file1.spec b/pytests/repo/tdnf-conflict-file1.spec index 55eda779..5ea7363e 100644 --- a/pytests/repo/tdnf-conflict-file1.spec +++ b/pytests/repo/tdnf-conflict-file1.spec @@ -16,8 +16,9 @@ Part of tdnf test spec. Two packages containing one identical file. %build %install -mkdir -p %_topdir/%buildroot/usr/lib/conflict -echo file > %_topdir/%buildroot/usr/lib/conflict/conflicting-file +mkdir -p %{buildroot}/usr/lib/conflict +echo file > %{buildroot}/usr/lib/conflict/conflicting-file + %files /usr/lib/conflict/conflicting-file diff --git a/pytests/repo/tdnf-missing-dep.spec b/pytests/repo/tdnf-missing-dep.spec index b624405d..75b65464 100644 --- a/pytests/repo/tdnf-missing-dep.spec +++ b/pytests/repo/tdnf-missing-dep.spec @@ -22,8 +22,8 @@ Part of tdnf test spec. Basic install/remove/upgrade test %build %install -mkdir -p %_topdir/%buildroot/lib/systemd/system/ -cat << EOF >> %_topdir/%buildroot/lib/systemd/system/%name.service +mkdir -p %{buildroot}/lib/systemd/system/ +cat << EOF >> %{buildroot}/lib/systemd/system/%name.service [Unit] Description=%name.service for whatprovides test. diff --git a/pytests/repo/tdnf-multi1.spec b/pytests/repo/tdnf-multi1.spec index ff8ceab8..a690d7cc 100644 --- a/pytests/repo/tdnf-multi1.spec +++ b/pytests/repo/tdnf-multi1.spec @@ -20,8 +20,8 @@ Part of tdnf test spec. Basic install/remove/upgrade test # files should not conflict %install -mkdir -p %_topdir/%buildroot/usr/share/multiinstall -touch %_topdir/%buildroot/usr/share/multiinstall-%{release} +mkdir -p %{buildroot}/usr/share/multiinstall +touch %{buildroot}/usr/share/multiinstall-%{release} %files /usr/share/multiinstall-%{release} diff --git a/pytests/repo/tdnf-multi2.spec b/pytests/repo/tdnf-multi2.spec index fba78695..84e1d3ba 100644 --- a/pytests/repo/tdnf-multi2.spec +++ b/pytests/repo/tdnf-multi2.spec @@ -20,8 +20,8 @@ Part of tdnf test spec. Basic install/remove/upgrade test # files should not conflict %install -mkdir -p %_topdir/%buildroot/usr/share/multiinstall -touch %_topdir/%buildroot/usr/share/multiinstall-%{release} +mkdir -p %{buildroot}/usr/share/multiinstall +touch %{buildroot}/usr/share/multiinstall-%{release} %files /usr/share/multiinstall-%{release} diff --git a/pytests/repo/tdnf-multi3.spec b/pytests/repo/tdnf-multi3.spec index c0519c83..e2ce20af 100644 --- a/pytests/repo/tdnf-multi3.spec +++ b/pytests/repo/tdnf-multi3.spec @@ -20,8 +20,8 @@ Part of tdnf test spec. Basic install/remove/upgrade test # files should not conflict %install -mkdir -p %_topdir/%buildroot/usr/share/multiinstall -touch %_topdir/%buildroot/usr/share/multiinstall-%{release} +mkdir -p %{buildroot}/usr/share/multiinstall +touch %{buildroot}/usr/share/multiinstall-%{release} %files /usr/share/multiinstall-%{release} diff --git a/pytests/repo/tdnf-multi4.spec b/pytests/repo/tdnf-multi4.spec index 9bcb0b42..6f61356c 100644 --- a/pytests/repo/tdnf-multi4.spec +++ b/pytests/repo/tdnf-multi4.spec @@ -20,8 +20,8 @@ Part of tdnf test spec. Basic install/remove/upgrade test # files should not conflict %install -mkdir -p %_topdir/%buildroot/usr/share/multiinstall -touch %_topdir/%buildroot/usr/share/multiinstall-%{release} +mkdir -p %{buildroot}/usr/share/multiinstall +touch %{buildroot}/usr/share/multiinstall-%{release} %files /usr/share/multiinstall-%{release} diff --git a/pytests/repo/tdnf-repoquery-base.spec b/pytests/repo/tdnf-repoquery-base.spec index 3f552665..d6cc10d1 100644 --- a/pytests/repo/tdnf-repoquery-base.spec +++ b/pytests/repo/tdnf-repoquery-base.spec @@ -17,8 +17,9 @@ depend on this in some way. %build %install -mkdir -p %_topdir/%buildroot/usr/lib/repoquery -touch %_topdir/%buildroot/usr/lib/repoquery/%name +mkdir -p %{buildroot}/usr/lib/repoquery +touch %{buildroot}/usr/lib/repoquery/%name + %files /usr/lib/repoquery/%name diff --git a/pytests/repo/tdnf-repoquery-changelog.spec b/pytests/repo/tdnf-repoquery-changelog.spec index 5d1419c7..b5a769ec 100644 --- a/pytests/repo/tdnf-repoquery-changelog.spec +++ b/pytests/repo/tdnf-repoquery-changelog.spec @@ -17,8 +17,9 @@ depend on this in some way. %build %install -mkdir -p %_topdir/%buildroot/usr/lib/repoquery -touch %_topdir/%buildroot/usr/lib/repoquery/%name +mkdir -p %{buildroot}/usr/lib/repoquery +touch %{buildroot}/usr/lib/repoquery/%name + %files /usr/lib/repoquery/%name diff --git a/pytests/repo/tdnf-repoquery-deps.spec.in b/pytests/repo/tdnf-repoquery-deps.spec.in index b90360de..5ca5892d 100644 --- a/pytests/repo/tdnf-repoquery-deps.spec.in +++ b/pytests/repo/tdnf-repoquery-deps.spec.in @@ -19,8 +19,9 @@ depend on tdnf-repoquery-base (or provide, ...) %build %install -mkdir -p %_topdir/%buildroot/usr/lib/repoquery -touch %_topdir/%buildroot/usr/lib/repoquery/%name +mkdir -p %{buildroot}/usr/lib/repoquery +touch %{buildroot}/usr/lib/repoquery/%name + %files /usr/lib/repoquery/%name diff --git a/pytests/repo/tdnf-repoquery-queryformat.spec b/pytests/repo/tdnf-repoquery-queryformat.spec index d7766633..0534b383 100644 --- a/pytests/repo/tdnf-repoquery-queryformat.spec +++ b/pytests/repo/tdnf-repoquery-queryformat.spec @@ -21,8 +21,9 @@ depend on this in some way. %build %install -mkdir -p %_topdir/%buildroot/usr/lib/repoquery -touch %_topdir/%buildroot/usr/lib/repoquery/%name +mkdir -p %{buildroot}/usr/lib/repoquery +touch %{buildroot}/usr/lib/repoquery/%name + %files /usr/lib/repoquery/%name diff --git a/pytests/repo/tdnf-test-cleanreq-leaf1.spec b/pytests/repo/tdnf-test-cleanreq-leaf1.spec index 62c97108..7bfa37bd 100644 --- a/pytests/repo/tdnf-test-cleanreq-leaf1.spec +++ b/pytests/repo/tdnf-test-cleanreq-leaf1.spec @@ -20,8 +20,8 @@ Part of tdnf test spec. Basic install/remove/upgrade test %build %install -mkdir -p %_topdir/%buildroot/lib/cleanreq/ -touch %_topdir/%buildroot/lib/cleanreq/%name +mkdir -p %{buildroot}/lib/cleanreq/ +touch %{buildroot}/lib/cleanreq/%name %files /lib/cleanreq/%name diff --git a/pytests/repo/tdnf-test-cleanreq-leaf2.spec b/pytests/repo/tdnf-test-cleanreq-leaf2.spec index e22ab0f1..690379c4 100644 --- a/pytests/repo/tdnf-test-cleanreq-leaf2.spec +++ b/pytests/repo/tdnf-test-cleanreq-leaf2.spec @@ -20,8 +20,8 @@ Part of tdnf test spec. Basic install/remove/upgrade test %build %install -mkdir -p %_topdir/%buildroot/lib/cleanreq/ -touch %_topdir/%buildroot/lib/cleanreq/%name +mkdir -p %{buildroot}/lib/cleanreq/ +touch %{buildroot}/lib/cleanreq/%name %files /lib/cleanreq/%name diff --git a/pytests/repo/tdnf-test-cleanreq-required.spec b/pytests/repo/tdnf-test-cleanreq-required.spec index 1678c782..fbdcb648 100644 --- a/pytests/repo/tdnf-test-cleanreq-required.spec +++ b/pytests/repo/tdnf-test-cleanreq-required.spec @@ -19,8 +19,8 @@ Part of tdnf test spec. Basic install/remove/upgrade test %build %install -mkdir -p %_topdir/%buildroot/lib/cleanreq/ -touch %_topdir/%buildroot/lib/cleanreq/required +mkdir -p %{buildroot}/lib/cleanreq/ +touch %{buildroot}/lib/cleanreq/required %files /lib/cleanreq/required diff --git a/pytests/repo/tdnf-test-noarch.spec b/pytests/repo/tdnf-test-noarch.spec index 748fb773..a68a0ec7 100644 --- a/pytests/repo/tdnf-test-noarch.spec +++ b/pytests/repo/tdnf-test-noarch.spec @@ -20,8 +20,8 @@ Part of tdnf test spec. Basic install/remove/upgrade test %build %install -mkdir -p %_topdir/%buildroot/lib/systemd/system/ -cat << EOF >> %_topdir/%buildroot/lib/systemd/system/%{name}.service +mkdir -p %{buildroot}/lib/systemd/system/ +cat << EOF >> %{buildroot}/lib/systemd/system/%{name}.service [Unit] Description=%{name} for arch related tests diff --git a/pytests/repo/tdnf-test-one.spec b/pytests/repo/tdnf-test-one.spec index a8021938..2cf39d21 100644 --- a/pytests/repo/tdnf-test-one.spec +++ b/pytests/repo/tdnf-test-one.spec @@ -19,8 +19,8 @@ Part of tdnf test spec. Basic install/remove/upgrade test %build %install -mkdir -p %_topdir/%buildroot/lib/systemd/system/ -cat << EOF >> %_topdir/%buildroot/lib/systemd/system/tdnf-test-one.service +mkdir -p %{buildroot}/lib/systemd/system/ +cat << EOF >> %{buildroot}/lib/systemd/system/tdnf-test-one.service [Unit] Description=tdnf-test-one.service for whatprovides test. diff --git a/pytests/repo/tdnf-test-toolarge.spec b/pytests/repo/tdnf-test-toolarge.spec index 5d4958e7..760b5425 100644 --- a/pytests/repo/tdnf-test-toolarge.spec +++ b/pytests/repo/tdnf-test-toolarge.spec @@ -20,9 +20,9 @@ out of disk space error. %build %install -mkdir -p %_topdir/%buildroot/lib/toolarge/ -touch %_topdir/%buildroot/lib/toolarge/largedata.txt -dd if=/dev/urandom of=%_topdir/%buildroot/lib/toolarge/largedata.txt bs=1M count=1 +mkdir -p %{buildroot}/lib/toolarge/ +touch %{buildroot}/lib/toolarge/largedata.txt +dd if=/dev/urandom of=%{buildroot}/lib/toolarge/largedata.txt bs=1M count=1 %files /lib/toolarge/largedata.txt diff --git a/pytests/repo/tdnf-verbose-scripts.spec b/pytests/repo/tdnf-verbose-scripts.spec index 4b1e2c71..28f04479 100644 --- a/pytests/repo/tdnf-verbose-scripts.spec +++ b/pytests/repo/tdnf-verbose-scripts.spec @@ -19,9 +19,9 @@ Part of tdnf test spec. Basic install/remove/upgrade test %build %install -mkdir -p %_topdir/%buildroot/lib/systemd/system/ -echo %_topdir/%buildroot/lib/systemd/system/%{name}.service -cat << EOF >> %_topdir/%buildroot/lib/systemd/system/%{name}.service +mkdir -p %{buildroot}/lib/systemd/system/ +echo %{buildroot}/lib/systemd/system/%{name}.service +cat << EOF >> %{buildroot}/lib/systemd/system/%{name}.service [Unit] Description=%{name}.service for rpm script test.