diff mbox series

ndctl: Generalized make-git-snapshot.sh

Message ID 20190215192117.28605-1-ira.weiny@intel.com (mailing list archive)
State Superseded
Headers show
Series ndctl: Generalized make-git-snapshot.sh | expand

Commit Message

Ira Weiny Feb. 15, 2019, 7:21 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 figure out where in what location it has been
cloned and create the rpmbuild directory if the user does not already
have it.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 make-git-snapshot.sh | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Dan Williams Feb. 15, 2019, 7:31 p.m. UTC | #1
On Fri, Feb 15, 2019 at 11:21 AM <ira.weiny@intel.com> wrote:
>
> 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 figure out where in what location it has been
> cloned and create the rpmbuild directory if the user does not already
> have it.
>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> ---
>  make-git-snapshot.sh | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/make-git-snapshot.sh b/make-git-snapshot.sh
> index 142419d623fe..26e29bd7953d 100755
> --- a/make-git-snapshot.sh
> +++ b/make-git-snapshot.sh
> @@ -2,10 +2,18 @@
>  set -e
>
>  NAME=ndctl
> -REFDIR="$HOME/git/ndctl"  # for faster cloning, if available
> +
> +pushd `dirname $0`
> +REFDIR=`pwd`
> +popd
> +
>  UPSTREAM=$REFDIR #TODO update once we have a public upstream
>  OUTDIR=$HOME/rpmbuild/SOURCES
>
> +if [ ! -d $OUTDIR ]; then
> +       mkdir -p $OUTDIR

Shouldn't this be rpmdev-setuptree?
Ira Weiny Feb. 15, 2019, 8:01 p.m. UTC | #2
On Fri, Feb 15, 2019 at 11:31:46AM -0800, Dan Williams wrote:
> On Fri, Feb 15, 2019 at 11:21 AM <ira.weiny@intel.com> wrote:
> >
> > 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 figure out where in what location it has been
> > cloned and create the rpmbuild directory if the user does not already
> > have it.
> >
> > Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> > ---
> >  make-git-snapshot.sh | 12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/make-git-snapshot.sh b/make-git-snapshot.sh
> > index 142419d623fe..26e29bd7953d 100755
> > --- a/make-git-snapshot.sh
> > +++ b/make-git-snapshot.sh
> > @@ -2,10 +2,18 @@
> >  set -e
> >
> >  NAME=ndctl
> > -REFDIR="$HOME/git/ndctl"  # for faster cloning, if available
> > +
> > +pushd `dirname $0`
> > +REFDIR=`pwd`
> > +popd
> > +
> >  UPSTREAM=$REFDIR #TODO update once we have a public upstream
> >  OUTDIR=$HOME/rpmbuild/SOURCES
> >
> > +if [ ! -d $OUTDIR ]; then
> > +       mkdir -p $OUTDIR
> 
> Shouldn't this be rpmdev-setuptree?

Sure looks like it...

I never knew about that command...

Ira
diff mbox series

Patch

diff --git a/make-git-snapshot.sh b/make-git-snapshot.sh
index 142419d623fe..26e29bd7953d 100755
--- a/make-git-snapshot.sh
+++ b/make-git-snapshot.sh
@@ -2,10 +2,18 @@ 
 set -e
 
 NAME=ndctl
-REFDIR="$HOME/git/ndctl"  # for faster cloning, if available
+
+pushd `dirname $0`
+REFDIR=`pwd`
+popd
+
 UPSTREAM=$REFDIR #TODO update once we have a public upstream
 OUTDIR=$HOME/rpmbuild/SOURCES
 
+if [ ! -d $OUTDIR ]; then
+	mkdir -p $OUTDIR
+fi
+
 [ -n "$1" ] && HEAD="$1" || HEAD="HEAD"
 
 WORKDIR="$(mktemp -d --tmpdir "$NAME.XXXXXXXXXX")"
@@ -14,7 +22,7 @@  trap 'rm -rf $WORKDIR' exit
 [ -d "$REFDIR" ] && REFERENCE="--reference $REFDIR"
 git clone $REFERENCE "$UPSTREAM" "$WORKDIR"
 
-VERSION=$(./git-version)
+VERSION=$($REFDIR/git-version)
 DIRNAME="ndctl-${VERSION}"
 git archive --remote="$WORKDIR" --format=tar --prefix="$DIRNAME/" HEAD | gzip > $OUTDIR/"ndctl-${VERSION}.tar.gz"