This commit updates the `macdeploycheck` formula to install the script directly from the tapped repository, ensuring consistency with the tapped revision. Additionally, the `install_brew_deps.sh` script is modified to provide clearer error messages when loading formulae fails, enhancing the overall user experience during dependency checks.
122 lines
3.8 KiB
Bash
Executable File
122 lines
3.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
repo_root="$(cd -- "${script_dir}/../.." && pwd)"
|
|
|
|
ts() { date +"%H:%M:%S"; }
|
|
|
|
run_with_heartbeat() {
|
|
local desc="$1"
|
|
shift
|
|
|
|
local start now elapsed hb_pid
|
|
start="$(date +%s)"
|
|
|
|
echo "==> [$(ts)] ${desc}"
|
|
|
|
# Heartbeat: print elapsed time periodically in case the underlying command is quiet
|
|
(
|
|
while true; do
|
|
sleep 20
|
|
now="$(date +%s)"
|
|
elapsed="$((now - start))"
|
|
echo " [$(ts)] ... still working (${elapsed}s elapsed) ..."
|
|
done
|
|
) &
|
|
hb_pid="$!"
|
|
|
|
set +e
|
|
"$@"
|
|
local rc=$?
|
|
set -e
|
|
|
|
kill "$hb_pid" >/dev/null 2>&1 || true
|
|
wait "$hb_pid" >/dev/null 2>&1 || true
|
|
|
|
now="$(date +%s)"
|
|
elapsed="$((now - start))"
|
|
|
|
if [[ $rc -ne 0 ]]; then
|
|
echo "Error: '${desc}' failed after ${elapsed}s (exit $rc)." >&2
|
|
return "$rc"
|
|
fi
|
|
|
|
echo "==> [$(ts)] Done: ${desc} (${elapsed}s)"
|
|
}
|
|
|
|
if [[ "$(uname -s)" != "Darwin" ]]; then
|
|
echo "Error: This script is for macOS only." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v brew >/dev/null 2>&1; then
|
|
echo "Error: Homebrew ('brew') not found in PATH." >&2
|
|
echo "Install Homebrew first: https://brew.sh/" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Homebrew taps are git clones; local formula changes must be committed to be visible.
|
|
if command -v git >/dev/null 2>&1 && git -C "$repo_root" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
if git -C "$repo_root" status --porcelain Formula/ | grep -q .; then
|
|
echo "Error: You have uncommitted changes under Formula/." >&2
|
|
echo "Homebrew taps are git clones, so uncommitted formulae won't be visible to 'brew tap'." >&2
|
|
echo "Commit your changes, then re-run this script." >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Optional: disable auto-update for faster, more predictable runs.
|
|
export HOMEBREW_NO_AUTO_UPDATE="${HOMEBREW_NO_AUTO_UPDATE:-1}"
|
|
|
|
cd "$repo_root"
|
|
|
|
echo "==> [$(ts)] Using repo: $repo_root"
|
|
|
|
# Strawberry includes local Homebrew formulae under Formula/.
|
|
# Homebrew requires formulae to be in a tap; we tap this repo via file:// and then
|
|
# update the tap clone to the latest commit (without untapping, since Homebrew may
|
|
# refuse to untap when formulae from this tap are installed).
|
|
run_with_heartbeat "Ensuring local tap exists: strawberry/local" bash -lc \
|
|
"brew tap | grep -q '^strawberry/local$' || brew tap strawberry/local 'file://$repo_root' >/dev/null"
|
|
|
|
run_with_heartbeat "Refreshing strawberry/local tap clone" bash -lc '
|
|
tap_repo="$(brew --repo strawberry/local)"
|
|
cd "$tap_repo"
|
|
# Make sure the remote points at the current local repo path.
|
|
git remote set-url origin "file://'"$repo_root"'"
|
|
git fetch -q origin
|
|
default_ref="$(git symbolic-ref -q --short refs/remotes/origin/HEAD || true)"
|
|
if [ -z "$default_ref" ]; then
|
|
default_ref="origin/master"
|
|
fi
|
|
git reset --hard -q "$default_ref"
|
|
'
|
|
|
|
for f in kdsingleapplication-qt6 qtsparkle-qt6 sparkle-framework libgpod macdeploycheck; do
|
|
if ! info_out="$(brew info "strawberry/local/${f}" 2>&1 >/dev/null)"; then
|
|
echo "Error: Unable to load formula strawberry/local/${f} from the tapped repo (brew info failed)." >&2
|
|
echo "Details (brew info):" >&2
|
|
echo "$info_out" >&2
|
|
echo "If you recently added/changed formulae, ensure they are committed, then refresh the tap:" >&2
|
|
echo " git -C \"$(brew --repo strawberry/local)\" pull --ff-only" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
run_with_heartbeat "Installing dependencies from Brewfile" \
|
|
brew bundle install --file "$repo_root/Brewfile" --verbose
|
|
|
|
cat <<EOF
|
|
|
|
Done.
|
|
|
|
Notes for packaging (optional):
|
|
- The CMake target 'deploy' expects these env vars for bundling GIO + GStreamer bits:
|
|
export GIO_EXTRA_MODULES="\$(brew --prefix)/lib/gio/modules"
|
|
export GST_PLUGIN_SCANNER="\$(brew --prefix gstreamer)/libexec/gstreamer-1.0/gst-plugin-scanner"
|
|
export GST_PLUGIN_PATH="\$(brew --prefix)/lib/gstreamer-1.0"
|
|
|
|
EOF
|
|
|