From 5314be5288e0ddbb77eb2e9b15ddf591d8e7468e Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Tue, 19 Aug 2025 09:11:55 -0400 Subject: [PATCH] Packit: fetch copr rpm version from Cargo.toml Current installation of nv from podman-next is failing because it's expecting aardvark-dns >= 102:1.16 while current av on podman-next is only 102:1.15 . From the latest build log, that seems to be because Packit is determining 1.15.0 as the version for av and 1.16.0 as the version for nv. This commit includes a script to fetch the version directly from Cargo.toml. A similar script will be added to av, thus ensuring both nv and av major.minor versions are in sync for copr rpms as well. Related: https://github.com/containers/aardvark-dns/pull/625/ Signed-off-by: Lokesh Mandvekar --- .packit-copr-rpm.sh | 36 ++++++++++++++++++++++++++++++++++++ .packit.yaml | 6 ++++++ 2 files changed, 42 insertions(+) create mode 100644 .packit-copr-rpm.sh diff --git a/.packit-copr-rpm.sh b/.packit-copr-rpm.sh new file mode 100644 index 0000000..e3a8d81 --- /dev/null +++ b/.packit-copr-rpm.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# This script handles any custom processing of the spec file using the `fix-spec-file` +# action in .packit.yaml. These steps only work on copr builds, not on official +# Fedora builds. + +set -uexo pipefail + +PACKAGE=netavark +SPEC_FILE=rpm/"$PACKAGE".spec + +# Get Version from HEAD +VERSION=$(grep '^version' Cargo.toml | cut -d\" -f2) + +# RPM Version can't take "-" +RPM_VERSION="${VERSION//-/\~}" + +# Generate source tarball from HEAD +git-archive-all -C "$(git rev-parse --show-toplevel)" --prefix="$PACKAGE"-"$VERSION"/ rpm/"$PACKAGE"-"$VERSION".tar.gz + +# RPM Spec modifications + +# Use the Version from HEAD in rpm spec +sed -i "s/^Version:.*/Version: $RPM_VERSION/" "$SPEC_FILE" + +# Use Packit's supplied variable in the Release field in rpm spec. +sed -i "s/^Release:.*/Release: $PACKIT_RPMSPEC_RELEASE%{?dist}/" "$SPEC_FILE" + +# Use above generated tarball as Source in rpm spec +sed -i "s/^Source0:.*.tar.gz/Source0: $PACKAGE-$VERSION.tar.gz/" $SPEC_FILE + +# Don't need Source1 for copr builds +sed -i "/^Source1/d" "$SPEC_FILE" + +# Update setup macro to use the correct build dir +sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" "$SPEC_FILE" diff --git a/.packit.yaml b/.packit.yaml index bcfce01..07ecd3e 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -15,9 +15,15 @@ packages: srpm_build_deps: - cargo + - git-archive-all - make - openssl-devel +# https://packit.dev/docs/configuration/actions +# fix-spec-file only operates on copr builds and doesn't affect official distro builds +actions: + fix-spec-file: "bash .packit-copr-rpm.sh" + jobs: - job: copr_build trigger: pull_request