#!/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-2008 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 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; 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 # 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 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 aMule*.app/Contents/MacOS/* 2> /dev/null rm -r aMule.app/Contents/Resources/webserver aMuleGUI.app/Contents/SharedSupport/webserver 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 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 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/|/usr/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/|/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 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." 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 cp -Rp aMule*.app diskimage/aMule-$VERSION/ 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;