forked from synfig/synfig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3-package-osx-dmg.sh
executable file
·378 lines (318 loc) · 14.6 KB
/
3-package-osx-dmg.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#!/bin/bash
#
#======= HEADER ===========
set -e
export RELEASE=1
export BUILDROOT_VERSION=1
#if [ `whoami` != "root" ]; then
# echo "Please use sudo to run this script. Aborting."
# exit 1
#fi
export SCRIPTPATH=$(cd `dirname "$0"`; pwd)
export MACPORTS="$(brew --prefix)/opt" # dictated by HomeBrew defaults
#======= HEADER END ===========
smart_find()
{
if [ -f "$1" ]; then
#HomeBrew
echo "$1"
else
#MacPorts
BINARY=`basename "$1"`
echo "$MACPORTS/bin/$BINARY"
fi
}
mkapp()
{
cd ${SCRIPTPATH}
VERSION=`get_version_release_string`
echo Now trying to build your new SynfigStudio app ...
APPDIR="${SCRIPTPATH}/_production/SynfigStudio.app"
#APPDIR_FINAL="${SCRIPTPATH}/_production/SynfigStudio.app"
APPCONTENTS="${APPDIR}/Contents/Resources"
# initial cleanup
[ ! -d ${APPDIR} ] || rm -rf ${APPDIR}
[ ! -d ${APPDIR_FINAL} ] || rm -rf ${APPDIR_FINAL}
cp -Rf "${SCRIPTPATH}/autobuild/osx/app-template" "$APPDIR"
mv "${APPDIR}/Contents/MacOS/synfigstudio.sh" "$APPDIR/Contents/MacOS/SynfigStudio.sh" || true
g++ "${SCRIPTPATH}/autobuild/osx/synfig_osx_launcher.cpp" -o "$APPDIR/Contents/MacOS/SynfigStudio"
#mkdir -p "$APPCONTENTS/bin"
#cp -R "$MACPORTS/bin/ffmpeg" "$APPCONTENTS/bin"
#"$SCRIPTPATH/macos-gather-deps.sh" "$APPCONTENTS/bin/ffmpeg"
#exit 0
#cp -R "$MACPORTS/synfig/bin/synfig" "$APPCONTENTS/bin"
mkdir -p "${APPCONTENTS}/etc"
mkdir -p "${APPCONTENTS}/share"
#FontConfig
cp -R "${MACPORTS}/../etc/fonts" "${APPCONTENTS}/etc"
# Synfig
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find ${SCRIPTPATH}/_production/build/bin/synfig`" "${SCRIPTPATH}/_production/build" "$APPCONTENTS"
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find ${SCRIPTPATH}/_production/build/bin/synfigstudio`" "${SCRIPTPATH}/_production/build" "$APPCONTENTS"
pushd "${SCRIPTPATH}/_production/build/lib/synfig/modules/"
for FILE in `ls -1 *.so`; do
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${SCRIPTPATH}/_production/build/lib/synfig/modules/$FILE" "${SCRIPTPATH}/_production/build" "$APPCONTENTS"
done
cp -R ${SCRIPTPATH}/_production/build/lib/synfig/modules/*.la "$APPCONTENTS/lib/synfig/modules/"
popd
cp -R "${SCRIPTPATH}/_production/build/etc" "$APPCONTENTS/"
cp -R "${SCRIPTPATH}/_production/build/share" "$APPCONTENTS/"
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/ffmpeg/bin/ffmpeg`" "$MACPORTS" "$APPCONTENTS"
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/ffmpeg/bin/ffprobe`" "$MACPORTS" "$APPCONTENTS"
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/libdv/bin/encodedv`" "$MACPORTS" "$APPCONTENTS"
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/sox/bin/sox`" "$MACPORTS" "$APPCONTENTS"
# Gtk3
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/gdk-pixbuf/bin/gdk-pixbuf-query-loaders`" "$MACPORTS" "$APPCONTENTS"
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/gdk-pixbuf/bin/gdk-pixbuf-pixdata`" "$MACPORTS" "$APPCONTENTS"
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/gtk+3/bin/gtk3-demo`" "$MACPORTS" "$APPCONTENTS"
if [ -d "$MACPORTS/gdk-pixbuf" ]; then
PKG_PREFIX="/gdk-pixbuf"
else
PKG_PREFIX=""
fi
pushd "${MACPORTS}${PKG_PREFIX}/lib/gdk-pixbuf-2.0/2.10.0/loaders/"
for FILE in `ls -1 *.so`; do
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${MACPORTS}${PKG_PREFIX}/lib/gdk-pixbuf-2.0/2.10.0/loaders/$FILE" "$MACPORTS" "$APPCONTENTS"
done
popd
cp -R "${MACPORTS}${PKG_PREFIX}/share/gir-1.0" "${APPCONTENTS}/share/"
cp -R "${MACPORTS}${PKG_PREFIX}/share/locale" "${APPCONTENTS}/share/"
if [ -d "$MACPORTS/librsvg-2.40.20" ]; then
PKG_PREFIX="/librsvg-2.40.20"
elif [ -d "$MACPORTS/librsvg" ]; then
PKG_PREFIX="/librsvg"
else
PKG_PREFIX=""
fi
pushd "${MACPORTS}${PKG_PREFIX}/lib/gdk-pixbuf-2.0/2.10.0/loaders/"
for FILE in `ls -1 *.so`; do
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${MACPORTS}${PKG_PREFIX}/lib/gdk-pixbuf-2.0/2.10.0/loaders/$FILE" "$MACPORTS" "$APPCONTENTS"
done
popd
if [ -d "$MACPORTS/gtk+3" ]; then
PKG_PREFIX="/gtk+3"
else
PKG_PREFIX=""
fi
pushd "${MACPORTS}${PKG_PREFIX}/lib/gtk-3.0/3.0.0/immodules/"
for FILE in `ls -1 *.so`; do
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${MACPORTS}${PKG_PREFIX}/lib/gtk-3.0/3.0.0/immodules/$FILE" "$MACPORTS" "$APPCONTENTS"
done
popd
pushd "${MACPORTS}${PKG_PREFIX}/lib/gtk-3.0/3.0.0/printbackends/"
for FILE in `ls -1 *.so`; do
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${MACPORTS}${PKG_PREFIX}/lib/gtk-3.0/3.0.0/printbackends/$FILE" "$MACPORTS" "$APPCONTENTS"
done
popd
cp -R "${MACPORTS}${PKG_PREFIX}/etc/gtk-3.0" "${APPCONTENTS}/etc/"
cp -R "${MACPORTS}${PKG_PREFIX}/lib/girepository-1.0" "${APPCONTENTS}/lib/"
cp -R "${MACPORTS}${PKG_PREFIX}/share/icons" "${APPCONTENTS}/share/"
cp -R "${MACPORTS}${PKG_PREFIX}/share/gir-1.0" "${APPCONTENTS}/share/"
cp -R "${MACPORTS}${PKG_PREFIX}/share/glib-2.0" "${APPCONTENTS}/share/"
cp -R "${MACPORTS}${PKG_PREFIX}/share/locale" "${APPCONTENTS}/share/"
cp -R "${MACPORTS}${PKG_PREFIX}/share/themes" "${APPCONTENTS}/share/"
if [ -d "$MACPORTS/gsettings-desktop-schemas" ]; then
PKG_PREFIX="/gsettings-desktop-schemas"
else
PKG_PREFIX=""
fi
cp -R "${MACPORTS}${PKG_PREFIX}/share/glib-2.0" "${APPCONTENTS}/share/"
glib-compile-schemas "${APPCONTENTS}/share/glib-2.0/schemas/"
if [ -d "$MACPORTS/hicolor-icon-theme" ]; then
PKG_PREFIX="/hicolor-icon-theme"
else
PKG_PREFIX=""
fi
cp -R "${MACPORTS}${PKG_PREFIX}/share/icons" "${APPCONTENTS}/share/"
if [ -d "$MACPORTS/adwaita-icon-theme" ]; then
PKG_PREFIX="/adwaita-icon-theme"
else
PKG_PREFIX=""
fi
cp -R "${MACPORTS}${PKG_PREFIX}/share/icons/Adwaita" "${APPCONTENTS}/share/icons/"
if [ -d "$MACPORTS/cairo" ]; then
PKG_PREFIX="/cairo"
else
PKG_PREFIX=""
fi
pushd "${MACPORTS}${PKG_PREFIX}/lib/cairo/"
for FILE in `ls -1 *.so`; do
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${MACPORTS}${PKG_PREFIX}/lib/cairo/$FILE" "$MACPORTS" "$APPCONTENTS"
done
mkdir -p "${APPCONTENTS}/lib/cairo/" || true
cp -R ${MACPORTS}${PKG_PREFIX}/lib/cairo/*.la "${APPCONTENTS}/lib/cairo/" || true
cp -R ${MACPORTS}${PKG_PREFIX}/lib/cairo/*.a "${APPCONTENTS}/lib/cairo/" || true
popd
#pushd "$MACPORTS/lib/engines/"
#for FILE in `ls -1 *.so`; do
# "$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/lib/engines/$FILE`" "$MACPORTS" "$APPCONTENTS"
#done
#popd
if [ -d "$MACPORTS/glib" ]; then
PKG_PREFIX="/glib"
else
PKG_PREFIX=""
fi
#mkdir -p "${APPCONTENTS}/share/glib-2.0/"
cp -R "${MACPORTS}${PKG_PREFIX}/share/glib-2.0" "${APPCONTENTS}/share/"
cp -R "${MACPORTS}${PKG_PREFIX}/share/locale" "${APPCONTENTS}/share/"
# Python 3
if [ -d "$MACPORTS/python3" ]; then
PKG_PREFIX="/python3"
else
PKG_PREFIX="/Library"
fi
pushd "${MACPORTS}${PKG_PREFIX}/Frameworks/Python.framework/Versions/"
PYTHON_VERSION=`ls -1 | head -n 1`
popd
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/python3/bin/python3`" "$MACPORTS" "$APPCONTENTS"
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${MACPORTS}${PKG_PREFIX}/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Resources/Python.app/Contents/MacOS/Python" "$MACPORTS" "$APPCONTENTS"
mkdir -p "${APPCONTENTS}/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/"
rsync -av --exclude "__pycache__" "${MACPORTS}${PKG_PREFIX}/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/" "${APPCONTENTS}/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/"
pushd "${APPCONTENTS}/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/" > /dev/null
mkdir -p ../../../../../../lib/python${PYTHON_VERSION}/site-packages
ln -sf ../../../../../../lib/python${PYTHON_VERSION}/site-packages site-packages
popd > /dev/null
rsync -av --exclude "__pycache__" /usr/local/lib/python${PYTHON_VERSION}/site-packages/lxml* "${APPCONTENTS}/lib/python${PYTHON_VERSION}/site-packages/"
#cp -R "${MACPORTS}${PKG_PREFIX}/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python3.3" "${APPCONTENTS}/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/"
#find ${APPCONTENTS}/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib -name "__pycache__" -exec rm -rf {} \;
# MLT
if [ -d "$MACPORTS/mlt" ]; then
PKG_PREFIX="/mlt"
else
PKG_PREFIX=""
fi
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${MACPORTS}${PKG_PREFIX}/bin/melt" "$MACPORTS" "$APPCONTENTS"
pushd "${MACPORTS}${PKG_PREFIX}/lib/mlt/"
for FILE in `ls -1 *.dylib`; do
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${MACPORTS}${PKG_PREFIX}/lib/mlt/$FILE" "$MACPORTS" "$APPCONTENTS"
done
popd
mkdir -p "${APPCONTENTS}/share/"
cp -R "${MACPORTS}${PKG_PREFIX}/share/mlt" "${APPCONTENTS}/share/"
# ImageMagick
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/imagemagick/bin/animate`" "$MACPORTS" "$APPCONTENTS"
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/imagemagick/bin/composite`" "$MACPORTS" "$APPCONTENTS"
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "`smart_find $MACPORTS/imagemagick/bin/convert`" "$MACPORTS" "$APPCONTENTS"
if [ -d "$MACPORTS/imagemagick" ]; then
PKG_PREFIX="/imagemagick"
else
PKG_PREFIX=""
fi
pushd "${MACPORTS}${PKG_PREFIX}/lib/"
IMAGEMAGICK_DIR=`ls -1d ImageMagick* |head -n 1`
popd
pushd "${MACPORTS}${PKG_PREFIX}/lib/${IMAGEMAGICK_DIR}"
IMAGEMAGICK_MODULES_DIR=`ls -1d modules-* |head -n 1`
popd
pushd "${MACPORTS}${PKG_PREFIX}/lib/${IMAGEMAGICK_DIR}"
IMAGEMAGICK_CONFIG_DIR=`ls -1d config-* |head -n 1`
popd
pushd "${MACPORTS}${PKG_PREFIX}/etc"
IMAGEMAGICK_ETC_DIR=`ls -1d ImageMagick-* |head -n 1`
popd
pushd "${MACPORTS}${PKG_PREFIX}/lib/${IMAGEMAGICK_DIR}/${IMAGEMAGICK_MODULES_DIR}/coders/"
for FILE in `ls -1 *.so`; do
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${MACPORTS}${PKG_PREFIX}/lib/${IMAGEMAGICK_DIR}/${IMAGEMAGICK_MODULES_DIR}/coders/$FILE" "$MACPORTS" "$APPCONTENTS"
done
cp -R ${MACPORTS}${PKG_PREFIX}/lib/${IMAGEMAGICK_DIR}/${IMAGEMAGICK_MODULES_DIR}/coders/*.la "${APPCONTENTS}/lib/${IMAGEMAGICK_DIR}/${IMAGEMAGICK_MODULES_DIR}/coders/"
popd
pushd "${MACPORTS}${PKG_PREFIX}/lib/${IMAGEMAGICK_DIR}/${IMAGEMAGICK_MODULES_DIR}/filters/"
for FILE in `ls -1 *.so`; do
"$SCRIPTPATH/autobuild/osx/relocate-binary.sh" "${MACPORTS}${PKG_PREFIX}/lib/${IMAGEMAGICK_DIR}/${IMAGEMAGICK_MODULES_DIR}/filters/$FILE" "$MACPORTS" "$APPCONTENTS"
done
cp -R ${MACPORTS}${PKG_PREFIX}/lib/${IMAGEMAGICK_DIR}/${IMAGEMAGICK_MODULES_DIR}/filters/*.la "${APPCONTENTS}/lib/${IMAGEMAGICK_DIR}/${IMAGEMAGICK_MODULES_DIR}/filters/"
popd
cp -R "${MACPORTS}${PKG_PREFIX}/lib/${IMAGEMAGICK_DIR}/${IMAGEMAGICK_CONFIG_DIR}" "${APPCONTENTS}/lib/${IMAGEMAGICK_DIR}/"
cp -R "${MACPORTS}${PKG_PREFIX}/etc/${IMAGEMAGICK_ETC_DIR}" "${APPCONTENTS}/etc/"
#cp -R "${MACPORTS}/share/icons" "$APPCONTENTS/share/"
#cp -R "${MACPORTS}/share/themes" "$APPCONTENTS/share/"
#cp -R "${MACPORTS}/share/mime" "$APPCONTENTS/share/"
# app bundle files
echo "*** Please do _NOT_ delete this file. The file script depends on it. ***" > "$APPCONTENTS/v$VERSION"
sed -i "" -e "s/_VERSION_/$VERSION/g" "$APPDIR/Contents/MacOS/SynfigStudio.sh"
sed -i "" -e "s/_VERSION_/$VERSION/g" "$APPDIR/Contents/Info.plist"
# save information about the ports which make up this build
echo "Synfig Studio $VERSION for Mac OS X" > "$APPCONTENTS/build-info.txt"
date >> "$APPCONTENTS/build-info.txt"
#port installed >> "$APPCONTENTS/build-info.txt"
#sed -i "" -e "s/are currently installed:/were used to build this package:/g" "$APPCONTENTS/build-info.txt"
#mv "${APPDIR}" "${APPDIR_FINAL}"
echo
echo "Your new Synfig Studio app bundle should now be ready to run."
echo
}
mkdmg()
{
cd "${SCRIPTPATH}/_production/"
# get OS major version
OSXVER=`uname -r | cut -f 1 -d '.'`
#VERSION=`synfig --version 2>&1 | cut -d " " -f 2`
VERSION=`get_version_release_string`
#echo Synfig version is: $VERSION
ARCH=`uname -m`
export FINAL_FILENAME=SynfigStudio-"$VERSION"
VOLNAME="SynfigStudio"
TRANSITORY_FILENAME="synfig-wla.sparseimage"
[ ! -f "$TRANSITORY_FILENAME" ] || rm -f "$TRANSITORY_FILENAME"
APPDIR="${SCRIPTPATH}/_production/SynfigStudio.app"
/usr/bin/hdiutil detach /Volumes/"$VOLNAME" || true
echo "Creating and attaching disk image..."
[ ! -e "$TRANSITORY_FILENAME" ] || rm -rf "$TRANSITORY_FILENAME"
/usr/bin/hdiutil create -type SPARSE -size 700m -fs "HFS+" -volname "$VOLNAME" -attach "$TRANSITORY_FILENAME"
echo "Copying files to disk image..."
cp -R $APPDIR /Volumes/"$VOLNAME"/SynfigStudio.app
cp -R ${SCRIPTPATH}/synfig-studio/COPYING /Volumes/"$VOLNAME"/LICENSE.txt
cp -R ${SCRIPTPATH}/autobuild/osx/README_FIRST.pdf /Volumes/"$VOLNAME"/README_FIRST.pdf
mv /Volumes/"$VOLNAME"/SynfigStudio.app/Contents/MacOS/synfigstudio /Volumes/"$VOLNAME"/SynfigStudio.app/Contents/MacOS/SynfigStudio || true
mv /Volumes/"$VOLNAME"/SynfigStudio.app/Contents/MacOS/synfigstudio.sh /Volumes/"$VOLNAME"/SynfigStudio.app/Contents/MacOS/SynfigStudio.sh || true
# open the window so that the icon database is generated
open /Volumes/"$VOLNAME" || true
sleep 3
echo "Detaching disk image..."
/usr/bin/hdiutil detach /Volumes/"$VOLNAME"
echo "Compressing disk image..."
[ ! -e "./${FINAL_FILENAME}.dmg" ] || rm -rf "./${FINAL_FILENAME}.dmg"
/usr/bin/hdiutil convert -imagekey zlib-level=9 -format UDBZ "$TRANSITORY_FILENAME" -o ./"${FINAL_FILENAME}"
echo "Removing uncompressed transitory dmg..."
/bin/rm -f "$TRANSITORY_FILENAME"
echo "Done!"
}
get_version_release_string()
{
pushd "$SCRIPTPATH" > /dev/null
VERSION=`cat synfig-core/configure.ac |egrep "AC_INIT\(\[Synfig Core\],"| sed "s|.*Core\],\[||" | sed "s|\],\[.*||"`
#if [ -z $BREED ]; then
# BREED="`git branch -a --no-color --contains HEAD | sed -e s/\*\ // | sed -e s/\(no\ branch\)// | tr '\n' ' ' | tr -s ' ' | sed s/^' '//`"
# if ( echo $BREED | egrep origin/master > /dev/null ); then
# #give a priority to master branch
# BREED='master'
# else
# BREED=`echo $BREED | cut -d ' ' -f 1`
# BREED=${BREED##*/}
# fi
# BREED=${BREED%_master}
#fi
if [[ ${VERSION##*-RC} != ${VERSION} ]]; then
#if [[ $BREED == 'master' ]]; then
BREED=rc${VERSION##*-RC}
#else
# BREED=rc${VERSION##*-RC}.$BREED
#fi
VERSION=${VERSION%%-*}
fi
if [ ! -z $BREED ]; then
BREED=`echo $BREED | tr _ . | tr - .` # No "-" or "_" characters, because RPM and DEB complain
BREED=.$BREED
fi
REVISION=`git show --pretty=format:%ci HEAD | head -c 10 | tr -d '-'`
echo "$VERSION-$REVISION$BREED"
#echo "$VERSION-$REVISION$BREED.$RELEASE"
popd >/dev/null
}
###=================================== MAIN ======================================
main() # dummy for navigation
{
true
}
mkapp
mkdmg