Skip to content

Commit d856745

Browse files
committed
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 <[email protected]>
1 parent a928e25 commit d856745

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed

.packit.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
specfile_path: rpm/podman-bootc.spec
2+
upstream_tag_template: v{version}
3+
4+
# add or remove files that should be synced
5+
files_to_sync:
6+
- rpm/podman-bootc.spec
7+
- .packit.yaml
8+
9+
# name in upstream package repository or registry (e.g. in PyPI)
10+
upstream_package_name: podman-bootc
11+
# downstream (Fedora) RPM package name
12+
downstream_package_name: podman-bootc
13+
14+
srpm_build_deps:
15+
- git-archive-all
16+
- make
17+
- golang
18+
19+
actions:
20+
fix-spec-file:
21+
- "bash rpm/packit.sh"
22+
23+
jobs:
24+
- job: copr_build
25+
trigger: pull_request
26+
enable_net: true
27+
targets:
28+
- fedora-all-x86_64
29+

rpm/packit.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
set -eox pipefail
4+
5+
PACKAGE=podman-bootc
6+
7+
# Set path to rpm spec file
8+
SPEC_FILE=rpm/$PACKAGE.spec
9+
10+
# Get full version from HEAD
11+
VERSION=$(git describe --always --long --dirty)
12+
13+
# RPM Version can't take "-"
14+
RPM_VERSION="${VERSION//-/\~}"
15+
16+
# Generate source tarball from HEAD
17+
RPM_SOURCE_FILE=$PACKAGE-$VERSION.tar.gz
18+
git-archive-all -C "$(git rev-parse --show-toplevel)" --prefix="$PACKAGE-$RPM_VERSION/" "rpm/$RPM_SOURCE_FILE"
19+
20+
# Generate vendor dir
21+
RPM_VENDOR_FILE=$PACKAGE-$VERSION-vendor.tar.gz
22+
go mod vendor
23+
tar -czf "rpm/$RPM_VENDOR_FILE" vendor/
24+
25+
# RPM Spec modifications
26+
# Use the Version from HEAD in rpm spec
27+
sed -i "s/^Version:.*/Version: $RPM_VERSION/" $SPEC_FILE
28+
29+
# Use Packit's supplied variable in the Release field in rpm spec.
30+
sed -i "s/^Release:.*/Release: $PACKIT_RPMSPEC_RELEASE%{?dist}/" $SPEC_FILE
31+
32+
# Ensure last part of the release string is the git shortcommit without a prepended "g"
33+
sed -i "/^Release: $PACKIT_RPMSPEC_RELEASE%{?dist}/ s/\(.*\)g/\1/" $SPEC_FILE
34+
35+
# Use above generated tarballs as Sources in rpm spec
36+
sed -i "s/^Source0:.*/Source0: $RPM_SOURCE_FILE/" $SPEC_FILE
37+
sed -i "s/^Source1:.*/Source1: $RPM_VENDOR_FILE/" $SPEC_FILE

rpm/podman-bootc.spec

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# https://github.com/containers/podman-bootc
2+
%global goipath github.com/containers/podman-bootc
3+
Version: 0.1.1
4+
5+
%gometa -L -f
6+
7+
%global golicenses LICENSE
8+
%global godocs README.md
9+
10+
Name: podman-bootc
11+
Release: %autorelease
12+
Summary: Streamlining podman + bootc interactions
13+
14+
License: Apache-2.0
15+
URL: %{gourl}
16+
Source0: %{gosource}
17+
Source1: vendor.tar.gz # Vendor file place holder
18+
19+
BuildRequires: gcc
20+
BuildRequires: golang
21+
BuildRequires: make
22+
BuildRequires: libvirt-devel
23+
24+
Requires: xorriso
25+
Requires: podman
26+
Requires: qemu
27+
Requires: libvirt
28+
29+
%description
30+
%{summary}.
31+
32+
%gopkg
33+
34+
%prep
35+
%goprep -Ak # k: keep vendor directory
36+
%setup -T -D -a 1
37+
%autopatch -p1
38+
39+
%build
40+
export BUILDTAGS="exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp remote"
41+
%gobuild -o %{gobuilddir}/bin/%%{name} %{goipath}
42+
43+
%install
44+
%gopkginstall
45+
install -m 0755 -vd %{buildroot}%{_bindir}
46+
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
47+
48+
%files
49+
%license LICENSE
50+
%doc README.md
51+
%{_bindir}/*
52+
53+
%gopkgfiles
54+
55+
%changelog
56+
%autochangelog

0 commit comments

Comments
 (0)