-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_mac_app.sh
More file actions
executable file
·143 lines (119 loc) · 4.57 KB
/
Copy pathcreate_mac_app.sh
File metadata and controls
executable file
·143 lines (119 loc) · 4.57 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
set -e
APP_NAME="Playerr"
ARCH="${1:-osx-arm64}" # Default to osx-arm64 if not provided
BUILD_DIR="build_artifacts/$ARCH"
OUTPUT_DIR="build_artifacts"
APP_BUNDLE="$OUTPUT_DIR/Playerr-$ARCH.app"
# Ensure build exists
if [ ! -d "$BUILD_DIR" ]; then
echo "Error: Build directory $BUILD_DIR does not exist. Run ./build_all.sh first."
exit 1
fi
echo "Creating macOS Bundle: $APP_BUNDLE..."
# Create structure
rm -rf "$APP_BUNDLE"
mkdir -p "$APP_BUNDLE/Contents/MacOS"
mkdir -p "$APP_BUNDLE/Contents/Resources"
# Create Icon
ICON_SRC="frontend/src/assets/app_logo.png"
if [ -f "$ICON_SRC" ] && command -v iconutil >/dev/null; then
echo "Generating .icns icon..."
ICONSET_DIR="MyIcon.iconset"
mkdir -p "$ICONSET_DIR"
# Create required sizes from source image (now square and transparent)
sips -z 16 16 "$ICON_SRC" --out "$ICONSET_DIR/icon_16x16.png" > /dev/null
sips -z 32 32 "$ICON_SRC" --out "$ICONSET_DIR/icon_16x16@2x.png" > /dev/null
sips -z 32 32 "$ICON_SRC" --out "$ICONSET_DIR/icon_32x32.png" > /dev/null
sips -z 64 64 "$ICON_SRC" --out "$ICONSET_DIR/icon_32x32@2x.png" > /dev/null
sips -z 128 128 "$ICON_SRC" --out "$ICONSET_DIR/icon_128x128.png" > /dev/null
sips -z 256 256 "$ICON_SRC" --out "$ICONSET_DIR/icon_128x128@2x.png" > /dev/null
sips -z 256 256 "$ICON_SRC" --out "$ICONSET_DIR/icon_256x256.png" > /dev/null
sips -z 512 512 "$ICON_SRC" --out "$ICONSET_DIR/icon_256x256@2x.png" > /dev/null
sips -z 512 512 "$ICON_SRC" --out "$ICONSET_DIR/icon_512x512.png" > /dev/null
sips -z 1024 1024 "$ICON_SRC" --out "$ICONSET_DIR/icon_512x512@2x.png" > /dev/null
iconutil -c icns "$ICONSET_DIR" -o "$APP_BUNDLE/Contents/Resources/AppIcon.icns"
rm -rf "$ICONSET_DIR"
else
echo "Warning: Icon source not found or iconutil missing. Skipping icon generation."
fi
# Create Info.plist
cat > "$APP_BUNDLE/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>$APP_NAME</string>
<key>CFBundleDisplayName</key>
<string>$APP_NAME</string>
<key>CFBundleIdentifier</key>
<string>app.playerr.desktop</string>
<key>CFBundleShortVersionString</key>
<string>0.4.8</string>
<key>CFBundleVersion</key>
<string>0.4.8</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleExecutable</key>
<string>Launcher</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>LSUIElement</key>
<false/>
</dict>
</plist>
EOF
# Create Launcher script
# This script ensures the binary runs with the correct working directory
cat > "$APP_BUNDLE/Contents/MacOS/Launcher" <<EOF
#!/bin/bash
DIR="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
# Execute Playerr.Host which is located next to this script (we will copy files there)
cd "\$DIR"
./Playerr.Host
EOF
chmod +x "$APP_BUNDLE/Contents/MacOS/Launcher"
# Copy all build artifacts into MacOS folder
echo "Copying application files..."
cp -R "$BUILD_DIR/"* "$APP_BUNDLE/Contents/MacOS/"
# Copy UI assets
echo "Copying UI assets..."
mkdir -p "$APP_BUNDLE/Contents/MacOS/_output/UI"
cp -a _output/UI/* "$APP_BUNDLE/Contents/MacOS/_output/UI/" 2>/dev/null || true
echo "Applying permissions and signing..."
chmod +x "$APP_BUNDLE/Contents/MacOS/Launcher"
chmod +x "$APP_BUNDLE/Contents/MacOS/Playerr.Host"
chmod +x "$APP_BUNDLE/Contents/MacOS/Photino.Native.dylib"
# Remove quarantine attributes to avoid "App is damaged" errors
xattr -cr "$APP_BUNDLE"
# Ad-hoc signing to satisfy Gatekeeper requirements
if command -v codesign >/dev/null; then
echo "Ad-hoc signing the app bundle..."
codesign --force --deep --sign - "$APP_BUNDLE"
fi
echo "=================================="
echo "Bundle Created Successfully!"
echo "Location: $APP_BUNDLE"
echo "=================================="
# Create DMG
DMG_NAME="$OUTPUT_DIR/Playerr-$ARCH.dmg"
VOL_NAME="Playerr Installer ($ARCH)"
echo "Creating DMG Installer: $DMG_NAME..."
rm -f "$DMG_NAME"
# Create a temporary folder for DMG content
DMG_TMP="_dmg_tmp"
rm -rf "$DMG_TMP"
mkdir -p "$DMG_TMP"
# Copy App to tmp
cp -R "$APP_BUNDLE" "$DMG_TMP/"
# Create Link to Applications
ln -s /Applications "$DMG_TMP/Applications"
# Create DMG
hdiutil create -volname "$VOL_NAME" -srcfolder "$DMG_TMP" -ov -format UDZO "$DMG_NAME"
# Clean up
rm -rf "$DMG_TMP"
echo "=================================="
echo "DMG Created Successfully!"
echo "File: $DMG_NAME"
echo "=================================="