You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.9 KiB
Bash
73 lines
1.9 KiB
Bash
9 years ago
|
#!/usr/bin/env bash
|
||
|
# vim:ts=4:sts=4:sw=4:et
|
||
|
#
|
||
|
# Author: Hari Sekhon
|
||
|
# Date: 2016-01-17 12:14:06 +0000 (Sun, 17 Jan 2016)
|
||
|
#
|
||
|
# https://github.com/harisekhon/bash-tools
|
||
|
#
|
||
|
# License: see accompanying Hari Sekhon LICENSE file
|
||
|
#
|
||
|
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help improve or steer this or other code I publish
|
||
|
#
|
||
9 years ago
|
# https://www.linkedin.com/in/harisekhon
|
||
9 years ago
|
#
|
||
|
|
||
|
set -euo pipefail
|
||
9 years ago
|
[ -n "${DEBUG:-}" ] && set -x
|
||
5 years ago
|
srcdir="$(cd "$(dirname "$0")" && pwd)"
|
||
9 years ago
|
|
||
5 years ago
|
git_url="${GIT_URL:-https://github.com}"
|
||
|
|
||
5 years ago
|
git_base_dir=~/github
|
||
|
|
||
|
mkdir -pv "$git_base_dir"
|
||
|
|
||
|
cd "$git_base_dir"
|
||
|
|
||
5 years ago
|
repofile="$srcdir/setup/repolist.txt"
|
||
|
|
||
|
if [ $# -gt 0 ]; then
|
||
|
repolist="$*"
|
||
|
else
|
||
|
repolist="${*:-${REPOS:-}}"
|
||
|
if [ -n "$repolist" ]; then
|
||
|
:
|
||
|
elif [ -f "$repofile" ]; then
|
||
|
echo "processing repos from file: $repofile"
|
||
|
repolist="$(sed 's/#.*//; /^[[:space:]]*$/d' < "$repofile")"
|
||
|
else
|
||
|
echo "fetching repos from GitHub repo list"
|
||
5 years ago
|
repolist="$(curl -sSL https://raw.githubusercontent.com/HariSekhon/bash-tools/master/setup/repolist.txt | sed 's/#.*//')"
|
||
5 years ago
|
fi
|
||
|
fi
|
||
|
|
||
5 years ago
|
run(){
|
||
5 years ago
|
local repolist="$*"
|
||
|
for repo in $repolist; do
|
||
5 years ago
|
repo_dir="${repo##*/}"
|
||
|
repo_dir="${repo_dir##*:}"
|
||
5 years ago
|
repo="${repo%%:*}"
|
||
5 years ago
|
if ! echo "$repo" | grep -q "/"; then
|
||
|
repo="HariSekhon/$repo"
|
||
|
fi
|
||
5 years ago
|
if [ -d "$repo_dir" ]; then
|
||
|
pushd "$repo_dir"
|
||
|
# make update does git pull but if that mechanism is broken then this first git pull will allow the repo to self-fix itself
|
||
|
git pull
|
||
|
if [ -n "${QUICK:-}" ] ||
|
||
|
[ -n "${NOBUILD:-}" ] ||
|
||
|
[ -n "${NO_BUILD:-}" ]; then
|
||
|
make update-no-recompile || exit 1
|
||
|
else
|
||
|
make update
|
||
|
fi
|
||
|
popd
|
||
9 years ago
|
else
|
||
5 years ago
|
git clone "$git_url/$repo" "$repo_dir"
|
||
9 years ago
|
fi
|
||
5 years ago
|
done
|
||
5 years ago
|
}
|
||
|
|
||
5 years ago
|
run "$repolist"
|