From fea979fb6f37f25b97b8ec0a2b782d0a40eca98f Mon Sep 17 00:00:00 2001 From: wei Date: Fri, 13 Nov 2026 11:57:14 +0800 Subject: [PATCH] Update to 0.1.6-alpha-1 - Update version number that were omitted from the previous commit. - Add generate dmg support for build_macos.sh. --- build_macos.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++--- constant.py | 2 +- pyproject.toml | 2 +- 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/build_macos.sh b/build_macos.sh index 62fb9f5..cd5e4aa 100755 --- a/build_macos.sh +++ b/build_macos.sh @@ -6,9 +6,9 @@ usage() { cat <<'EOF' Usage: ./build_macos.sh [--dry-run] [Nuitka options...] -Sync build dependencies and create build/TapLauncher.app for the current -Python architecture (Apple Silicon or Intel). Requires uv and Xcode Command -Line Tools (install with: xcode-select --install). +Sync build dependencies and create build/TapLauncher.app and TapLauncher.dmg +for the current Python architecture (Apple Silicon or Intel). Requires uv and +Xcode Command Line Tools (install with: xcode-select --install). --dry-run Print the build command without syncing or compiling. --help Show this help. @@ -37,6 +37,12 @@ if ! command -v uv >/dev/null 2>&1; then echo "Error: uv is required. See https://docs.astral.sh/uv/getting-started/installation/" >&2 exit 1 fi +for command_name in ditto hdiutil; do + if ! command -v "$command_name" >/dev/null 2>&1; then + echo "Error: required macOS command not found: $command_name" >&2 + exit 1 + fi +done project_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" cd "$project_dir" @@ -72,4 +78,56 @@ fi uv sync --group build "${build_command[@]}" -printf '\nBuild completed. Default application path: %s/build/TapLauncher.app\n' "$project_dir" + +app_path="$project_dir/build/TapLauncher.app" +dmg_path="$project_dir/build/TapLauncher.dmg" + +if [[ ! -d "$app_path/Contents/MacOS" ]]; then + echo "Error: application output is missing or incomplete: $app_path" >&2 + exit 1 +fi + +printf '\nApplication build completed: %s\n' "$app_path" + +dmg_staging_dir="$(mktemp -d "$project_dir/build/dmg-temp.XXXXXX")" +dmg_output_dir="$(mktemp -d "$project_dir/build/dmg-output.XXXXXX")" +dmg_candidate="$dmg_output_dir/TapLauncher.dmg" + +cleanup() { + rm -rf "$dmg_staging_dir" + rm -rf "$dmg_output_dir" +} +trap cleanup EXIT INT TERM + +ditto --noqtn "$app_path" "$dmg_staging_dir/TapLauncher.app" +ln -s /Applications "$dmg_staging_dir/Applications" + +create_dmg() { + hdiutil create \ + -volname "TapLauncher" \ + -srcfolder "$dmg_staging_dir" \ + -format UDZO \ + -imagekey zlib-level=9 \ + "$dmg_candidate" +} + +for attempt in 1 2 3; do + if create_dmg; then + break + fi + if [[ "$attempt" -eq 3 ]]; then + echo "Error: unable to create DMG after $attempt attempts." >&2 + exit 1 + fi + echo "DMG creation failed (attempt $attempt/3); retrying..." >&2 + rm -f "$dmg_candidate" + sleep "$attempt" +done + +if ! hdiutil verify "$dmg_candidate"; then + echo "Error: DMG verification failed; existing output was not replaced." >&2 + exit 1 +fi + +mv -f "$dmg_candidate" "$dmg_path" +printf 'DMG build completed: %s\n' "$dmg_path" diff --git a/constant.py b/constant.py index 46dcb65..4f8eb7e 100644 --- a/constant.py +++ b/constant.py @@ -1,4 +1,4 @@ -LAUNCHER_VERSION = "0.1.5-alpha" +LAUNCHER_VERSION = "0.1.6-alpha-1" LAUNCHER_NAME = "TapLauncher" LAUNCHER_DIR_NAME = "TapLauncher" MAIN_REPO_URL = "https://repo.weispace.net/wei/Launcher/" diff --git a/pyproject.toml b/pyproject.toml index c083ac6..a855174 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "testlauncher" -version = "0.1.6a0" +version = "0.1.6a1" description = "A lightweight Minecraft launcher." readme = "README.md" requires-python = ">=3.10"