diff mbox series

[V3] ndctl: Generalized make-git-snapshot.sh

Message ID 20190215235743.3591-1-ira.weiny@intel.com (mailing list archive)
State Accepted
Commit ab7650a34c09644d3786f5cf7ac755216213f7ee
Headers show
Series [V3] ndctl: Generalized make-git-snapshot.sh | expand

Commit Message

Ira Weiny Feb. 15, 2019, 11:57 p.m. UTC
From: Ira Weiny <ira.weiny@intel.com>

make-git-snapshot.sh made an assumption of the git tree location.

Furthermore, it assumed the user has an rpmbuild environment directory
structure set up.

Enhance the script to error out if not run in the root of the git tree
and create the output directory if the user does not already have it.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>

Changes since V2
	Don't use $0 to determine git tree location
	Instead expect user to run within root of git tree
		Error out if not

Changes since V1
	use rpmdev-setuptree

 make-git-snapshot.sh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/make-git-snapshot.sh b/make-git-snapshot.sh
index 142419d623fe..0b5de17a6d5c 100755
--- a/make-git-snapshot.sh
+++ b/make-git-snapshot.sh
@@ -2,10 +2,21 @@ 
 set -e
-REFDIR="$HOME/git/ndctl"  # for faster cloning, if available
+if [ ! -x ./git-version ]; then
+	echo "$0 : ERROR: Must run from top level of git tree"
+	exit 1
 UPSTREAM=$REFDIR #TODO update once we have a public upstream
+if [ ! -d $OUTDIR ]; then
+	mkdir -p $OUTDIR
 [ -n "$1" ] && HEAD="$1" || HEAD="HEAD"
 WORKDIR="$(mktemp -d --tmpdir "$NAME.XXXXXXXXXX")"