#!/bin/bash # mk-tar-git-rev ######################## # This script will clone or update git master # and create a tarball using the specified githash. # Run this in SOURCES: $ ./mk-tar-git-rev # ###################### name="phototonic" url="https://github.com/oferkv/phototonic.git" # Update or clone git echo "Please wait - this may take some time ..." if [[ -d $name ]]; then cd $name git pull cd .. else git clone "$url" $name fi # Get version, revision and githash from git gitdesc() { desc=$(git describe $1) ver=$(echo $desc | cut -d- -f1 | sed 's/v//') rev=$(echo $desc | cut -d- -f2) hash=$(echo $desc | cut -d- -f3 | sed 's/g//') #cd .. } cd $name echo "####################################" git log --oneline|head -n10 echo "####################################" gitdesc echo "Current HEAD is at $desc" hash=$(git log --oneline|head -n1|cut -d' ' -f1) read -e -i "$hash" -p "Enter the git hash to use: " hash git checkout $hash gitdesc $hash cd .. rm -rf $name-$ver.$rev mv $name $name-$ver.$rev tar --exclude=.git -czf "$name-$ver.$rev.tar.gz" $name-$ver.$rev/ && \ echo "#####################################" && \ echo "Written $name-$ver.$rev.tar.gz" && \ echo "#####################################" mv $name-$ver.$rev $name cd $name git checkout master cd ..