4 # package a combination of sfa+sface into a snow leopard dmg install disk
7 # we leverage the first similar packaging initially made by Baris Metin
10 # sface-skel.dmg is the skeleton that has Qt and all the other third-party software
11 # it is expected to be found in the local directory
12 # should be made available on http://mirror.onelab.eu/third-party/ as well
13 # the script expects the taglevels for both sfa and sface,
14 # in order to retrieve the corresponding code and to label the resulting package properly
17 # the place to search for the skeleton
18 SKEL_REPO=http://mirror.onelab.eu/third-party
20 sfa_GITPATH=git://git.onelab.eu/sfa.git@sfa-1.0-20
21 sface_GITPATH=git://git.onelab.eu/sface.git@sface-0.1-5
22 sface_GITPATH=git://git.onelab.eu/sface.git@master
24 # hard-wired for snow-leopard for now
27 # does not affect final dmg size as it's compressed
30 ########################################
31 COMMAND=$(basename $0)
33 # extract the tag part of a GITPATH
34 function git_url () { echo $1 | cut -d @ -f 1 ; }
35 function git_tag () { echo $1 | cut -d @ -f 2 ; }
37 # go in $dest and retrieve $path part of codebase based on gitpath, e.g.
39 # git://git.onelab.eu/sface.git@sface-0.1-5
41 # /Volumes/sface-skel-sn/sface.app/Contents/Resources/
42 # or, with the -f (-file) option:
44 # git://git.onelab.eu/sface.git@sface-0.1-5
46 # /Volumes/sface-skel-sn/sface.app/appIcon.icns
47 function git_retrieve () {
49 case "$1" in -f|--file) filemode=true; shift;; esac
54 giturl=$(git_url $gitpath)
55 gittag=$(git_tag $gitpath)
56 if [ -z "$filemode"] ; then
57 [ -d $dest ] || mkdir -p $dest
58 pushd $dest >& /dev/null
59 git archive --remote=${giturl} ${gittag} | tar -xf - ${path}
62 git archive --remote=${giturl} ${gittag} | tar -xOf - ${path} > ${dest}
72 skel_name=sface-skel-${arch}
73 skel_dmg=./${skel_name}.dmg
74 skel_mnt=/Volumes/${skel_name}
76 sfa_release=sfa-$(git_tag $sfa_GITPATH | sed -e s,sfa-,,)
77 sface_release=sface-$(git_tag $sface_GITPATH | sed -e s,sface-,,)
78 release=$(git_tag $sfa_GITPATH)-$(git_tag $sface_GITPATH)
80 img_name=${sface_release}-${sfa_release}-${arch}
81 img_dmg=./${img_name}.dmg
82 img_raw_dmg=./${img_name}.raw.dmg
83 img_mnt=/Volumes/${img_name}
86 [ -f $img_dmg ] && die "output dmg $img_dmg already exists"
87 [ -f $img_raw_dmg ] && die "please clean up tmp file $img_raw_dmg"
89 # mount the skeleton if not yet avail.
90 if [ ! -d $skel_mnt ] ; then
92 if [ ! -f $skel_dmg ] ; then
93 echo "Retrieving $skel_dmg from $SKEL_REPO"
94 curl -O $SKEL_REPO/$skel_dmg
96 # needless to check for existence as curl will have created on anyway
97 if ! hdiutil mount $skel_dmg ; then
98 die "Could not mount $skel_dmg
99 Please check it is published at $SKEL_REPO
100 Also make sure to trash the current one before retrying"
103 [ -d $skel_mnt ] || die "Could not mount skeleton $skel_dmg"
105 # if image already mounted, it's an old run
106 [ -d $img_mnt ] && die "Image already mounted on $img_mount"
108 hdiutil create -size $DISK_SIZE -fs HFS+J -volname ${img_name} $img_raw_dmg
109 hdiutil attach -readwrite -mount required $img_raw_dmg
111 # copy skeleton as-is
112 tar -C $skel_mnt -cf - . | tar -C $img_mnt -xf -
113 # places relative to mount point
115 resource_path=$app/Contents/Resources
116 bin_path=$app/Contents/MacOS
117 icon_path=$app/Contents/Resources/
118 background_path=background
119 # retrieve sfa/sfa and sface/sface in the image
120 git_retrieve $sfa_GITPATH sfa $img_mnt/$resource_path/
121 git_retrieve $sface_GITPATH sface $img_mnt/$resource_path/
122 # copy binaries from sface to the bin dir
123 for bin in sface.bin sface-run; do
124 git_retrieve --file $sface_GITPATH $bin $img_mnt/$bin_path/$bin
126 # install background and app icons
127 git_retrieve --file $sface_GITPATH macos/background.png $img_mnt/$background_path/background.png
128 git_retrieve --file $sface_GITPATH macos/appIcon.icns $img_mnt/$icon_path/appIcon.icns
130 git_retrieve --file $sface_GITPATH macos/appIcon.icns $img_mnt/.VolumeIcon.icns
132 # this apparently requires xcode
133 /Developer/Tools/SetFile -a V $img_mnt/$background_path
134 # clean up just in case
135 find $img_mnt -name '*pyc' | xargs rm -f
136 find $img_mnt -name '*~' | xargs rm -f
138 echo "Please open $img_mnt under Finder ..."
141 hdiutil detach $img_mnt
143 hdiutil convert -format UDZO -imagekey zlib-level=9 -o $img_dmg $img_raw_dmg
144 # clean up the raw image
146 # unmount the skeleton
147 hdiutil unmount $skel_mnt