X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions%2Fmain;fp=functions%2Fmain;h=35ec62ccf3e75c62333d3fea29c9af4ef08f444c;hb=d1040a12fae93e20587519a732730cb4c9cb5050;hp=4af62ad87c267a9182b7c7bb17befcc2b346fdb0;hpb=17485f96d72ad6b0822c5082a8b24ce71946f536;p=hvlinux.git diff --git a/functions/main b/functions/main index 4af62ad..35ec62c 100644 --- a/functions/main +++ b/functions/main @@ -202,6 +202,40 @@ get_pkg_ver_underscore() echo ${1} | sed "s!.*_\([0-9].*\)!\1!g" } +# Extracting the version number from a complete package name +# when the package name uses the underscore as the separator. +# Arg. #1: Complete package name with version (ex: icu4c-54_1 will output 54.1) +get_pkg_ver_underscore2() +{ + # Checking for correct number of arguments + if [ $# -ne 1 ]; then + echo "${FUNCNAME}(), wrong number of arguments: ${*}" + return 1 + fi + + local v=$(get_pkg_ver ${1}) + + # Replace underscore by dot + echo ${v} | sed "s!_!\.!g" +} + +# Convert package version dots to uderscore. +# Ex: gcc-3.4.6 will output 3_4_6 +# Arg. #1: Complete package name with version +ver_dots_to_underscore() +{ + # Checking for correct number of arguments + if [ $# -ne 1 ]; then + echo "${FUNCNAME}(), wrong number of arguments: ${*}" + return 1 + fi + + local v=$(get_pkg_ver ${1}) + + # Replace dots by underscores + echo ${v} | sed "s!\.!_!g" +} + # Extracting the first digit version number from a complete package name. # Arg. #1: Complete package name with version (ex: gcc-3.4.4 will output 3) get_pkg_ver1() @@ -215,6 +249,20 @@ get_pkg_ver1() echo ${1} | sed "s!^.*-\([0-9]*\)\..*!\1!g" } +# Extracting the first digit version number from a complete package name, +# when the package name uses the underscore as the separator. +# Arg. #1: Complete package name with version (ex: icu4c-54_1 will output 54) +get_pkg_ver1_underscore() +{ + # Checking for correct number of arguments + if [ $# -ne 1 ]; then + echo "${FUNCNAME}(), wrong number of arguments: ${*}" + return 1 + fi + + echo ${1} | sed "s!^.*-\([0-9]*\)_.*!\1!g" +} + # Extracting the first 2 digits version number from a complete package name. # Arg. #1: Complete package name with version (ex: gcc-3.4.4 will output 3.4) get_pkg_ver2()