~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to project/macosx/make-app-bundle

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-09-27 21:41:30 UTC
  • mfrom: (1.2.43)
  • mto: This revision was merged to the branch mainline in revision 86.
  • Revision ID: package-import@ubuntu.com-20120927214130-i8v3ufr21nesp29i
Tags: 4:3.0.0~beta1a-1
* New upstream release

* Fix "wrongly conflicts phonon-backend-vlc" dropped (Closes: #688142)
* debian/watch include download.kde.org

* digikam 3.0.0 uses features from unreleased kdegraphics >=4.10 & ships 
a private version of the kdegraphics libs - this is not the Debian way :-(
* Unsatisfactory Conflicts: libkipi8, libkexiv2-10, libkdcraw20, libksane0
* Suspend digikam-dbg >130Mb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
# Function checkLink:
 
3
# args: $1 - file
 
4
 
 
5
 
 
6
# Will loop through all dynamic links for $file, and update each to be relative.
 
7
function checkLink
 
8
{
 
9
    #echo "checkLink called with $1 $2"
 
10
    local FILE=$1
 
11
 
 
12
    otool -L $FILE | grep -v "${APP}" | grep -v '/usr/lib' | grep -v '/System/' | grep -v "@executable_path" | cut -f 1 -d ' ' | while read X
 
13
    do 
 
14
        local NAME=${LIB}/`basename "$X"`
 
15
        if [ ! -f "${NAME}" ]
 
16
        then
 
17
            cp $X "${NAME}"
 
18
 
 
19
            #Recursively update the linkage of libraries
 
20
            checkLink "${NAME}"
 
21
        fi
 
22
    done
 
23
}
 
24
 
 
25
PROGN=digiKam
 
26
APP=${PROGN}.app
 
27
CONTENTS=${APP}/Contents
 
28
RESOURCES=${CONTENTS}/Resources
 
29
MACOS=${CONTENTS}/MacOS
 
30
BIN=${MACOS}/bin
 
31
ETC=${MACOS}/etc
 
32
LIB=${MACOS}/lib
 
33
SHARE=${MACOS}/share
 
34
RELEASE=build/release
 
35
DMG=${RELEASE}/${PROGN}.dmg
 
36
EXECUTABLE=bin/digikam
 
37
BUILD_FOLDER=./project/macosx
 
38
DTVER=`git describe --tags $branch | sed 's,^release-,,;s,-,+,;s,-,~,;'`
 
39
 
 
40
#Find where MacPorts is installed.  We take a known binary (port), which is in <MacPorts>/bin, and 
 
41
# go up a level to get the main install folder.
 
42
MACPORTS_PREFIX=`which port`
 
43
MACPORTS_PREFIX=`dirname $MACPORTS_PREFIX`
 
44
MACPORTS_PREFIX=`dirname $MACPORTS_PREFIX`
 
45
 
 
46
if [ ! -d ${RELEASE} ]; then
 
47
    echo "Please run this from the root of the project; i.e. ${BUILD_FOLDER}/`basename $0`."
 
48
    exit
 
49
fi
 
50
 
 
51
if [ -d "${APP}" ]; then
 
52
    echo "Removing old application..."
 
53
    rm -rf "${APP}"
 
54
fi
 
55
 
 
56
if [ -f ${DMG} ]; then
 
57
    echo "Removing old disk image..."
 
58
    rm "${DMG}"
 
59
fi
 
60
 
 
61
echo "Making application directory structure..."
 
62
mkdir -p "${RESOURCES}"
 
63
mkdir -p "${ETC}"
 
64
mkdir -p "${LIB}"
 
65
mkdir -p "${SHARE}/mime"
 
66
 
 
67
#Copy over non-explicitly linked libraries
 
68
echo "Copying libraries from ${MACPORTS_PREFIX}..."
 
69
cp -R ${MACPORTS_PREFIX}/lib/pango ${LIB}
 
70
cp -R ${MACPORTS_PREFIX}/lib/gtk-2.0 ${LIB}
 
71
cp -R ${MACPORTS_PREFIX}/lib/gdk-pixbuf-2.0 ${LIB}
 
72
 
 
73
#Copy over mimes (if a mime is copied, and nobody hears, is it really copied?)
 
74
echo "Copying shared files from ${MACPORTS_PREFIX}..."
 
75
cp -R ${MACPORTS_PREFIX}/share/mime/* ${SHARE}/mime
 
76
 
 
77
#Copy over etc files, and modify as needed
 
78
echo "Copying configuration files from ${MACPORTS_PREFIX} and modifying for standalone app bundle..."
 
79
cp -R $MACPORTS_PREFIX/etc/gtk-2.0 ${ETC}
 
80
cp -R $MACPORTS_PREFIX/etc/pango ${ETC}
 
81
ESCAPED_MACPORTS_PREFIX=`echo ${MACPORTS_PREFIX} | sed -e 's/\\//\\\\\\//g'`
 
82
sed -i .bak -e "s/${ESCAPED_MACPORTS_PREFIX}/@executable_path\/../g" ${ETC}/gtk-2.0/gdk-pixbuf.loaders ${ETC}/pango/pango.modules
 
83
echo -e "[Pango]\nModuleFiles = /tmp/`basename ${EXECUTABLE}`_pango.modules" > ${ETC}/pango/pangorc
 
84
 
 
85
#Copy over the release files
 
86
echo "Copying release files..."
 
87
cp -R ${RELEASE}/* ${MACOS}
 
88
 
 
89
#Copy application-specific stuff like icons and startup script
 
90
echo "Creating required application bundle files..."
 
91
cp ${BUILD_FOLDER}/Info.plist ${CONTENTS}
 
92
sed -i -e 's/VERSION/'${DTVER}'/g' ${CONTENTS}/Info.plist
 
93
cp cmake/macosx/darktable.icns ${RESOURCES}
 
94
cp ${BUILD_FOLDER}/start ${MACOS}
 
95
 
 
96
#Copy and relink the explicitly defined libraries
 
97
echo "Recursively copying libraries referenced by executable..."
 
98
checkLink "${MACOS}/${EXECUTABLE}"
 
99
 
 
100
#Make a .dmg for distribution and delete the .app
 
101
echo "Creating distribution .dmg ..."
 
102
 
 
103
# Creating temporary rw image
 
104
SIZE=$(( $(du -sm "${APP}"| awk '{print $1}') + 3 ))
 
105
hdiutil create -srcfolder "${APP}" -volname "${PROGN}" -fs HFS+ \
 
106
               -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M pack.temp.dmg
 
107
 
 
108
# mounting image without auto-open to create window style params
 
109
device=$(hdiutil attach -readwrite -noverify -noautoopen "pack.temp.dmg" | \
 
110
         egrep '^/dev/' | sed 1q | awk '{print $1}')
 
111
echo '
 
112
 tell application "Finder"
 
113
    tell disk "'${PROGN}'"
 
114
        open
 
115
        set current view of container window to icon view
 
116
        set toolbar visible of container window to false
 
117
        set statusbar visible of container window to false
 
118
        set the bounds of container window to {400, 100, 885, 330}
 
119
        set theViewOptions to the icon view options of container window
 
120
        set arrangement of theViewOptions to not arranged
 
121
        set icon size of theViewOptions to 72
 
122
        #   set background picture of theViewOptions to file ".backgroundimage:digikam.svg"
 
123
        make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
 
124
        set position of item "'${PROGN}'" of container window to {100, 100}
 
125
        set position of item "Applications" of container window to {375, 100}
 
126
        update without registering applications
 
127
        close
 
128
        open
 
129
        delay 5
 
130
    end tell
 
131
 end tell
 
132
' | osascript
 
133
 
 
134
# Finalizing creation 
 
135
chmod -Rf go-w /Volumes/"${PROGN}"
 
136
sync
 
137
sync
 
138
hdiutil detach ${device}
 
139
 
 
140
if [ -f build/"${PROGN}".dmg ]
 
141
   then echo "removing old .dmg file" && rm -if build/"${PROGN}".dmg
 
142
fi
 
143
 
 
144
hdiutil convert "pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o build/"${PROGN}"
 
145
rm -f pack.temp.dmg 
 
146
 
 
147
echo "Cleaning up..."
 
148
rm -rf ${APP}
 
149
du -sh build/"${PROGN}".dmg
 
150
 
 
151
echo "All done!"