Some buildsystem fixes for optional modules and Qt vars
[quassel.git] / scripts / build / macosx_makePackage.sh
1 #!/bin/bash
2
3 myname=$0
4 if [ -s "$myname" ] && [ -x "$myname" ]; then
5     # $myname is already a valid file name
6
7     mypath=$myname
8 else
9     case "$myname" in
10     /*) exit 1;;             # absolute path - do not search PATH
11     *)
12         # Search all directories from the PATH variable. Take
13         # care to interpret leading and trailing ":" as meaning
14         # the current directory; the same is true for "::" within
15         # the PATH.
16     
17         # Replace leading : with . in PATH, store in p
18         p=${PATH/#:/.:}
19         # Replace trailing : with .
20         p=${p//%:/:.}
21         # Replace :: with :.:
22         p=${p//::/:.:}
23         # Temporary input field separator, see FAQ #1
24         OFS=$IFS IFS=:
25         # Split the path on colons and loop through each of them
26         for dir in $p; do
27                 [ -f "$dir/$myname" ] || continue # no file
28                 [ -x "$dir/$myname" ] || continue # not executable
29                 mypath=$dir/$myname
30                 break           # only return first matching file
31         done
32         # Restore old input field separator
33         IFS=$OFS
34         ;;
35     esac
36 fi
37
38 if [ ! -f "$mypath" ]; then
39     echo >&2 "cannot find full path name: $myname"
40     exit 1
41 fi
42
43 SCRIPTDIR=$(dirname $mypath)
44 QUASSEL_VERSION=$(git-describe)
45 BUILDTYPE=$1
46
47 # check the working dir
48 WORKINGDIR=$2
49 if [[ ! -n $2 ]]; then
50     WORKINGDIR="."
51 fi
52 WORKINGDIR="${WORKINGDIR}/"
53 PACKAGETMPDIR="${WORKINGDIR}PACKAGE_TMP_DIR_${BUILDTYPE}"
54 if [[ $BUILDTYPE = "Core" ]] || [[ $BUILDTYPE = "Client" ]]; then
55     QUASSEL_DMG="Quassel${BUILDTYPE}_MacOSX-universal_${QUASSEL_VERSION}.dmg"
56     mkdir $PACKAGETMPDIR
57     if [[ $BUILDTYPE = "Client" ]]; then
58         cp -r ${WORKINGDIR}Quassel\ Client.app ${PACKAGETMPDIR}/
59         ${SCRIPTDIR}/macosx_DeployApp.py "${PACKAGETMPDIR}/Quassel Client.app"
60     else
61         cp ${WORKINGDIR}quasselcore ${PACKAGETMPDIR}/
62         ${SCRIPTDIR}/macosx_DeployApp.py --nobundle ${PACKAGETMPDIR}
63     fi
64     hdiutil create -srcfolder ${PACKAGETMPDIR} -format UDBZ -volname "Quassel ${BUILDTYPE} - ${QUASSEL_VERSION}" "${WORKINGDIR}Quassel${BUILDTYPE}_MacOSX-universal_${QUASSEL_VERSION}.dmg" >/dev/null
65     rm -rf ${PACKAGETMPDIR}
66 else
67     echo >&2 "Valid parameters are \"Client\" or \"Core\""
68 fi