Debian Codegraph @

bin/build-deploy-csoundqt-osx.sh

raw symbols SCIP
1 #!/usr/bin/env
2 #############################################################################
3 # Bash-script to build and deployment the csoundqt-d-py-cs6-osx-0.9.2.app #
4 # 2016 by Johannes Schütt & Tarmo Johannes #
5 # GNU Licences #
6 # #
7 #############################################################################
8
9 # create the build-path e.g. <cd ~/src/>
10 # go to https://csoundqt.github.io
11 # cd ~/src
12 # git clone https://github.com/CsoundQt/CsoundQt.git
13 # then start build
14 DATE=`date +%Y-%m-%d`
15
16 cd ~/src/CsoundQt
17 rm -rf ~/src/CsoundQt/bin/CsoundQt-d-py-cs6-0.9.2-${DATE}.dmg
18 rm -rf ~/src/CsoundQt/bin/CsoundQt-d-py-cs6.app
19 git pull
20 make clean
21 ~/Qt5.4.2/5.4/clang_64/bin/qmake /Users/jschuet1/src/CsoundQt/qcs.pro -r -spec macx-clang CONFIG+=x86_64CONFIG+=rtmidi CONFIG+=pythonqt CONFIG+=release CONFIG+=record_support CONFIG+=debugger
22 make
23 make install
24 # written into qcs.pro
25 #install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python Python.framework/Versions/2.7/Python ~/src/CsoundQt/bin/CsoundQt-d-py-cs6.app/Contents/MacOS/CsoundQt-d-py-cs6
26 #install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python Python.framework/Versions/2.7/Python ~/src/CsoundQt/bin/CsoundQt-d-py-cs6.app/Contents/Frameworks/libPythonQt.1.dylib
27 #install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python Python.framework/Versions/2.7/Python ~/src/CsoundQt/bin/CsoundQt-d-py-cs6.app/Contents/Frameworks/libPythonQt_QtAll.1.dylib
28 echo "-------> DONE!"
29 sleep 2
30 echo "---> now I create the DMG"
31
32 #create the dmg
33 cd ~/src/CsoundQt/bin/
34
35 # Mount the disk image
36 # by Andy Maloney
37 # http://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/
38
39 # make sure we are in the correct dir when we double-click a .command file
40 dir=${0%/*}
41 if [ -d "$dir" ]; then
42 cd "$dir"
43 fi
44
45 # set up your app name, version number, and background image file name
46 APP_NAME="CsoundQt-d-py-cs6"
47 VERSION="0.9.2.1"
48 DMG_BACKGROUND_IMG="Background.png"
49
50
51 # you should not need to change these
52 APP_EXE="${APP_NAME}.app/Contents/MacOS/${APP_NAME}"
53
54 VOL_NAME="${APP_NAME}-${VERSION}" # volume name will be "SuperCoolApp 1.0.0"
55 DMG_TMP="${VOL_NAME}-temp.dmg"
56 DMG_FINAL="${VOL_NAME}-${DATE}.dmg" # final DMG name will be "SuperCoolApp 1.0.0.dmg"
57 STAGING_DIR="./Install" # we copy all our stuff into this dir
58
59 # Check the background image DPI and convert it if it isn't 72x72
60 _BACKGROUND_IMAGE_DPI_H=`sips -g dpiHeight ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'`
61 _BACKGROUND_IMAGE_DPI_W=`sips -g dpiWidth ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'`
62
63 if [ $(echo " $_BACKGROUND_IMAGE_DPI_H != 72.0 " | bc) -eq 1 -o $(echo " $_BACKGROUND_IMAGE_DPI_W != 72.0 " | bc) -eq 1 ]; then
64 echo "WARNING: The background image's DPI is not 72. This will result in distorted backgrounds on Mac OS X 10.7+."
65 echo " I will convert it to 72 DPI for you."
66
67 _DMG_BACKGROUND_TMP="${DMG_BACKGROUND_IMG%.*}"_dpifix."${DMG_BACKGROUND_IMG##*.}"
68
69 sips -s dpiWidth 72 -s dpiHeight 72 ${DMG_BACKGROUND_IMG} --out ${_DMG_BACKGROUND_TMP}
70
71 DMG_BACKGROUND_IMG="${_DMG_BACKGROUND_TMP}"
72 fi
73
74 # clear out any old data
75 rm -rf "${STAGING_DIR}" "${DMG_TMP}" "${DMG_FINAL}"
76
77 # copy over the stuff we want in the final disk image to our staging dir
78 mkdir -p "${STAGING_DIR}"
79 cp -rpf "${APP_NAME}.app" "${STAGING_DIR}"
80 # ... cp anything else you want in the DMG - documentation, etc.
81
82 pushd "${STAGING_DIR}"
83
84 # strip the executable
85 echo "Stripping ${APP_EXE}..."
86 strip -u -r "${APP_EXE}"
87
88 # compress the executable if we have upx in PATH
89 # UPX: http://upx.sourceforge.net/
90 if hash upx 2>/dev/null; then
91 echo "Compressing (UPX) ${APP_EXE}..."
92 upx -9 "${APP_EXE}"
93 fi
94
95 # ... perform any other stripping/compressing of libs and executables
96
97 popd
98
99 # figure out how big our DMG needs to be
100 # assumes our contents are at least 1M!
101 SIZE=`du -sh "${STAGING_DIR}" | sed 's/\([0-9\.]*\)M\(.*\)/\1/'`
102 SIZE=`echo "${SIZE} + 1.0" | bc | awk '{print int($1+0.5)}'`
103
104 if [ $? -ne 0 ]; then
105 echo "Error: Cannot compute size of staging dir"
106 exit
107 fi
108
109 # create the temp DMG file
110 hdiutil create -srcfolder "${STAGING_DIR}" -volname "${VOL_NAME}" -fs HFS+ \
111 -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M "${DMG_TMP}"
112
113 echo "Created DMG: ${DMG_TMP}"
114
115 # mount it and save the device
116 DEVICE=$(hdiutil attach -readwrite -noverify "${DMG_TMP}" | \
117 egrep '^/dev/' | sed 1q | awk '{print $1}')
118
119 sleep 2
120
121 # add a link to the Applications dir
122 echo "Add link to /Applications"
123 pushd /Volumes/"${VOL_NAME}"
124 ln -s /Applications
125 popd
126
127 # add a background image
128 mkdir /Volumes/"${VOL_NAME}"/.background
129 cp "${DMG_BACKGROUND_IMG}" /Volumes/"${VOL_NAME}"/.background/
130
131 # tell the Finder to resize the window, set the background,
132 # change the icon size, place the icons in the right position, etc.
133 echo '
134 tell application "Finder"
135 tell disk "'${VOL_NAME}'"
136 open
137 set current view of container window to icon view
138 set toolbar visible of container window to false
139 set statusbar visible of container window to false
140 set the bounds of container window to {400, 100, 920, 440}
141 set viewOptions to the icon view options of container window
142 set arrangement of viewOptions to not arranged
143 set icon size of viewOptions to 72
144 set background picture of viewOptions to file ".background:'${DMG_BACKGROUND_IMG}'"
145 set position of item "'${APP_NAME}'.app" of container window to {160, 205}
146 set position of item "Applications" of container window to {360, 205}
147 close
148 open
149 update without registering applications
150 delay 2
151 end tell
152 end tell
153 ' | osascript
154
155 sync
156
157 # unmount it
158 hdiutil detach "${DEVICE}"
159
160 # now make the final image a compressed disk image
161 echo "Creating compressed image"
162 hdiutil convert "${DMG_TMP}" -format UDZO -imagekey zlib-level=9 -o "${DMG_FINAL}"
163
164 # clean up
165 rm -rf "${DMG_TMP}"
166 rm -rf "${STAGING_DIR}"
167 # sending to git repository
168
169 echo "... finished."
170 exit
171