refactored profile support handling a bit
[profile/ivi/bluetooth-qt.git] / makedist
1 #!/bin/bash
2
3
4
5
6 # Determine project name based on current directory
7 PROJECT=$(basename $PWD)
8
9 # NOTE: Don't like this?  Then uncomment one of the following as appropriate
10 #
11 # Just set it explictly to whatever you like:
12 # PROJECT=libseaside
13 #
14 # Parse it from any Qt *.pro or *.pri files in CWD:
15 # PROJECT=$(grep -E "TARGET ?= ?" *.pr[io]|cut -d' ' -f3)
16
17 while getopts ht: o
18 do   case $o in
19    h)   head=1;;
20    t)   TAG="$OPTARG";;
21    ?) printf >&2 "Usage: $0 [-h] [-t TAG]\n"
22       exit 2;;
23    esac
24 done
25
26 # Grab most recent tag from git unless TAG is set
27 if [ -z "$TAG" ] ; then 
28   TAG=$(git describe --tags --abbrev=0)
29 fi
30
31 # Parse out just the version number
32 #PARTS=(${TAG//-/ })
33 #VERSION=${PARTS[1]}
34 VERSION=${TAG}
35
36 # Set name of toplevel directory for the archive
37 PREFIX="${PROJECT}-${VERSION}/"
38
39 # Set name of resulting release archive file
40 ARCHIVE=${PROJECT}-${VERSION}.tar.bz2
41
42 [ -e ${ARCHIVE} ] && rm -rf ${ARCHIVE} && echo "Removed: ${ARCHIVE}"
43
44 if [ ! -z "$head" ] ; then
45   TAG="HEAD"
46 fi
47
48 git archive --format=tar --prefix=${PREFIX} $TAG | bzip2 -c -- > ${ARCHIVE} && {
49         echo "Created: ${ARCHIVE}"
50 } || {
51         echo "Creation of release archive ${ARCHIVE} failed.  Reason unknown."
52 }