Skip to content

Commit f82debc

Browse files
committed
Add macOS DMG packaging script and SHA256 checksum generator
create-dmg.sh builds a distributable .dmg with binary, start.sh, web-static, explorer, config, and bundled libsecp256k1. Supports both x86_64 and arm64 architectures with install_name_tool fixup.
1 parent 2ce272d commit f82debc

2 files changed

Lines changed: 175 additions & 0 deletions

File tree

installer/checksums.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# Generate SHA256 checksums for all release artifacts
3+
#
4+
# Usage: ./checksums.sh [directory]
5+
# Default: current directory
6+
#
7+
# Generates SHA256SUMS file compatible with `sha256sum -c`
8+
9+
set -e
10+
11+
DIR="${1:-.}"
12+
OUTPUT="$DIR/SHA256SUMS"
13+
14+
echo "Generating SHA256 checksums for release artifacts in $DIR"
15+
echo ""
16+
17+
cd "$DIR"
18+
rm -f SHA256SUMS
19+
20+
# Find release artifacts
21+
FILES=$(find . -maxdepth 1 \( \
22+
-name '*.dmg' -o \
23+
-name '*.exe' -o \
24+
-name '*.zip' -o \
25+
-name '*.tar.gz' -o \
26+
-name '*-setup*' -o \
27+
-name 'c2pool-*' -type d \
28+
\) | sort)
29+
30+
if [ -z "$FILES" ]; then
31+
echo "No release artifacts found. Looking for binaries..."
32+
FILES=$(find . -maxdepth 2 -name 'c2pool' -o -name 'c2pool.exe' | sort)
33+
fi
34+
35+
for f in $FILES; do
36+
[ -f "$f" ] || continue
37+
sha256sum "$f" >> SHA256SUMS 2>/dev/null || shasum -a 256 "$f" >> SHA256SUMS
38+
echo " $(tail -1 SHA256SUMS)"
39+
done
40+
41+
echo ""
42+
echo "Written to: $DIR/SHA256SUMS"
43+
cat SHA256SUMS

installer/macos/create-dmg.sh

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/bin/bash
2+
# c2pool macOS DMG builder
3+
#
4+
# Usage:
5+
# ./create-dmg.sh <binary> <arch>
6+
#
7+
# Examples:
8+
# ./create-dmg.sh ~/c2pool-build/build/src/c2pool/c2pool x86_64
9+
# ./create-dmg.sh ~/c2pool-build/build-arm64/src/c2pool/c2pool arm64
10+
#
11+
# The script expects web-static/, explorer/, config/, start.sh in the
12+
# repo root (same level as src/). Output: c2pool-VERSION-macos-ARCH.dmg
13+
14+
set -e
15+
16+
BINARY="$1"
17+
ARCH="${2:-$(uname -m)}"
18+
VERSION="0.1.1-alpha"
19+
VOLNAME="c2pool-${VERSION}"
20+
DMG_NAME="c2pool-${VERSION}-macos-${ARCH}.dmg"
21+
22+
if [ -z "$BINARY" ] || [ ! -f "$BINARY" ]; then
23+
echo "Usage: $0 <path-to-c2pool-binary> [arch]"
24+
echo " arch: x86_64 or arm64 (default: native)"
25+
exit 1
26+
fi
27+
28+
# Verify binary architecture
29+
ACTUAL_ARCH=$(file "$BINARY" | grep -o 'x86_64\|arm64' | head -1)
30+
if [ "$ACTUAL_ARCH" != "$ARCH" ]; then
31+
echo "ERROR: binary is $ACTUAL_ARCH but arch=$ARCH specified"
32+
exit 1
33+
fi
34+
35+
# Find repo root (script is in installer/macos/)
36+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
37+
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
38+
39+
# Staging directory
40+
STAGE=$(mktemp -d)
41+
APP_DIR="$STAGE/$VOLNAME"
42+
mkdir -p "$APP_DIR/lib"
43+
44+
echo "Building $DMG_NAME from $BINARY"
45+
echo " Repo: $REPO_ROOT"
46+
echo " Stage: $STAGE"
47+
48+
# Copy binary
49+
cp "$BINARY" "$APP_DIR/c2pool"
50+
chmod +x "$APP_DIR/c2pool"
51+
52+
# Copy bundled assets
53+
cp -R "$REPO_ROOT/web-static" "$APP_DIR/web-static"
54+
cp -R "$REPO_ROOT/config" "$APP_DIR/config"
55+
if [ -d "$REPO_ROOT/explorer" ]; then
56+
cp -R "$REPO_ROOT/explorer" "$APP_DIR/explorer"
57+
fi
58+
59+
# Copy start script
60+
if [ -f "$REPO_ROOT/start.sh" ]; then
61+
cp "$REPO_ROOT/start.sh" "$APP_DIR/start.sh"
62+
chmod +x "$APP_DIR/start.sh"
63+
else
64+
# Generate a start script
65+
cat > "$APP_DIR/start.sh" << 'STARTEOF'
66+
#!/bin/bash
67+
DIR="$(cd "$(dirname "$0")" && pwd)"
68+
CONFIG="${1:-$DIR/config/c2pool_mainnet.yaml}"
69+
export DYLD_LIBRARY_PATH="$DIR/lib:${DYLD_LIBRARY_PATH:-}"
70+
echo "=== c2pool ==="
71+
echo "Config: $CONFIG"
72+
exec "$DIR/c2pool" --integrated --net litecoin \
73+
--embedded-ltc --embedded-doge \
74+
--dashboard-dir "$DIR/web-static" \
75+
--config "$CONFIG"
76+
STARTEOF
77+
chmod +x "$APP_DIR/start.sh"
78+
fi
79+
80+
# Copy secp256k1 dylib
81+
if [ "$ARCH" = "arm64" ]; then
82+
SECP_LIB="/Users/user0/arm64-deps/lib/libsecp256k1.dylib"
83+
SECP_REAL="/Users/user0/arm64-deps/lib/libsecp256k1.6.dylib"
84+
else
85+
SECP_LIB="/usr/local/lib/libsecp256k1.dylib"
86+
SECP_REAL="/usr/local/lib/libsecp256k1.6.dylib"
87+
fi
88+
if [ -f "$SECP_REAL" ]; then
89+
cp "$SECP_REAL" "$APP_DIR/lib/libsecp256k1.6.dylib"
90+
ln -sf libsecp256k1.6.dylib "$APP_DIR/lib/libsecp256k1.dylib"
91+
# Fix dylib load path so binary finds the bundled lib
92+
install_name_tool -change "$SECP_LIB" "@executable_path/lib/libsecp256k1.6.dylib" "$APP_DIR/c2pool" 2>/dev/null || true
93+
install_name_tool -change "$SECP_REAL" "@executable_path/lib/libsecp256k1.6.dylib" "$APP_DIR/c2pool" 2>/dev/null || true
94+
elif [ -f "$SECP_LIB" ]; then
95+
cp "$SECP_LIB" "$APP_DIR/lib/libsecp256k1.dylib"
96+
install_name_tool -change "$SECP_LIB" "@executable_path/lib/libsecp256k1.dylib" "$APP_DIR/c2pool" 2>/dev/null || true
97+
fi
98+
99+
# Add a README
100+
cat > "$APP_DIR/README.txt" << 'README'
101+
c2pool — P2Pool rebirth in C++
102+
https://github.com/frstrtr/c2pool
103+
104+
Quick start:
105+
1. Open Terminal
106+
2. cd to this directory
107+
3. ./start.sh
108+
109+
Or run directly:
110+
./c2pool --integrated --net litecoin --embedded-ltc --embedded-doge
111+
112+
Dashboard: http://localhost:8080
113+
Stratum: stratum+tcp://localhost:9327
114+
115+
Miners connect with their payout address as the stratum username.
116+
README
117+
118+
# Create DMG
119+
OUTPUT="$REPO_ROOT/$DMG_NAME"
120+
rm -f "$OUTPUT"
121+
hdiutil create -volname "$VOLNAME" \
122+
-srcfolder "$APP_DIR" \
123+
-ov -format UDZO \
124+
"$OUTPUT"
125+
126+
# Cleanup
127+
rm -rf "$STAGE"
128+
129+
echo ""
130+
echo "Created: $OUTPUT"
131+
echo "Size: $(du -h "$OUTPUT" | cut -f1)"
132+
echo "SHA256: $(shasum -a 256 "$OUTPUT" | cut -d' ' -f1)"

0 commit comments

Comments
 (0)