Upstream tarball 20080721
[amule.git] / src / utils / scripts / mac_packager
blob9af295a14ce874b972112da7fbc19818905110e0
1 #!/bin/sh
2 ##################################################
3 # aMule.app bundle creator. #
4 ##################################################
6 ## This file is part of the aMule Project
7 ##
8 ## Copyright (c) 2004-2008 Angel Vidal ( kry@amule.org )
9 ## Copyright (c) 2003-2008 aMule Team ( http://www.amule-project.net )
11 ## This program is free software; you can redistribute it and/or
12 ## modify it under the terms of the GNU General Public License
13 ## as published by the Free Software Foundation; either
14 ## version 2 of the License, or (at your option) any later version.
16 ## This program is distributed in the hope that it will be useful,
17 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ## GNU General Public License for more details.
21 ## You should have received a copy of the GNU General Public License
22 ## along with this program; if not, write to the Free Software
23 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 echo ""
27 echo -n "Step 1: Cleaning bundle... "
28 rm aMule.app/Contents/Frameworks/libwx_* aMule.app/Contents/MacOS/* 1> /dev/null 2> /dev/null
29 rm -r aMule.app/Contents/Resources/webserver 1> /dev/null 2> /dev/null
30 rm -r aMule.app/Contents/SharedSupport 1> /dev/null 2> /dev/null
31 echo "Done"
32 echo ""
33 echo -n "Step 2: Copying aMule to app bundle... "
34 cp src/amule aMule.app/Contents/MacOS/
35 cp src/webserver/src/amuleweb aMule.app/Contents/MacOS/
36 cp src/ed2k aMule.app/Contents/MacOS/
37 cp src/amulecmd aMule.app/Contents/MacOS/
38 cp -R src/webserver aMule.app/Contents/Resources
39 find aMule.app/Contents/Resources/webserver \( -name .svn -o -name "Makefile*" -o -name src \) -print0 | xargs -0 rm -rf
40 echo "Done"
41 echo ""
42 echo -n "Step 3: Installing translations to app bundle... "
43 orig_dir=`pwd`
44 cd po
45 make install datadir=$orig_dir/aMule.app/Contents/SharedSupport 1> /dev/null 2> /dev/null
46 cd $orig_dir
47 echo "Done"
48 echo ""
49 echo "Step 4: Copying libs to Framework"
50 echo " wxWidgets..."
51 # wxWidgets libs to frameworks
52 for i in $( otool -L aMule.app/Contents/MacOS/amule \
53 aMule.app/Contents/MacOS/amuleweb \
54 aMule.app/Contents/MacOS/ed2k \
55 aMule.app/Contents/MacOS/amulecmd \
56 | sort -u | grep libwx_ | cut -d " " -f 1 ); do
57 cp $i aMule.app/Contents/Frameworks;
58 done
59 echo "Libs copy done."
60 echo ""
61 echo "Step 5: Update libs info"
62 #then install_name_tool on them to fix the path on the shared lib
63 cd aMule.app/Contents/
64 for i in $( ls Frameworks | grep -v CVS); do
65 echo " Updating $i"
66 #update library id
67 install_name_tool -id @executable_path/../Frameworks/$i Frameworks/$i
68 #update library links
69 for j in $( otool -L Frameworks/$i | grep libwx_ | cut -d " " -f 1 ); do
70 install_name_tool -change \
71 $j @executable_path/../Frameworks/`echo $j | rev | cut -d "/" -f 1 | rev` \
72 Frameworks/$i 1> /dev/null 2> /dev/null
74 done
75 echo " Updating aMule lib info for $i"
76 #update amule executable
77 install_name_tool -change \
78 `otool -L MacOS/amule | grep $i | cut -d " " -f 1` \
79 @executable_path/../Frameworks/$i MacOS/amule 1> /dev/null 2> /dev/null
80 install_name_tool -change \
81 `otool -L MacOS/amuleweb | grep $i | cut -d " " -f 1` \
82 @executable_path/../Frameworks/$i MacOS/amuleweb 1> /dev/null 2> /dev/null
83 install_name_tool -change \
84 `otool -L MacOS/ed2k | grep $i | cut -d " " -f 1` \
85 @executable_path/../Frameworks/$i MacOS/ed2k 1> /dev/null 2> /dev/null
86 install_name_tool -change \
87 `otool -L MacOS/amulecmd | grep $i | cut -d " " -f 1` \
88 @executable_path/../Frameworks/$i MacOS/amulecmd 1> /dev/null 2> /dev/null
89 done
90 echo "Libs info updated, aMule.app is ready to package."
91 echo ""
92 cd ../..
93 echo -n "Creating aMule.zip... "
94 zip -9 -r aMule.zip aMule.app/ -j docs/README.Mac.txt docs/COPYING > /dev/null
95 echo "Done"
96 echo ""