mirror of
git://f0xx.org/android_cast
synced 2026-07-29 03:18:32 +03:00
37 lines
1.3 KiB
Bash
Executable File
37 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Initialize wireguard-android submodule (third-party/wireguard-android in .gitmodules).
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
SUB_PATH="third-party/wireguard-android"
|
|
SUB_NAME="third-party/wireguard-android"
|
|
|
|
if ! grep -q "$SUB_PATH" .gitmodules 2>/dev/null; then
|
|
echo "error: .gitmodules missing $SUB_PATH" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# .gitmodules without a gitlink in the tree breaks plain `git submodule update`.
|
|
if ! git cat-file -e "HEAD:$SUB_PATH" 2>/dev/null \
|
|
&& ! git ls-files --stage "$SUB_PATH" | grep -q '^160000'; then
|
|
url="$(git config -f .gitmodules --get "submodule.$SUB_NAME.url" || true)"
|
|
if [ -z "$url" ]; then
|
|
echo "error: no url for submodule.$SUB_NAME in .gitmodules" >&2
|
|
exit 1
|
|
fi
|
|
sha="$(git ls-remote "$url" HEAD | awk 'NR==1 {print $1}')"
|
|
if [ -z "$sha" ]; then
|
|
echo "error: could not resolve HEAD for $url" >&2
|
|
exit 1
|
|
fi
|
|
echo "registering missing gitlink for $SUB_PATH at $sha"
|
|
git update-index --add --cacheinfo 160000,"$sha","$SUB_PATH"
|
|
echo "warning: gitlink was missing from the tree — commit third-party/wireguard-android after init" >&2
|
|
fi
|
|
|
|
git submodule sync "$SUB_PATH"
|
|
git submodule update --init --recursive "$SUB_PATH"
|
|
echo "wireguard-android ready under $SUB_PATH"
|
|
echo "Gradle includes :tunnel when $SUB_PATH/tunnel exists."
|