Prior to the meson conversion rpmbuild.sh with no arguments would find a
pre-created ndctl.spec file relative to the script. Restore that
behavior by looking for the script in the build/ directory, and try to
create it if not there.

Yes, this fails if someone picks a directory other than build/ for the
output directory, but build/ is conventional.

Another regression from autotools is the loss of support for building
"dirty" rpms i.e. rpms from git source trees with uncommitted changes.
At least provide a coherent error message for that case.

Reported-by: Jane Chu <[email protected]>
Reported-by: Vishal Verma <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
---
 rpmbuild.sh |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/rpmbuild.sh b/rpmbuild.sh
index b1f4d9e5c0f3..d9823e5eda61 100755
--- a/rpmbuild.sh
+++ b/rpmbuild.sh
@@ -4,6 +4,15 @@ spec=${1:-$(dirname $0)/rhel/ndctl.spec)}
 
 pushd $(dirname $0) >/dev/null
 [ ! -d ~/rpmbuild/SOURCES ] && echo "rpmdev tree not found" && exit 1
+if ./git-version | grep -q dirty; then
+       echo "Uncommitted changes detected, commit or undo them to proceed"
+       git status -uno --short
+       exit 1
+fi
+if [ ! -f $spec ]; then
+       meson compile -C build rhel/ndctl.spec
+       spec=$(dirname $0)/build/rhel/ndctl.spec
+fi
 ./make-git-snapshot.sh
 popd > /dev/null
 rpmbuild --nocheck -ba $spec


Reply via email to