aboutsummaryrefslogtreecommitdiff
path: root/contrib/create_osx_dmg.sh
blob: af164e56cf357f881134d5118c92cc8d3d223a8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
# 
# Creates a Bitcoin.dmg OSX file from the contrib/BitcoinTemplate.dmg file
#
# Recipe from: http://digital-sushi.org/entry/how-to-create-a-disk-image-installer-for-apple-mac-os-x/
#
# To make a prettier BitcoinTemplate.dmg:
#  + open (mount) BitcoinTemplate.dmg
#  + change the file properties, icon positions, background image, etc
#  + eject, then commit the changed BitcoinTemplate.dmg
#

CWD=$(pwd)

if [ $# -lt 1 ]; then
    if [ $(basename $CWD) == "contrib" ]
    then
        TOP=$(dirname $CWD)
    else
        echo "Usage: $0 /path/to/bitcoin/tree"
        exit 1
    fi
else
    TOP=$1
fi

CONTRIB=$TOP/contrib
BUILD_DIR=/tmp/bitcoin_osx_build

# First, compile bitcoin and bitcoind
cd "$TOP/src"
if [ ! -e bitcoin ]; then make -f makefile.osx bitcoin; fi
if [ ! -e bitcoind ]; then make -f makefile.osx bitcoind; fi
strip bitcoin bitcoind

mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"

rm -f Bitcoin.sparseimage
hdiutil convert "$CONTRIB/BitcoinTemplate.dmg" -format UDSP -o Bitcoin
hdiutil mount Bitcoin.sparseimage

# Copy over placeholders in /Volumes/Bitcoin
cp "$TOP/src/bitcoind" /Volumes/Bitcoin/
cp "$TOP/src/bitcoin" /Volumes/Bitcoin/Bitcoin.app/Contents/MacOS/

# Create source code .zip
cd "$TOP"
git archive -o /Volumes/Bitcoin/bitcoin.zip $(git branch 2>/dev/null|grep -e ^* | cut -d ' ' -f 2)

# Fix permissions
chmod -Rf go-w /Volumes/Bitcoin

cd "$BUILD_DIR"
hdiutil eject /Volumes/Bitcoin
rm -f "$CWD/Bitcoin.dmg"
hdiutil convert Bitcoin.sparseimage -format UDBZ -o "$CWD/Bitcoin.dmg"

cd "$CWD"
rm -rf "$BUILD_DIR"