Skip to content

Commit

Permalink
add .packit.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
lsm5 committed Jul 21, 2023
1 parent effab47 commit 42ed153
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
39 changes: 39 additions & 0 deletions .packit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

# This script handles any custom processing of the spec file generated using the `post-upstream-clone`
# action and gets used by the fix-spec-file action in .packit.yaml.

set -eox pipefail

PACKAGE=crun

# Set path to rpm spec file
SPEC_FILE=rpm/$PACKAGE.spec

# Get Version from HEAD
VERSION=$(git describe)

# RPM Version can't take "-"
RPM_VERSION=$(echo $VERSION | sed -e 's/-/~/')

# Generate source tarball from HEAD
git-archive-all -v --force-submodules $PACKAGE-$VERSION.tar.xz

# rpmbuild expects source tarball in the same dir as spec file
mv podman-$VERSION.tar.xz rpm/

# 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.
# podman.spec is generated using `rpkg spec --outdir ./` as mentioned in the
# `post-upstream-clone` action in .packit.yaml.
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.xz/" $SPEC_FILE

# Update setup macro to use the correct build dir
sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE
8 changes: 3 additions & 5 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ jobs:
project: packit-builds
enable_net: true
srpm_build_deps:
- autoconf
- automake
- libtool
- git-archive-all
- make
actions:
post-upstream-clone:
- bash -c "./autogen.sh"
fix-spec-file:
- "bash .packit.sh"

- <<: *copr
# Run on commit to main branch
Expand Down

0 comments on commit 42ed153

Please sign in to comment.