add fetch-3rd-party.sh and remove installExternal.sh

The new script not only clones the git repo once but can also pulls
updates from all git repositories every time it is executed and allows
to symlink binaries into $HOME/bin
This commit is contained in:
Thomas Preisner 2017-10-10 14:09:32 +02:00
parent c1a8e98d61
commit 5fd4472c50
2 changed files with 37 additions and 5 deletions

37
fetch-3rd-party.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash -e
::() {
echo ":: $*" >&2
"$@"
}
# usage: fetch <name> <git repo> [<bin symlinks> ...]
fetch() {
dir="$HOME/misc/$1"
if [ -d "$dir" ]; then
# try to pull changes from repository without merging
:: git --git-dir="$dir/.git" --work-tree="$dir" pull --ff-only
else
# clone repository if it does not exist yet
:: git clone "$2" "$dir"
fi
shift
shift
# symlink all following filenames into $HOME/bin if existent
while x="$1"; shift; do
file=$(:: find "$dir" -name "$x" | head -n 1)
if [ -z "$file" ]; then
echo "Missing file: $x"
else
target="${file##*/}"
target="${target%.py}"
:: ln -sf "$file" "$HOME/bin/$target"
fi
done
}
fetch barpyrus https://github.com/t-wissmann/barpyrus.git
fetch i3lock-fancy https://github.com/meskarune/i3lock-fancy.git lock
fetch siji https://github.com/stark/siji
:: sh -c 'cd $HOME/misc/siji && ./install.sh -d "$HOME/.fonts"'

View file

@ -1,5 +0,0 @@
#! /bin/bash
mkdir ~/misc
cd ~/misc
git clone https://github.com/t-wissmann/barpyrus.git