-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy path.packit-copr-rpm.sh
More file actions
36 lines (24 loc) · 1.14 KB
/
.packit-copr-rpm.sh
File metadata and controls
36 lines (24 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 -exo pipefail
PACKAGE=aardvark-dns
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"