Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Konflux imported: Get RPMs from build instead of from a (sub)task(s) #72

Merged
merged 11 commits into from
Dec 19, 2024
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.8.3
hooks:
- id: ruff-format
- id: ruff
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ repo file then you can find it in the `Repo Download` on the Copr page.

Currently, we don't build automatically because there are no tests and
an unnoticed push to `main` could silently break our RHEL/Fedora pipelines.
To create a new build:
To create a new SRPM, either:

- run `rpmdev-bumpspec mini-tps.spec` to bump the release in the spec file
- run `packit srpm --no-update-release` to create a SRPM
- Go to [@osci/mini-tps New Build](https://copr.fedorainfracloud.org/coprs/g/osci/mini-tps/add_build_upload),
select the SRPM file and hit `Build`
- run `packit srpm` or
- run `rpmdev-bumpspec mini-tps.spec` and `packit srpm --no-update-release`

Then, go to [@osci/mini-tps New Build](https://copr.fedorainfracloud.org/coprs/g/osci/mini-tps/add_build_upload),
select the SRPM file and hit `Build`

To enable the automatic builds, all you need to do is uncomment the `copr_build` job
in the [.packit.yaml](.packit.yaml).
Expand Down
7 changes: 6 additions & 1 deletion mini-tps.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Name: mini-tps
Version: 0.1
Release: 183%{?dist}
Release: 184%{?dist}
Summary: Mini TPS - Test Package Sanity

License: GPLv2
Expand Down Expand Up @@ -73,6 +73,11 @@ install -pD -m 0755 profiles/fedora/prepare-system %{buildroot}%{_libexecdir}/mi


%changelog
* Tue Dec 17 2024 Jiri Popelka <[email protected]> - 0.1-184
- Konflux imported: Get RPMs from build intead of from a (sub)task(s)
- Don't install redhat-internal-cert-install rpm
- viewer: ignore UTF-8 errors

* Fri Nov 01 2024 Michal Srb <[email protected]> - 0.1-183
- Remove Resilient Storage repos for 10

Expand Down
38 changes: 18 additions & 20 deletions mtps-get-builds
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ if [ -z "${YUMDNFCMD:-}" ]; then source "$(dirname "${BASH_SOURCE[0]}")/mtps-set
RET_NO_RPMS_IN_BREW=7
RET_NO_RPMS_IN_REPOS=8

rpms_from_answer() {
local arch="$1" && shift
local xml="$1" && shift
build_rpms_info2rpms() {
local arch="$1" && shift # architecture
local xml="$1" && shift # listBuildRPMs response
local tmpfile="$(mktemp)"
echo "$xml" > "$tmpfile"
local cmd="cat //member[value/string='$arch']/../member[name='nvr']/value/string/text()"
Expand All @@ -33,8 +33,8 @@ rpms_from_answer() {
echo "$rpm"
}

build_from_answer() {
local xml="$1" && shift
build_rpms_info2buid_id() {
local xml="$1" && shift # listBuildRPMs response
local build_id=
build_id="$(echo "$xml" | xmllint --xpath 'string(//member[name="build_id"]/value/int/text())' -)"
debug "Brew build id: $build_id"
Expand All @@ -55,18 +55,16 @@ brew_list_build_rpms() {
# Build can be: NVR or build number.
local build="$1" && shift
local re='^[0-9]+$'
if [[ $build =~ $re ]] ; then
build="<i4>$build</i4>"
fi
[[ $build =~ $re ]] && build="<i4>$build</i4>"
local query="$(cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>listBuildRPMs</methodName>
<params>
<value>$build</value>
<param>
</param>
</params>
<methodName>listBuildRPMs</methodName>
<params>
<param>
<value>$build</value>
</param>
</params>
</methodCall>
EOF
)"
Expand All @@ -83,7 +81,7 @@ mk_repo() {
repo_dir="${repo_dir%%/}"
local repo="$(cat << EOF
[brew-${brew_id}]
name=Repo for $brew_id Brew build
name=Brew build $brew_id repo
baseurl=file:///${repo_dir}/
enabled=$repo_enabled
gpgcheck=0
Expand Down Expand Up @@ -302,12 +300,12 @@ debug "Create repo: $GB_CREATEREPO"

build_rpms="$(brew_list_build_rpms $GB_BUILD)"
# rpms_from_build is a list of packages in form NVR: dhcp-relay-4.3.6-27.el8+7 dhcp-server-4.3.6-27.el8+7
rpms_from_build="$(rpms_from_answer "$GB_ARCH" "$build_rpms")"
rpms_from_build="$(build_rpms_info2rpms "$GB_ARCH" "$build_rpms")"
rpms_from_build_all="$rpms_from_build"
rpms_from_build_noarch="$(rpms_from_answer "noarch" "$build_rpms")"
rpms_from_build_noarch="$(build_rpms_info2rpms "noarch" "$build_rpms")"
rpms_from_build_noarch_all="$rpms_from_build_noarch"
srpm="$(rpms_from_answer "src" "$build_rpms").src.rpm"
brew_build_id="$(build_from_answer "$build_rpms")"
srpm="$(build_rpms_info2rpms "src" "$build_rpms").src.rpm"
brew_build_id="$(build_rpms_info2buid_id "$build_rpms")"
srpm_url="$(mk_url "$srpm" "${srpm%%.src.rpm}" "src")"

echo "Brew build ID: $brew_build_id"
Expand All @@ -323,7 +321,7 @@ if [ -n "$GB_ONLYINREPO" ]; then
# Purpose:
#
# * Brew builds always have 1 input SRPM.
# * Brew builds can have many PRM.
# * Brew builds can have many RPMs.
#
# RCM team can choose only some RPM. And make AppStream / BaseOS / Compose
# only from some RPMs, ignoring other RPMs from Brew build. This options
Expand Down
32 changes: 17 additions & 15 deletions mtps-get-module
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,19 @@ send_query() {

brew_get_build() {
# getBuild query
# Build can be: NVR or build number.
# Build can be: int ID or a string NVR
local build="$1" && shift
local re='^[0-9]+$'
[[ $build =~ $re ]] && build="<int>$build</int>"
local query="$(cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>getBuild</methodName>
<params>
<value>$build</value>
<param>
</param>
</params>
<methodName>getBuild</methodName>
<params>
<param>
<value>$build</value>
</param>
</params>
</methodCall>
EOF
)"
Expand All @@ -118,17 +120,17 @@ EOF

brew_get_latest_builds() {
# getLatestBuilds query
# Build can be: NVR or build number.
local tag="$1" && shift
# Tag is int (ID)
local tag_id="$1" && shift
local query="$(cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>getLatestBuilds</methodName>
<params>
<value>$tag</value>
<param>
</param>
</params>
<methodName>getLatestBuilds</methodName>
<params>
<param>
<value><int>$tag_id</int></value>
</param>
</params>
</methodCall>
EOF
)"
Expand Down
Loading
Loading