From e53e50f7a1e3b784d86541ca0e74fa561f69d70f Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Wed, 13 Mar 2024 19:36:45 +0530 Subject: [PATCH] [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 --- Makefile | 12 ++++++++++-- rpm/Makefile | 12 ++++++++++++ rpm/update-spec-version.sh | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 rpm/Makefile create mode 100644 rpm/update-spec-version.sh diff --git a/Makefile b/Makefile index 2e801fa2fc..f1ab6b8bf4 100644 --- a/Makefile +++ b/Makefile @@ -218,5 +218,13 @@ lint: install.tools # CAUTION: This is not a replacement for RPMs provided by your distro. # Only intended to build and test the latest unreleased changes. .PHONY: rpm -rpm: - rpkg local +rpm: ## Build rpm packages + $(MAKE) -C rpm + +# Remember that rpms install exec to /usr/bin/buildah while a `make install` +# installs them to /usr/local/bin/buildah which is likely before. Always use +# a full path to test installed buildah or you risk to call another executable. +.PHONY: rpm-install +rpm-install: package ## Install rpm packages + $(call err_if_empty,PKG_MANAGER) -y install rpm/RPMS/*/*.rpm + /usr/bin/buildah version diff --git a/rpm/Makefile b/rpm/Makefile new file mode 100644 index 0000000000..754de71628 --- /dev/null +++ b/rpm/Makefile @@ -0,0 +1,12 @@ +.PHONY: rpm +rpm: + $(shell /usr/bin/bash ./update-spec-version.sh) + spectool -g buildah.spec + rpmbuild -ba \ + --define '_sourcedir $(shell pwd)' \ + --define '_rpmdir %{_sourcedir}/RPMS' \ + --define '_srcrpmdir %{_sourcedir}/SRPMS' \ + --define '_builddir %{_sourcedir}/BUILD' \ + buildah.spec + @echo ___RPMS can be found in rpm/RPMS/.___ + @echo ___Undo any changes to Version, Source0 and %autosetup in rpm/buildah.spec before committing.___ diff --git a/rpm/update-spec-version.sh b/rpm/update-spec-version.sh new file mode 100644 index 0000000000..445b3c5da1 --- /dev/null +++ b/rpm/update-spec-version.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# This script will update the Version field in the spec which is set to 0 by +# default. Useful for local manual rpm builds where the Version needs to be set +# correctly. + +set -eox pipefail + +PACKAGE=buildah +SPEC_FILE=$PACKAGE.spec +VERSION=$(grep 'Version = ' ../define/types.go | cut -d\" -f2) +RPM_VERSION=$(echo $VERSION | sed -e 's/^v//' -e 's/-/~/g') + +# Update spec file to use local changes +sed -i "s/^Version:.*/Version: $RPM_VERSION/" $SPEC_FILE +sed -i "s/^Source:.*/Source: $PACKAGE-$VERSION.tar.gz/" $SPEC_FILE +sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE + +# Generate Source0 archive from HEAD +(cd .. && git archive --format=tar.gz --prefix=$PACKAGE-$VERSION/ HEAD -o rpm/$PACKAGE-$VERSION.tar.gz)