Browse Source

installing git when wget_semver first time

master
pvincent 3 years ago
parent
commit
598e95c59e
  1. 36
      tools/wget_semver

36
tools/wget_semver

@ -3,7 +3,7 @@
REPO_TYPE=$1 REPO_TYPE=$1
REPO_NAME=$2 REPO_NAME=$2
function usage {
function usage() {
local BASECMD=$(basename "$0") local BASECMD=$(basename "$0")
echo 'usage: <REPO_TYPE> <REPO_NAME> [DESTINATION]' echo 'usage: <REPO_TYPE> <REPO_NAME> [DESTINATION]'
echo 'example:' echo 'example:'
@ -14,42 +14,44 @@ function usage {
exit -1 exit -1
} }
function get_github {
local all_releases=$( git ls-remote --tags --sort="v:refname" git://github.com/$REPO_NAME )
function get_github() {
local all_releases=$(git ls-remote --tags --sort="v:refname" git://github.com/$REPO_NAME)
# extract only VERSION without 'v' # extract only VERSION without 'v'
local non_v_release=$( echo "$all_releases" \
| grep -v "refs/tags/v" | grep -v dev | grep -v rc | tail -n1 | cut -f2 | cut -d '/' -f3 )
local non_v_release=$(echo "$all_releases" |
grep -v "refs/tags/v" | grep -v dev | grep -v rc | tail -n1 | cut -f2 | cut -d '/' -f3)
non_v_release=${non_v_release%^\{\}} # remove extra characters ^{} from github non_v_release=${non_v_release%^\{\}} # remove extra characters ^{} from github
[ -n "$non_v_release" ] && echo $non_v_release && return [ -n "$non_v_release" ] && echo $non_v_release && return
# extract remaining version including 'v' # extract remaining version including 'v'
local v_release=$( echo "$all_releases" \
| grep -v dev | grep -v rc | tail -n1 | cut -f2 | cut -d '/' -f3 )
local v_release=$(echo "$all_releases" |
grep -v dev | grep -v rc | tail -n1 | cut -f2 | cut -d '/' -f3)
v_release=${v_release%^\{\}} # remove extra characters ^{} from github v_release=${v_release%^\{\}} # remove extra characters ^{} from github
echo $v_release echo $v_release
} }
function get_artcode {
release=$( git ls-remote --tags --sort="v:refname" \
https://git.artcode.re/$REPO_NAME \
| tail -n1 | cut -f2 | cut -d '/' -f3 )
function get_artcode() {
release=$(git ls-remote --tags --sort="v:refname" \
https://git.artcode.re/$REPO_NAME |
tail -n1 | cut -f2 | cut -d '/' -f3)
echo $release echo $release
} }
[[ $# -ne 2 ]] && usage [[ $# -ne 2 ]] && usage
if [ -z "$(command -v git)" ]; then
echo "INSTALLING PACKAGE <GIT> required"
sudo apt install -y git
fi
case $REPO_TYPE in case $REPO_TYPE in
github )
github)
get_github get_github
;; ;;
artcode )
artcode)
get_artcode get_artcode
;; ;;
* )
*)
echo "repository type <${REPO_TYPE}> not yet supported!" && exit 1 echo "repository type <${REPO_TYPE}> not yet supported!" && exit 1
;; ;;
esac esac
Loading…
Cancel
Save