Repository navigation
Expand file tree
/
Copy pathmake-dmg.sh
More file actions
executable file
·87 lines (72 loc) · 2.63 KB
/
Copy pathmake-dmg.sh
File metadata and controls
executable file
·87 lines (72 loc) · 2.63 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#
# Packages FlexDisplay as a distributable .dmg.
#
# ./Scripts/make-dmg.sh
#
# Produces build/FlexDisplay-<version>.dmg containing the app and a shortcut to
# /Applications, so installing is the usual drag-and-drop.
#
# Signing: uses whatever build.sh produced. With no FLEXDISPLAY_IDENTITY that is an ad-hoc
# signature, which is fine on the machine that built it but will be blocked by Gatekeeper on
# any other Mac — see the note printed at the end.
#
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
APP_NAME="FlexDisplay"
VOLUME_NAME="FlexDisplay"
cd "$ROOT"
# Always package a release build; a debug binary is slower and much larger.
"$ROOT/Scripts/build.sh" release
APP="$ROOT/build/$APP_NAME.app"
if [[ ! -d "$APP" ]]; then
echo "error: $APP does not exist" >&2
exit 1
fi
VERSION="$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$APP/Contents/Info.plist")"
DMG="$ROOT/build/$APP_NAME-$VERSION.dmg"
STAGING="$ROOT/build/dmg-staging"
echo "==> Staging"
rm -rf "$STAGING"
mkdir -p "$STAGING"
cp -R "$APP" "$STAGING/"
# The /Applications symlink is what makes the window a drag-to-install target.
ln -s /Applications "$STAGING/Applications"
# Finder writes .DS_Store and friends into anything it has looked at; they would otherwise
# be baked into the image.
find "$STAGING" -name '.DS_Store' -delete 2>/dev/null || true
echo "==> Building $DMG"
rm -f "$DMG"
hdiutil create \
-volname "$VOLUME_NAME" \
-srcfolder "$STAGING" \
-ov \
-format UDZO \
-imagekey zlib-level=9 \
"$DMG" >/dev/null
rm -rf "$STAGING"
if [[ -n "${FLEXDISPLAY_IDENTITY:-}" ]]; then
echo "==> Signing the disk image"
codesign --force --sign "$FLEXDISPLAY_IDENTITY" "$DMG"
fi
SIZE="$(du -h "$DMG" | cut -f1)"
echo
echo "==> Done: $DMG ($SIZE)"
echo
echo "To install: open the .dmg and drag FlexDisplay to Applications."
echo
if [[ -z "${FLEXDISPLAY_IDENTITY:-}" ]]; then
cat <<'EOF'
Note on signing
---------------
This build is ad-hoc signed because no Developer ID was available. It runs fine on the
machine that built it. On any OTHER Mac, Gatekeeper will refuse to open it, and the user
would have to clear the quarantine flag by hand:
xattr -dr com.apple.quarantine /Applications/FlexDisplay.app
For real distribution, get a Developer ID Application certificate and re-run:
FLEXDISPLAY_IDENTITY="Developer ID Application: Your Name (TEAMID)" ./Scripts/make-dmg.sh
xcrun notarytool submit build/FlexDisplay-<version>.dmg \
--apple-id you@example.com --team-id TEAMID --password <app-specific-password> --wait
xcrun stapler staple build/FlexDisplay-<version>.dmg
EOF
fi