From d8567452ad09168524558b977c4a1fbba6ef533a Mon Sep 17 00:00:00 2001 From: German Maglione Date: Mon, 3 Jun 2024 11:54:48 +0200 Subject: [PATCH] Add packit initial support Adds a rpm spec file and packit configuration to trigger copr rpm builds on every merge request. Signed-off-by: German Maglione --- .packit.yaml | 29 ++++++++++++++++++++++ rpm/packit.sh | 37 ++++++++++++++++++++++++++++ rpm/podman-bootc.spec | 56 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 .packit.yaml create mode 100644 rpm/packit.sh create mode 100644 rpm/podman-bootc.spec diff --git a/.packit.yaml b/.packit.yaml new file mode 100644 index 00000000..f7eeb4a7 --- /dev/null +++ b/.packit.yaml @@ -0,0 +1,29 @@ +specfile_path: rpm/podman-bootc.spec +upstream_tag_template: v{version} + +# add or remove files that should be synced +files_to_sync: + - rpm/podman-bootc.spec + - .packit.yaml + +# name in upstream package repository or registry (e.g. in PyPI) +upstream_package_name: podman-bootc +# downstream (Fedora) RPM package name +downstream_package_name: podman-bootc + +srpm_build_deps: + - git-archive-all + - make + - golang + +actions: + fix-spec-file: + - "bash rpm/packit.sh" + +jobs: + - job: copr_build + trigger: pull_request + enable_net: true + targets: + - fedora-all-x86_64 + diff --git a/rpm/packit.sh b/rpm/packit.sh new file mode 100644 index 00000000..afc0802d --- /dev/null +++ b/rpm/packit.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -eox pipefail + +PACKAGE=podman-bootc + +# Set path to rpm spec file +SPEC_FILE=rpm/$PACKAGE.spec + +# Get full version from HEAD +VERSION=$(git describe --always --long --dirty) + +# RPM Version can't take "-" +RPM_VERSION="${VERSION//-/\~}" + +# Generate source tarball from HEAD +RPM_SOURCE_FILE=$PACKAGE-$VERSION.tar.gz +git-archive-all -C "$(git rev-parse --show-toplevel)" --prefix="$PACKAGE-$RPM_VERSION/" "rpm/$RPM_SOURCE_FILE" + +# Generate vendor dir +RPM_VENDOR_FILE=$PACKAGE-$VERSION-vendor.tar.gz +go mod vendor +tar -czf "rpm/$RPM_VENDOR_FILE" vendor/ + +# 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 + +# Ensure last part of the release string is the git shortcommit without a prepended "g" +sed -i "/^Release: $PACKIT_RPMSPEC_RELEASE%{?dist}/ s/\(.*\)g/\1/" $SPEC_FILE + +# Use above generated tarballs as Sources in rpm spec +sed -i "s/^Source0:.*/Source0: $RPM_SOURCE_FILE/" $SPEC_FILE +sed -i "s/^Source1:.*/Source1: $RPM_VENDOR_FILE/" $SPEC_FILE diff --git a/rpm/podman-bootc.spec b/rpm/podman-bootc.spec new file mode 100644 index 00000000..adbcb228 --- /dev/null +++ b/rpm/podman-bootc.spec @@ -0,0 +1,56 @@ +# https://github.com/containers/podman-bootc +%global goipath github.com/containers/podman-bootc +Version: 0.1.1 + +%gometa -L -f + +%global golicenses LICENSE +%global godocs README.md + +Name: podman-bootc +Release: %autorelease +Summary: Streamlining podman + bootc interactions + +License: Apache-2.0 +URL: %{gourl} +Source0: %{gosource} +Source1: vendor.tar.gz # Vendor file place holder + +BuildRequires: gcc +BuildRequires: golang +BuildRequires: make +BuildRequires: libvirt-devel + +Requires: xorriso +Requires: podman +Requires: qemu +Requires: libvirt + +%description +%{summary}. + +%gopkg + +%prep +%goprep -Ak # k: keep vendor directory +%setup -T -D -a 1 +%autopatch -p1 + +%build +export BUILDTAGS="exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp remote" +%gobuild -o %{gobuilddir}/bin/%%{name} %{goipath} + +%install +%gopkginstall +install -m 0755 -vd %{buildroot}%{_bindir} +install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ + +%files +%license LICENSE +%doc README.md +%{_bindir}/* + +%gopkgfiles + +%changelog +%autochangelog