Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .packit-copr-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/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="containers-common"
SPEC_FILE=common/rpm/"$PACKAGE".spec

# Get Version from HEAD
VERSION=$(grep '^const Version' common/version/version.go | 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"/ common/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

# Update setup macro to use the correct build dir
sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" "$SPEC_FILE"
9 changes: 9 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ packages:
downstream_package_name: containers-common
specfile_path: common/rpm/containers-common.spec

srpm_build_deps:
- git-archive-all
- make

# 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
Expand Down
Loading