getlib (485B)
1 #!/bin/sh 2 3 set -e 4 5 base="${1%%@*}" 6 tag="${1##*@}" 7 test "$tag" = "$1" && 8 tag='' 9 10 url=https://"$base" 11 dir=lib/"$base"/src 12 13 if ! test -d "$dir" 14 then 15 git clone -q "$url" "$dir" 16 fetch=false 17 fi 18 19 cd "$dir" 20 21 ${fetch:-true} && 22 git fetch -q 23 test "$tag" && 24 git checkout -q "$tag" 25 26 # Reset would work, but this seems safer 27 # (In case the git directory is somehow deleted, etc.) 28 git restore . 29 30 if test -d ../patches; then 31 for p in ../patches/* 32 do 33 patch -suNp1 < "$p" 34 done 35 fi 36 37 echo "$dir"