Files
openwrt-build-helper/add-external-repos.sh
Zhe Yuan 351e7c41f3 Require the OpenWrt root in add-external-repos.sh
Every path in the script is relative to the current directory, so running
it from anywhere else cloned the packages into that directory instead.
Now that the helper checkout lives at openwrt/helper/, running it there
would populate helper/package/ rather than the real package/.

Use the same guard the other helper scripts already have.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 20:31:32 -04:00

52 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Update or clone specified OpenWRT package repositories
set -e # Exit immediately if any command fails
umask 022 # Set default file permissions (files=644, dirs=755)
# --- Check if inside OpenWRT source directory ---
# Every path below is relative to the current directory, so running this from
# the helper checkout would clone into helper/package/ instead of the real
# OpenWRT package/ directory.
if [ ! -f "feeds.conf.default" ] || [ ! -d "package" ]; then
echo "[ERROR] Must run inside OpenWRT root directory."
echo "[ERROR] From the OpenWrt root, run it as: ./helper/add-external-repos.sh"
exit 1
fi
# Define repositories in the format: "git_url branch local_dir"
REPOS=(
"https://github.com/muink/luci-app-netspeedtest.git master package/luci-app-netspeedtest"
"https://github.com/EasyTier/luci-app-easytier.git main package/luci-app-easytier"
"https://github.com/jerrykuku/luci-theme-argon.git master package/luci-theme-argon"
)
for REPO_INFO in "${REPOS[@]}"; do
set -- $REPO_INFO
REPO_URL=$1
REPO_BRANCH=$2
LOCAL_DIR=$3
echo "----------------------------------------"
echo "Processing $LOCAL_DIR ($REPO_BRANCH)"
echo "----------------------------------------"
if [ -d "$LOCAL_DIR/.git" ]; then
echo "Repository exists, updating..."
pushd "$LOCAL_DIR" > /dev/null
git fetch origin "$REPO_BRANCH"
git checkout "$REPO_BRANCH"
git pull --ff-only origin "$REPO_BRANCH"
popd > /dev/null
else
echo "Repository not found, cloning..."
git clone --depth 1 --branch "$REPO_BRANCH" --single-branch "$REPO_URL" "$LOCAL_DIR"
fi
echo "Done: $LOCAL_DIR"
echo
done
echo "✅ All repositories updated successfully."