fix
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# CONSTANTS
|
# CONSTANTS
|
||||||
|
|
||||||
readonly REQUIRED_PKGS=(file jq vim)
|
readonly REQUIRED_PKGS=(file jq vim git)
|
||||||
readonly BACKUP='ORIGINAL'
|
readonly BACKUP='ORIGINAL'
|
||||||
|
|
||||||
# FUNCTIONS
|
# FUNCTIONS
|
||||||
|
|||||||
+32
-32
@@ -4,56 +4,56 @@ REPO_TYPE=$1
|
|||||||
REPO_NAME=$2
|
REPO_NAME=$2
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
local basecmd
|
local basecmd
|
||||||
basecmd=$(basename "$0")
|
basecmd=$(basename "$0")
|
||||||
echo 'usage: <REPO_TYPE> <REPO_NAME> [DESTINATION]'
|
echo 'usage: <REPO_TYPE> <REPO_NAME> [DESTINATION]'
|
||||||
echo 'example:'
|
echo 'example:'
|
||||||
echo -e '\t# REPO_TYPE=github'
|
echo -e '\t# REPO_TYPE=github'
|
||||||
echo -e "\t${basecmd} github Dolibarr/dolibarr\n"
|
echo -e "\t${basecmd} github Dolibarr/dolibarr\n"
|
||||||
echo -e '\t# REPO_TYPE=artcode'
|
echo -e '\t# REPO_TYPE=artcode'
|
||||||
echo -e "\t${basecmd} artcode libre/libre-gnome\n"
|
echo -e "\t${basecmd} artcode libre/libre-gnome\n"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_github {
|
function get_github {
|
||||||
local all_releases=$(git ls-remote --tags --sort="v:refname" https://github.com/"$REPO_NAME" | grep -Eo "v?([0-9]+\.){2}[0-9]+$")
|
local all_releases=$(git ls-remote --tags --sort="v:refname" https://github.com/"$REPO_NAME" | grep -Eo "v?([0-9]+\.){2}[0-9]+$")
|
||||||
|
|
||||||
# extract only VERSION without 'v'
|
# extract only VERSION without 'v'
|
||||||
local non_v_release=$(echo "$all_releases" | grep -v v | tail -n1 | cut -f2 | cut -d '/' -f3)
|
local non_v_release=$(echo "$all_releases" | grep -v v | 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
|
||||||
|
|
||||||
# extract remaining version including 'v'
|
# extract remaining version including 'v'
|
||||||
local v_release=$(echo "$all_releases" | tail -n1 | cut -f2 | cut -d '/' -f3)
|
local v_release=$(echo "$all_releases" | 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
|
||||||
|
|
||||||
# compare which newer from non_v_release to v_release
|
# compare which newer from non_v_release to v_release
|
||||||
if [ -n "$non_v_release" ] && [ "v$non_v_release" \> "$v_release" ]; then
|
if [ -n "$non_v_release" ] && [ "v$non_v_release" \> "$v_release" ]; then
|
||||||
echo $non_v_release
|
echo $non_v_release
|
||||||
else
|
else
|
||||||
echo $v_release
|
echo $v_release
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_artcode {
|
function get_artcode {
|
||||||
git ls-remote --tags --sort="v:refname" "https://git.artcode.re/$REPO_NAME" | tail -n1 | cut -f2 | cut -d '/' -f3
|
git ls-remote --tags --sort="v:refname" "https://git.artcode.re/$REPO_NAME" | tail -n1 | cut -f2 | cut -d '/' -f3
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ $# -ne 2 ]] && usage
|
[[ $# -ne 2 ]] && usage
|
||||||
|
|
||||||
if [ -z "$(command -v git)" ]; then
|
if [ -z "$(command -v git)" ]; then
|
||||||
echo "INSTALLING PACKAGE <GIT> required"
|
echo "INSTALLING PACKAGE <GIT> required"
|
||||||
source "$MIAOU_BASH_DIR/lib/functions.bash"
|
source "$MIAOU_BASH_DIR/lib/functions.bash"
|
||||||
"$CURDIR/tools/idem_apt_install" git
|
"$MIAOU_BASH_DIR/tools/idem_apt_install" git
|
||||||
fi
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user