PageRenderTime 105ms CodeModel.GetById 60ms app.highlight 11ms RepoModel.GetById 30ms app.codeStats 0ms

/admin/mac/create-dmg.sh

http://github.com/tomahawk-player/tomahawk
Shell | 59 lines | 22 code | 12 blank | 25 comment | 1 complexity | b33bde83c6858e7c42daf7c50fe5b633 MD5 | raw file
 1#!/bin/sh
 2# author: max@last.fm, muesli@tomahawk-player.org
 3# brief:  Produces a compressed DMG from a bundle directory
 4# usage:  Pass the bundle directory as the only parameter
 5# note:   This script depends on the Tomahawk build system, and must be run from
 6#         the build directory
 7################################################################################
 8
 9
10#if [ -z $VERSION ]
11#then
12#    echo VERSION must be set
13#    exit 2
14#fi
15
16if [ -z "$1" ]
17then
18    echo "Please pass the bundle.app directory as the first parameter."
19    exit 3
20fi
21################################################################################
22
23
24NAME=$(basename "$1" | perl -pe 's/(.*).app/\1/')
25IN="$1"
26TMP="dmg/$NAME"
27OUT="$NAME.dmg"
28mkdir -p "$TMP"
29################################################################################
30
31
32# clean up
33rm -rf "$TMP"
34rm -f "$OUT"
35
36# create DMG contents and copy files
37mkdir -p "$TMP/.background"
38cp ../admin/mac/dmg_background.png "$TMP/.background/background.png"
39cp ../admin/mac/DS_Store.in "$TMP/.DS_Store"
40chmod go-rwx "$TMP/.DS_Store"
41ln -s /Applications "$TMP/Applications"
42# copies the prepared bundle into the dir that will become the DMG 
43cp -R "$IN" "$TMP"
44
45# create
46hdiutil makehybrid -hfs -hfs-volume-name "$NAME" -hfs-openfolder "$TMP" "$TMP" -o tmp.dmg
47hdiutil convert -format UDZO -imagekey zlib-level=9 tmp.dmg -o "$OUT"
48
49# cleanup
50rm tmp.dmg
51
52#hdiutil create -srcfolder "$TMP" \
53#               -format UDZO -imagekey zlib-level=9 \
54#               -scrub \
55#               "$OUT" \
56#               || die "Error creating DMG :("
57
58# done !
59echo 'DMG size:' `du -hs "$OUT" | awk '{print $1}'`