forked from Sankore/Sankore-3.1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.macx.sh
executable file
·239 lines (191 loc) · 7.78 KB
/
release.macx.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/bash
# --------------------------------------------------------------------
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ---------------------------------------------------------------------
BASE_TROLLTECH_DIRECTORY=/usr/local/Trolltech/Qt-4.8.0
# Executables
QMAKE=$BASE_TROLLTECH_DIRECTORY/bin/qmake
MACDEPLOYQT=$BASE_TROLLTECH_DIRECTORY/bin/macdeployqt
DMGUTIL="`pwd`/../Sankore-ThirdParty/refnum/dmgutil/dmgutil.pl"
DSYMUTIL=/usr/bin/dsymutil
STRIP=/usr/bin/strip
PLISTBUDDY=/usr/libexec/PlistBuddy
ICEBERG=/usr/local/bin/freeze
LRELEASE=$BASE_TROLLTECH_DIRECTORY/bin/lrelease
# Directories
BUILD_DIR="build/macx/release"
PRODUCT_DIR="$BUILD_DIR/product"
BASE_QT_TRANSLATIONS_DIRECTORY=../Qt4.8/translations
function notify {
GROWLNOTIFY=`which growlnotify`
if [ -x "$GROWLNOTIFY" ]; then
$GROWLNOTIFY --name uniboard-build --iconpath /Developer/Applications/Xcode.app --message "$1" "Uniboard"
fi
printf "\033[32m--->\033[0m $1\n"
}
function abort {
printf "\033[31merror:\033[0m $1\n"
exit 1
}
function warn {
abort "$1"
}
function checkExecutable {
if [ ! -x "$1" ]; then
abort "$1 not found"
fi
}
function addQtTranslations {
for eachTranslation in `ls $BASE_QT_TRANSLATIONS_DIRECTORY/qt_??.qm`
do
# looking fo the language code for each qt translation file
languageCode=`echo $eachTranslation | sed 's/.*qt_\(.*\).qm/\1/'`
basicDir=$PRODUCT_DIR/Open-Sankore.app/Contents/Resources/
for eachDirectory in `ls $basicDir`
do
# looping through the Sankore availables languages
directoryLanguageCode=`echo $eachDirectory | sed 's/\(.*\)\.lproj/\1/'`
if [ ! -z $directoryLanguageCode ]; then
if [[ $eachDirectory == *".lproj"* && $eachDirectory != "empty.lproj" && $directoryLanguageCode == *$languageCode* ]]; then
# sankore translation found for qt translation file
cp $eachTranslation $basicDir/$eachDirectory
if [ $directoryLanguageCode != $languageCode ]; then
# handling fr and fr_CH code.
mv $basicDir/$eachDirectory/qt_$languageCode.qm $basicDir/$eachDirectory/qt_$directoryLanguageCode.qm
fi
fi
fi
done
done
}
trap "defaults write com.mnemis.Uniboard.release Running -bool NO" EXIT
notify "Running Uniboard release script (`date`)"
script_is_running=`defaults read com.mnemis.Uniboard.release Running 2>/dev/null`
if [[ $? -eq 0 ]] && [[ "$script_is_running" = "1" ]]; then
trap EXIT
abort "another release script already running"
fi
defaults write com.mnemis.Uniboard.release Running -bool YES
# Check for executables
checkExecutable "$QMAKE"
checkExecutable "$MACDEPLOYQT"
checkExecutable "$DMGUTIL"
checkExecutable "$DSYMUTIL"
checkExecutable "$STRIP"
checkExecutable "$PLISTBUDDY"
checkExecutable "$ICEBERG"
checkExecutable "$LRELEASE"
# delete the build directory
notify "Cleaning ..."
rm -rf "$BUILD_DIR"
# application translations
notify "Generating applications translatons"
$LRELEASE "Sankore_3.1.pro"
# generate Makefiles
notify "Generating Makefile ..."
QMAKE_CMD="$QMAKE Sankore_3.1.pro -spec macx-g++"
$QMAKE_CMD
# build
notify "Compiling ..."
make -j4 release
notify "Qt Translations ..."
$LRELEASE $BASE_QT_TRANSLATIONS_DIRECTORY/translations.pro
addQtTranslations
cp -R resources/customizations $PRODUCT_DIR/Open-Sankore.app/Contents/Resources
cp -R resources/startupHints $PRODUCT_DIR/Open-Sankore.app/Contents/Resources
notify "Tagging ..."
VERSION=`cat "$BUILD_DIR/version"`
if [ ! -f "$BUILD_DIR/version" ]; then
echo "version not found"
exit 1
else
LAST_COMMITED_VERSION="`git describe $(git rev-list --tags --max-count=1)`"
if [ "v$VERSION" != "$LAST_COMMITED_VERSION" ]; then
echo creating a tag with the version $VERSION
# git tag -a "v$VERSION" -m "Generated setup for v$VERSION"
# git push origin --tags
fi
fi
if [ $? != 0 ]; then
abort "compilation failed"
fi
NAME="Open-Sankore"
DMG="$NAME.dmg"
VOLUME="/Volumes/$NAME"
APP="$PRODUCT_DIR/Open-Sankore.app"
DSYM_NAME="$NAME (r$SVN_REVISION).dSYM"
DSYM="$PRODUCT_DIR/$DSYM_NAME"
GSYM_i386="$PRODUCT_DIR/$NAME i386.sym"
INFO_PLIST="$APP/Contents/Info.plist"
rm -f "$APP/Contents/Resources/empty.lproj"
notify "Removing .svn directories ..."
find "$APP" -name .svn -exec rm -rf {} \; 2> /dev/null
#NNE - remove the backup files (file which ends with ~)
find "$APP" -name "*~" -exec rm -f '{}' \;
# set various version infomration in Info.plist
$PLISTBUDDY -c "Set :CFBundleVersion $VERSION" "$INFO_PLIST"
$PLISTBUDDY -c "Set :CFBundleShortVersionString $VERSION" "$INFO_PLIST"
$PLISTBUDDY -c "Set :CFBundleGetInfoString $NAME" "$INFO_PLIST"
# bundle Qt Frameworks into the app bundle
notify "Bulding frameworks ..."
cd "`pwd`/build/macx/release/product/"
$MACDEPLOYQT "`pwd`/Open-Sankore.app"
#find . -name *.dylib -exec codesign --force --verify --verbose --sign "3rd Party Mac Developer Application: webdoc (394B9J3ZHJ)" {} \;
#codesign --force --verify --verbose --sign "3rd Party Mac Developer Application: webdoc (394B9J3ZHJ)" Open-Sankore.app
#find Open-Sankore.app/Contents/Frameworks/ -type f -exec codesign --force --verify --verbose --sign "3rd Party Mac Developer Application: webdoc (394B9J3ZHJ)" {} \;
cd -
notify "Extracting debug information ..."
$DSYMUTIL "$APP/Contents/MacOS/Open-Sankore" -o "$DSYM"
$STRIP -S "$APP/Contents/MacOS/Open-Sankore"
if [ "$1" == "pkg" ]; then
BASE_ICEBERG_CONFIG_FILE="Open-Sankore.packproj"
#copy the standard file for working with
ICEBERG_CONFIG_FILE="Open-Sankore-working.packproj"
cp -r $BASE_ICEBERG_CONFIG_FILE $ICEBERG_CONFIG_FILE
# set version information
$PLISTBUDDY -c "Set :Hierarchy:Attributes:Settings:Description:International:IFPkgDescriptionVersion $VERSION" "$ICEBERG_CONFIG_FILE"
$PLISTBUDDY -c "Set :Hierarchy:Attributes:Settings:Display\ Information:CFBundleShortVersionString $VERSION" "$ICEBERG_CONFIG_FILE"
$PLISTBUDDY -c "Set :Hierarchy:Attributes:Settings:Version:IFMajorVersion `echo $VERSION | awk 'BEGIN { FS = "." }; { print $1 }'`" "$ICEBERG_CONFIG_FILE"
$PLISTBUDDY -c "Set :Hierarchy:Attributes:Settings:Version:IFMinorVersion `echo $VERSION | awk 'BEGIN { FS = "." }; { print $2 }'`" "$ICEBERG_CONFIG_FILE"
PRODUCT_DIR="install/mac/"
if [ ! -d "${PRODUCT_DIR}" ]; then
mkdir -p "${PRODUCT_DIR}"
fi
$ICEBERG $ICEBERG_CONFIG_FILE
#clean up mess
rm -rf $ICEBERG_CONFIG_FILE
exit 0
fi
notify "Creating dmg ..."
umount "$VOLUME" 2> /dev/null
$DMGUTIL --open --volume="$NAME" "$DMG"
cp *.pdf "$VOLUME"
cp LICENSE.txt "$VOLUME"
cp -R "$APP" "$VOLUME"
ln -s /Applications "$VOLUME"
$DMGUTIL --set --iconsize=96 --toolbar=false --icon=resources/macx/UniboardDmg.icns "$VOLUME"
$DMGUTIL --set --x=20 --y=60 --width=580 --height=520 "$VOLUME"
$DMGUTIL --set --x=180 --y=80 "$VOLUME/`basename \"$APP\"`"
$DMGUTIL --set --x=400 --y=80 "$VOLUME/Applications"
$DMGUTIL --set --x=180 --y=240 "$VOLUME/ReleaseNotes.pdf"
$DMGUTIL --set --x=400 --y=240 "$VOLUME/JournalDesModifications.pdf"
$DMGUTIL --set --x=180 --y=400 "$VOLUME/LICENSE.txt"
$DMGUTIL --close --volume="$NAME" "$DMG"
notify "$NAME is built"
PRODUCT_DIR="install/mac/"
if [ ! -d "${PRODUCT_DIR}" ]; then
mkdir -p "${PRODUCT_DIR}"
fi
mv "$DMG" "${PRODUCT_DIR}"
exit 0