parent
3c1896a946
commit
6754b8acff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,96 @@ |
||||
#!/bin/bash |
||||
|
||||
set -e |
||||
|
||||
# 项目信息 |
||||
APP_NAME="Wormhole Client" |
||||
VERSION="v1.0.0" |
||||
|
||||
# 路径配置 |
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" |
||||
|
||||
echo "🚀 Building Wormhole Client DMG Installer" |
||||
echo "==========================================" |
||||
echo "📦 Version: $VERSION" |
||||
echo "📁 Project: $PROJECT_ROOT" |
||||
echo "" |
||||
|
||||
# 检查必要的工具 |
||||
echo "🔍 Checking required tools..." |
||||
|
||||
# 检查 Go |
||||
if ! command -v go &> /dev/null; then |
||||
echo "❌ Go is not installed. Please install Go first." |
||||
exit 1 |
||||
fi |
||||
echo "✅ Go: $(go version)" |
||||
|
||||
# 检查 hdiutil (macOS 内置) |
||||
if ! command -v hdiutil &> /dev/null; then |
||||
echo "❌ hdiutil not found. This script requires macOS." |
||||
exit 1 |
||||
fi |
||||
echo "✅ hdiutil: Available" |
||||
|
||||
# 检查 osascript (macOS 内置) |
||||
if ! command -v osascript &> /dev/null; then |
||||
echo "❌ osascript not found. This script requires macOS." |
||||
exit 1 |
||||
fi |
||||
echo "✅ osascript: Available" |
||||
|
||||
echo "" |
||||
|
||||
# 步骤 1: 构建应用程序包 |
||||
echo "📱 Step 1: Building macOS application bundle..." |
||||
echo "----------------------------------------------" |
||||
if [ -f "$SCRIPT_DIR/build-macos.sh" ]; then |
||||
chmod +x "$SCRIPT_DIR/build-macos.sh" |
||||
"$SCRIPT_DIR/build-macos.sh" |
||||
else |
||||
echo "❌ build-macos.sh not found!" |
||||
exit 1 |
||||
fi |
||||
|
||||
echo "" |
||||
|
||||
# 步骤 2: 创建 DMG |
||||
echo "💿 Step 2: Creating DMG installer..." |
||||
echo "------------------------------------" |
||||
if [ -f "$SCRIPT_DIR/create-dmg.sh" ]; then |
||||
chmod +x "$SCRIPT_DIR/create-dmg.sh" |
||||
"$SCRIPT_DIR/create-dmg.sh" |
||||
else |
||||
echo "❌ create-dmg.sh not found!" |
||||
exit 1 |
||||
fi |
||||
|
||||
echo "" |
||||
|
||||
# 完成总结 |
||||
echo "🎉 BUILD COMPLETED SUCCESSFULLY!" |
||||
echo "=================================" |
||||
BUILD_DIR="$PROJECT_ROOT/build" |
||||
FINAL_DMG="$BUILD_DIR/Wormhole-Client-$VERSION.dmg" |
||||
|
||||
if [ -f "$FINAL_DMG" ]; then |
||||
echo "📦 DMG File: $FINAL_DMG" |
||||
echo "📊 File Size: $(du -h "$FINAL_DMG" | cut -f1)" |
||||
echo "🔗 SHA256: $(shasum -a 256 "$FINAL_DMG" | cut -d' ' -f1)" |
||||
echo "" |
||||
echo "📋 Distribution Ready:" |
||||
echo "1. Test the DMG by double-clicking it" |
||||
echo "2. Verify the application installs and runs correctly" |
||||
echo "3. Share the DMG file for distribution" |
||||
echo "" |
||||
echo "🔒 Security Notes:" |
||||
echo "- Users may need to allow the app in System Preferences > Security & Privacy" |
||||
echo "- Consider code signing for easier distribution" |
||||
echo "- For distribution outside the App Store, users may need to right-click and 'Open'" |
||||
echo "" |
||||
echo "✨ Your macOS installer is ready!" |
||||
else |
||||
echo "❌ DMG creation failed!" |
||||
exit 1 |
||||
fi |
@ -0,0 +1,172 @@ |
||||
#!/bin/bash |
||||
|
||||
set -e |
||||
|
||||
# 项目信息 |
||||
APP_NAME="Wormhole Client" |
||||
BUNDLE_ID="com.azoic.wormhole-client" |
||||
VERSION="v1.0.0" |
||||
BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S') |
||||
|
||||
# 路径配置 |
||||
PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
||||
BUILD_DIR="$PROJECT_ROOT/build" |
||||
APP_DIR="$BUILD_DIR/$APP_NAME.app" |
||||
CONTENTS_DIR="$APP_DIR/Contents" |
||||
MACOS_DIR="$CONTENTS_DIR/MacOS" |
||||
RESOURCES_DIR="$CONTENTS_DIR/Resources" |
||||
DMG_DIR="$BUILD_DIR/dmg" |
||||
TEMP_DMG="$BUILD_DIR/temp.dmg" |
||||
FINAL_DMG="$BUILD_DIR/Wormhole-Client-$VERSION.dmg" |
||||
|
||||
echo "🚀 Building Wormhole Client for macOS..." |
||||
echo "📦 Version: $VERSION" |
||||
echo "📅 Build Time: $BUILD_TIME" |
||||
|
||||
# 清理构建目录 |
||||
echo "🧹 Cleaning build directory..." |
||||
rm -rf "$BUILD_DIR" |
||||
mkdir -p "$BUILD_DIR" |
||||
|
||||
# 构建二进制文件 |
||||
echo "🔨 Building binary..." |
||||
cd "$PROJECT_ROOT" |
||||
GOOS=darwin GOARCH=amd64 go build \ |
||||
-ldflags "-X main.version=$VERSION -X main.buildTime=$BUILD_TIME" \ |
||||
-o "$BUILD_DIR/wormhole-client" \ |
||||
cmd/wormhole-client/main.go |
||||
|
||||
echo "✅ Binary built successfully" |
||||
|
||||
# 创建应用程序包结构 |
||||
echo "📦 Creating application bundle..." |
||||
mkdir -p "$MACOS_DIR" |
||||
mkdir -p "$RESOURCES_DIR" |
||||
|
||||
# 复制二进制文件 |
||||
cp "$BUILD_DIR/wormhole-client" "$MACOS_DIR/" |
||||
|
||||
# 复制配置文件 |
||||
cp -r configs "$RESOURCES_DIR/" |
||||
|
||||
# 创建或复制应用图标 |
||||
ICON_PATH="$PROJECT_ROOT/assets/icons/app.icns" |
||||
if [ -f "$ICON_PATH" ]; then |
||||
echo "📱 Using custom app icon..." |
||||
cp "$ICON_PATH" "$RESOURCES_DIR/" |
||||
else |
||||
echo "🎨 Creating default app icon..." |
||||
if [ -f "$PROJECT_ROOT/scripts/create-icon.sh" ]; then |
||||
chmod +x "$PROJECT_ROOT/scripts/create-icon.sh" |
||||
"$PROJECT_ROOT/scripts/create-icon.sh" |
||||
if [ -f "$ICON_PATH" ]; then |
||||
cp "$ICON_PATH" "$RESOURCES_DIR/" |
||||
fi |
||||
fi |
||||
fi |
||||
|
||||
# 创建启动脚本 |
||||
cat > "$MACOS_DIR/Wormhole Client" << 'EOF' |
||||
#!/bin/bash |
||||
|
||||
# Wormhole Client macOS Launcher |
||||
set -e |
||||
|
||||
# 获取应用程序路径 |
||||
APP_PATH="$(cd "$(dirname "$0")/.." && pwd)" |
||||
RESOURCES_PATH="$APP_PATH/Resources" |
||||
BINARY_PATH="$APP_PATH/MacOS/wormhole-client" |
||||
CONFIG_PATH="$RESOURCES_PATH/configs/client.yaml" |
||||
|
||||
# 检查二进制文件 |
||||
if [ ! -f "$BINARY_PATH" ]; then |
||||
echo "❌ Application binary not found" |
||||
exit 1 |
||||
fi |
||||
|
||||
# 设置工作目录 |
||||
cd "$RESOURCES_PATH" |
||||
|
||||
# 如果没有参数,启动 HTTP 模式并打开浏览器 |
||||
if [ $# -eq 0 ]; then |
||||
echo "🚀 Starting Wormhole Client in HTTP proxy mode..." |
||||
echo "🌐 Web interface will open automatically" |
||||
|
||||
# 后台启动应用 |
||||
"$BINARY_PATH" -config "$CONFIG_PATH" -mode http & |
||||
APP_PID=$! |
||||
|
||||
# 等待服务启动 |
||||
sleep 3 |
||||
|
||||
# 打开 Web 界面 |
||||
open "http://127.0.0.1:8080/gui" 2>/dev/null || echo "📱 Visit http://127.0.0.1:8080/gui to access the web interface" |
||||
|
||||
# 等待应用程序结束 |
||||
wait $APP_PID |
||||
else |
||||
# 有参数时直接传递 |
||||
exec "$BINARY_PATH" -config "$CONFIG_PATH" "$@" |
||||
fi |
||||
EOF |
||||
|
||||
chmod +x "$MACOS_DIR/Wormhole Client" |
||||
|
||||
# 创建 Info.plist |
||||
cat > "$CONTENTS_DIR/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>CFBundleDevelopmentRegion</key> |
||||
<string>en</string> |
||||
<key>CFBundleDisplayName</key> |
||||
<string>$APP_NAME</string> |
||||
<key>CFBundleExecutable</key> |
||||
<string>Wormhole Client</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>$BUNDLE_ID</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundleName</key> |
||||
<string>$APP_NAME</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>APPL</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>$VERSION</string> |
||||
<key>CFBundleVersion</key> |
||||
<string>$VERSION</string> |
||||
<key>LSMinimumSystemVersion</key> |
||||
<string>10.13</string> |
||||
<key>NSHighResolutionCapable</key> |
||||
<true/> |
||||
<key>LSApplicationCategoryType</key> |
||||
<string>public.app-category.networking</string> |
||||
<key>LSUIElement</key> |
||||
<false/> |
||||
<key>NSHumanReadableCopyright</key> |
||||
<string>Copyright © 2024 Azoic. All rights reserved.</string> |
||||
<key>CFBundleIconFile</key> |
||||
<string>app</string> |
||||
<key>CFBundleDocumentTypes</key> |
||||
<array> |
||||
<dict> |
||||
<key>CFBundleTypeExtensions</key> |
||||
<array> |
||||
<string>yaml</string> |
||||
<string>yml</string> |
||||
</array> |
||||
<key>CFBundleTypeName</key> |
||||
<string>Configuration File</string> |
||||
<key>CFBundleTypeRole</key> |
||||
<string>Editor</string> |
||||
</dict> |
||||
</array> |
||||
</dict> |
||||
</plist> |
||||
EOF |
||||
|
||||
echo "✅ Application bundle created" |
||||
|
||||
echo "🎯 Build completed successfully!" |
||||
echo "📁 Application bundle: $APP_DIR" |
@ -0,0 +1,152 @@ |
||||
#!/bin/bash |
||||
|
||||
set -e |
||||
|
||||
# 项目信息 |
||||
APP_NAME="Wormhole Client" |
||||
VERSION="v1.0.0" |
||||
|
||||
# 路径配置 |
||||
PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
||||
BUILD_DIR="$PROJECT_ROOT/build" |
||||
APP_DIR="$BUILD_DIR/$APP_NAME.app" |
||||
DMG_DIR="$BUILD_DIR/dmg" |
||||
TEMP_DMG="$BUILD_DIR/temp.dmg" |
||||
FINAL_DMG="$BUILD_DIR/Wormhole-Client-$VERSION.dmg" |
||||
|
||||
# DMG 配置 |
||||
DMG_TITLE="Wormhole Client $VERSION" |
||||
DMG_SIZE="100m" |
||||
DMG_BACKGROUND="$PROJECT_ROOT/scripts/dmg-background.png" |
||||
DMG_ICON_SIZE=128 |
||||
DMG_TEXT_SIZE=16 |
||||
|
||||
echo "📦 Creating DMG installer for Wormhole Client..." |
||||
|
||||
# 检查应用程序包是否存在 |
||||
if [ ! -d "$APP_DIR" ]; then |
||||
echo "❌ Application bundle not found. Please run build-macos.sh first." |
||||
exit 1 |
||||
fi |
||||
|
||||
# 清理并创建 DMG 目录 |
||||
echo "🧹 Preparing DMG directory..." |
||||
rm -rf "$DMG_DIR" |
||||
mkdir -p "$DMG_DIR" |
||||
|
||||
# 复制应用程序到 DMG 目录 |
||||
echo "📱 Copying application to DMG..." |
||||
cp -R "$APP_DIR" "$DMG_DIR/" |
||||
|
||||
# 创建 Applications 符号链接 |
||||
echo "🔗 Creating Applications symlink..." |
||||
ln -s "/Applications" "$DMG_DIR/Applications" |
||||
|
||||
# 创建 README 文件 |
||||
echo "📝 Creating README..." |
||||
cat > "$DMG_DIR/README.txt" << EOF |
||||
Wormhole SOCKS5 Client $VERSION |
||||
|
||||
安装说明: |
||||
1. 将 "Wormhole Client.app" 拖拽到 Applications 文件夹 |
||||
2. 双击运行应用程序 |
||||
3. 首次运行时,可能需要在系统偏好设置中允许运行 |
||||
|
||||
使用方法: |
||||
- HTTP 模式:./wormhole-client -mode http |
||||
- 全局模式:sudo ./wormhole-client -mode global (需要管理员权限) |
||||
|
||||
Web 管理界面:http://127.0.0.1:8080/gui |
||||
统计信息:http://127.0.0.1:8080/stats |
||||
|
||||
更多信息请访问:https://github.com/azoic/wormhole-client |
||||
|
||||
Copyright © 2024 Azoic. All rights reserved. |
||||
EOF |
||||
|
||||
# 创建临时 DMG |
||||
echo "💿 Creating temporary DMG..." |
||||
hdiutil create -srcfolder "$DMG_DIR" -volname "$DMG_TITLE" -fs HFS+ \ |
||||
-fsargs "-c c=64,a=16,e=16" -format UDRW -size "$DMG_SIZE" "$TEMP_DMG" |
||||
|
||||
# 挂载临时 DMG 进行自定义 |
||||
echo "🎨 Customizing DMG appearance..." |
||||
DEVICE=$(hdiutil attach -readwrite -noverify -noautoopen "$TEMP_DMG" | \ |
||||
egrep '^/dev/' | sed 1q | awk '{print $1}') |
||||
|
||||
# 等待挂载完成 |
||||
sleep 2 |
||||
|
||||
# 设置 DMG 窗口属性 |
||||
MOUNT_DIR="/Volumes/$DMG_TITLE" |
||||
|
||||
# 使用 AppleScript 设置 Finder 窗口 |
||||
/usr/bin/osascript << EOF |
||||
tell application "Finder" |
||||
tell disk "$DMG_TITLE" |
||||
open |
||||
set current view of container window to icon view |
||||
set toolbar visible of container window to false |
||||
set statusbar visible of container window to false |
||||
set the bounds of container window to {400, 100, 920, 440} |
||||
set theViewOptions to the icon view options of container window |
||||
set arrangement of theViewOptions to not arranged |
||||
set icon size of theViewOptions to $DMG_ICON_SIZE |
||||
set text size of theViewOptions to $DMG_TEXT_SIZE |
||||
|
||||
-- 设置图标位置 |
||||
set position of item "Wormhole Client.app" of container window to {140, 120} |
||||
set position of item "Applications" of container window to {380, 120} |
||||
set position of item "README.txt" of container window to {260, 280} |
||||
|
||||
-- 应用更改 |
||||
update without registering applications |
||||
delay 2 |
||||
end tell |
||||
end tell |
||||
EOF |
||||
|
||||
# 等待 AppleScript 完成 |
||||
sleep 3 |
||||
|
||||
# 卸载临时 DMG |
||||
hdiutil detach "$DEVICE" |
||||
|
||||
# 创建最终的只读 DMG |
||||
echo "✨ Creating final DMG..." |
||||
rm -f "$FINAL_DMG" |
||||
hdiutil convert "$TEMP_DMG" -format UDZO -imagekey zlib-level=9 -o "$FINAL_DMG" |
||||
|
||||
# 清理临时文件 |
||||
echo "🧹 Cleaning up..." |
||||
rm -f "$TEMP_DMG" |
||||
rm -rf "$DMG_DIR" |
||||
|
||||
# 显示结果 |
||||
echo "" |
||||
echo "🎉 DMG creation completed successfully!" |
||||
echo "📁 DMG file: $FINAL_DMG" |
||||
echo "📊 File size: $(du -h "$FINAL_DMG" | cut -f1)" |
||||
echo "" |
||||
echo "✅ Installation package ready for distribution!" |
||||
|
||||
# 验证 DMG |
||||
echo "🔍 Verifying DMG integrity..." |
||||
if hdiutil verify "$FINAL_DMG"; then |
||||
echo "✅ DMG verification passed" |
||||
else |
||||
echo "❌ DMG verification failed" |
||||
exit 1 |
||||
fi |
||||
|
||||
# 显示安装说明 |
||||
echo "" |
||||
echo "📋 Installation Instructions:" |
||||
echo "1. Double-click the DMG file to mount it" |
||||
echo "2. Drag 'Wormhole Client.app' to the Applications folder" |
||||
echo "3. Eject the DMG" |
||||
echo "4. Launch 'Wormhole Client' from Applications" |
||||
echo "" |
||||
echo "🔒 Security Note:" |
||||
echo "If macOS blocks the app, go to System Preferences > Security & Privacy" |
||||
echo "and click 'Open Anyway' to allow the application to run." |
Loading…
Reference in new issue