Skip to content

Commit 1a519ac

Browse files
committed
[skip-ci] Makefile: update rpm target
rpkg is now deprecated. This commit makes the rpm target consistent with the one in Podman. Using skip-ci as we don't need to run cirrus tests for this change. Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
1 parent 1589b0a commit 1a519ac

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,13 @@ lint: install.tools
218218
# CAUTION: This is not a replacement for RPMs provided by your distro.
219219
# Only intended to build and test the latest unreleased changes.
220220
.PHONY: rpm
221-
rpm:
222-
rpkg local
221+
rpm: ## Build rpm packages
222+
$(MAKE) -C rpm
223+
224+
# Remember that rpms install exec to /usr/bin/buildah while a `make install`
225+
# installs them to /usr/local/bin/buildah which is likely before. Always use
226+
# a full path to test installed buildah or you risk to call another executable.
227+
.PHONY: rpm-install
228+
rpm-install: package ## Install rpm packages
229+
$(call err_if_empty,PKG_MANAGER) -y install rpm/RPMS/*/*.rpm
230+
/usr/bin/buildah version

rpm/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.PHONY: rpm
2+
rpm:
3+
$(shell /usr/bin/bash ./update-spec-version.sh)
4+
spectool -g buildah.spec
5+
rpmbuild -ba \
6+
--define '_sourcedir $(shell pwd)' \
7+
--define '_rpmdir %{_sourcedir}/RPMS' \
8+
--define '_srcrpmdir %{_sourcedir}/SRPMS' \
9+
--define '_builddir %{_sourcedir}/BUILD' \
10+
buildah.spec
11+
@echo ___RPMS can be found in rpm/RPMS/.___
12+
@echo ___Undo any changes to Version, Source0 and %autosetup in rpm/buildah.spec before committing.___

rpm/update-spec-version.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# This script will update the Version field in the spec which is set to 0 by
4+
# default. Useful for local manual rpm builds where the Version needs to be set
5+
# correctly.
6+
7+
set -eox pipefail
8+
9+
PACKAGE=buildah
10+
SPEC_FILE=$PACKAGE.spec
11+
VERSION=$(grep 'Version = ' ../define/types.go | cut -d\" -f2)
12+
RPM_VERSION=$(echo $VERSION | sed -e 's/^v//' -e 's/-/~/g')
13+
14+
# Update spec file to use local changes
15+
sed -i "s/^Version:.*/Version: $RPM_VERSION/" $SPEC_FILE
16+
sed -i "s/^Source:.*/Source: $PACKAGE-$VERSION.tar.gz/" $SPEC_FILE
17+
sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE
18+
19+
# Generate Source0 archive from HEAD
20+
(cd .. && git archive --format=tar.gz --prefix=$PACKAGE-$VERSION/ HEAD -o rpm/$PACKAGE-$VERSION.tar.gz)

0 commit comments

Comments
 (0)