synfigstudio-osx-build.sh 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. #!/bin/bash
  2. #
  3. # SynfigStudio mac package build script
  4. # Copyright (c) 2008-2009 Simone Karin Lehmann (GimpOSX parts)
  5. # Copyright (c) 2012-2013 Konstantin Dmitriev
  6. #
  7. # This package is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License as
  9. # published by the Free Software Foundation; either version 2 of
  10. # the License, or (at your option) any later version.
  11. #
  12. # This package is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # General Public License for more details.
  16. #
  17. #
  18. # = Usage notes =
  19. #
  20. # * You need to have XCode and git installed
  21. # * Builds from current repository, current revision. So you should manually checkout the desired revision to build
  22. # * If no repository found - then sources fetched into ~/src/synfig and the latest master branch is built
  23. # * Executing script without arguments makes a full clean build and produces dmg package
  24. # * You can pass arguments to the script to invoke particular stage.
  25. # Available stages: mkmacports, mkdeps, mketl, mksynfig, mksynfigstudio, mkapp, mkdmg
  26. # Example:
  27. # synfigstudio-osx-build.sh mkdeps
  28. # * You can pass a custom command to be invoked in the build environment.
  29. # Example (uninstalls glibmm package from the buildroot):
  30. # synfigstudio-osx-build.sh port uninstall glibmm
  31. # * If you suspect something is wrong with your macports installation you can always start from scratch by removing ~/src/macports dir
  32. # TODO: Don't build into /tmp/skl
  33. # TODO: Disable 32bit?
  34. #======= HEADER ===========
  35. set -e
  36. export RELEASE=1
  37. export BUILDROOT_VERSION=1
  38. if [ `whoami` != "root" ]; then
  39. echo "Please use sudo to run this script. Aborting."
  40. exit 1
  41. fi
  42. export SCRIPTPATH=$(cd `dirname "$0"`; pwd)
  43. SYNFIG_REPO_DIR=$(dirname "$SCRIPTPATH")
  44. SCRIPTDIR_IS_REPO=0
  45. if [ -e "$SYNFIG_REPO_DIR/build.conf" ]; then
  46. source "$SYNFIG_REPO_DIR/build.conf"
  47. fi
  48. if [ ! -z $UNIVERSAL ] && [[ ! $UNIVERSAL == 0 ]]; then
  49. export BUILDDIR=~/synfig-buildroot/build.u
  50. else
  51. export BUILDDIR=~/synfig-buildroot/build
  52. export UNIVERSAL=0
  53. fi
  54. if [ ! -z $X11 ] && [[ ! $X11 == 0 ]]; then
  55. export X11=1
  56. export BUILDDIR=${BUILDDIR}.x11
  57. fi
  58. if [ ! -z $DEBUG ] && [[ ! $DEBUG == 0 ]]; then
  59. echo
  60. echo "Debug mode: enabled"
  61. echo
  62. DEBUG='--enable-debug --enable-optimization=0'
  63. export BUILDDIR=${BUILDDIR}.debug
  64. else
  65. DEBUG=''
  66. fi
  67. LNKDIR=/tmp/skl/SynfigStudio
  68. MACPORTS=$LNKDIR/Contents/Resources
  69. MPSRC=MacPorts-2.3.3
  70. export SYNFIG_PREFIX=${MACPORTS}/synfig/
  71. export PATH="$MACPORTS/bin:${SYNFIG_PREFIX}/bin:$MACPORTS/sbin:$PATH"
  72. export SYNFIG_MODULE_LIST=${SYNFIG_PREFIX}/etc/synfig_modules.cfg
  73. export PKG_CONFIG_PATH=${MACPORTS}/lib/pkgconfig:${SYNFIG_PREFIX}/lib/pkgconfig$PKG_CONFIG_PATH
  74. export LD_LIBRARY_PATH=${MACPORTS}/lib:${SYNFIG_PREFIX}/lib:${SYNFIG_PREFIX}/lib64:$LD_LIBRARY_PATH
  75. #export ACLOCAL_FLAGS="-I ${SYNFIG_PREFIX}/share/aclocal -I ${MACPORTS}/share/aclocal"
  76. #export CPPFLAGS="-fpermissive -I${MACPORTS}/include -I${SYNFIG_PREFIX}/include"
  77. export CPPFLAGS="-I${MACPORTS}/include -I${SYNFIG_PREFIX}/include"
  78. export LDFLAGS="-L${MACPORTS}/lib -L${SYNFIG_PREFIX}/lib"
  79. if [[ ! $UNIVERSAL == 0 ]]; then
  80. export CFLAGS="-arch i386 -arch x86_64"
  81. export CXXFLAGS="-arch i386 -arch x86_64"
  82. export LDFLAGS="$LDFLAGS -arch i386 -arch x86_64"
  83. fi
  84. #======= HEADER END ===========
  85. prepare()
  86. {
  87. # == workarounds ==
  88. #We should do that, otherwise python won't build:
  89. if [ -e $MACPORTS/tmp/app ]; then
  90. [ ! -e $MACPORTS/tmp/app.bak ] || rm -rf $MACPORTS/tmp/app.bak
  91. echo "Backing up custom /Applications/MacPorts dir..."
  92. mv $MACPORTS/tmp/app $MACPORTS/tmp/app.bak || true
  93. fi
  94. # Cleanup some stuff, remaining from older installations
  95. rm /Library/LaunchDaemons/org.macports.rsyncd.plist || true
  96. # == symlinks ==
  97. if [ ! -e "$BUILDDIR" ]; then
  98. mkdir -p "$BUILDDIR"
  99. fi
  100. echo -n setting symlink to build directory...
  101. test -d /tmp/skl || mkdir -p /tmp/skl
  102. chmod a+w /tmp/skl
  103. test -L $LNKDIR && rm $LNKDIR
  104. test -L $MACPORTS && rm $MACPORTS
  105. mkdir -p `dirname $MACPORTS`
  106. ln -s "$BUILDDIR" $MACPORTS
  107. chmod a+w $MACPORTS
  108. echo
  109. }
  110. mkmacports()
  111. {
  112. # cleanup previous installation
  113. if [ -e "$BUILDDIR/" ]; then
  114. rm -rf "$BUILDDIR/"
  115. fi
  116. mkdir -p "$BUILDDIR/"
  117. mkdir -p ~/src
  118. cd ~/src
  119. # compile MacPorts and do a selfupdate
  120. if [ ! -d "$MPSRC" ]; then
  121. #curl -LO http://svn.macports.org/repository/macports/downloads/$MPSRC/$MPSRC.tar.bz2
  122. curl -LO http://distfiles.macports.org/MacPorts/$MPSRC.tar.bz2
  123. echo -n extracting MacPorts sources ...
  124. bunzip2 $MPSRC.tar.bz2
  125. tar -xf $MPSRC.tar
  126. rm $MPSRC.tar
  127. echo done.
  128. fi
  129. # this is the main part on which this building and packaging process relies on
  130. echo Compiling and updating MacPorts...
  131. cd $MPSRC
  132. ./configure --prefix $MACPORTS --with-tclpackage=$MACPORTS/share/macports/Tcl \
  133. --with-install-user=`id -un` \
  134. --with-install-group=`id -gn`
  135. make clean
  136. make -j$JOBS
  137. #sudo make install
  138. make install
  139. cd - > /dev/null
  140. export PATH="$MACPORTS/bin:$MACPORTS/sbin:$PATH"
  141. # give our build directory user perms so we don't need sudo in further steps. Avoid sudo whenever it's possible!
  142. #sudo chown -R $UID "$BUILDDIR"
  143. # do a selfupdate
  144. echo Now selfupdating MacPorts. Please wait ...
  145. port -d selfupdate
  146. # now give some hints
  147. echo
  148. echo "Yor MacPorts installation is now ready to build SynfigStudio for Mac OS X."
  149. }
  150. mkdeps()
  151. {
  152. # test if we have MacPorts installed
  153. if [ ! -e "$MACPORTS/bin/port" ]; then
  154. mkmacports
  155. fi
  156. if [ -e "$MACPORTS/bin/synfig" ]; then
  157. echo "=========================== !!! =========================="
  158. echo " Macports installation is outdated. Force rebuild..."
  159. echo "=========================== !!! =========================="
  160. sleep 10
  161. rm -rf "$MACPORTS"
  162. mkmacports
  163. fi
  164. echo $BUILDROOT_VERSION > "$MACPORTS/etc/buildroot-id"
  165. if [[ `cat "$MACPORTS/etc/buildroot-id"` != "${BUILDROOT_VERSION}" ]]; then
  166. echo "======================= !!! ======================"
  167. echo " Buildroot version changed. Force rebuild..."
  168. echo "======================= !!! ======================"
  169. sleep 10
  170. rm -rf "$MACPORTS"
  171. mkmacports
  172. fi
  173. # Don't write into /Applications/MacPorts
  174. [ -d $MACPORTS/tmp/app ] || mkdir -p $MACPORTS/tmp/app
  175. sed -i "" -e "s|/Applications/MacPorts|$MACPORTS/tmp/app|g" "$MACPORTS/etc/macports/macports.conf" || true
  176. if [[ ! $UNIVERSAL == 0 ]]; then
  177. if [[ $X11 == 1 ]]; then
  178. echo "+universal +x11 +nonfree" > $MACPORTS/etc/macports/variants.conf
  179. else
  180. echo "+universal +no_x11 +quartz -x11 +nonfree" > $MACPORTS/etc/macports/variants.conf
  181. fi
  182. else
  183. if [[ $X11 == 1 ]]; then
  184. echo "+x11 +nonfree" > $MACPORTS/etc/macports/variants.conf
  185. else
  186. echo "+no_x11 +quartz -x11 +nonfree" > $MACPORTS/etc/macports/variants.conf
  187. fi
  188. fi
  189. pushd ${SCRIPTPATH}/macports
  190. portindex
  191. popd
  192. echo "file://${SCRIPTPATH}/macports [nosync]" > $MACPORTS/etc/macports/sources.conf
  193. echo "rsync://rsync.macports.org/release/tarballs/ports.tar [default]" >> $MACPORTS/etc/macports/sources.conf
  194. # workaround the bug introduced in MacPorts 2.2.0 - https://trac.macports.org/ticket/39850
  195. cp -rf $MACPORTS/etc/macports/macports.conf $MACPORTS/etc/macports/macports.conf.bak
  196. sed '/sandbox_enable/d' $MACPORTS/etc/macports/macports.conf.bak > $MACPORTS/etc/macports/macports.conf
  197. echo "sandbox_enable no" >> $MACPORTS/etc/macports/macports.conf
  198. port selfupdate
  199. # We have to make sure python 2 is default, because some packages won't build with python 3
  200. port select --set python python27 || true
  201. port upgrade outdated || true
  202. CORE_DEPS=" \
  203. fontconfig \
  204. freetype \
  205. gettext \
  206. ImageMagick \
  207. libmng \
  208. libpng \
  209. libsigcxx2 \
  210. libtool \
  211. libxmlxx2 \
  212. mlt \
  213. openexr \
  214. pkgconfig \
  215. ffmpeg \
  216. boost \
  217. cairo \
  218. libtool"
  219. STUDIO_DEPS=" \
  220. gtkmm3 \
  221. python33 \
  222. gnome-themes-standard \
  223. intltool"
  224. port install -f $CORE_DEPS $STUDIO_DEPS
  225. # We have to make sure python 2 is default, because some packages won't build with python 3
  226. port select --set python python27
  227. # ...but we still need python3 binary available
  228. pushd $MACPORTS/bin/ > /dev/null
  229. ln -sf python3.3 python3
  230. popd > /dev/null
  231. cp ${SCRIPTPATH}/gtk-3.0/settings.ini ${MACPORTS}/etc/gtk-3.0/
  232. }
  233. mketl()
  234. {
  235. # building ETL
  236. pushd ${SYNFIG_REPO_DIR}/ETL
  237. rm -f aclocal.m4
  238. autoreconf --install --force
  239. make clean || true
  240. ./configure --prefix=${SYNFIG_PREFIX} --includedir=${SYNFIG_PREFIX}/include
  241. make -j$JOBS install
  242. popd
  243. }
  244. mksynfig()
  245. {
  246. # building synfig-core
  247. pushd ${SYNFIG_REPO_DIR}/synfig-core
  248. export CXXFLAGS="$CXXFLAGS -I${SYNFIG_PREFIX}/include/ImageMagick"
  249. make clean || true
  250. /bin/sh ./bootstrap.sh
  251. if [[ ! $UNIVERSAL == 0 ]]; then
  252. export DEPTRACK="--disable-dependency-tracking"
  253. fi
  254. /bin/sh ./configure ${DEPTRACK} --prefix=${SYNFIG_PREFIX} --includedir=${SYNFIG_PREFIX}/include --disable-static --enable-shared --with-magickpp --without-libavcodec --with-boost=${MACPORTS} ${DEBUG}
  255. make -j$JOBS install
  256. popd
  257. }
  258. mksynfigstudio()
  259. {
  260. # Copy launch script, so we can test synfigstudio without building an app package
  261. [ ! -e "${MACPORTS}/../MacOS" ] || rm -rf "${MACPORTS}/../MacOS"
  262. cp -rf $SCRIPTPATH/app-template/Contents/MacOS ${MACPORTS}/../MacOS
  263. # building synfig-studio
  264. pushd ${SYNFIG_REPO_DIR}/synfig-studio
  265. make clean || true
  266. CONFIGURE_PACKAGE_OPTIONS='--disable-update-mimedb'
  267. /bin/sh ./bootstrap.sh
  268. if [[ ! $UNIVERSAL == 0 ]]; then
  269. export DEPTRACK="--disable-dependency-tracking"
  270. fi
  271. /bin/sh ./configure ${DEPTRACK} --prefix=${SYNFIG_PREFIX} --includedir=${SYNFIG_PREFIX}/include --disable-static --enable-shared $DEBUG $CONFIGURE_PACKAGE_OPTIONS
  272. make -j$JOBS install
  273. for n in AUTHORS COPYING NEWS README
  274. do
  275. cp -f $n ${MACPORTS}
  276. done
  277. popd
  278. }
  279. mkapp()
  280. {
  281. VERSION=`get_version_release_string`
  282. echo Now trying to build your new SynfigStudio app ...
  283. DIR=`dirname "$BUILDDIR"`
  284. APPDIR="$DIR/SynfigStudio-new-app"
  285. APPCONTENTS="$APPDIR/Contents/Resources"
  286. # initial cleanup
  287. [ ! -e $DIR/SynfigStudio-new-app ] || rm -rf $DIR/SynfigStudio-new-app
  288. [ ! -e $DIR/SynfigStudio.app ] || rm -rf $DIR/SynfigStudio.app
  289. cp -R "$SCRIPTPATH/app-template" "$APPDIR"
  290. mv $APPDIR/Contents/MacOS/synfigstudio $APPDIR/Contents/MacOS/SynfigStudio || true
  291. #mkdir -p "$APPCONTENTS/bin"
  292. #cp -R "$MACPORTS/bin/ffmpeg" "$APPCONTENTS/bin"
  293. #"$SCRIPTPATH/macos-gather-deps.sh" "$APPCONTENTS/bin/ffmpeg"
  294. #exit 0
  295. #cp -R "$MACPORTS/synfig/bin/synfig" "$APPCONTENTS/bin"
  296. mkdir -p "$APPCONTENTS/etc"
  297. mkdir -p "$APPCONTENTS/share"
  298. # Synfig
  299. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/synfig/bin/synfig" "$MACPORTS" "$APPCONTENTS"
  300. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/synfig/bin/synfigstudio" "$MACPORTS" "$APPCONTENTS"
  301. pushd "$MACPORTS/synfig/lib/synfig/modules/"
  302. for FILE in `ls -1 *.so`; do
  303. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/synfig/lib/synfig/modules/$FILE" "$MACPORTS" "$APPCONTENTS"
  304. done
  305. cp -R $MACPORTS/synfig/lib/synfig/modules/*.la "$APPCONTENTS/synfig/lib/synfig/modules/"
  306. popd
  307. cp -R "$MACPORTS/synfig/etc" "$APPCONTENTS/synfig/"
  308. cp -R "$MACPORTS/synfig/share" "$APPCONTENTS/synfig/"
  309. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/ffmpeg" "$MACPORTS" "$APPCONTENTS"
  310. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/ffprobe" "$MACPORTS" "$APPCONTENTS"
  311. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/encodedv" "$MACPORTS" "$APPCONTENTS"
  312. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/sox" "$MACPORTS" "$APPCONTENTS"
  313. # Gtk3
  314. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/gdk-pixbuf-query-loaders" "$MACPORTS" "$APPCONTENTS"
  315. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/gdk-pixbuf-pixdata" "$MACPORTS" "$APPCONTENTS"
  316. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/gtk3-demo" "$MACPORTS" "$APPCONTENTS"
  317. pushd "$MACPORTS/lib/gdk-pixbuf-2.0/2.10.0/loaders/"
  318. for FILE in `ls -1 *.so`; do
  319. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/lib/gdk-pixbuf-2.0/2.10.0/loaders/$FILE" "$MACPORTS" "$APPCONTENTS"
  320. done
  321. popd
  322. pushd "$MACPORTS/lib/gtk-3.0/3.0.0/immodules/"
  323. for FILE in `ls -1 *.so`; do
  324. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/lib/gtk-3.0/3.0.0/immodules/$FILE" "$MACPORTS" "$APPCONTENTS"
  325. done
  326. popd
  327. pushd "$MACPORTS/lib/gtk-3.0/3.0.0/printbackends/"
  328. for FILE in `ls -1 *.so`; do
  329. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/lib/gtk-3.0/3.0.0/printbackends/$FILE" "$MACPORTS" "$APPCONTENTS"
  330. done
  331. popd
  332. pushd "$MACPORTS/lib/cairo/"
  333. for FILE in `ls -1 *.so`; do
  334. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/lib/cairo/$FILE" "$MACPORTS" "$APPCONTENTS"
  335. done
  336. cp -R $MACPORTS/lib/cairo/*.la "$APPCONTENTS/lib/cairo/"
  337. popd
  338. #pushd "$MACPORTS/lib/engines/"
  339. #for FILE in `ls -1 *.so`; do
  340. # "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/lib/engines/$FILE" "$MACPORTS" "$APPCONTENTS"
  341. #done
  342. #popd
  343. cp -R "$MACPORTS/etc/gtk-3.0" "$APPCONTENTS/etc/"
  344. cp -R "$MACPORTS/lib/girepository-1.0" "$APPCONTENTS/lib/"
  345. mkdir -p "$APPCONTENTS/share/glib-2.0/"
  346. cp -R "$MACPORTS/share/glib-2.0/schemas" "$APPCONTENTS/share/glib-2.0"
  347. # Python 3
  348. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/python3" "$MACPORTS" "$APPCONTENTS"
  349. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/Library/Frameworks/Python.framework/Versions/3.3/Resources/Python.app/Contents/MacOS/Python" "$MACPORTS" "$APPCONTENTS"
  350. mkdir -p "$APPCONTENTS/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/"
  351. rsync -av --exclude "__pycache__" "$MACPORTS/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/" "$APPCONTENTS/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/"
  352. #cp -R "$MACPORTS/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3" "$APPCONTENTS/Library/Frameworks/Python.framework/Versions/3.3/lib/"
  353. #find $APPCONTENTS/Library/Frameworks/Python.framework/Versions/3.3/lib -name "__pycache__" -exec rm -rf {} \;
  354. # MLT
  355. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/melt" "$MACPORTS" "$APPCONTENTS"
  356. pushd "$MACPORTS/lib/mlt/"
  357. for FILE in `ls -1 *.dylib`; do
  358. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/lib/mlt/$FILE" "$MACPORTS" "$APPCONTENTS"
  359. done
  360. popd
  361. cp -R "$MACPORTS/share/mlt" "$APPCONTENTS/share/"
  362. # ImageMagick
  363. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/animate" "$MACPORTS" "$APPCONTENTS"
  364. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/composite" "$MACPORTS" "$APPCONTENTS"
  365. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/bin/convert" "$MACPORTS" "$APPCONTENTS"
  366. pushd "$MACPORTS/lib/ImageMagick-6.9.2/modules-Q16/coders/"
  367. for FILE in `ls -1 *.so`; do
  368. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/lib/ImageMagick-6.9.2/modules-Q16/coders/$FILE" "$MACPORTS" "$APPCONTENTS"
  369. done
  370. cp -R $MACPORTS/lib/ImageMagick-6.9.2/modules-Q16/coders/*.la "$APPCONTENTS/lib/ImageMagick-6.9.2/modules-Q16/coders/"
  371. popd
  372. pushd "$MACPORTS/lib/ImageMagick-6.9.2/modules-Q16/filters/"
  373. for FILE in `ls -1 *.so`; do
  374. "$SCRIPTPATH/osx-relocate-binary.sh" "$MACPORTS/lib/ImageMagick-6.9.2/modules-Q16/filters/$FILE" "$MACPORTS" "$APPCONTENTS"
  375. done
  376. cp -R $MACPORTS/lib/ImageMagick-6.9.2/modules-Q16/filters/*.la "$APPCONTENTS/lib/ImageMagick-6.9.2/modules-Q16/filters/"
  377. popd
  378. cp -R "$MACPORTS/lib/ImageMagick-6.9.2/config-Q16" "$APPCONTENTS/lib/ImageMagick-6.9.2/"
  379. cp -R "$MACPORTS/etc/ImageMagick-6" "$APPCONTENTS/etc/"
  380. cp -R "$MACPORTS/share/icons" "$APPCONTENTS/share/"
  381. cp -R "$MACPORTS/share/themes" "$APPCONTENTS/share/"
  382. cp -R "$MACPORTS/share/mime" "$APPCONTENTS/share/"
  383. # app bundle files
  384. echo "*** Please do _NOT_ delete this file. The file script depends on it. ***" > "$APPCONTENTS/v$VERSION"
  385. sed -i "" -e "s/_VERSION_/$VERSION/g" "$APPDIR/Contents/MacOS/SynfigStudio"
  386. sed -i "" -e "s/_VERSION_/$VERSION/g" "$APPDIR/Contents/Info.plist"
  387. # save information about the ports which make up this build
  388. echo "Synfig Studio $VERSION for Mac OS X $OSNAME" > "$APPCONTENTS/build-info.txt"
  389. date >> "$APPCONTENTS/build-info.txt"
  390. port installed >> "$APPCONTENTS/build-info.txt"
  391. sed -i "" -e "s/are currently installed:/were used to build this package:/g" "$APPCONTENTS/build-info.txt"
  392. mv "$APPDIR" "$DIR/SynfigStudio.app"
  393. echo
  394. echo "Your new Synfig Studio app bundle should now be ready to run."
  395. echo
  396. }
  397. mkdmg()
  398. {
  399. cd ~
  400. # get OS major version
  401. OSXVER=`uname -r | cut -f 1 -d '.'`
  402. #VERSION=`synfig --version 2>&1 | cut -d " " -f 2`
  403. VERSION=`get_version_release_string`
  404. #echo Synfig version is: $VERSION
  405. ARCH=`uname -m`
  406. if [[ ! $UNIVERSAL == 0 ]]; then
  407. export FINAL_FILENAME=synfigstudio-"$VERSION"
  408. else
  409. export FINAL_FILENAME=synfigstudio-"$VERSION"."$ARCH"
  410. fi
  411. VOLNAME="SynfigStudio"
  412. TRANSITORY_FILENAME="synfig-wla.sparseimage"
  413. APPDIR=`dirname "$BUILDDIR"`/SynfigStudio.app
  414. /usr/bin/hdiutil detach /Volumes/"$VOLNAME" || true
  415. echo "Creating and attaching disk image..."
  416. [ ! -e "$TRANSITORY_FILENAME" ] || rm -rf "$TRANSITORY_FILENAME"
  417. /usr/bin/hdiutil create -type SPARSE -size 700m -fs "HFS+" -volname "$VOLNAME" -attach "$TRANSITORY_FILENAME"
  418. echo "Copying files to disk image..."
  419. cp -R $APPDIR /Volumes/"$VOLNAME"/SynfigStudio.app
  420. cp -R ${SYNFIG_REPO_DIR}/synfig-studio/COPYING /Volumes/"$VOLNAME"/LICENSE.txt
  421. mv /Volumes/"$VOLNAME"/SynfigStudio.app/Contents/MacOS/synfigstudio /Volumes/"$VOLNAME"/SynfigStudio.app/Contents/MacOS/SynfigStudio || true
  422. # open the window so that the icon database is generated
  423. open /Volumes/"$VOLNAME" || true
  424. sleep 3
  425. echo "Detaching disk image..."
  426. /usr/bin/hdiutil detach /Volumes/"$VOLNAME"
  427. echo "Compressing disk image..."
  428. [ ! -e "$FINAL_FILENAME" ] || rm -rf "$FINAL_FILENAME"
  429. /usr/bin/hdiutil convert -imagekey zlib-level=9 -format UDBZ "$TRANSITORY_FILENAME" -o ./"$FINAL_FILENAME"
  430. echo "Removing uncompressed transitory dmg..."
  431. /bin/rm -f "$TRANSITORY_FILENAME"
  432. echo "Done!"
  433. }
  434. get_version_release_string()
  435. {
  436. pushd "$SYNFIG_REPO_DIR" > /dev/null
  437. VERSION=`cat synfig-core/configure.ac |egrep "AC_INIT\(\[Synfig Core\],"| sed "s|.*Core\],\[||" | sed "s|\],\[.*||"`
  438. #if [ -z $BREED ]; then
  439. # BREED="`git branch -a --no-color --contains HEAD | sed -e s/\*\ // | sed -e s/\(no\ branch\)// | tr '\n' ' ' | tr -s ' ' | sed s/^' '//`"
  440. # if ( echo $BREED | egrep origin/master > /dev/null ); then
  441. # #give a priority to master branch
  442. # BREED='master'
  443. # else
  444. # BREED=`echo $BREED | cut -d ' ' -f 1`
  445. # BREED=${BREED##*/}
  446. # fi
  447. # BREED=${BREED%_master}
  448. #fi
  449. if [[ ${VERSION##*-RC} != ${VERSION} ]]; then
  450. #if [[ $BREED == 'master' ]]; then
  451. BREED=rc${VERSION##*-RC}
  452. #else
  453. # BREED=rc${VERSION##*-RC}.$BREED
  454. #fi
  455. VERSION=${VERSION%%-*}
  456. fi
  457. if [ ! -z $BREED ]; then
  458. BREED=`echo $BREED | tr _ . | tr - .` # No "-" or "_" characters, becuse RPM and DEB complain
  459. BREED=.$BREED
  460. fi
  461. REVISION=`git show --pretty=format:%ci HEAD | head -c 10 | tr -d '-'`
  462. echo "$VERSION-$REVISION$BREED"
  463. #echo "$VERSION-$REVISION$BREED.$RELEASE"
  464. popd >/dev/null
  465. }
  466. mkall()
  467. {
  468. mkdeps
  469. # cleanup previous synfig installation if any
  470. [ ! -d "$SYNFIG_PREFIX" ] || rm -rf "$SYNFIG_PREFIX"
  471. mketl
  472. mksynfig
  473. mksynfigstudio
  474. #port install synfigstudio || true
  475. #synfig -q installer_logo.sif -o installer_logo.png --time 0
  476. #synfig(294) [23:51:01] info: Loading modules from /tmp/skl/#SynfigStudio.app/Contents/Resources/etc/synfig_modules.cfg
  477. #synfig: warning: Unable to find module "mod_magickpp" (file not found)
  478. #synfig: warning: Unable to find module "mod_libavcodec" (file not found)
  479. #synfig(294) [23:51:01] error: Standard Exception: basic_string::_S_construct NULL not valid
  480. #Unable to load 'installer_logo.sif'.
  481. #Throwing out job...
  482. #Nothing to do!
  483. #Workaround:
  484. #[ ! -e ~/src/macports/synfig-build ] || rm -rf ~/src/macports/synfig-build
  485. #cd $MACPORTS/var/macports/build/
  486. #DIRPATH=`ls`
  487. #cd -
  488. #VERSION=`synfig --version 2>&1 | cut -d " " -f 2`
  489. #cp -R "$MACPORTS/var/macports/build/$DIRPATH/synfigstudio/work/synfigstudio-$VERSION" ~/src/macports/synfig-build
  490. #cd ~/src/macports/synfig-build/images
  491. #make
  492. #cd -
  493. #cp -R ~/src/macports/synfig-build/images/* #"$MACPORTS/var/macports/build/$DIRPATH/synfigstudio/work/synfigstudio-$VERSION/images"
  494. #Workaround end
  495. #port install synfigstudio
  496. mkapp
  497. mkdmg
  498. }
  499. do_cleanup()
  500. {
  501. #restore Applications/MacPorts dir
  502. if [ -e $MACPORTS/tmp/app.bak ]; then
  503. echo "Restoring custom /Applications/MacPorts dir."
  504. rm -rf $MACPORTS/tmp/app || true
  505. mv $MACPORTS/tmp/app.bak $MACPORTS/tmp/app
  506. fi
  507. rm -rf $LNKDIR || true
  508. }
  509. ###=================================== MAIN ======================================
  510. main() # dummy for navigation
  511. {
  512. true
  513. }
  514. #Init traps
  515. trap do_cleanup INT
  516. # number of jobs
  517. export JOBS=`sysctl hw.ncpu | cut -f 2 -d " "`
  518. echo "Detected processors count: $JOBS"
  519. # get OS X version. 8=Tiger, 9=Leopard, 10=Snowleopard
  520. export OS=`uname -r | cut -d "." -f1`
  521. if [ $OS -eq 9 -o $OS -eq 10 ]; then
  522. GTKFONT=9.8
  523. THEME=Leopard
  524. else
  525. GTKFONT=12.5
  526. THEME=Tiger
  527. fi
  528. # set OS code name
  529. OSNAME=$THEME
  530. if [ $OS -eq 10 ]; then
  531. OSNAME=Snowleopard
  532. fi
  533. if [ ! $OS -eq 13 ]; then # if not Mountain Lion then set compatibility mode
  534. export MACOSX_DEPLOYMENT_TARGET=10.5
  535. echo "Enabling binary compatibility mode: MACOSX_DEPLOYMENT_TARGET=10.5"
  536. fi
  537. prepare
  538. # Fetch sources
  539. #port install python33
  540. #port select --set python python33
  541. #port install git-core
  542. if ! ( which git ); then
  543. echo "ERROR: No git found. Please install git from http://code.google.com/p/git-osx-installer/"
  544. exit 1
  545. fi
  546. #detecting repo
  547. pushd $SCRIPTPATH >/dev/null
  548. if git rev-parse --git-dir >/dev/null; then
  549. SYNFIG_REPO_DIR=$(dirname `git rev-parse --git-dir`)
  550. SCRIPTDIR_IS_REPO=1
  551. fi
  552. popd >/dev/null
  553. if [ ! -e ${SYNFIG_REPO_DIR} ]; then
  554. pushd `dirname "${SYNFIG_REPO_DIR}"`
  555. git clone git://github.com/synfig/synfig.git
  556. popd
  557. fi
  558. VERSION=`get_version_release_string`
  559. pushd ${SYNFIG_REPO_DIR} >/dev/null
  560. if [[ $WORKDIR_IS_REPO == 0 ]]; then
  561. git fetch
  562. git reset --hard HEAD
  563. SELECTEDREVISION=origin/master
  564. git checkout $SELECTEDREVISION
  565. fi
  566. echo
  567. echo
  568. echo "BUILDING synfigstudio-$VERSION"
  569. echo
  570. echo
  571. #sleep 5
  572. popd > /dev/null
  573. if [ -z $1 ]; then
  574. mkall
  575. else
  576. echo "Executing custom user command..."
  577. $@
  578. fi
  579. do_cleanup