git2tarxz.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. # Create source tarball from rju (aka jack-tools) git repo, with
  3. # generated version number.
  4. # Note that this script doesn't need to be run as root. It does need to
  5. # be able to write to the current directory it's run from.
  6. # Takes one optional argument, which is the commit or tag to create a
  7. # tarball of. With no arg, HEAD is used.
  8. PRGNAM=jack-tools
  9. CLONE_URL=https://gitlab.com/rd--/rju.git
  10. set -e
  11. GITDIR=$( mktemp -dt $PRGNAM.git.XXXXXX )
  12. rm -rf $GITDIR
  13. git clone --depth 1 $CLONE_URL $GITDIR
  14. CWD="$( pwd )"
  15. cd $GITDIR
  16. if [ "$1" != "" ]; then
  17. git reset --hard "$1" || exit 1
  18. fi
  19. git submodule update --init --recursive --depth 1
  20. GIT_SHA=$( git rev-parse --short HEAD )
  21. DATE=$( git log --date=format:%Y%m%d --format=%cd | head -1 )
  22. VERSION=${DATE}_${GIT_SHA}
  23. rm -rf .git cmd/r-common/.git
  24. cd "$CWD"
  25. rm -rf $PRGNAM-$VERSION $PRGNAM-$VERSION.tar.xz
  26. mv $GITDIR $PRGNAM-$VERSION
  27. tar cvfJ $PRGNAM-$VERSION.tar.xz $PRGNAM-$VERSION
  28. echo
  29. echo "Created tarball: $PRGNAM-$VERSION.tar.xz"
  30. echo "VERSION=$VERSION"