#!/bin/bash ################################################## # aMule.app bundle creator. # ################################################## ## This file is part of the aMule Project ## ## Copyright (c) 2004 Angel Vidal (Kry) ( kry@amule.org ) ## Copyright (c) 2003-2004 aMule Project ( http://www.amule-project.net ) ## Copyright (c) 2007-2009 Gianluca Toso ( gtoso __AT__ presso.net ) ## ## 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 2 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, write to the Free Software ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA STRIP=${STRIP:-0}; # Default no strip binaries DOZIP=${DOZIP:-0}; # Zip DODMG=${DODMG:-1}; # DiskImage UDBZ (OS X 10.4+ only) DOCS="docs/AUTHORS docs/COPYING docs/Changelog docs/EC_Protocol.txt docs/README docs/README.Mac.txt docs/amulesig.txt SVNDATE" VERSION=${VERSION:-SVN}; # Used in the archive name NSUFFIX=${NSUFFIX:+-$NSUFFIX}; # Used in the archive name NSUFFIX=${NSUFFIX:-""}; [ -e src/amulegui ] && GUI=1 || GUI=0; [ -e src/utils/wxCas/src/wxcas ] && WXCAS=1 || WXCAS=0; [ -e src/utils/aLinkCreator/src/alc ] && ALC=1 || ALC=0; echo "" echo -n "Step 1: Cleaning bundles... " # TODO: include SharedSupport and skins directories, webserver and man symlinks # in aMule bundle mkdir -m 0755 aMule.app/Contents/SharedSupport 2> /dev/null mkdir -m 0755 aMule.app/Contents/SharedSupport/skins 2> /dev/null mkdir -m 0755 aMule.app/Contents/SharedSupport/cas 2> /dev/null # amuleweb search in Resources, amule/amulegui search in SharedSupport # fixed in SVN but not in 2.2.x if [ -z "${VERSION#2.2.[12345]}" ]; then ln -sn ../Resources/webserver aMule.app/Contents/SharedSupport/webserver 2> /dev/null ln -sn ../Resources/webserver aMuleGUI.app/Contents/SharedSupport/webserver 2> /dev/null fi # if you have MacOS dir in your PATH, man automatically search here (AUTOPATH) # at least on Tiger ln -sn SharedSupport/man aMule.app/Contents/man 2> /dev/null #rm $(ls -d aMule*.app/Contents/Frameworks/*|grep -vE "libthreadutil|libixml|libupnp") 2> /dev/null rm *.app/Contents/Frameworks/* 2> /dev/null rm *.app/Contents/MacOS/* 2> /dev/null rm -r aMule*.app/Contents/Resources/webserver 2> /dev/null rm -r *.app/Contents/SharedSupport/locale 2> /dev/null rm aMule*.app/Contents/SharedSupport/skins/* 2> /dev/null rm -r aMule.app/Contents/SharedSupport/man 2> /dev/null echo "Done" echo "" echo -n "Step 2: Copying aMule to app bundles... " cp src/amule aMule.app/Contents/MacOS/ cp src/webserver/src/amuleweb aMule.app/Contents/MacOS/ cp src/ed2k aMule.app/Contents/MacOS/ cp src/amulecmd aMule.app/Contents/MacOS/ cp src/amuled aMule.app/Contents/MacOS/ 2> /dev/null cp src/utils/cas/cas aMule.app/Contents/MacOS/ 2> /dev/null cp src/utils/aLinkCreator/src/alcc aMule.app/Contents/MacOS/ 2> /dev/null cp src/utils/fileview/mulefileview aMule.app/Contents/MacOS/ 2> /dev/null ((STRIP)) && strip aMule.app/Contents/MacOS/* 2> /dev/null cp -R src/webserver aMule.app/Contents/Resources/ find aMule.app/Contents/Resources/webserver \( -name .svn -o -name "Makefile*" -o -name src \) -print0 | xargs -0 rm -rf cp src/skins/*.zip aMule.app/Contents/SharedSupport/skins/ cp src/utils/cas/stat.png src/utils/cas/tmp.html aMule.app/Contents/SharedSupport/cas/ orig_dir="`pwd`" (cd docs/man && make install prefix="$orig_dir/aMule.app/Contents/SharedSupport") 1> /dev/null 2> /dev/null (cd src/utils/cas/docs && make install prefix="$orig_dir/aMule.app/Contents/SharedSupport") 1> /dev/null 2> /dev/null (cd src/utils/aLinkCreator/docs && make install prefix="$orig_dir/aMule.app/Contents/SharedSupport") 1> /dev/null 2> /dev/null apps="aMule" if ((GUI)); then cp src/amulegui aMuleGUI.app/Contents/MacOS/ cp src/amulecmd aMuleGUI.app/Contents/MacOS/ ((STRIP)) && strip aMuleGUI.app/Contents/MacOS/* 2> /dev/null cp src/skins/*.zip aMuleGUI.app/Contents/SharedSupport/skins/ # If amulegui doesn't find the webserver templates, # set the preferences from it causes the reset of the template preference cp -R aMule.app/Contents/Resources/webserver aMuleGUI.app/Contents/Resources/ apps="$apps aMuleGUI" fi; if ((WXCAS)); then cp src/utils/wxCas/src/wxcas WxCas.app/Contents/MacOS/ apps="$apps WxCas" fi; if ((ALC)); then cp src/utils/aLinkCreator/src/alc aLinkCreator.app/Contents/MacOS/ apps="$apps aLinkCreator" fi; echo "Done" step=3; for app in $apps; do echo "" echo -n "Step $((step++)): Installing translations to $app bundle... " orig_dir="`pwd`" cd po make install datadir="$orig_dir/$app.app/Contents/SharedSupport" 1> /dev/null 2> /dev/null cd "$orig_dir" echo "Done" echo "" echo "Step $((step++)): Copying libs to $app Framework" echo " wxWidgets/MacPorts..." # wxWidgets and MacPorts libs to frameworks for i in $( otool -L $app.app/Contents/MacOS/* 2> /dev/null \ | sort -u | grep -E 'libwx_|/opt/local|/usr/local/' | cut -d " " -f 1 ); do cp -p $i $app.app/Contents/Frameworks; done for i in $( otool -L $app.app/Contents/Frameworks/* 2> /dev/null \ | sort -u | grep -E 'libwx_|/opt/local|/usr/local/' | cut -d " " -f 1 ); do cp -np $i $app.app/Contents/Frameworks; done # Some MacPorts libraries have not user write permission chmod 644 $app.app/Contents/Frameworks/* echo "Libs copy done." echo "" echo "Step $((step++)): Update $app libs info" #then install_name_tool on them to fix the path on the shared lib cd $app.app/Contents/ for i in $( ls Frameworks ); do echo " Updating $i" #update library id install_name_tool -id @executable_path/../Frameworks/$i Frameworks/$i #update library links for j in $( otool -L Frameworks/$i | grep -E 'libwx_|/opt/local|/usr/local/' | cut -d " " -f 1 ); do install_name_tool -change \ $j @executable_path/../Frameworks/`echo $j | rev | cut -d "/" -f 1 | rev` \ Frameworks/$i done done; #update executables for i in $( ls MacOS | grep -v 'ed2kHelperScript\.app' ); do echo " Updating $i libs info" for j in $( otool -L MacOS/$i | grep -E 'libwx_|/opt/local|/usr/local/' | cut -d " " -f 1 ); do install_name_tool -change \ $j @executable_path/../Frameworks/`echo $j | rev | cut -d "/" -f 1 | rev` MacOS/$i done; done; cd ../.. echo "Libs info updated, $app.app is ready to package." if ((DOZIP)); then echo "" echo -n "Creating $app-${VERSION}${NSUFFIX}.zip... " zip -9 -r -y "$app-${VERSION}${NSUFFIX}.zip" $app.app/ $DOCS > /dev/null \ && echo "Done" || echo "Failed" fi; done echo "" if ((DODMG)); then echo -n "Creating aMule-${VERSION}${NSUFFIX}.dmg... " rm -r diskimage/aMule-$VERSION/* 2> /dev/null mkdir -p -m 0755 diskimage/aMule-$VERSION 2> /dev/null for app in $apps; do cp -Rp $app.app diskimage/aMule-$VERSION/; done mkdir -m 0755 diskimage/Docs 2> /dev/null cp -p $DOCS diskimage/Docs/ 2> /dev/null if out=$(/usr/bin/hdiutil create -srcfolder diskimage "aMule-${VERSION}${NSUFFIX}.dmg" -ov -volname aMule -format UDBZ 2>&1); then echo "Done"; else echo "Failed"; echo -e "\nDetails:\n$out" fi; echo "" fi;