#!/bin/sh ################################################## # 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 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 [ -e src/amulegui ] && gui=1 || gui=0; echo "" echo -n "Step 1: Cleaning bundles... " rm $(ls -d aMule*.app/Contents/Frameworks/*|grep -vE "libthreadutil|libixml|libupnp") 2> /dev/null rm aMule*.app/Contents/MacOS/* 2> /dev/null rm -r aMule.app/Contents/Resources/webserver aMuleGUI.app/Contents/SharedSupport/webserver 2> /dev/null # TODO: include SharedSupport directory, webserver symlink and skins directory in aMule bundle mkdir -m 0755 aMule.app/Contents/SharedSupport 2> /dev/null mkdir -m 0755 aMule.app/Contents/SharedSupport/skins 2> /dev/null # amuleweb search in Resources, amule/amulegui search in SharedSupport ln -sn ../Resources/webserver aMule.app/Contents/SharedSupport/webserver 2> /dev/null # if you have MacOS in PATH, man automatically search here (AUTOPATH) ln -sn SharedSupport/man aMule.app/Contents/man 2> /dev/null rm -r aMule*.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 bundle... " 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 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/ 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 if ((gui)); then cp src/amulegui aMuleGUI.app/Contents/MacOS/ cp src/amulecmd aMuleGUI.app/Contents/MacOS/ 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/SharedSupport/ fi; echo "Done" ((gui)) && apps="aMule aMuleGUI" || apps="aMule" 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/' | cut -d " " -f 1 ); do cp $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 | grep -v CVS); 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/' | cut -d " " -f 1 ); do install_name_tool -change \ $j @executable_path/../Frameworks/`echo $j | rev | cut -d "/" -f 1 | rev` \ Frameworks/$i 1> /dev/null 2> /dev/null done echo " Updating $app lib info for $i" #update executables for j in $( ls MacOS | grep -v 'ed2kHelperScript\.app' ); do install_name_tool -change \ `otool -L MacOS/$j | grep $i | cut -d " " -f 1` \ @executable_path/../Frameworks/$i MacOS/$j 1> /dev/null 2> /dev/null done; done; cd ../.. echo "Libs info updated, $app.app is ready to package." echo "" echo -n "Creating $app.zip... " zip -9 -r -y $app.zip $app.app/ -j docs/README.Mac.txt docs/COPYING > /dev/null echo "Done"; done echo ""