This commit adds a check for the availability of `brew bundle` in the `install_brew_deps.sh` script, ensuring that users are informed to update Homebrew if the command is missing. Additionally, the `macdeploycheck` formula is updated to correct the path for the script installation, aligning it with the tapped repository structure. These changes improve the robustness and user experience during the installation of Homebrew dependencies.
134 lines
4.4 KiB
Bash
Executable File
134 lines
4.4 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
|
|
|
|
# Brewfile support (`brew bundle`) is built into modern Homebrew. The historical
|
|
# tap `homebrew/bundle` has been deprecated and may be empty on newer Homebrew.
|
|
# If `brew bundle` is missing, the fix is to update Homebrew itself.
|
|
if ! brew bundle --help >/dev/null 2>&1; then
|
|
run_with_heartbeat "Updating Homebrew (required for 'brew bundle')" bash -lc "brew update"
|
|
if ! brew bundle --help >/dev/null 2>&1; then
|
|
echo "Error: This Homebrew installation does not provide 'brew bundle'." >&2
|
|
echo "Update Homebrew (e.g. 'brew update') or reinstall Homebrew, then re-run this script." >&2
|
|
exit 1
|
|
fi
|
|
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
|
|
|