Blame SOURCES/0141-build-Automate-rpmbuild.sh.patch

2eb93d
From 55f36387ee8a88c489863103347ae275b1bc9191 Mon Sep 17 00:00:00 2001
2eb93d
From: Dan Williams <dan.j.williams@intel.com>
2eb93d
Date: Wed, 23 Feb 2022 18:41:45 -0800
2eb93d
Subject: [PATCH 141/217] build: Automate rpmbuild.sh
2eb93d
2eb93d
Prior to the meson conversion rpmbuild.sh with no arguments would find a
2eb93d
pre-created ndctl.spec file relative to the script. Restore that
2eb93d
behavior by looking for the script in the build/ directory, and try to
2eb93d
create it if not there.
2eb93d
2eb93d
Yes, this fails if someone picks a directory other than build/ for the
2eb93d
output directory, but build/ is conventional.
2eb93d
2eb93d
Another regression from autotools is the loss of support for building
2eb93d
"dirty" rpms i.e. rpms from git source trees with uncommitted changes.
2eb93d
At least provide a coherent error message for that case.
2eb93d
2eb93d
Link: https://lore.kernel.org/r/164567050589.2266739.68846452427328787.stgit@dwillia2-desk3.amr.corp.intel.com
2eb93d
Reported-by: Jane Chu <jane.chu@oracle.com>
2eb93d
Reported-by: Vishal Verma <vishal.l.verma@intel.com>
2eb93d
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2eb93d
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
2eb93d
---
2eb93d
 rpmbuild.sh | 9 +++++++++
2eb93d
 1 file changed, 9 insertions(+)
2eb93d
2eb93d
diff --git a/rpmbuild.sh b/rpmbuild.sh
2eb93d
index b1f4d9e..d9823e5 100755
2eb93d
--- a/rpmbuild.sh
2eb93d
+++ b/rpmbuild.sh
2eb93d
@@ -4,6 +4,15 @@ spec=${1:-$(dirname $0)/rhel/ndctl.spec)}
2eb93d
 
2eb93d
 pushd $(dirname $0) >/dev/null
2eb93d
 [ ! -d ~/rpmbuild/SOURCES ] && echo "rpmdev tree not found" && exit 1
2eb93d
+if ./git-version | grep -q dirty; then
2eb93d
+	echo "Uncommitted changes detected, commit or undo them to proceed"
2eb93d
+	git status -uno --short
2eb93d
+	exit 1
2eb93d
+fi
2eb93d
+if [ ! -f $spec ]; then
2eb93d
+	meson compile -C build rhel/ndctl.spec
2eb93d
+	spec=$(dirname $0)/build/rhel/ndctl.spec
2eb93d
+fi
2eb93d
 ./make-git-snapshot.sh
2eb93d
 popd > /dev/null
2eb93d
 rpmbuild --nocheck -ba $spec
2eb93d
-- 
2eb93d
2.27.0
2eb93d