File: build-dmg.sh

package info (click to toggle)
tuxpaint 1%3A0.9.35-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 64,512 kB
  • sloc: ansic: 62,209; makefile: 1,425; sh: 790; objc: 303; cpp: 186; python: 182; php: 43
file content (69 lines) | stat: -rwxr-xr-x 2,174 bytes parent folder | download | duplicates (2)
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
61
62
63
64
65
66
67
68
69
#!/bin/bash

##############################################################################
# Script to generate TuxPaint.dmg from TuxPaint.app.
#
# Generating a pretty DMG file programmatically is a bit of an art.  Many
# thanks to the appdmg project for showing how:
# (https://github.com/LinusU/node-appdmg)
#

BUNDLE=TuxPaint.app

if [[ ! -d "$BUNDLE" ]]; then
    ARCHBUNDLE=TuxPaint-$(uname -m).app

    if [[ -d "$ARCHBUNDLE" ]]; then
        echo "  $BUNDLE missing.  Did you forget to either run 'macos/build-universal.sh' first,"
        echo "  or rename $ARCHBUNDLE to $BUNDLE first?"
    else
        echo "  Did you forget to 'make' $ARCHBUNDLE first?"
    fi 1>&2

    exit 1
fi

TEMP_DMG=temp.dmg
TEMP_DMG_SIZE=`expr \`du -sm "$BUNDLE" | cut -f1\` \* 15 / 10`m
FINAL_DMG=TuxPaint.dmg
VOLNAME="Tux Paint"
ICON="macos/tuxpaint.icns"
BACKGROUND="macos/background.png"

echo "   * Creating the temporary image..."
hdiutil create "$TEMP_DMG" -ov -fs HFS+ -size "$TEMP_DMG_SIZE" -volname "$VOLNAME" \
&& VOLUME=`hdiutil attach "$TEMP_DMG" -nobrowse -noverify -noautoopen | grep Apple_HFS | sed 's/^.*Apple_HFS[[:blank:]]*//'` \
|| exit 1

echo "   * Adding the image background..."
mkdir "$VOLUME/.background" \
&& tiffutil -cathidpicheck "$BACKGROUND" -out "$VOLUME/.background/background.tiff" \
|| exit 1

echo "   * Setting the folder icon..."
cp "$ICON" "$VOLUME/.VolumeIcon.icns" \
&& xattr -wx com.apple.FinderInfo '00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' "$VOLUME" \
|| exit 1

echo "   * Copying the contents..."
ln -s "/Applications" "$VOLUME" \
&& cp -a "$BUNDLE" "$VOLUME" \
&& cp -a "macos/DS_Store" "$VOLUME/.DS_Store" \
|| exit 1

echo "   * Configuring the folder to open upon mount..."
if [[ "$(uname -m)" == "arm64" ]]; then
    bless --folder "$VOLUME"
else
    bless --folder "$VOLUME" --openfolder "$VOLUME"
fi || exit 1

echo "   * Unmounting the temporary image..."
hdiutil detach "$VOLUME"

echo "   * Creating the final image..."
hdiutil convert "$TEMP_DMG" -ov -format "UDBZ" -imagekey "zlib-level=9" -o "$FINAL_DMG"

echo "   * Deleting the temporary image..."
rm -f "$TEMP_DMG"