aMule Forum

English => Multiplatform => Mac OSX => Topic started by: mirko.g on September 23, 2009, 01:09:57 PM

Title: mac_packager
Post by: mirko.g on September 23, 2009, 01:09:57 PM
Building aMule I noticed that mac_packager missed something and we spoke about it in other threads.
I compared a working copy of aMule and a compiled aMule (to be packaged). According to the script this is what I noticed:

About the first point, I toke the bundle of a working copy of aMule "suite" and made the bundles manually updating Info.plist of each tool. I don't know if this is the right way: all apps work correctly (after quick test) except wxCas.

For the second point I guess this is enough:
Code: [Select]
mkdir -m 0755 aMule.app/Contents/SharedSupport aMule.app/Contents/SharedSupport/skins
cp src/skins/*.zip aMule.app/Contents/SharedSupport/skins/
I also saw a cas folder on working aMule.

For the third point, I think the problem is the filter used (grep libwx_). I generally use either grep /opt/local for macports only, or grep -E '/opt/local/|/usr/local' for self-compiled libs. Since I got some error sometimes I have to use otool -L on the libraries obtained with the previous filter for dependencies.
Title: Re: mac_packager
Post by: mirko.g on September 23, 2009, 01:43:34 PM
This is what I was working on... (it's incomplete/work-in-progress)
http://www.mac-factory.org/redmine/repositories/annotate/macmule/script/mac_packager
Title: Re: mac_packager
Post by: mirko.g on September 23, 2009, 04:30:25 PM
I also saw a cas folder on working aMule.

Well, I found stat.png and tmp.html into aMule.app/Contents/SharedSupport/cas/ and I guess they come from src/utils/cas/: don't they?
Title: Re: mac_packager
Post by: GonoszTopi on September 23, 2009, 05:00:37 PM
Yes, they do.
Title: Re: mac_packager
Post by: mirko.g on September 23, 2009, 06:13:15 PM
Attached a first patch (http://www.mac-factory.org/redmine/repositories/diff/macmule/script/mac_packager?rev=17&rev_to=15) for original mac_packager.
What's new:
Title: Re: mac_packager
Post by: Kry on September 23, 2009, 08:24:31 PM
That will fail badly for people like me, who don't install libraries.
Title: Re: mac_packager
Post by: mirko.g on September 23, 2009, 10:38:51 PM
That will fail badly for people like me, who don't install libraries.

Yep but we hope there aren't so many people like you!  ;D
Just kidding... In my very humble opinion if you didn't plan to move libraries from system into bundle there should be another way to produce something useful with mac_packager. According to the wiki page (http://wiki.amule.org/index.php/HowTo_compile_on_Mac#Step_5:_Compile_aMule) we are producing a useless stuff.

How do you usually build aMule for Mac OS? Do I ignore the existence of an alternative way to only run aMule without any of the needed libraries?  :o
Title: Re: mac_packager
Post by: Kry on September 24, 2009, 07:30:54 AM
mac_packager should move the libraries that are NOT in the system to the bundle. You are moving the libraries that ARE installed in two specific locations, which is different.

You need to modify it so it takes libraries that are not in the default system locations.
Title: Re: mac_packager
Post by: GonoszTopi on September 24, 2009, 08:00:03 AM
So you mean anyone downloading the produced bundle should also install macports with the necessary libraries?
Title: Re: mac_packager
Post by: mirko.g on September 24, 2009, 08:44:49 AM
mac_packager should move the libraries that are NOT in the system to the bundle.

Sorry but I cannot understand. Are you talking about wxWidgets? And how we should provide the (other) needed libraries?

Quote
You are moving the libraries that ARE installed in two specific locations, which is different.

Yep. The libraries I used to compile wxWidgets and the same aMule.
Take a look to this:
Code: [Select]
$ otool -L amule | sort -u | cut -d " " -f 1
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
/System/Library/Frameworks/WebKit.framework/Versions/A/WebKit
/opt/local/lib/libiconv.2.dylib
/opt/local/lib/libixml.2.dylib
/opt/local/lib/libthreadutil.2.dylib
/opt/local/lib/libupnp.3.dylib
/opt/local/lib/libz.1.dylib
/usr/lib/libSystem.B.dylib
/usr/lib/libobjc.A.dylib
/usr/lib/libstdc++.6.dylib

This is why I have the same question:
So you mean anyone downloading the produced bundle should also install macports with the necessary libraries?
(And I wonder why there is /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL into).
Title: Re: mac_packager
Post by: Kry on September 24, 2009, 08:55:06 AM
So you mean anyone downloading the produced bundle should also install macports with the necessary libraries?

What? The complete opposite. Re-read my post. I'm with a high fever and sick as hell, but I can't see how you would take that from my post.
Title: Re: mac_packager
Post by: wuischke on September 24, 2009, 09:25:39 AM
Quote
I'm with a high fever and sick as hell
Oh, get well soon.

Have a look at the mac_packager script:
Code: [Select]
for i in $( otool -L    aMule.app/Contents/MacOS/amule \
                                                aMule.app/Contents/MacOS/amuleweb \
                                                aMule.app/Contents/MacOS/ed2k \
                                                aMule.app/Contents/MacOS/amulecmd \
                        | sort -u | grep libwx_ | cut -d " " -f 1 ); do
        cp $i aMule.app/Contents/Frameworks;
man otool tells us that the -L switch is used to Display the names and version numbers of  the  shared  libraries that the object file uses.. Object file in this case means the amule, amuleweb, ed2k and amulecmd applications. If you want to check for more applications, add them there.

Just as a reminder: | is the pipe character, it takes all output from one command and sends it as input to another command.

In our case it takes the names and version numbers of all shares libraries and sends it to the sort -u command. This command sorts the names and removes all duplicates.

The sorted list without duplicates is then sent to the grep filter command. The filter is libwx_, this means only libraries with libwx_ in their name will be used. The syntax to filter for multiple libraries would be grep 'libname1\|libname2\|libname3'.

Finally cut is used to separate the input data by a space (" ") and output only the first part. The input "/usr/lib/libnamea 1.2.3" would be separated to "/usr/lib/libnamea" and "1.2.3" and only "/usr/lib/libnamea" would be output.

In the end we get a list of library paths. We copy each of this libraries to the app bundle.


I believe the only thing to change is the grep command to include more libraries.
Title: Re: mac_packager
Post by: mirko.g on September 24, 2009, 09:47:05 AM
I believe the only thing to change is the grep command to include more libraries.

This is why I used:
Code: [Select]
for i in $( otool -L aMule.app/Contents/MacOS/* \
| sort -u | grep -E '/opt/local/|/usr/local/' | cut -d " " -f 1 ); do
cp $i aMule.app/Contents/Frameworks;
done

I've never seen any libwx_ into any (mac os) package since amule 2.2.3... but I can include it too...
Using the syntax above for grep we also need to respect dependencies, so this is necessary too:
Code: [Select]
for i in $( otool -L aMule.app/Contents/Frameworks/* \
| sort -u | grep -E '/opt/local|/usr/local/' | cut -d " " -f 1 ); do
cp $i aMule.app/Contents/Frameworks;
done
Title: Re: mac_packager
Post by: GonoszTopi on September 24, 2009, 10:05:49 AM
Re-read my post. I'm with a high fever and sick as hell, but I can't see how you would take that from my post.
Done, and wishing you the best to get well soon (all lowercase, without (TM) ;) ). I must have misunderstood you.

I believe the only thing to change is the grep command to include more libraries.
Seems to be. Looking at the list mirko.g quoted above, I'd change it to
Code: [Select]
grep -E -v '^\W*/System/|^\W*/usr/lib/'
to filter out system libraries, but that has to be verified by someone actually using mac_packager.
Title: Re: mac_packager
Post by: wuischke on September 24, 2009, 10:06:49 AM
Oh, it looks like I could have spared my explanations, you know well enough what you do...stupid me for not checking your code first.

Anyway:
Quote
You need to modify it so it takes libraries that are not in the default system locations.
Reading this, grep -v '/usr/bin\|/any/other/system/directories' should do the job. I trust you know the relavant directories a lot better than me. ;-)
Title: Re: mac_packager
Post by: mirko.g on September 24, 2009, 10:46:06 AM
Oh, it looks like I could have spared my explanations, you know well enough what you do...stupid me for not checking your code first.

Fortunately bash scripting is not new to me as Mac OS development...  :P

Quote
Reading this, grep -v '/usr/bin\|/any/other/system/directories' should do the job. I trust you know the relavant directories a lot better than me. ;-)

Seems to be. Looking at the list mirko.g quoted above, I'd change it to
Code: [Select]
grep -E -v '^\W*/System/|^\W*/usr/lib/'
to filter out system libraries, but that has to be verified by someone actually using mac_packager.

Inverting the sense of matching you won't filter object file names...
Title: Re: mac_packager
Post by: GonoszTopi on September 24, 2009, 11:10:06 AM
you won't filter object file names...
Should we? In my understanding otool -L (http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/otool.1.html) doesn't produce object file names, nor does the example provided by you (http://forum.amule.org/index.php?topic=17291.msg93168#msg93168) show any.
Title: Re: mac_packager
Post by: mirko.g on September 24, 2009, 11:29:44 AM
Should we? In my understanding otool -L (http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/otool.1.html) doesn't produce object file names, nor does the example provided by you (http://forum.amule.org/index.php?topic=17291.msg93168#msg93168) show any.

I simply cut away the last line.
Code: [Select]
$ otool -L *
amule:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 123.0.0)
/opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/opt/local/lib/libupnp.3.dylib (compatibility version 4.0.0, current version 4.5.0)
/opt/local/lib/libthreadutil.2.dylib (compatibility version 5.0.0, current version 5.3.0)
/opt/local/lib/libixml.2.dylib (compatibility version 3.0.0, current version 3.4.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 152.0.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 15.0.0)
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0, current version 531.9.0)
/opt/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 44.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.0.0)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 38.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 751.0.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1038.0.0)
ed2k:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 123.0.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 44.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.0.0)
otool: can't map file: ed2kHelperScript.app (Invalid argument)
This is the normal output of otool even with one object only.
I should get rid of that error too... maybe this works:
Code: [Select]
for i in $( otool -L aMule.app/Contents/MacOS/* 2> /dev/null \
| sort -u | grep -E '/opt/local/|/usr/local/|libwx_' | cut -d " " -f 1 ); do
cp $i aMule.app/Contents/Frameworks;
done
for i in $( otool -L aMule.app/Contents/Frameworks/* 2> /dev/null \
| sort -u | grep -E '/opt/local/|/usr/local/|libwx_' | cut -d " " -f 1 ); do
cp $i aMule.app/Contents/Frameworks;
done
Title: Re: mac_packager
Post by: GonoszTopi on September 24, 2009, 12:13:35 PM
I should get rid of that error too...

Ok, using
Code: [Select]
grep -E -v '^\W*/System/|^\W*/usr/lib/|^\w'
will get rid of anything not indented (including error messages) besides system libraries (/System/*, /usr/lib/*). What do you think?
Title: Re: mac_packager
Post by: mirko.g on September 24, 2009, 12:15:28 PM
What do you think?

That's perfect!  ;)
Title: Re: mac_packager
Post by: mirko.g on September 24, 2009, 01:24:20 PM
About GeoIP support, this works with libgeoip from MacPorts only and I don't know were the self-compiled version can store GeoIP.dat:
Code: [Select]
$ mkdir aMule.app/Contents/Resources/GeoIP
$ cp -p /opt/local/share/GeoIP/GeoIP.dat aMule.app/Contents/Resources/GeoIP

I don't know if this was in you intentions but it would be great if mac_packager toke care of extra tools too (otherwise, why should we compile them???  :P).
This is what I usually do by hand, for aMule:
Code: [Select]
$ cp src/amuled aMule.app/Contents/MacOS/
$ cp src/utils/aLinkCreator/src/alcc aMule.app/Contents/MacOS/
$ cp src/utils/cas/cas aMule.app/Contents/MacOS/
$ cp src/utils/fileview/mulefileview aMule.app/Contents/MacOS/

aMuleGUI:
Code: [Select]
$ cp src/amulegui aMuleGUI.app/Contents/MacOS/
$ cp src/amulecmd aMuleGUI.app/Contents/MacOS/
$ cp -R src/webserver aMuleGUI.app/Contents/Resources/

wxCas:
Code: [Select]
$ cp src/utils/wxCas/src/wxcas WxCas.app/Contents/MacOS/
aLinkCreator:
Code: [Select]
cp src/utils/aLinkCreator/src/alc aLinkCreator.app/Contents/MacOS/
And for every app I repeat step 3 to 5 of mac_packager.
Do I miss anything else?

(my last revision (http://www.mac-factory.org/redmine/repositories/annotate/macmule/script/mac_packager))
Title: Re: mac_packager
Post by: Stu Redman on September 24, 2009, 11:10:48 PM
About GeoIP support, this works with libgeoip from MacPorts only and I don't know were the self-compiled version can store GeoIP.dat:
SVN is downloading the latest GeoIP.dat itself and stores it in aMule's config folder so don't bother packaging it.  :)
Title: Re: mac_packager
Post by: mr_hyde on September 29, 2009, 04:39:04 AM
Don't know if this can be useful: I rememmber that a user (gtoso) wrote a mac_packager to package not only the monolithic amule...
Try to give a look at http://gtoso.tor.it/pub/amule/osx/svn/OSXBuild/

Bye,
  Mr Hyde
Title: Re: mac_packager
Post by: mirko.g on September 29, 2009, 07:49:23 PM
Don't know if this can be useful: I rememmber that a user (gtoso) wrote a mac_packager to package not only the monolithic amule...
Try to give a look at http://gtoso.tor.it/pub/amule/osx/svn/OSXBuild/

Thanks, good starting point... I was going the same direction: I will save a lot of time... ;)