forked from rpm-software-management/mock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testing-farm: install the correct package versions
- Loading branch information
Showing
3 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
mock/integration-tests/setup-playbook/files/install-copr-packages
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,98 @@ | ||
#! /bin/bash | ||
|
||
# Install an RPM package (and its dependencies) identified by | ||
# the (a) package name, (b) upstream commmit and (c) Copr directory. The short | ||
# variant of the upstream commit must be part of the package Release tag. | ||
# | ||
# ARG1: coprowner/projectname:dir or https:// | ||
# ARG2: upstream-commit | ||
# ARGN: packagename1 packagename2 ... | ||
|
||
# TODO: DNF5/YUM compat? | ||
DNF=/usr/bin/dnf-3 | ||
REPOQUERY=( "$DNF" repoquery ) | ||
|
||
copr_dir=$1 ; shift | ||
commit=${1} ; shift | ||
copr_uri=https://download.copr.fedorainfracloud.org/results | ||
|
||
copr_chroot() ( | ||
# mimic: https://github.com/rpm-software-management/dnf5/blob/c6edcd75260accf7070f261e5b406fcf1f5db328/dnf5-plugins/copr_plugin/copr_config.cpp#L71-L80 | ||
. /etc/os-release | ||
name=$ID | ||
version=$VERSION_ID | ||
arch=$(rpm --eval %_arch) | ||
if test "$name" = fedora; then | ||
if test "$REDHAT_SUPPORT_PRODUCT_VERSION" = rawhide; then | ||
version=rawhide | ||
fi | ||
fi | ||
echo "$name-$version-$arch" | ||
) | ||
|
||
repo=$copr_uri/$copr_dir/$(copr_chroot) | ||
|
||
echo >&2 "using repo: $repo" | ||
|
||
repoid=xyztest | ||
|
||
export clean_cache=true | ||
|
||
|
||
repos=( "--repofrompath=$repoid,$repo" ) | ||
|
||
_repoquery() { | ||
local opts=( "${repos[@]}" --disablerepo='*' --enablerepo "$repoid" ) | ||
if ${clean_cache-true}; then | ||
opts+=( "--setopt=$repoid.metadata_expire=1" ) | ||
fi | ||
local cmd=( "${REPOQUERY[@]}" "${opts[@]}" "$@" ) | ||
info "Executing: ${cmd[*]}" | ||
"${cmd[@]}" 2>/dev/null | ||
} | ||
|
||
info() { echo >&2 "INFO: $*" ; } | ||
error() { echo >&2 "ERROR: $*" ; false; } | ||
die() { echo >&2 "FATAL: $*" ; exit 1 ; } | ||
|
||
find_nvr() { | ||
# ARGS: $1=pkg $2=commit | ||
# RETURN: $find_nvr_result | ||
# STATUS: true if found | ||
local _pkgname=$1 _commit=${2:0:7} _found=false | ||
while read -r name version release; do | ||
test -z "$name" && continue | ||
test "$name" = "$_pkgname" || continue | ||
case $release in | ||
*$_commit*) | ||
find_nvr_result=$name-$version-$release | ||
$_found && error "second occurence of $name-$version-$release" | ||
_found=true | ||
;; | ||
*) | ||
continue | ||
;; | ||
esac | ||
done < <( _repoquery --qf='%{NAME} %{VERSION} %{RELEASE}\n' ) | ||
$_found || error "$_pkgname with $commit in release not found" | ||
} | ||
|
||
nvrs=() | ||
SECONDS=0 | ||
TIMEOUT=${TIMEOUT-1200} # 20 minutes by default | ||
for pkg; do | ||
while true; do | ||
if find_nvr "$pkg" "$commit"; then | ||
nvrs+=( "$find_nvr_result" ) | ||
clean_cache=false | ||
break | ||
fi | ||
test "$SECONDS" -gt "$TIMEOUT" && die "The timeout ${TIMEOUT}s left" | ||
clean_cache=true | ||
sleep 5 | ||
done | ||
done | ||
|
||
cmd=( "$DNF" -y install "${nvrs[@]}" "${repos[@]}" --nogpgcheck ) | ||
info "Running: ${cmd[*]}" | ||
"${cmd[@]}" |
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
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 |
---|---|---|
@@ -1,4 +1,11 @@ | ||
#!/bin/sh -eux | ||
#!/bin/sh -xe | ||
|
||
test -n "$PACKIT_COPR_PROJECT" || { | ||
PACKIT_COPR_PROJECT=@mock/mock | ||
PACKIT_COMMIT_SHA=$(curl -H "Accept: application/vnd.github.VERSION.sha" https://api.github.com/repos/rpm-software-management/mock/commits/main) | ||
} | ||
|
||
install-copr-packages "$PACKIT_COPR_PROJECT" "$PACKIT_COMMIT_SHA" mock-core-configs mock | ||
|
||
cd ../../../behave | ||
behave |