Difference between revisions of "Projects/Marble/MacPackaging"

Jump to: navigation, search
(moved from Projects/Marble)
 
(update dmg script to latest version)
 
(2 intermediate revisions by 2 users not shown)
Line 12: Line 12:
 
To generate a Diskimage (.dmg) one can use this script (based on parts by Tim Sutton, thanks!):
 
To generate a Diskimage (.dmg) one can use this script (based on parts by Tim Sutton, thanks!):
  
<code bash>
+
<syntaxhighlight lang="bash">
VERSION=0.7.1
+
VERSION=1.3.0
 
APPNAME=Marble
 
APPNAME=Marble
 
+
 
VOLNAME=${APPNAME}-${VERSION}
 
VOLNAME=${APPNAME}-${VERSION}
 
DMGNAME=${VOLNAME}Uncompressed.dmg
 
DMGNAME=${VOLNAME}Uncompressed.dmg
 
COMPRESSEDDMGNAME=${VOLNAME}.dmg
 
COMPRESSEDDMGNAME=${VOLNAME}.dmg
 
+
 
function deploy_file() {
 
function deploy_file() {
for n in $(otool -L $1 | grep Qt); do
+
LOCAL_LIB_PATH=/usr/local/Cellar/qt/4.8.0/lib
path=`echo $n | grep Qt`
+
for n in $(otool -L $1 | grep -E \(Qt\|phonon\)); do
 +
path=`echo $n | grep -E \(Qt\|phonon\)`
 
    if [ $path ] ; then
 
    if [ $path ] ; then
 
    name=$(basename $path)
 
    name=$(basename $path)
Line 28: Line 29:
 
fi
 
fi
 
done
 
done
 
+
 
for framework in $FRAMEWORKS ; do
 
for framework in $FRAMEWORKS ; do
 
install_name_tool -change \
 
install_name_tool -change \
$framework.framework/Versions/4/$framework \
+
$LOCAL_LIB_PATH/$framework.framework/Versions/4/$framework \
 
@executable_path/../Frameworks/$framework.framework/Versions/4/$framework \
 
@executable_path/../Frameworks/$framework.framework/Versions/4/$framework \
 
$1
 
$1
 
done
 
done
 
}
 
}
 
+
 
function deploy_plugins() {
 
function deploy_plugins() {
for plugin in $1/Contents/Resources/plugins/*; do
+
find $1/Contents/MacOS/resources/plugins -iname *.so | while read plugin; do
 
deploy_file $plugin
 
deploy_file $plugin
 
done
 
done
 
}
 
}
 
+
 
function set_bundle_display_options() {
 
function set_bundle_display_options() {
 
osascript <<-EOF
 
osascript <<-EOF
Line 59: Line 60:
 
             set icon size of the icon view options of container window to 64
 
             set icon size of the icon view options of container window to 64
 
             set arrangement of the icon view options of container window to not arranged
 
             set arrangement of the icon view options of container window to not arranged
             set position of item "Marble.app" to {100,150}
+
             set position of item "Applications" to {100,150}
             set position of item "Applications" to {280, 150}
+
             set position of item "Marble.app" to {280, 150}
             set background picture of the icon view options of container window to file "background.png" of folder "Pictures"
+
             set background picture of the icon view options of container window to file "background.jpg" of folder "Pictures"
 
             set the bounds of the container window to {0, 0, 300, 400}
 
             set the bounds of the container window to {0, 0, 300, 400}
 
             update without registering applications
 
             update without registering applications
Line 70: Line 71:
 
     end tell
 
     end tell
 
EOF
 
EOF
 
+
 
}
 
}
 
+
 
function create_symlinks() {
 
function create_symlinks() {
 
cd "$1/Contents/Resources"
 
cd "$1/Contents/Resources"
Line 79: Line 80:
 
cd -
 
cd -
 
}
 
}
 
+
 
+
 
+
 
+
 
rm ~/Desktop/${DMGNAME}
 
rm ~/Desktop/${DMGNAME}
 
rm ~/Desktop/${COMPRESSEDDMGNAME}
 
rm ~/Desktop/${COMPRESSEDDMGNAME}
hdiutil create -size 150m -fs HFS+ -volname ${VOLNAME} ~/Desktop/${DMGNAME}
+
hdiutil create -size 250m -fs HFS+ -volname ${VOLNAME} ~/Desktop/${DMGNAME}
 
+
 
# Mount the disk image
 
# Mount the disk image
 
hdiutil attach ~/Desktop/${DMGNAME}
 
hdiutil attach ~/Desktop/${DMGNAME}
 
+
 
# Obtain device information
 
# Obtain device information
 
DEVS=$(hdiutil attach ~/Desktop/${DMGNAME} | cut -f 1)
 
DEVS=$(hdiutil attach ~/Desktop/${DMGNAME} | cut -f 1)
 
DEV=$(echo $DEVS | cut -f 1 -d ' ')
 
DEV=$(echo $DEVS | cut -f 1 -d ' ')
 
VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
 
VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
 
+
 
# copy in the application bundle
 
# copy in the application bundle
 
cp -Rp /Applications/${APPNAME}.app ${VOLUME}/${APPNAME}.app
 
cp -Rp /Applications/${APPNAME}.app ${VOLUME}/${APPNAME}.app
 
+
 
# fix the libs
 
# fix the libs
 
macdeployqt ${VOLUME}/${APPNAME}.app
 
macdeployqt ${VOLUME}/${APPNAME}.app
 
create_symlinks ${VOLUME}/${APPNAME}.app
 
create_symlinks ${VOLUME}/${APPNAME}.app
deploy_file "${VOLUME}/${APPNAME}.app/Contents/MacOS/lib/libmarblewidget.7.dylib"
+
deploy_file "${VOLUME}/${APPNAME}.app/Contents/MacOS/lib/libmarblewidget.13.dylib"
 
deploy_plugins ${VOLUME}/${APPNAME}.app
 
deploy_plugins ${VOLUME}/${APPNAME}.app
 +
 +
# copy the translations
 +
cp -r marble/tools/translations/lang ${VOLUME}/${APPNAME}.app/Contents/MacOS/resources/data
  
 
# copy in background image
 
# copy in background image
 
mkdir -p ${VOLUME}/Pictures
 
mkdir -p ${VOLUME}/Pictures
# fixme: path
+
cp marble/install_mac/marble_mac.jpg ${VOLUME}/Pictures/background.jpg
cp ~/Desktop/marble-dmg-background.png ${VOLUME}/Pictures/background.png
+
 
# symlink applications
 
# symlink applications
 
ln -s /Applications/ ${VOLUME}/Applications
 
ln -s /Applications/ ${VOLUME}/Applications
 
set_bundle_display_options ${VOLUME}
 
set_bundle_display_options ${VOLUME}
 
mv ${VOLUME}/Pictures ${VOLUME}/.Pictures
 
mv ${VOLUME}/Pictures ${VOLUME}/.Pictures
 
+
 
# Unmount the disk image
 
# Unmount the disk image
 
hdiutil detach $DEV
 
hdiutil detach $DEV
Line 118: Line 121:
 
# Convert the disk image to read-only
 
# Convert the disk image to read-only
 
hdiutil convert ~/Desktop/${DMGNAME} -format UDBZ -o ~/Desktop/${COMPRESSEDDMGNAME}
 
hdiutil convert ~/Desktop/${DMGNAME} -format UDBZ -o ~/Desktop/${COMPRESSEDDMGNAME}
</code>
+
 
 +
</syntaxhighlight>
  
  

Latest revision as of 18:41, 19 January 2013

[edit] Packaging Marble

Here is some advice about how packaging is supposed to happen on the mac platform.

[edit] Qt-Only

Configure Marble with:

cmake -DCMAKE_BUILD_TYPE=release -DQTONLY=ON -DCMAKE_INSTALL_PREFIX=/Applications/ ../marble

To generate a Diskimage (.dmg) one can use this script (based on parts by Tim Sutton, thanks!):

VERSION=1.3.0
APPNAME=Marble
 
VOLNAME=${APPNAME}-${VERSION}
DMGNAME=${VOLNAME}Uncompressed.dmg
COMPRESSEDDMGNAME=${VOLNAME}.dmg
 
function deploy_file() {
	LOCAL_LIB_PATH=/usr/local/Cellar/qt/4.8.0/lib
	for n in $(otool -L $1 | grep -E \(Qt\|phonon\)); do
		path=`echo $n | grep -E \(Qt\|phonon\)`
	    if [ $path ] ; then
	    	name=$(basename $path)
			FRAMEWORKS="$FRAMEWORKS $name"
		fi
	done
 
	for framework in $FRAMEWORKS ; do
		install_name_tool -change \
			$LOCAL_LIB_PATH/$framework.framework/Versions/4/$framework \
			@executable_path/../Frameworks/$framework.framework/Versions/4/$framework \
			$1
	done
}
 
function deploy_plugins() {
	find $1/Contents/MacOS/resources/plugins -iname *.so | while read plugin; do
		deploy_file $plugin
	done
}
 
function set_bundle_display_options() {
	osascript <<-EOF
    tell application "Finder"
        set f to POSIX file ("${1}" as string) as alias
        tell folder f
            open
            tell container window
                set toolbar visible to false
                set statusbar visible to false
                set current view to icon view
                delay 1 -- sync
                set the bounds to {20, 50, 300, 400}
            end tell
            delay 1 -- sync
            set icon size of the icon view options of container window to 64
            set arrangement of the icon view options of container window to not arranged
            set position of item "Applications" to {100,150}
            set position of item "Marble.app" to {280, 150}
            set background picture of the icon view options of container window to file "background.jpg" of folder "Pictures"
            set the bounds of the container window to {0, 0, 300, 400}
            update without registering applications
            delay 5 -- sync
            close
        end tell
        delay 5 -- sync
    end tell
EOF
 
}
 
function create_symlinks() {
	cd "$1/Contents/Resources"
	ln -s "../MacOS/resources/data/"    "data"
	ln -s "../MacOS/resources/plugins/" "plugins"
	cd -
}
 
 
 
 
rm ~/Desktop/${DMGNAME}
rm ~/Desktop/${COMPRESSEDDMGNAME}
hdiutil create -size 250m -fs HFS+ -volname ${VOLNAME} ~/Desktop/${DMGNAME}
 
# Mount the disk image
hdiutil attach ~/Desktop/${DMGNAME}
 
# Obtain device information
DEVS=$(hdiutil attach ~/Desktop/${DMGNAME} | cut -f 1)
DEV=$(echo $DEVS | cut -f 1 -d ' ')
VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
 
# copy in the application bundle
cp -Rp /Applications/${APPNAME}.app ${VOLUME}/${APPNAME}.app
 
# fix the libs
macdeployqt ${VOLUME}/${APPNAME}.app
create_symlinks ${VOLUME}/${APPNAME}.app
deploy_file "${VOLUME}/${APPNAME}.app/Contents/MacOS/lib/libmarblewidget.13.dylib"
deploy_plugins ${VOLUME}/${APPNAME}.app
 
# copy the translations
cp -r marble/tools/translations/lang ${VOLUME}/${APPNAME}.app/Contents/MacOS/resources/data
 
# copy in background image
mkdir -p ${VOLUME}/Pictures
cp marble/install_mac/marble_mac.jpg ${VOLUME}/Pictures/background.jpg
# symlink applications
ln -s /Applications/ ${VOLUME}/Applications
set_bundle_display_options ${VOLUME}
mv ${VOLUME}/Pictures ${VOLUME}/.Pictures
 
# Unmount the disk image
hdiutil detach $DEV
 
# Convert the disk image to read-only
hdiutil convert ~/Desktop/${DMGNAME} -format UDBZ -o ~/Desktop/${COMPRESSEDDMGNAME}


It uses the macdeployqt tool which copies Qt and its plugins into the App Bundle. macdeployqt also tells the main application to link against the libs contained in the bundle, instead of the system libs. This does not happen to the libmarblewidget and the Marble plugins, so it has to be done by the script. The script also sets a background Image for the dmg. (Place it at ~/Desktop/marble-dmg-background.png or change the path in the script)

After that you should have Marble-version.dmg on you Desktop.


This page was last modified on 19 January 2013, at 18:41. This page has been accessed 3,032 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal