-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-pkg.sh
More file actions
executable file
·79 lines (62 loc) · 1.84 KB
/
build-pkg.sh
File metadata and controls
executable file
·79 lines (62 loc) · 1.84 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
#!/bin/bash
set -e
# Build macOS installer package (.pkg)
# Usage: ./build-pkg.sh <intel_binary> <arm64_binary> <output_pkg>
if [ $# -ne 3 ]; then
echo "Usage: ./build-pkg.sh <intel_binary> <arm64_binary> <output_pkg>"
echo "Example: ./build-pkg.sh bin/dist/duso-intel bin/dist/duso-arm64 bin/dist/duso.pkg"
exit 1
fi
INTEL_BIN="$1"
ARM64_BIN="$2"
OUTPUT_PKG="$3"
# Check files exist
if [ ! -f "$INTEL_BIN" ]; then
echo "Error: Intel binary not found: $INTEL_BIN"
exit 1
fi
if [ ! -f "$ARM64_BIN" ]; then
echo "Error: ARM64 binary not found: $ARM64_BIN"
exit 1
fi
# Create temporary directories
TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT
PAYLOAD_DIR="$TEMP_DIR/payload/usr/local/bin"
SCRIPTS_DIR="$TEMP_DIR/scripts"
mkdir -p "$PAYLOAD_DIR" "$SCRIPTS_DIR"
# Copy binaries to payload
cp "$INTEL_BIN" "$PAYLOAD_DIR/duso-intel"
cp "$ARM64_BIN" "$PAYLOAD_DIR/duso-silicon"
chmod +x "$PAYLOAD_DIR/duso-intel" "$PAYLOAD_DIR/duso-silicon"
# Create postinstall script
cat > "$SCRIPTS_DIR/postinstall" << 'POSTINSTALL_SCRIPT'
#!/bin/bash
set -e
ARCH=$(uname -m)
INSTALL_DIR="/usr/local/bin"
# Remove existing duso (binary or symlink) if it exists
rm -f "$INSTALL_DIR/duso"
if [ "$ARCH" = "arm64" ]; then
cp "$INSTALL_DIR/duso-silicon" "$INSTALL_DIR/duso"
elif [ "$ARCH" = "x86_64" ]; then
cp "$INSTALL_DIR/duso-intel" "$INSTALL_DIR/duso"
else
echo "Error: Unsupported architecture: $ARCH"
exit 1
fi
chmod +x "$INSTALL_DIR/duso"
rm -f "$INSTALL_DIR/duso-intel" "$INSTALL_DIR/duso-silicon"
echo "duso installed to $INSTALL_DIR/duso"
POSTINSTALL_SCRIPT
chmod +x "$SCRIPTS_DIR/postinstall"
# Build the package
echo "Creating package: $OUTPUT_PKG"
pkgbuild \
--root "$TEMP_DIR/payload" \
--scripts "$SCRIPTS_DIR" \
--install-location "/" \
--identifier com.ludonode.duso \
--version "1.0" \
"$OUTPUT_PKG"
echo "✓ Package created: $OUTPUT_PKG"