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

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