1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 06:58:51 +03:00

wireguard init

This commit is contained in:
Anton Afanasyeu
2026-06-11 11:27:37 +02:00
parent f5c107bb85
commit 4122ff1977
2 changed files with 30 additions and 6 deletions

View File

@@ -3,11 +3,34 @@
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
if ! grep -q 'third-party/wireguard-android' .gitmodules 2>/dev/null; then
echo "error: .gitmodules missing third-party/wireguard-android — use repo .gitmodules from git" >&2
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
git submodule sync third-party/wireguard-android
git submodule update --init --recursive third-party/wireguard-android
echo "wireguard-android ready under third-party/wireguard-android"
echo "Gradle includes :tunnel when third-party/wireguard-android/tunnel exists."
# .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."