-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that rpms installed in tmt come from copr
Add a script to ensure that the llvm package installed comes from the copr repo. A failure in the script aborts the test plan
- Loading branch information
Jesus Checa Hidalgo
committed
Aug 27, 2024
1 parent
e93cddd
commit 5e95fa5
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# Script to assert that the llvm rpm installed during tmt prepare steps comes | ||
# from the copr repo and matches exactly. | ||
# Rely on dnf4 (/usr/bin/dnf-3) to avoid conflicts in newer Fedoras with dnf5. | ||
# The script expects $COPR_PROJECT envvar to check the repo. | ||
if [[ -z $COPR_PROJECT ]]; then | ||
echo "*** Missing COPR_PROJECT required environment variable." | ||
exit 1 | ||
fi | ||
|
||
# Ensure the repo is available | ||
if ! dnf-3 repolist | grep -q "$COPR_PROJECT"; then | ||
echo "*** copr repo $COPR_PROJECT not enabled in dnf" | ||
fi | ||
|
||
assert_package_match (){ | ||
local pkg=$1 | ||
local rpm_queryfmt="%{name}-%{version}-%{release}.%{arch}" | ||
local installed_pkg pkg_from_copr | ||
installed_pkg=$(rpm -q --qf "$rpm_queryfmt" "$pkg"."$(uname -m)") | ||
pkg_from_copr=$(dnf-3 -q --disablerepo=* --enablerepo=*"$COPR_PROJECT"* \ | ||
repoquery --queryformat "$rpm_queryfmt" "$pkg"."$(uname -m)") | ||
|
||
if [[ "$installed_pkg" != "$pkg_from_copr" ]]; then | ||
echo "*** Unexpected $pkg package installed: $installed_pkg" | ||
echo "*** Expected $pkg: $pkg_from_copr" | ||
exit 1 | ||
fi | ||
} | ||
|
||
for pkg in llvm clang; do | ||
assert_package_match "$pkg" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters