1 #!/bin/sh 2 3 proj="iperf" 4 5 if [ "x$2" != "x" ]; then 6 tag=$2 7 else 8 tag=`awk '/IPERF_VERSION / { 9 gsub(/"/, "", $3); 10 print $3 }' src/version.h` 11 fi 12 13 dirname=`echo $tag $proj | awk '{ 14 gsub(/-ALPHA/, "a", $1); 15 gsub(/-BETA/, "b", $1); 16 gsub(/-RELEASE/, "", $1); 17 print $2"-"$1 }'` 18 19 # echo tag $tag 20 # echo dirname $dirname 21 22 do_tag () 23 { 24 git tag -s -m "tagging $tag" $tag 25 } 26 27 do_tar () 28 { 29 tarball=${dirname}.tar.gz 30 rm -f ${tarball} 31 git archive --format=tar --prefix ${dirname}/ ${tag} | gzip -9 > ${tarball} 32 33 # Compute SHA256 hash 34 case `uname -s` in 35 FreeBSD) sha=sha256 ;; 36 Linux) sha=sha256sum ;; 37 Darwin) sha="shasum -a 256" ;; 38 *) sha=echo ;; 39 esac 40 ${sha} ${tarball} | tee ${tarball}.sha256 41 } 42 43 usage () 44 { 45 cat <<EOF 46 $0: tag|tar 47 48 tag -- create a tag 49 tar -- create a tarball from a tag 50 51 General use is to do: 52 53 ./$0 tag 54 ./$0 tar 55 56 An optional argument may be specified to both the tag and tar 57 subcommands to explicitly specify a tag string. If not specified, the 58 contents of src/version.h are used. 59 60 EOF 61 } 62 63 case $1 in 64 tag) do_tag ;; 65 tar) do_tar ;; 66 *) echo "unknown command: $1"; usage ;; 67 esac 68 69 exit 70