support système sans python2

This commit is contained in:
Jephté Clain 2023-08-12 20:50:16 +04:00
parent 108215fce4
commit bfdf9b5bef
5 changed files with 1035 additions and 448 deletions

View File

@ -14,19 +14,21 @@ rm -f .nutools-devel
# supprimer fichiers de développement # supprimer fichiers de développement
rm -rf lib/pyulib/{build,devel,migrate,test} rm -rf lib/pyulib/{build,devel,migrate,test}
# compiler les modules python de support if progexists python2; then
estep "Compilation des modules python" # compiler les modules python de support
progexists python2 && PYTHON=python2 || PYTHON=python estep "Compilation des modules python"
"$PYTHON" -m compileall lib/ulib/support/python PYTHON=python2
#"$PYTHON" -m compileall lib/nulib/python "$PYTHON" -m compileall lib/ulib/support/python
#"$PYTHON" -m compileall lib/nulib/python
# liens pour les scripts python # liens pour les scripts python
for i in plver plbck uencdetect urandomize umail uxpath wofixsql; do for i in plver plbck uencdetect urandomize umail uxpath wofixsql; do
ln -s lib/pywrapper "$i" ln -s lib/pywrapper "$i"
done done
ln -s lib/ulib/support/cgiupload.py ln -s lib/ulib/support/cgiupload.py
ln -s lib/ulib/support/cgiparams.py ln -s lib/ulib/support/cgiparams.py
ln -s lib/ulib/support/cgilsxml.py ln -s lib/ulib/support/cgilsxml.py
fi
# liens pour les scripts shell # liens pour les scripts shell
for i in cg cgs; do for i in cg cgs; do

View File

@ -5,15 +5,18 @@ source "$ULIBDIR/ulib" || exit 1
urequire DEFAULTS urequire DEFAULTS
cd "$scriptdir/../.." cd "$scriptdir/../.."
log=/tmp/nutools-pyulib-install.log
etitle -s "Installation des packages python"
enote "Le log de l'installation se trouve dans $log"
./uinst -y lib/pyulib >&"$log"
eend
# setup.py laisse des fichiers avec les droits de root, et ces fichiers ne if progexists python2; then
# peuvent être supprimés par l'utilisateur qui lance uinst. Les supprimer ici. log=/tmp/nutools-pyulib-install.log
rm -rf lib/pyulib/build etitle -s "Installation des packages python"
enote "Le log de l'installation se trouve dans $log"
./uinst -y lib/pyulib >&"$log"
eend
# setup.py laisse des fichiers avec les droits de root, et ces fichiers ne
# peuvent être supprimés par l'utilisateur qui lance uinst. Les supprimer ici.
rm -rf lib/pyulib/build
fi
dest="@@dest@@" dest="@@dest@@"
for i in ulib ulibsh; do for i in ulib ulibsh; do

View File

@ -65,7 +65,15 @@ export TMPDIR="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}"
[ -f /etc/debian_chroot ] && UTOOLS_CHROOT=1 [ -f /etc/debian_chroot ] && UTOOLS_CHROOT=1
[ -f /etc/nutoolsrc ] && . /etc/nutoolsrc [ -f /etc/nutoolsrc ] && . /etc/nutoolsrc
[ -f ~/.nutoolsrc ] && . ~/.nutoolsrc [ -f ~/.nutoolsrc ] && . ~/.nutoolsrc
true
UNAME_SYSTEM=`uname -s`
[ "${UNAME_SYSTEM#CYGWIN}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Cygwin
[ "${UNAME_SYSTEM#MINGW32}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Mingw
UNAME_MACHINE=`uname -m`
if [ -n "$UTOOLS_CHROOT" ]; then
[ -n "$UTOOLS_UNAME_SYSTEM" ] && eval "UNAME_SYSTEM=$UTOOLS_UNAME_SYSTEM"
[ -n "$UTOOLS_UNAME_MACHINE" ] && eval "UNAME_MACHINE=$UTOOLS_UNAME_MACHINE"
fi
##@inc]base.init ##@inc]base.init
##@inc[base.core ##@inc[base.core
## Fonctions de base: fondement ## Fonctions de base: fondement
@ -160,44 +168,45 @@ function qwc() {
s="${s//\"/\\\"}" s="${s//\"/\\\"}"
s="${s//\$/\\\$}" s="${s//\$/\\\$}"
s="${s//\`/\\\`}" s="${s//\`/\\\`}"
local r a b local r a b c
while [ -n "$s" ]; do while [ -n "$s" ]; do
if [[ "$s" == *\** ]]; then a=; b=; c=
if [[ "$s" == *\?* ]]; then a=; [[ "$s" == *\** ]] && { a="${s%%\**}"; a=${#a}; }
a="${s%%\**}" b=; [[ "$s" == *\?* ]] && { b="${s%%\?*}"; b=${#b}; }
b="${s%%\?*}" c=; [[ "$s" == *\[* ]] && { c="${s%%\[*}"; c=${#c}; }
if [ ${#a} -lt ${#b} ]; then if [ -z "$a" -a -z "$b" -a -z "$c" ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\**}"
s="${s#*\*}"
r="$r\"$a\"*"
fi
elif [[ "$s" == *\?* ]]; then
if [[ "$s" == *\** ]]; then
a="${s%%\**}"
b="${s%%\?*}"
if [ ${#a} -lt ${#b} ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\?*}"
s="${s#*\?}"
r="$r\"$a\"?"
fi
else
r="$r\"$s\"" r="$r\"$s\""
break break
fi fi
if [ -n "$a" ]; then
[ -n "$b" ] && [ $a -lt $b ] && b=
[ -n "$c" ] && [ $a -lt $c ] && c=
fi
if [ -n "$b" ]; then
[ -n "$a" ] && [ $b -lt $a ] && a=
[ -n "$c" ] && [ $b -lt $c ] && c=
fi
if [ -n "$c" ]; then
[ -n "$a" ] && [ $c -lt $a ] && a=
[ -n "$b" ] && [ $c -lt $b ] && b=
fi
if [ -n "$a" ]; then # PREFIX*
a="${s%%\**}"
s="${s#*\*}"
[ -n "$a" ] && r="$r\"$a\""
r="$r*"
elif [ -n "$b" ]; then # PREFIX?
a="${s%%\?*}"
s="${s#*\?}"
[ -n "$a" ] && r="$r\"$a\""
r="$r?"
elif [ -n "$c" ]; then # PREFIX[class]
a="${s%%\[*}"
b="${s#*\[}"; b="${b%%\]*}"
s="${s:$((${#a} + ${#b} + 2))}"
[ -n "$a" ] && r="$r\"$a\""
r="$r[$b]"
fi
done done
recho_ "$r" recho_ "$r"
} }
@ -224,6 +233,48 @@ function echo_setv() {
fi fi
echo "$__s_var=$(qvalr "$*")" echo "$__s_var=$(qvalr "$*")"
} }
function echo_setv2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
if [ $# -eq 0 ]; then
echo_setv "$__s_var" "${!__s_var}"
else
echo_setv "$__s_var" "$@"
fi
}
function seta() {
local __s_array="$1"; shift
if [[ "$__s_array" == *=* ]]; then
set -- "${__s_array#*=}" "$@"
__s_array="${__s_array%%=*}"
fi
eval "$__s_array=(\"\$@\")"
}
function _seta() {
local __s_array="$1"; shift
eval "$__s_array=(\"\$@\")"
}
function echo_seta() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
echo "$__s_var=($(qvals "$@"))"
}
function echo_seta2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
elif [ $# -eq 0 ]; then
eval "set -- \"\${$__s_var[@]}\""
fi
echo "$__s_var=($(qvals "$@"))"
}
function setx() { function setx() {
if [ "$1" == -a ]; then if [ "$1" == -a ]; then
shift shift
@ -747,6 +798,19 @@ function yesval() {
is_yes "$1" && echo 1 is_yes "$1" && echo 1
} }
function setyesval() {
is_yes "$2" && _setv "$1" 1 || _setv "$1" ""
}
function normyesval() {
is_yes "${2:-"${!1}"}" && _setv "$1" 1 || _setv "$1" ""
}
function normyesvals() {
local __nyv_yesvar
for __nyv_yesvar in "$@"; do
is_yes "${!__nyv_yesvar}" && _setv "$__nyv_yesvar" 1 || _setv "$__nyv_yesvar" ""
done
}
function setb() { function setb() {
local __s_var="$1"; shift local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then if [[ "$__s_var" == *=* ]]; then
@ -1049,44 +1113,45 @@ function qwc() {
s="${s//\"/\\\"}" s="${s//\"/\\\"}"
s="${s//\$/\\\$}" s="${s//\$/\\\$}"
s="${s//\`/\\\`}" s="${s//\`/\\\`}"
local r a b local r a b c
while [ -n "$s" ]; do while [ -n "$s" ]; do
if [[ "$s" == *\** ]]; then a=; b=; c=
if [[ "$s" == *\?* ]]; then a=; [[ "$s" == *\** ]] && { a="${s%%\**}"; a=${#a}; }
a="${s%%\**}" b=; [[ "$s" == *\?* ]] && { b="${s%%\?*}"; b=${#b}; }
b="${s%%\?*}" c=; [[ "$s" == *\[* ]] && { c="${s%%\[*}"; c=${#c}; }
if [ ${#a} -lt ${#b} ]; then if [ -z "$a" -a -z "$b" -a -z "$c" ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\**}"
s="${s#*\*}"
r="$r\"$a\"*"
fi
elif [[ "$s" == *\?* ]]; then
if [[ "$s" == *\** ]]; then
a="${s%%\**}"
b="${s%%\?*}"
if [ ${#a} -lt ${#b} ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\?*}"
s="${s#*\?}"
r="$r\"$a\"?"
fi
else
r="$r\"$s\"" r="$r\"$s\""
break break
fi fi
if [ -n "$a" ]; then
[ -n "$b" ] && [ $a -lt $b ] && b=
[ -n "$c" ] && [ $a -lt $c ] && c=
fi
if [ -n "$b" ]; then
[ -n "$a" ] && [ $b -lt $a ] && a=
[ -n "$c" ] && [ $b -lt $c ] && c=
fi
if [ -n "$c" ]; then
[ -n "$a" ] && [ $c -lt $a ] && a=
[ -n "$b" ] && [ $c -lt $b ] && b=
fi
if [ -n "$a" ]; then # PREFIX*
a="${s%%\**}"
s="${s#*\*}"
[ -n "$a" ] && r="$r\"$a\""
r="$r*"
elif [ -n "$b" ]; then # PREFIX?
a="${s%%\?*}"
s="${s#*\?}"
[ -n "$a" ] && r="$r\"$a\""
r="$r?"
elif [ -n "$c" ]; then # PREFIX[class]
a="${s%%\[*}"
b="${s#*\[}"; b="${b%%\]*}"
s="${s:$((${#a} + ${#b} + 2))}"
[ -n "$a" ] && r="$r\"$a\""
r="$r[$b]"
fi
done done
recho_ "$r" recho_ "$r"
} }
@ -1113,6 +1178,48 @@ function echo_setv() {
fi fi
echo "$__s_var=$(qvalr "$*")" echo "$__s_var=$(qvalr "$*")"
} }
function echo_setv2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
if [ $# -eq 0 ]; then
echo_setv "$__s_var" "${!__s_var}"
else
echo_setv "$__s_var" "$@"
fi
}
function seta() {
local __s_array="$1"; shift
if [[ "$__s_array" == *=* ]]; then
set -- "${__s_array#*=}" "$@"
__s_array="${__s_array%%=*}"
fi
eval "$__s_array=(\"\$@\")"
}
function _seta() {
local __s_array="$1"; shift
eval "$__s_array=(\"\$@\")"
}
function echo_seta() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
echo "$__s_var=($(qvals "$@"))"
}
function echo_seta2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
elif [ $# -eq 0 ]; then
eval "set -- \"\${$__s_var[@]}\""
fi
echo "$__s_var=($(qvals "$@"))"
}
function setx() { function setx() {
if [ "$1" == -a ]; then if [ "$1" == -a ]; then
shift shift
@ -1625,7 +1732,7 @@ function __po_parse_optdescs() {
option_="${optdesc_%::}" option_="${optdesc_%::}"
if [[ "$2" == *=* ]]; then if [[ "$2" == *=* ]]; then
name_="${2%%=*}=" name_="${2%%=*}="
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "$name_"
else else
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=()" [ -n "$reset_" ] && eval "$name_=()"
@ -1635,7 +1742,7 @@ function __po_parse_optdescs() {
option_="${optdesc_%:}" option_="${optdesc_%:}"
if [[ "$2" == *=* ]]; then if [[ "$2" == *=* ]]; then
name_="${2%%=*}=" name_="${2%%=*}="
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "$name_"
else else
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=()" [ -n "$reset_" ] && eval "$name_=()"
@ -1644,7 +1751,7 @@ function __po_parse_optdescs() {
else else
option_="$optdesc_" option_="$optdesc_"
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "${2%%=*}="
flag_= flag_=
fi fi
@ -1958,44 +2065,45 @@ function qwc() {
s="${s//\"/\\\"}" s="${s//\"/\\\"}"
s="${s//\$/\\\$}" s="${s//\$/\\\$}"
s="${s//\`/\\\`}" s="${s//\`/\\\`}"
local r a b local r a b c
while [ -n "$s" ]; do while [ -n "$s" ]; do
if [[ "$s" == *\** ]]; then a=; b=; c=
if [[ "$s" == *\?* ]]; then a=; [[ "$s" == *\** ]] && { a="${s%%\**}"; a=${#a}; }
a="${s%%\**}" b=; [[ "$s" == *\?* ]] && { b="${s%%\?*}"; b=${#b}; }
b="${s%%\?*}" c=; [[ "$s" == *\[* ]] && { c="${s%%\[*}"; c=${#c}; }
if [ ${#a} -lt ${#b} ]; then if [ -z "$a" -a -z "$b" -a -z "$c" ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\**}"
s="${s#*\*}"
r="$r\"$a\"*"
fi
elif [[ "$s" == *\?* ]]; then
if [[ "$s" == *\** ]]; then
a="${s%%\**}"
b="${s%%\?*}"
if [ ${#a} -lt ${#b} ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\?*}"
s="${s#*\?}"
r="$r\"$a\"?"
fi
else
r="$r\"$s\"" r="$r\"$s\""
break break
fi fi
if [ -n "$a" ]; then
[ -n "$b" ] && [ $a -lt $b ] && b=
[ -n "$c" ] && [ $a -lt $c ] && c=
fi
if [ -n "$b" ]; then
[ -n "$a" ] && [ $b -lt $a ] && a=
[ -n "$c" ] && [ $b -lt $c ] && c=
fi
if [ -n "$c" ]; then
[ -n "$a" ] && [ $c -lt $a ] && a=
[ -n "$b" ] && [ $c -lt $b ] && b=
fi
if [ -n "$a" ]; then # PREFIX*
a="${s%%\**}"
s="${s#*\*}"
[ -n "$a" ] && r="$r\"$a\""
r="$r*"
elif [ -n "$b" ]; then # PREFIX?
a="${s%%\?*}"
s="${s#*\?}"
[ -n "$a" ] && r="$r\"$a\""
r="$r?"
elif [ -n "$c" ]; then # PREFIX[class]
a="${s%%\[*}"
b="${s#*\[}"; b="${b%%\]*}"
s="${s:$((${#a} + ${#b} + 2))}"
[ -n "$a" ] && r="$r\"$a\""
r="$r[$b]"
fi
done done
recho_ "$r" recho_ "$r"
} }
@ -2022,6 +2130,48 @@ function echo_setv() {
fi fi
echo "$__s_var=$(qvalr "$*")" echo "$__s_var=$(qvalr "$*")"
} }
function echo_setv2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
if [ $# -eq 0 ]; then
echo_setv "$__s_var" "${!__s_var}"
else
echo_setv "$__s_var" "$@"
fi
}
function seta() {
local __s_array="$1"; shift
if [[ "$__s_array" == *=* ]]; then
set -- "${__s_array#*=}" "$@"
__s_array="${__s_array%%=*}"
fi
eval "$__s_array=(\"\$@\")"
}
function _seta() {
local __s_array="$1"; shift
eval "$__s_array=(\"\$@\")"
}
function echo_seta() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
echo "$__s_var=($(qvals "$@"))"
}
function echo_seta2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
elif [ $# -eq 0 ]; then
eval "set -- \"\${$__s_var[@]}\""
fi
echo "$__s_var=($(qvals "$@"))"
}
function setx() { function setx() {
if [ "$1" == -a ]; then if [ "$1" == -a ]; then
shift shift
@ -2534,7 +2684,7 @@ function __po_parse_optdescs() {
option_="${optdesc_%::}" option_="${optdesc_%::}"
if [[ "$2" == *=* ]]; then if [[ "$2" == *=* ]]; then
name_="${2%%=*}=" name_="${2%%=*}="
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "$name_"
else else
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=()" [ -n "$reset_" ] && eval "$name_=()"
@ -2544,7 +2694,7 @@ function __po_parse_optdescs() {
option_="${optdesc_%:}" option_="${optdesc_%:}"
if [[ "$2" == *=* ]]; then if [[ "$2" == *=* ]]; then
name_="${2%%=*}=" name_="${2%%=*}="
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "$name_"
else else
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=()" [ -n "$reset_" ] && eval "$name_=()"
@ -2553,7 +2703,7 @@ function __po_parse_optdescs() {
else else
option_="$optdesc_" option_="$optdesc_"
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "${2%%=*}="
flag_= flag_=
fi fi
@ -2988,44 +3138,45 @@ function qwc() {
s="${s//\"/\\\"}" s="${s//\"/\\\"}"
s="${s//\$/\\\$}" s="${s//\$/\\\$}"
s="${s//\`/\\\`}" s="${s//\`/\\\`}"
local r a b local r a b c
while [ -n "$s" ]; do while [ -n "$s" ]; do
if [[ "$s" == *\** ]]; then a=; b=; c=
if [[ "$s" == *\?* ]]; then a=; [[ "$s" == *\** ]] && { a="${s%%\**}"; a=${#a}; }
a="${s%%\**}" b=; [[ "$s" == *\?* ]] && { b="${s%%\?*}"; b=${#b}; }
b="${s%%\?*}" c=; [[ "$s" == *\[* ]] && { c="${s%%\[*}"; c=${#c}; }
if [ ${#a} -lt ${#b} ]; then if [ -z "$a" -a -z "$b" -a -z "$c" ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\**}"
s="${s#*\*}"
r="$r\"$a\"*"
fi
elif [[ "$s" == *\?* ]]; then
if [[ "$s" == *\** ]]; then
a="${s%%\**}"
b="${s%%\?*}"
if [ ${#a} -lt ${#b} ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\?*}"
s="${s#*\?}"
r="$r\"$a\"?"
fi
else
r="$r\"$s\"" r="$r\"$s\""
break break
fi fi
if [ -n "$a" ]; then
[ -n "$b" ] && [ $a -lt $b ] && b=
[ -n "$c" ] && [ $a -lt $c ] && c=
fi
if [ -n "$b" ]; then
[ -n "$a" ] && [ $b -lt $a ] && a=
[ -n "$c" ] && [ $b -lt $c ] && c=
fi
if [ -n "$c" ]; then
[ -n "$a" ] && [ $c -lt $a ] && a=
[ -n "$b" ] && [ $c -lt $b ] && b=
fi
if [ -n "$a" ]; then # PREFIX*
a="${s%%\**}"
s="${s#*\*}"
[ -n "$a" ] && r="$r\"$a\""
r="$r*"
elif [ -n "$b" ]; then # PREFIX?
a="${s%%\?*}"
s="${s#*\?}"
[ -n "$a" ] && r="$r\"$a\""
r="$r?"
elif [ -n "$c" ]; then # PREFIX[class]
a="${s%%\[*}"
b="${s#*\[}"; b="${b%%\]*}"
s="${s:$((${#a} + ${#b} + 2))}"
[ -n "$a" ] && r="$r\"$a\""
r="$r[$b]"
fi
done done
recho_ "$r" recho_ "$r"
} }
@ -3052,6 +3203,48 @@ function echo_setv() {
fi fi
echo "$__s_var=$(qvalr "$*")" echo "$__s_var=$(qvalr "$*")"
} }
function echo_setv2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
if [ $# -eq 0 ]; then
echo_setv "$__s_var" "${!__s_var}"
else
echo_setv "$__s_var" "$@"
fi
}
function seta() {
local __s_array="$1"; shift
if [[ "$__s_array" == *=* ]]; then
set -- "${__s_array#*=}" "$@"
__s_array="${__s_array%%=*}"
fi
eval "$__s_array=(\"\$@\")"
}
function _seta() {
local __s_array="$1"; shift
eval "$__s_array=(\"\$@\")"
}
function echo_seta() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
echo "$__s_var=($(qvals "$@"))"
}
function echo_seta2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
elif [ $# -eq 0 ]; then
eval "set -- \"\${$__s_var[@]}\""
fi
echo "$__s_var=($(qvals "$@"))"
}
function setx() { function setx() {
if [ "$1" == -a ]; then if [ "$1" == -a ]; then
shift shift
@ -3602,6 +3795,19 @@ function yesval() {
is_yes "$1" && echo 1 is_yes "$1" && echo 1
} }
function setyesval() {
is_yes "$2" && _setv "$1" 1 || _setv "$1" ""
}
function normyesval() {
is_yes "${2:-"${!1}"}" && _setv "$1" 1 || _setv "$1" ""
}
function normyesvals() {
local __nyv_yesvar
for __nyv_yesvar in "$@"; do
is_yes "${!__nyv_yesvar}" && _setv "$__nyv_yesvar" 1 || _setv "$__nyv_yesvar" ""
done
}
function setb() { function setb() {
local __s_var="$1"; shift local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then if [[ "$__s_var" == *=* ]]; then
@ -3664,6 +3870,17 @@ function quote_form() { _qform "$@"; }
function quoted_form() { qform "$@"; } function quoted_form() { qform "$@"; }
function set_array_cmd() {
if [ $# -eq 1 ]; then echo_seta "$1"
elif [ "$2" == @ ]; then echo_seta "$1" "${@:3}"
else eval "echo_seta \"\$1\" \"\${$2[@]}\""
fi
}
function set_array() {
eval "$(set_array_cmd "$@")"
}
if [ -n "$BASH_VERSINFO" -a "${BASH_VERSINFO[0]}" -lt 4 ]; then if [ -n "$BASH_VERSINFO" -a "${BASH_VERSINFO[0]}" -lt 4 ]; then
urequire base.string urequire base.string
function strlower() { tr A-Z a-z <<<"$*"; } function strlower() { tr A-Z a-z <<<"$*"; }
@ -3718,30 +3935,22 @@ if [ -n "$BASH_VERSINFO" -a "${BASH_VERSINFO[0]}" -lt 4 ]; then
} }
fi fi
##@inc]base.compat ##@inc]base.compat
uprovide base ##@inc[base.deprecated
urequire base.init base.core base.string base.num base.bool base.array base.quote base.split base.args base.tools base.compat ## Fonctions dépréciées
uprovide base.deprecated
UNAME_SYSTEM=`uname -s`
[ "${UNAME_SYSTEM#CYGWIN}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Cygwin
[ "${UNAME_SYSTEM#MINGW32}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Mingw
UNAME_MACHINE=`uname -m`
if [ -n "$UTOOLS_CHROOT" ]; then
[ -n "$UTOOLS_UNAME_SYSTEM" ] && eval "UNAME_SYSTEM=$UTOOLS_UNAME_SYSTEM"
[ -n "$UTOOLS_UNAME_MACHINE" ] && eval "UNAME_MACHINE=$UTOOLS_UNAME_MACHINE"
fi
function setyesval() { function set_array_cmd() {
is_yes "$2" && _setv "$1" 1 || _setv "$1" "" if [ $# -eq 1 ]; then echo_seta2 "$1"
elif [ "$2" == @ ]; then echo_seta "$1" "${@:3}"
else eval "echo_seta \"\$1\" \"\${$2[@]}\""
fi
} }
function normyesval() { function set_array() {
is_yes "${2:-"${!1}"}" && _setv "$1" 1 || _setv "$1" "" eval "$(set_array_cmd "$@")"
}
function normyesvals() {
local __nyv_yesvar
for __nyv_yesvar in "$@"; do
is_yes "${!__nyv_yesvar}" && _setv "$__nyv_yesvar" 1 || _setv "$__nyv_yesvar" ""
done
} }
function quote_in() { function quote_in() {
sed 's/\\/\\\\/g sed 's/\\/\\\\/g
s/"/\\"/g s/"/\\"/g
@ -3764,27 +3973,11 @@ function quoted_sargs() {
done done
recho "$s" recho "$s"
} }
##@inc]base.deprecated
uprovide base
urequire base.init base.core base.string base.num base.bool base.array base.quote base.split base.args base.tools base.compat
urequire base.deprecated
function set_array_cmd() {
[ $# -eq 1 ] && set -- "$1" "$1"
local __sac_s __sac_v __sac_f
__sac_s="$1=("; shift
if [ "$1" == "@" ]; then
shift
else
eval "set -- \"\${$1[@]}\""
fi
__sac_f=1
for __sac_v in "$@"; do
[ -n "$__sac_f" ] && __sac_f= || __sac_s="$__sac_s "
__sac_s="$__sac_s$(qvalm "$__sac_v")"
done
__sac_s="$__sac_s)"
echo "$__sac_s"
}
function set_array() {
eval "$(set_array_cmd "$@")"
}
function array_count() { function array_count() {
eval "echo \${#$1[*]}" eval "echo \${#$1[*]}"
} }
@ -4070,22 +4263,25 @@ function get_time_fr() {
} }
function parse_date() { function parse_date() {
local value="$1" type="${2:-date}" local value="$1" type="${2:-date}"
local now="$(awk 'BEGIN { print mktime(strftime("%Y %m %d 00 00 00 +0400")) }')" local now="$(awk 'BEGIN { print mktime(strftime("%Y %m %d 00 00 00")) }')"
case "$value" in case "$value" in
=*) value="${value#=}";;
+*) value="$(($now + ${value#+} * 86400))";; +*) value="$(($now + ${value#+} * 86400))";;
-*) value="$(($now - ${value#-} * 86400))";;
*) value="$(<<<"$value" awk -F/ '{ *) value="$(<<<"$value" awk -F/ '{
nd = strftime("%d"); nm = strftime("%m"); ny = strftime("%Y") nd = strftime("%d"); nm = strftime("%m"); ny = strftime("%Y")
d = $1 + 0; if (d < 1) d = nd; d = $1 + 0; if (d < 1) d = nd;
m = $2 + 0; if (m < 1) m = nm; m = $2 + 0; if (m < 1) m = nm;
if ($3 == "") y = ny; if ($3 == "") y = ny;
else { y = $3 + 0; if (y < 100) y = y + 2000; } else { y = $3 + 0; if (y < 100) y = y + 2000; }
print mktime(sprintf("%04i %02i %02i 00 00 00 +0400", y, m, d)); print mktime(sprintf("%04i %02i %02i 00 00 00", y, m, d));
}')";; }')";;
esac esac
case "$type" in case "$type" in
d|date) awk '{ print strftime("%d/%m/%Y", $0 + 0) }' <<<"$value";; d|date) awk '{ print strftime("%d/%m/%Y", $0 + 0) }' <<<"$value";;
l|ldap) awk '{ print strftime("%Y%m%d%H%M%S+0400", $0 + 0) }' <<<"$value";; l|ldap) awk '{ print strftime("%Y%m%d%H%M%S+0400", $0 + 0) }' <<<"$value";;
m|mysql) awk '{ print strftime("%Y-%m-%d", $0 + 0) }' <<<"$value";; m|mysql) awk '{ print strftime("%Y-%m-%d", $0 + 0) }' <<<"$value";;
t|ts|timestamp) echo "$value";;
*) recho "$value";; *) recho "$value";;
esac esac
} }
@ -4197,6 +4393,18 @@ function ppath() {
recho "$path" recho "$path"
} }
function ppath2() {
local path="$1" cwd="$2"
path="$(abspath "$path")" # essayer de normaliser le chemin
[ -n "$cwd" ] || cwd="$(pwd)"
[ "$path" = "$cwd" ] && path="../$(basename -- "$path")"
[ "$cwd" != "/" -a "$cwd" != "$HOME" ] && path="${path#$cwd/}"
[ "${path#$HOME/}" != "$path" ] && path="~${path#$HOME}"
recho "$path"
}
function relpath() { function relpath() {
local p="$(abspath "$1" "$3")" cwd="$2" local p="$(abspath "$1" "$3")" cwd="$2"
if [ -z "$cwd" ]; then if [ -z "$cwd" ]; then
@ -4465,13 +4673,13 @@ function testdiff() {
! quietdiff "$@" ! quietdiff "$@"
} }
function testupdated() { function testupdated() {
if [ -f "$2" ]; then if [ -n "$3" ]; then return 0
testdiff "$1" "$2" elif [ -f "$2" ]; then testdiff "$1" "$2"
else else return 0
return 0
fi fi
} }
function testnewer() { function testnewer() {
[ -n "$3" ] && return 0
test ! -e "$2" -o "$1" -nt "$2" test ! -e "$2" -o "$1" -nt "$2"
} }
function ps_all() { function ps_all() {
@ -4481,7 +4689,9 @@ function progexists() {
test -n "$1" -a -x "$(which "$1" 2>/dev/null)" test -n "$1" -a -x "$(which "$1" 2>/dev/null)"
} }
function has_python() { function has_python() {
progexists python progexists python2 && return 0
progexists python && return 0
return 1
} }
function has_gawk() { function has_gawk() {
progexists gawk progexists gawk
@ -4694,10 +4904,23 @@ s/[\xE2\x80\x90\xE2\x80\x91\xE2\x80\x92\xE2\x80\x93\xE2\x80\x94\xE2\x80\x95]/-/g
s/[]/\x27/g s/[]/\x27/g
s/[«»“”]/"/g s/[«»“”]/"/g
s/[\xC2\xA0\xE2\x80\x87\xE2\x80\xAF\xE2\x81\xA0]/ /g s/[\xC2\xA0\xE2\x80\x87\xE2\x80\xAF\xE2\x81\xA0]/ /g
s/[\xE2\x80\xA6]/.../g
s/[œ]/oe/g s/[œ]/oe/g
s/[Œ]/OE/g s/[Œ]/OE/g
s/[æ]/ae/g s/[æ]/ae/g
s/[Æ]/AE/g s/[Æ]/AE/g
s/a\xCC\x80/à/g
s/e\xCC\x81/é/g; s/e\xCC\x80/è/g; s/e\xCC\x82/ê/g; s/e\xCC\x88/ë/g
s/i\xCC\x88/ï/g; s/i\xCC\x82/î/g
s/o\xCC\x82/ô/g; s/o\xCC\x88/ö/g
s/u\xCC\x88/ü/g; s/u\xCC\x82/û/g
s/c\xCC\xA7/ç/g
s/A\xCC\x80/À/g
s/E\xCC\x81/É/g; s/E\xCC\x80/È/g; s/E\xCC\x82/Ê/g; s/E\xCC\x88/Ë/g
s/I\xCC\x88/Ï/g; s/I\xCC\x82/Î/g
s/O\xCC\x82/Ô/g; s/O\xCC\x88/Ö/g
s/U\xCC\x88/Ü/g; s/U\xCC\x82/Û/g
s/C\xCC\xA7/Ç/g
' '
} }
function _noaccents() { function _noaccents() {
@ -4831,6 +5054,7 @@ function is_archive() {
name="${name%.jar}" name="${name%.jar}"
name="${name%.war}" name="${name%.war}"
name="${name%.ear}" name="${name%.ear}"
[ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && name="${name%.sh}"
[ "$name" != "$1" ] [ "$name" != "$1" ]
} }
function extract_archive() { function extract_archive() {
@ -4850,6 +5074,12 @@ function extract_archive() {
cd "$destdir" cd "$destdir"
jar xf "$arch" "$@" jar xf "$arch" "$@"
) || return ) || return
elif [ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && endswith "$arch" .sh; then
(
arch="$(abspath "$arch")"
cd "$destdir"
"${BASH:-/bin/sh}" "$arch" --tar xf "$@"
) || return
else else
return 1 return 1
fi fi
@ -4865,6 +5095,7 @@ function get_archive_basename() {
basename="${basename%.jar}" basename="${basename%.jar}"
basename="${basename%.war}" basename="${basename%.war}"
basename="${basename%.ear}" basename="${basename%.ear}"
[ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && basename="${basename%.sh}"
echo "$basename" echo "$basename"
} }
function get_archive_appname() { function get_archive_appname() {
@ -4878,6 +5109,7 @@ function get_archive_appname() {
appname="${appname%.jar}" appname="${appname%.jar}"
appname="${appname%.war}" appname="${appname%.war}"
appname="${appname%.ear}" appname="${appname%.ear}"
[ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && appname="${appname%.sh}"
echo "$appname" | awk '{ echo "$appname" | awk '{
if (match($0, /[-_.]([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/)) { if (match($0, /[-_.]([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/)) {
print substr($0, 1, RSTART - 1) print substr($0, 1, RSTART - 1)
@ -5119,6 +5351,12 @@ function unquote_html(s) {
gsub(/&amp;/, "\\&", s) gsub(/&amp;/, "\\&", s)
return s return s
} }
function qawk(s) {
gsub(/\\/, "\\\\", s)
gsub(/"/, "\\\"", s)
gsub(/\n/, "\\n", s)
return "\"" s "\""
}
function qval(s) {'" function qval(s) {'"
gsub(/'/, \"'\\\\''\", s) gsub(/'/, \"'\\\\''\", s)
return \"'\" s \"'\" return \"'\" s \"'\"
@ -5202,6 +5440,12 @@ function __parse_date_fr(date, parts, y, m, d) {
m = int(parts[2]) m = int(parts[2])
d = int(parts[1]) d = int(parts[1])
return mktime(sprintf("%04i %02i %02i 00 00 00 +0400", y, m, d)) return mktime(sprintf("%04i %02i %02i 00 00 00 +0400", y, m, d))
} else if (match(date, /([0-9][0-9]?)\/([0-9][0-9]?)\/([0-9][0-9])/, parts)) {
basey = int(strftime("%Y")); basey = basey - basey % 100
y = basey + int(parts[3])
m = int(parts[2])
d = int(parts[1])
return mktime(sprintf("%04i %02i %02i 00 00 00 +0400", y, m, d))
} }
return -1 return -1
} }
@ -5846,7 +6090,7 @@ function pidfile_check() {
} }
function page_maybe() { function page_maybe() {
if isatty; then if isatty; then
less -XF "$@" less -XFR "$@"
else else
cat cat
fi fi
@ -6558,7 +6802,7 @@ function ask_any() {
lf="$(strlower "$f")" lf="$(strlower "$f")"
[ "$r" == "$lf" ] && return $i [ "$r" == "$lf" ] && return $i
if [ -z "$defi" ]; then if [ -z "$defi" ]; then
[[ "$f" =~ [A-Z] ]] && defi="$i" [ -z "${f/[A-Z]/}" ] && defi="$i"
fi fi
if [ "$lf" == o ]; then if [ "$lf" == o ]; then
case "$r" in o|y|1|v|t) return $i;; esac case "$r" in o|y|1|v|t) return $i;; esac
@ -6572,7 +6816,8 @@ function ask_any() {
else else
i=0 i=0
while [ $i -lt $count ]; do while [ $i -lt $count ]; do
[[ "${format:$i:1}" =~ [A-Z] ]] && return $i f="${format:$i:1}"
[ -z "${f/[A-Z]/}" ] && return $i
i=$(($i + 1)) i=$(($i + 1))
done done
return 0 return 0
@ -7098,18 +7343,36 @@ SYSDIST_ALIASES=(
10.7=lion 10.6=snowleopard 10.5=leopard 10.4=tiger 10.3=panther 10.7=lion 10.6=snowleopard 10.5=leopard 10.4=tiger 10.3=panther
) )
debianlike_SYSVERS=() debianlike_SYSVERS=()
debian_SYSVERS=(stretch jessie wheezy squeeze lenny etch) debian_SYSVERS=(
ubuntu_SYSVERS=(oneiric natty maverick lucid karmic jaunty intrepid hardy) forky trixie bookworm bullseye buster stretch jessie wheezy squeeze lenny etch
)
ubuntu_SYSVERS=(
mantic lunar kinetic jammy
impish hirsute groovy focal
eoan disco cosmic bionic
artful zesty yakkety xenial
wily vivid utopic trusty
saucy raring quantal precise
oneiric natty maverick lucid
karmic jaunty intrepid hardy
)
redhatlike_SYSVERS=() redhatlike_SYSVERS=()
ol_SYSVERS=(ol7 ol6 redhat7 redhat6) ol_SYSVERS=(ol8 ol7 ol6 redhat8 redhat7 redhat6)
rhel_SYSVERS=(rhel7 rhel6 rhel5 rhel4 redhat7 redhat6 redhat5 redhat4) rhel_SYSVERS=(rhel8 rhel7 rhel6 rhel5 rhel4 redhat8 redhat7 redhat6 redhat5 redhat4)
fedora_SYSVERS=(fedora14 fedora13 fedora12 fedora11) fedora_SYSVERS=(fedora14 fedora13 fedora12 fedora11)
centos_SYSVERS=(centos7 centos6 centos5 centos4 redhat7 redhat6 redhat5 redhat4) centos_SYSVERS=(centos7 centos6 centos5 centos4 redhat7 redhat6 redhat5 redhat4)
suse_SYSVERS=() suse_SYSVERS=()
gentoo_SYSVERS=() gentoo_SYSVERS=()
SYSVER_ALIASES=( SYSVER_ALIASES=(
9=stretch 8=jessie 7=wheezy 6=squeeze 5=lenny 4=etch 14=forky 13=trixie 12=bookworm 11=bullseye 10=buster 9=stretch 8=jessie 7=wheezy 6=squeeze 5=lenny 4=etch
11.10=oneiric 11.04=natty 10.10=maverick 10.04=lucid 9.10=karmic 9.04=jaunty 8.10=intrepid 8.04=hardy 23.10=mantic 23.04=lunar 22.10=kinetic 22.04=jammy
21.10=impish 21.04=hirsute 20.10=groovy 20.04=focal
19.10=eoan 19.04=disco 18.10=cosmic 18.04=bionic
17.10=artful 17.04=zesty 16.10=yakkety 16.04=xenial
15.10=wily 15.04=vivid 14.10=utopic 14.04=trusty
13.10=saucy 13.04=raring 12.10=quantal 12.04=precise
11.10=oneiric 11.04=natty 10.10=maverick 10.04=lucid
9.10=karmic 9.04=jaunty 8.10=intrepid 8.04=hardy
) )
function __setup_ALL_SYSvars() { function __setup_ALL_SYSvars() {
@ -7214,6 +7477,8 @@ function __compute_sysinfos() {
esac esac
if [ -n "$debian_version" ]; then if [ -n "$debian_version" ]; then
case "$debian_version" in case "$debian_version" in
11*|bullseye*) MYSYSDIST=(debian debianlike); MYSYSVER=(bullseye);;
10*|buster*) MYSYSDIST=(debian debianlike); MYSYSVER=(buster);;
9*|stretch*) MYSYSDIST=(debian debianlike); MYSYSVER=(stretch);; 9*|stretch*) MYSYSDIST=(debian debianlike); MYSYSVER=(stretch);;
8*|jessie*) MYSYSDIST=(debian debianlike); MYSYSVER=(jessie);; 8*|jessie*) MYSYSDIST=(debian debianlike); MYSYSVER=(jessie);;
7*|wheezy*) MYSYSDIST=(debian debianlike); MYSYSVER=(wheezy);; 7*|wheezy*) MYSYSDIST=(debian debianlike); MYSYSVER=(wheezy);;
@ -7227,6 +7492,7 @@ function __compute_sysinfos() {
elif [ -n "$oracle_release" ]; then elif [ -n "$oracle_release" ]; then
MYSYSDIST=(ol rhel redhatlike) MYSYSDIST=(ol rhel redhatlike)
case "$oracle_release" in case "$oracle_release" in
Oracle*Linux*release\ 8*) MYSYSVER=(ol8 rhel8 redhat8);;
Oracle*Linux*release\ 7*) MYSYSVER=(ol7 rhel7 redhat7);; Oracle*Linux*release\ 7*) MYSYSVER=(ol7 rhel7 redhat7);;
Oracle*Linux*release\ 6*) MYSYSVER=(ol6 rhel6 redhat6);; Oracle*Linux*release\ 6*) MYSYSVER=(ol6 rhel6 redhat6);;
esac esac
@ -7242,10 +7508,12 @@ function __compute_sysinfos() {
Fedora*13*) MYSYSVER=(fedora13);; Fedora*13*) MYSYSVER=(fedora13);;
Fedora*12*) MYSYSVER=(fedora12);; Fedora*12*) MYSYSVER=(fedora12);;
Fedora*11*) MYSYSVER=(fedora11);; Fedora*11*) MYSYSVER=(fedora11);;
Red*Hat*Enterprise*Linux*release\ 8*) MYSYSVER=(rhel8 redhat8);;
Red*Hat*Enterprise*Linux*release\ 7*) MYSYSVER=(rhel7 redhat7);; Red*Hat*Enterprise*Linux*release\ 7*) MYSYSVER=(rhel7 redhat7);;
Red*Hat*Enterprise*Linux*release\ 6*) MYSYSVER=(rhel6 redhat6);; Red*Hat*Enterprise*Linux*release\ 6*) MYSYSVER=(rhel6 redhat6);;
Red*Hat*Enterprise*Linux*release\ 5*) MYSYSVER=(rhel5 redhat5);; Red*Hat*Enterprise*Linux*release\ 5*) MYSYSVER=(rhel5 redhat5);;
Red*Hat*Enterprise*Linux*release\ 4*) MYSYSVER=(rhel4 redhat4);; Red*Hat*Enterprise*Linux*release\ 4*) MYSYSVER=(rhel4 redhat4);;
CentOS*release\ 8*) MYSYSVER=(centos8 redhat8);;
CentOS*release\ 7*) MYSYSVER=(centos7 redhat7);; CentOS*release\ 7*) MYSYSVER=(centos7 redhat7);;
CentOS*release\ 6*) MYSYSVER=(centos6 redhat6);; CentOS*release\ 6*) MYSYSVER=(centos6 redhat6);;
CentOS*release\ 5*) MYSYSVER=(centos5 redhat5);; CentOS*release\ 5*) MYSYSVER=(centos5 redhat5);;
@ -7607,6 +7875,29 @@ function on_default() {
fi fi
return 1 return 1
} }
function require_debian() {
set -- -d debian "$@"
if check_sysinfos "$@"; then
urequire debian
return 0
fi
local -a infos; local info
for info in "$@"; do
if ! [[ "$info" == -* ]]; then
infos=("${infos[@]}" "$info")
fi
done
local msg="Ce script n'est pas supporté sur $(get_sysinfos_desc)"
[ -n "$*" ] && msg="$msg
Il faut au moins l'un des systèmes suivants: ${infos[*]}"
[ -n "$UINST" -a -n "$ABORT" ] && touch "$ABORT"
die "$msg"
}
function require_stretch() {
require_debian -v stretch+
}
##@inc]../sysinfos ##@inc]../sysinfos
##@inc[../compat ##@inc[../compat
# Code de support pour les architectures autre que Linux # Code de support pour les architectures autre que Linux

View File

@ -502,36 +502,36 @@ Essayez avec 'uinst -C'"
fi fi
# Tester s'il faut bootstrapper # Tester s'il faut bootstrapper
if [ -f "$srcdir/.nutools-bootstrap" ]; then #if [ -f "$srcdir/.nutools-bootstrap" ]; then
local need_python need_gawk # local need_python need_gawk
has_python || need_python=1 # has_python || need_python=1
has_gawk || need_gawk=1 # has_gawk || need_gawk=1
if check_sysinfos -s linux; then # if check_sysinfos -s linux; then
if [ -n "$need_python" -o -n "$need_gawk" ]; then # if [ -n "$need_python" -o -n "$need_gawk" ]; then
eimportant "Il FAUT installer Python 2 et $(get_color y)*GNU*$(get_color z)awk pour que nutools fonctionne correctement." # eimportant "Il FAUT installer Python 2 et $(get_color y)*GNU*$(get_color z)awk pour que nutools fonctionne correctement."
if check_sysinfos -d debian; then # if check_sysinfos -d debian; then
if ask_yesno "Voulez-vous que ce script essaye d'installer automatiquement ces dépendances (requière les droits root)?" O; then # if ask_yesno "Voulez-vous que ce script essaye d'installer automatiquement ces dépendances (requière les droits root)?" O; then
urequire debian # urequire debian
pkg_install ${need_python:+python} ${need_gawk:+gawk} || { # pkg_install ${need_python:+python} ${need_gawk:+gawk} || {
eerror "Une erreur s'est produite pendant l'installation. Veuillez faire l'installation manuellement" # eerror "Une erreur s'est produite pendant l'installation. Veuillez faire l'installation manuellement"
return 1 # return 1
} # }
need_python= # need_python=
need_gawk= # need_gawk=
fi # fi
fi # fi
fi # fi
fi # fi
if [ -n "$need_python" ]; then # if [ -n "$need_python" ]; then
eerror "Python 2 est requis. Veuillez faire l'installation avant de relancer ce script." # eerror "Python 2 est requis. Veuillez faire l'installation avant de relancer ce script."
return 1 # return 1
fi # fi
if [ -n "$need_gawk" ]; then # if [ -n "$need_gawk" ]; then
ewarn "$(get_color y)*GNU*$(get_color z)awk est requis mais n'est pas installé. Ce script va continuer, mais les résultats ne sont pas garantis." # ewarn "$(get_color y)*GNU*$(get_color z)awk est requis mais n'est pas installé. Ce script va continuer, mais les résultats ne sont pas garantis."
fi # fi
# s'assurer que les libraries *locales* sont dans PYTHONPATH # # s'assurer que les libraries *locales* sont dans PYTHONPATH
source "$ULIBDIR/pyulib/pyulib" # source "$ULIBDIR/pyulib/pyulib"
fi #fi
if [ -n "$UINST_AUTOPREFIX" ]; then if [ -n "$UINST_AUTOPREFIX" ]; then
# initialiser le moteur de préfixes # initialiser le moteur de préfixes

689
ucrontab
View File

@ -153,7 +153,15 @@ export TMPDIR="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}"
[ -f /etc/debian_chroot ] && UTOOLS_CHROOT=1 [ -f /etc/debian_chroot ] && UTOOLS_CHROOT=1
[ -f /etc/nutoolsrc ] && . /etc/nutoolsrc [ -f /etc/nutoolsrc ] && . /etc/nutoolsrc
[ -f ~/.nutoolsrc ] && . ~/.nutoolsrc [ -f ~/.nutoolsrc ] && . ~/.nutoolsrc
true
UNAME_SYSTEM=`uname -s`
[ "${UNAME_SYSTEM#CYGWIN}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Cygwin
[ "${UNAME_SYSTEM#MINGW32}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Mingw
UNAME_MACHINE=`uname -m`
if [ -n "$UTOOLS_CHROOT" ]; then
[ -n "$UTOOLS_UNAME_SYSTEM" ] && eval "UNAME_SYSTEM=$UTOOLS_UNAME_SYSTEM"
[ -n "$UTOOLS_UNAME_MACHINE" ] && eval "UNAME_MACHINE=$UTOOLS_UNAME_MACHINE"
fi
##@inc]base.init ##@inc]base.init
##@inc[base.core ##@inc[base.core
## Fonctions de base: fondement ## Fonctions de base: fondement
@ -248,44 +256,45 @@ function qwc() {
s="${s//\"/\\\"}" s="${s//\"/\\\"}"
s="${s//\$/\\\$}" s="${s//\$/\\\$}"
s="${s//\`/\\\`}" s="${s//\`/\\\`}"
local r a b local r a b c
while [ -n "$s" ]; do while [ -n "$s" ]; do
if [[ "$s" == *\** ]]; then a=; b=; c=
if [[ "$s" == *\?* ]]; then a=; [[ "$s" == *\** ]] && { a="${s%%\**}"; a=${#a}; }
a="${s%%\**}" b=; [[ "$s" == *\?* ]] && { b="${s%%\?*}"; b=${#b}; }
b="${s%%\?*}" c=; [[ "$s" == *\[* ]] && { c="${s%%\[*}"; c=${#c}; }
if [ ${#a} -lt ${#b} ]; then if [ -z "$a" -a -z "$b" -a -z "$c" ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\**}"
s="${s#*\*}"
r="$r\"$a\"*"
fi
elif [[ "$s" == *\?* ]]; then
if [[ "$s" == *\** ]]; then
a="${s%%\**}"
b="${s%%\?*}"
if [ ${#a} -lt ${#b} ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\?*}"
s="${s#*\?}"
r="$r\"$a\"?"
fi
else
r="$r\"$s\"" r="$r\"$s\""
break break
fi fi
if [ -n "$a" ]; then
[ -n "$b" ] && [ $a -lt $b ] && b=
[ -n "$c" ] && [ $a -lt $c ] && c=
fi
if [ -n "$b" ]; then
[ -n "$a" ] && [ $b -lt $a ] && a=
[ -n "$c" ] && [ $b -lt $c ] && c=
fi
if [ -n "$c" ]; then
[ -n "$a" ] && [ $c -lt $a ] && a=
[ -n "$b" ] && [ $c -lt $b ] && b=
fi
if [ -n "$a" ]; then # PREFIX*
a="${s%%\**}"
s="${s#*\*}"
[ -n "$a" ] && r="$r\"$a\""
r="$r*"
elif [ -n "$b" ]; then # PREFIX?
a="${s%%\?*}"
s="${s#*\?}"
[ -n "$a" ] && r="$r\"$a\""
r="$r?"
elif [ -n "$c" ]; then # PREFIX[class]
a="${s%%\[*}"
b="${s#*\[}"; b="${b%%\]*}"
s="${s:$((${#a} + ${#b} + 2))}"
[ -n "$a" ] && r="$r\"$a\""
r="$r[$b]"
fi
done done
recho_ "$r" recho_ "$r"
} }
@ -312,6 +321,48 @@ function echo_setv() {
fi fi
echo "$__s_var=$(qvalr "$*")" echo "$__s_var=$(qvalr "$*")"
} }
function echo_setv2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
if [ $# -eq 0 ]; then
echo_setv "$__s_var" "${!__s_var}"
else
echo_setv "$__s_var" "$@"
fi
}
function seta() {
local __s_array="$1"; shift
if [[ "$__s_array" == *=* ]]; then
set -- "${__s_array#*=}" "$@"
__s_array="${__s_array%%=*}"
fi
eval "$__s_array=(\"\$@\")"
}
function _seta() {
local __s_array="$1"; shift
eval "$__s_array=(\"\$@\")"
}
function echo_seta() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
echo "$__s_var=($(qvals "$@"))"
}
function echo_seta2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
elif [ $# -eq 0 ]; then
eval "set -- \"\${$__s_var[@]}\""
fi
echo "$__s_var=($(qvals "$@"))"
}
function setx() { function setx() {
if [ "$1" == -a ]; then if [ "$1" == -a ]; then
shift shift
@ -835,6 +886,19 @@ function yesval() {
is_yes "$1" && echo 1 is_yes "$1" && echo 1
} }
function setyesval() {
is_yes "$2" && _setv "$1" 1 || _setv "$1" ""
}
function normyesval() {
is_yes "${2:-"${!1}"}" && _setv "$1" 1 || _setv "$1" ""
}
function normyesvals() {
local __nyv_yesvar
for __nyv_yesvar in "$@"; do
is_yes "${!__nyv_yesvar}" && _setv "$__nyv_yesvar" 1 || _setv "$__nyv_yesvar" ""
done
}
function setb() { function setb() {
local __s_var="$1"; shift local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then if [[ "$__s_var" == *=* ]]; then
@ -1137,44 +1201,45 @@ function qwc() {
s="${s//\"/\\\"}" s="${s//\"/\\\"}"
s="${s//\$/\\\$}" s="${s//\$/\\\$}"
s="${s//\`/\\\`}" s="${s//\`/\\\`}"
local r a b local r a b c
while [ -n "$s" ]; do while [ -n "$s" ]; do
if [[ "$s" == *\** ]]; then a=; b=; c=
if [[ "$s" == *\?* ]]; then a=; [[ "$s" == *\** ]] && { a="${s%%\**}"; a=${#a}; }
a="${s%%\**}" b=; [[ "$s" == *\?* ]] && { b="${s%%\?*}"; b=${#b}; }
b="${s%%\?*}" c=; [[ "$s" == *\[* ]] && { c="${s%%\[*}"; c=${#c}; }
if [ ${#a} -lt ${#b} ]; then if [ -z "$a" -a -z "$b" -a -z "$c" ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\**}"
s="${s#*\*}"
r="$r\"$a\"*"
fi
elif [[ "$s" == *\?* ]]; then
if [[ "$s" == *\** ]]; then
a="${s%%\**}"
b="${s%%\?*}"
if [ ${#a} -lt ${#b} ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\?*}"
s="${s#*\?}"
r="$r\"$a\"?"
fi
else
r="$r\"$s\"" r="$r\"$s\""
break break
fi fi
if [ -n "$a" ]; then
[ -n "$b" ] && [ $a -lt $b ] && b=
[ -n "$c" ] && [ $a -lt $c ] && c=
fi
if [ -n "$b" ]; then
[ -n "$a" ] && [ $b -lt $a ] && a=
[ -n "$c" ] && [ $b -lt $c ] && c=
fi
if [ -n "$c" ]; then
[ -n "$a" ] && [ $c -lt $a ] && a=
[ -n "$b" ] && [ $c -lt $b ] && b=
fi
if [ -n "$a" ]; then # PREFIX*
a="${s%%\**}"
s="${s#*\*}"
[ -n "$a" ] && r="$r\"$a\""
r="$r*"
elif [ -n "$b" ]; then # PREFIX?
a="${s%%\?*}"
s="${s#*\?}"
[ -n "$a" ] && r="$r\"$a\""
r="$r?"
elif [ -n "$c" ]; then # PREFIX[class]
a="${s%%\[*}"
b="${s#*\[}"; b="${b%%\]*}"
s="${s:$((${#a} + ${#b} + 2))}"
[ -n "$a" ] && r="$r\"$a\""
r="$r[$b]"
fi
done done
recho_ "$r" recho_ "$r"
} }
@ -1201,6 +1266,48 @@ function echo_setv() {
fi fi
echo "$__s_var=$(qvalr "$*")" echo "$__s_var=$(qvalr "$*")"
} }
function echo_setv2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
if [ $# -eq 0 ]; then
echo_setv "$__s_var" "${!__s_var}"
else
echo_setv "$__s_var" "$@"
fi
}
function seta() {
local __s_array="$1"; shift
if [[ "$__s_array" == *=* ]]; then
set -- "${__s_array#*=}" "$@"
__s_array="${__s_array%%=*}"
fi
eval "$__s_array=(\"\$@\")"
}
function _seta() {
local __s_array="$1"; shift
eval "$__s_array=(\"\$@\")"
}
function echo_seta() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
echo "$__s_var=($(qvals "$@"))"
}
function echo_seta2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
elif [ $# -eq 0 ]; then
eval "set -- \"\${$__s_var[@]}\""
fi
echo "$__s_var=($(qvals "$@"))"
}
function setx() { function setx() {
if [ "$1" == -a ]; then if [ "$1" == -a ]; then
shift shift
@ -1713,7 +1820,7 @@ function __po_parse_optdescs() {
option_="${optdesc_%::}" option_="${optdesc_%::}"
if [[ "$2" == *=* ]]; then if [[ "$2" == *=* ]]; then
name_="${2%%=*}=" name_="${2%%=*}="
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "$name_"
else else
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=()" [ -n "$reset_" ] && eval "$name_=()"
@ -1723,7 +1830,7 @@ function __po_parse_optdescs() {
option_="${optdesc_%:}" option_="${optdesc_%:}"
if [[ "$2" == *=* ]]; then if [[ "$2" == *=* ]]; then
name_="${2%%=*}=" name_="${2%%=*}="
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "$name_"
else else
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=()" [ -n "$reset_" ] && eval "$name_=()"
@ -1732,7 +1839,7 @@ function __po_parse_optdescs() {
else else
option_="$optdesc_" option_="$optdesc_"
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "${2%%=*}="
flag_= flag_=
fi fi
@ -2046,44 +2153,45 @@ function qwc() {
s="${s//\"/\\\"}" s="${s//\"/\\\"}"
s="${s//\$/\\\$}" s="${s//\$/\\\$}"
s="${s//\`/\\\`}" s="${s//\`/\\\`}"
local r a b local r a b c
while [ -n "$s" ]; do while [ -n "$s" ]; do
if [[ "$s" == *\** ]]; then a=; b=; c=
if [[ "$s" == *\?* ]]; then a=; [[ "$s" == *\** ]] && { a="${s%%\**}"; a=${#a}; }
a="${s%%\**}" b=; [[ "$s" == *\?* ]] && { b="${s%%\?*}"; b=${#b}; }
b="${s%%\?*}" c=; [[ "$s" == *\[* ]] && { c="${s%%\[*}"; c=${#c}; }
if [ ${#a} -lt ${#b} ]; then if [ -z "$a" -a -z "$b" -a -z "$c" ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\**}"
s="${s#*\*}"
r="$r\"$a\"*"
fi
elif [[ "$s" == *\?* ]]; then
if [[ "$s" == *\** ]]; then
a="${s%%\**}"
b="${s%%\?*}"
if [ ${#a} -lt ${#b} ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\?*}"
s="${s#*\?}"
r="$r\"$a\"?"
fi
else
r="$r\"$s\"" r="$r\"$s\""
break break
fi fi
if [ -n "$a" ]; then
[ -n "$b" ] && [ $a -lt $b ] && b=
[ -n "$c" ] && [ $a -lt $c ] && c=
fi
if [ -n "$b" ]; then
[ -n "$a" ] && [ $b -lt $a ] && a=
[ -n "$c" ] && [ $b -lt $c ] && c=
fi
if [ -n "$c" ]; then
[ -n "$a" ] && [ $c -lt $a ] && a=
[ -n "$b" ] && [ $c -lt $b ] && b=
fi
if [ -n "$a" ]; then # PREFIX*
a="${s%%\**}"
s="${s#*\*}"
[ -n "$a" ] && r="$r\"$a\""
r="$r*"
elif [ -n "$b" ]; then # PREFIX?
a="${s%%\?*}"
s="${s#*\?}"
[ -n "$a" ] && r="$r\"$a\""
r="$r?"
elif [ -n "$c" ]; then # PREFIX[class]
a="${s%%\[*}"
b="${s#*\[}"; b="${b%%\]*}"
s="${s:$((${#a} + ${#b} + 2))}"
[ -n "$a" ] && r="$r\"$a\""
r="$r[$b]"
fi
done done
recho_ "$r" recho_ "$r"
} }
@ -2110,6 +2218,48 @@ function echo_setv() {
fi fi
echo "$__s_var=$(qvalr "$*")" echo "$__s_var=$(qvalr "$*")"
} }
function echo_setv2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
if [ $# -eq 0 ]; then
echo_setv "$__s_var" "${!__s_var}"
else
echo_setv "$__s_var" "$@"
fi
}
function seta() {
local __s_array="$1"; shift
if [[ "$__s_array" == *=* ]]; then
set -- "${__s_array#*=}" "$@"
__s_array="${__s_array%%=*}"
fi
eval "$__s_array=(\"\$@\")"
}
function _seta() {
local __s_array="$1"; shift
eval "$__s_array=(\"\$@\")"
}
function echo_seta() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
echo "$__s_var=($(qvals "$@"))"
}
function echo_seta2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
elif [ $# -eq 0 ]; then
eval "set -- \"\${$__s_var[@]}\""
fi
echo "$__s_var=($(qvals "$@"))"
}
function setx() { function setx() {
if [ "$1" == -a ]; then if [ "$1" == -a ]; then
shift shift
@ -2622,7 +2772,7 @@ function __po_parse_optdescs() {
option_="${optdesc_%::}" option_="${optdesc_%::}"
if [[ "$2" == *=* ]]; then if [[ "$2" == *=* ]]; then
name_="${2%%=*}=" name_="${2%%=*}="
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "$name_"
else else
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=()" [ -n "$reset_" ] && eval "$name_=()"
@ -2632,7 +2782,7 @@ function __po_parse_optdescs() {
option_="${optdesc_%:}" option_="${optdesc_%:}"
if [[ "$2" == *=* ]]; then if [[ "$2" == *=* ]]; then
name_="${2%%=*}=" name_="${2%%=*}="
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "$name_"
else else
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=()" [ -n "$reset_" ] && eval "$name_=()"
@ -2641,7 +2791,7 @@ function __po_parse_optdescs() {
else else
option_="$optdesc_" option_="$optdesc_"
name_="$2" name_="$2"
[ -n "$reset_" ] && eval "$name_=" [ -n "$reset_" ] && eval "${2%%=*}="
flag_= flag_=
fi fi
@ -3076,44 +3226,45 @@ function qwc() {
s="${s//\"/\\\"}" s="${s//\"/\\\"}"
s="${s//\$/\\\$}" s="${s//\$/\\\$}"
s="${s//\`/\\\`}" s="${s//\`/\\\`}"
local r a b local r a b c
while [ -n "$s" ]; do while [ -n "$s" ]; do
if [[ "$s" == *\** ]]; then a=; b=; c=
if [[ "$s" == *\?* ]]; then a=; [[ "$s" == *\** ]] && { a="${s%%\**}"; a=${#a}; }
a="${s%%\**}" b=; [[ "$s" == *\?* ]] && { b="${s%%\?*}"; b=${#b}; }
b="${s%%\?*}" c=; [[ "$s" == *\[* ]] && { c="${s%%\[*}"; c=${#c}; }
if [ ${#a} -lt ${#b} ]; then if [ -z "$a" -a -z "$b" -a -z "$c" ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\**}"
s="${s#*\*}"
r="$r\"$a\"*"
fi
elif [[ "$s" == *\?* ]]; then
if [[ "$s" == *\** ]]; then
a="${s%%\**}"
b="${s%%\?*}"
if [ ${#a} -lt ${#b} ]; then
s="${s#*\*}"
r="$r\"$a\"*"
else
s="${s#*\?}"
r="$r\"$b\"?"
fi
else
a="${s%%\?*}"
s="${s#*\?}"
r="$r\"$a\"?"
fi
else
r="$r\"$s\"" r="$r\"$s\""
break break
fi fi
if [ -n "$a" ]; then
[ -n "$b" ] && [ $a -lt $b ] && b=
[ -n "$c" ] && [ $a -lt $c ] && c=
fi
if [ -n "$b" ]; then
[ -n "$a" ] && [ $b -lt $a ] && a=
[ -n "$c" ] && [ $b -lt $c ] && c=
fi
if [ -n "$c" ]; then
[ -n "$a" ] && [ $c -lt $a ] && a=
[ -n "$b" ] && [ $c -lt $b ] && b=
fi
if [ -n "$a" ]; then # PREFIX*
a="${s%%\**}"
s="${s#*\*}"
[ -n "$a" ] && r="$r\"$a\""
r="$r*"
elif [ -n "$b" ]; then # PREFIX?
a="${s%%\?*}"
s="${s#*\?}"
[ -n "$a" ] && r="$r\"$a\""
r="$r?"
elif [ -n "$c" ]; then # PREFIX[class]
a="${s%%\[*}"
b="${s#*\[}"; b="${b%%\]*}"
s="${s:$((${#a} + ${#b} + 2))}"
[ -n "$a" ] && r="$r\"$a\""
r="$r[$b]"
fi
done done
recho_ "$r" recho_ "$r"
} }
@ -3140,6 +3291,48 @@ function echo_setv() {
fi fi
echo "$__s_var=$(qvalr "$*")" echo "$__s_var=$(qvalr "$*")"
} }
function echo_setv2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
if [ $# -eq 0 ]; then
echo_setv "$__s_var" "${!__s_var}"
else
echo_setv "$__s_var" "$@"
fi
}
function seta() {
local __s_array="$1"; shift
if [[ "$__s_array" == *=* ]]; then
set -- "${__s_array#*=}" "$@"
__s_array="${__s_array%%=*}"
fi
eval "$__s_array=(\"\$@\")"
}
function _seta() {
local __s_array="$1"; shift
eval "$__s_array=(\"\$@\")"
}
function echo_seta() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
fi
echo "$__s_var=($(qvals "$@"))"
}
function echo_seta2() {
local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then
set -- "${__s_var#*=}" "$@"
__s_var="${__s_var%%=*}"
elif [ $# -eq 0 ]; then
eval "set -- \"\${$__s_var[@]}\""
fi
echo "$__s_var=($(qvals "$@"))"
}
function setx() { function setx() {
if [ "$1" == -a ]; then if [ "$1" == -a ]; then
shift shift
@ -3690,6 +3883,19 @@ function yesval() {
is_yes "$1" && echo 1 is_yes "$1" && echo 1
} }
function setyesval() {
is_yes "$2" && _setv "$1" 1 || _setv "$1" ""
}
function normyesval() {
is_yes "${2:-"${!1}"}" && _setv "$1" 1 || _setv "$1" ""
}
function normyesvals() {
local __nyv_yesvar
for __nyv_yesvar in "$@"; do
is_yes "${!__nyv_yesvar}" && _setv "$__nyv_yesvar" 1 || _setv "$__nyv_yesvar" ""
done
}
function setb() { function setb() {
local __s_var="$1"; shift local __s_var="$1"; shift
if [[ "$__s_var" == *=* ]]; then if [[ "$__s_var" == *=* ]]; then
@ -3752,6 +3958,17 @@ function quote_form() { _qform "$@"; }
function quoted_form() { qform "$@"; } function quoted_form() { qform "$@"; }
function set_array_cmd() {
if [ $# -eq 1 ]; then echo_seta "$1"
elif [ "$2" == @ ]; then echo_seta "$1" "${@:3}"
else eval "echo_seta \"\$1\" \"\${$2[@]}\""
fi
}
function set_array() {
eval "$(set_array_cmd "$@")"
}
if [ -n "$BASH_VERSINFO" -a "${BASH_VERSINFO[0]}" -lt 4 ]; then if [ -n "$BASH_VERSINFO" -a "${BASH_VERSINFO[0]}" -lt 4 ]; then
urequire base.string urequire base.string
function strlower() { tr A-Z a-z <<<"$*"; } function strlower() { tr A-Z a-z <<<"$*"; }
@ -3806,30 +4023,22 @@ if [ -n "$BASH_VERSINFO" -a "${BASH_VERSINFO[0]}" -lt 4 ]; then
} }
fi fi
##@inc]base.compat ##@inc]base.compat
uprovide base ##@inc[base.deprecated
urequire base.init base.core base.string base.num base.bool base.array base.quote base.split base.args base.tools base.compat ## Fonctions dépréciées
uprovide base.deprecated
UNAME_SYSTEM=`uname -s`
[ "${UNAME_SYSTEM#CYGWIN}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Cygwin
[ "${UNAME_SYSTEM#MINGW32}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Mingw
UNAME_MACHINE=`uname -m`
if [ -n "$UTOOLS_CHROOT" ]; then
[ -n "$UTOOLS_UNAME_SYSTEM" ] && eval "UNAME_SYSTEM=$UTOOLS_UNAME_SYSTEM"
[ -n "$UTOOLS_UNAME_MACHINE" ] && eval "UNAME_MACHINE=$UTOOLS_UNAME_MACHINE"
fi
function setyesval() { function set_array_cmd() {
is_yes "$2" && _setv "$1" 1 || _setv "$1" "" if [ $# -eq 1 ]; then echo_seta2 "$1"
elif [ "$2" == @ ]; then echo_seta "$1" "${@:3}"
else eval "echo_seta \"\$1\" \"\${$2[@]}\""
fi
} }
function normyesval() { function set_array() {
is_yes "${2:-"${!1}"}" && _setv "$1" 1 || _setv "$1" "" eval "$(set_array_cmd "$@")"
}
function normyesvals() {
local __nyv_yesvar
for __nyv_yesvar in "$@"; do
is_yes "${!__nyv_yesvar}" && _setv "$__nyv_yesvar" 1 || _setv "$__nyv_yesvar" ""
done
} }
function quote_in() { function quote_in() {
sed 's/\\/\\\\/g sed 's/\\/\\\\/g
s/"/\\"/g s/"/\\"/g
@ -3852,27 +4061,11 @@ function quoted_sargs() {
done done
recho "$s" recho "$s"
} }
##@inc]base.deprecated
uprovide base
urequire base.init base.core base.string base.num base.bool base.array base.quote base.split base.args base.tools base.compat
urequire base.deprecated
function set_array_cmd() {
[ $# -eq 1 ] && set -- "$1" "$1"
local __sac_s __sac_v __sac_f
__sac_s="$1=("; shift
if [ "$1" == "@" ]; then
shift
else
eval "set -- \"\${$1[@]}\""
fi
__sac_f=1
for __sac_v in "$@"; do
[ -n "$__sac_f" ] && __sac_f= || __sac_s="$__sac_s "
__sac_s="$__sac_s$(qvalm "$__sac_v")"
done
__sac_s="$__sac_s)"
echo "$__sac_s"
}
function set_array() {
eval "$(set_array_cmd "$@")"
}
function array_count() { function array_count() {
eval "echo \${#$1[*]}" eval "echo \${#$1[*]}"
} }
@ -4158,22 +4351,25 @@ function get_time_fr() {
} }
function parse_date() { function parse_date() {
local value="$1" type="${2:-date}" local value="$1" type="${2:-date}"
local now="$(awk 'BEGIN { print mktime(strftime("%Y %m %d 00 00 00 +0400")) }')" local now="$(awk 'BEGIN { print mktime(strftime("%Y %m %d 00 00 00")) }')"
case "$value" in case "$value" in
=*) value="${value#=}";;
+*) value="$(($now + ${value#+} * 86400))";; +*) value="$(($now + ${value#+} * 86400))";;
-*) value="$(($now - ${value#-} * 86400))";;
*) value="$(<<<"$value" awk -F/ '{ *) value="$(<<<"$value" awk -F/ '{
nd = strftime("%d"); nm = strftime("%m"); ny = strftime("%Y") nd = strftime("%d"); nm = strftime("%m"); ny = strftime("%Y")
d = $1 + 0; if (d < 1) d = nd; d = $1 + 0; if (d < 1) d = nd;
m = $2 + 0; if (m < 1) m = nm; m = $2 + 0; if (m < 1) m = nm;
if ($3 == "") y = ny; if ($3 == "") y = ny;
else { y = $3 + 0; if (y < 100) y = y + 2000; } else { y = $3 + 0; if (y < 100) y = y + 2000; }
print mktime(sprintf("%04i %02i %02i 00 00 00 +0400", y, m, d)); print mktime(sprintf("%04i %02i %02i 00 00 00", y, m, d));
}')";; }')";;
esac esac
case "$type" in case "$type" in
d|date) awk '{ print strftime("%d/%m/%Y", $0 + 0) }' <<<"$value";; d|date) awk '{ print strftime("%d/%m/%Y", $0 + 0) }' <<<"$value";;
l|ldap) awk '{ print strftime("%Y%m%d%H%M%S+0400", $0 + 0) }' <<<"$value";; l|ldap) awk '{ print strftime("%Y%m%d%H%M%S+0400", $0 + 0) }' <<<"$value";;
m|mysql) awk '{ print strftime("%Y-%m-%d", $0 + 0) }' <<<"$value";; m|mysql) awk '{ print strftime("%Y-%m-%d", $0 + 0) }' <<<"$value";;
t|ts|timestamp) echo "$value";;
*) recho "$value";; *) recho "$value";;
esac esac
} }
@ -4285,6 +4481,18 @@ function ppath() {
recho "$path" recho "$path"
} }
function ppath2() {
local path="$1" cwd="$2"
path="$(abspath "$path")" # essayer de normaliser le chemin
[ -n "$cwd" ] || cwd="$(pwd)"
[ "$path" = "$cwd" ] && path="../$(basename -- "$path")"
[ "$cwd" != "/" -a "$cwd" != "$HOME" ] && path="${path#$cwd/}"
[ "${path#$HOME/}" != "$path" ] && path="~${path#$HOME}"
recho "$path"
}
function relpath() { function relpath() {
local p="$(abspath "$1" "$3")" cwd="$2" local p="$(abspath "$1" "$3")" cwd="$2"
if [ -z "$cwd" ]; then if [ -z "$cwd" ]; then
@ -4553,13 +4761,13 @@ function testdiff() {
! quietdiff "$@" ! quietdiff "$@"
} }
function testupdated() { function testupdated() {
if [ -f "$2" ]; then if [ -n "$3" ]; then return 0
testdiff "$1" "$2" elif [ -f "$2" ]; then testdiff "$1" "$2"
else else return 0
return 0
fi fi
} }
function testnewer() { function testnewer() {
[ -n "$3" ] && return 0
test ! -e "$2" -o "$1" -nt "$2" test ! -e "$2" -o "$1" -nt "$2"
} }
function ps_all() { function ps_all() {
@ -4569,7 +4777,9 @@ function progexists() {
test -n "$1" -a -x "$(which "$1" 2>/dev/null)" test -n "$1" -a -x "$(which "$1" 2>/dev/null)"
} }
function has_python() { function has_python() {
progexists python progexists python2 && return 0
progexists python && return 0
return 1
} }
function has_gawk() { function has_gawk() {
progexists gawk progexists gawk
@ -4782,10 +4992,23 @@ s/[\xE2\x80\x90\xE2\x80\x91\xE2\x80\x92\xE2\x80\x93\xE2\x80\x94\xE2\x80\x95]/-/g
s/[]/\x27/g s/[]/\x27/g
s/[«»“”]/"/g s/[«»“”]/"/g
s/[\xC2\xA0\xE2\x80\x87\xE2\x80\xAF\xE2\x81\xA0]/ /g s/[\xC2\xA0\xE2\x80\x87\xE2\x80\xAF\xE2\x81\xA0]/ /g
s/[\xE2\x80\xA6]/.../g
s/[œ]/oe/g s/[œ]/oe/g
s/[Œ]/OE/g s/[Œ]/OE/g
s/[æ]/ae/g s/[æ]/ae/g
s/[Æ]/AE/g s/[Æ]/AE/g
s/a\xCC\x80/à/g
s/e\xCC\x81/é/g; s/e\xCC\x80/è/g; s/e\xCC\x82/ê/g; s/e\xCC\x88/ë/g
s/i\xCC\x88/ï/g; s/i\xCC\x82/î/g
s/o\xCC\x82/ô/g; s/o\xCC\x88/ö/g
s/u\xCC\x88/ü/g; s/u\xCC\x82/û/g
s/c\xCC\xA7/ç/g
s/A\xCC\x80/À/g
s/E\xCC\x81/É/g; s/E\xCC\x80/È/g; s/E\xCC\x82/Ê/g; s/E\xCC\x88/Ë/g
s/I\xCC\x88/Ï/g; s/I\xCC\x82/Î/g
s/O\xCC\x82/Ô/g; s/O\xCC\x88/Ö/g
s/U\xCC\x88/Ü/g; s/U\xCC\x82/Û/g
s/C\xCC\xA7/Ç/g
' '
} }
function _noaccents() { function _noaccents() {
@ -4919,6 +5142,7 @@ function is_archive() {
name="${name%.jar}" name="${name%.jar}"
name="${name%.war}" name="${name%.war}"
name="${name%.ear}" name="${name%.ear}"
[ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && name="${name%.sh}"
[ "$name" != "$1" ] [ "$name" != "$1" ]
} }
function extract_archive() { function extract_archive() {
@ -4938,6 +5162,12 @@ function extract_archive() {
cd "$destdir" cd "$destdir"
jar xf "$arch" "$@" jar xf "$arch" "$@"
) || return ) || return
elif [ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && endswith "$arch" .sh; then
(
arch="$(abspath "$arch")"
cd "$destdir"
"${BASH:-/bin/sh}" "$arch" --tar xf "$@"
) || return
else else
return 1 return 1
fi fi
@ -4953,6 +5183,7 @@ function get_archive_basename() {
basename="${basename%.jar}" basename="${basename%.jar}"
basename="${basename%.war}" basename="${basename%.war}"
basename="${basename%.ear}" basename="${basename%.ear}"
[ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && basename="${basename%.sh}"
echo "$basename" echo "$basename"
} }
function get_archive_appname() { function get_archive_appname() {
@ -4966,6 +5197,7 @@ function get_archive_appname() {
appname="${appname%.jar}" appname="${appname%.jar}"
appname="${appname%.war}" appname="${appname%.war}"
appname="${appname%.ear}" appname="${appname%.ear}"
[ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && appname="${appname%.sh}"
echo "$appname" | awk '{ echo "$appname" | awk '{
if (match($0, /[-_.]([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/)) { if (match($0, /[-_.]([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/)) {
print substr($0, 1, RSTART - 1) print substr($0, 1, RSTART - 1)
@ -5207,6 +5439,12 @@ function unquote_html(s) {
gsub(/&amp;/, "\\&", s) gsub(/&amp;/, "\\&", s)
return s return s
} }
function qawk(s) {
gsub(/\\/, "\\\\", s)
gsub(/"/, "\\\"", s)
gsub(/\n/, "\\n", s)
return "\"" s "\""
}
function qval(s) {'" function qval(s) {'"
gsub(/'/, \"'\\\\''\", s) gsub(/'/, \"'\\\\''\", s)
return \"'\" s \"'\" return \"'\" s \"'\"
@ -5290,6 +5528,12 @@ function __parse_date_fr(date, parts, y, m, d) {
m = int(parts[2]) m = int(parts[2])
d = int(parts[1]) d = int(parts[1])
return mktime(sprintf("%04i %02i %02i 00 00 00 +0400", y, m, d)) return mktime(sprintf("%04i %02i %02i 00 00 00 +0400", y, m, d))
} else if (match(date, /([0-9][0-9]?)\/([0-9][0-9]?)\/([0-9][0-9])/, parts)) {
basey = int(strftime("%Y")); basey = basey - basey % 100
y = basey + int(parts[3])
m = int(parts[2])
d = int(parts[1])
return mktime(sprintf("%04i %02i %02i 00 00 00 +0400", y, m, d))
} }
return -1 return -1
} }
@ -5934,7 +6178,7 @@ function pidfile_check() {
} }
function page_maybe() { function page_maybe() {
if isatty; then if isatty; then
less -XF "$@" less -XFR "$@"
else else
cat cat
fi fi
@ -6646,7 +6890,7 @@ function ask_any() {
lf="$(strlower "$f")" lf="$(strlower "$f")"
[ "$r" == "$lf" ] && return $i [ "$r" == "$lf" ] && return $i
if [ -z "$defi" ]; then if [ -z "$defi" ]; then
[[ "$f" =~ [A-Z] ]] && defi="$i" [ -z "${f/[A-Z]/}" ] && defi="$i"
fi fi
if [ "$lf" == o ]; then if [ "$lf" == o ]; then
case "$r" in o|y|1|v|t) return $i;; esac case "$r" in o|y|1|v|t) return $i;; esac
@ -6660,7 +6904,8 @@ function ask_any() {
else else
i=0 i=0
while [ $i -lt $count ]; do while [ $i -lt $count ]; do
[[ "${format:$i:1}" =~ [A-Z] ]] && return $i f="${format:$i:1}"
[ -z "${f/[A-Z]/}" ] && return $i
i=$(($i + 1)) i=$(($i + 1))
done done
return 0 return 0
@ -7386,18 +7631,36 @@ SYSDIST_ALIASES=(
10.7=lion 10.6=snowleopard 10.5=leopard 10.4=tiger 10.3=panther 10.7=lion 10.6=snowleopard 10.5=leopard 10.4=tiger 10.3=panther
) )
debianlike_SYSVERS=() debianlike_SYSVERS=()
debian_SYSVERS=(stretch jessie wheezy squeeze lenny etch) debian_SYSVERS=(
ubuntu_SYSVERS=(oneiric natty maverick lucid karmic jaunty intrepid hardy) forky trixie bookworm bullseye buster stretch jessie wheezy squeeze lenny etch
)
ubuntu_SYSVERS=(
mantic lunar kinetic jammy
impish hirsute groovy focal
eoan disco cosmic bionic
artful zesty yakkety xenial
wily vivid utopic trusty
saucy raring quantal precise
oneiric natty maverick lucid
karmic jaunty intrepid hardy
)
redhatlike_SYSVERS=() redhatlike_SYSVERS=()
ol_SYSVERS=(ol7 ol6 redhat7 redhat6) ol_SYSVERS=(ol8 ol7 ol6 redhat8 redhat7 redhat6)
rhel_SYSVERS=(rhel7 rhel6 rhel5 rhel4 redhat7 redhat6 redhat5 redhat4) rhel_SYSVERS=(rhel8 rhel7 rhel6 rhel5 rhel4 redhat8 redhat7 redhat6 redhat5 redhat4)
fedora_SYSVERS=(fedora14 fedora13 fedora12 fedora11) fedora_SYSVERS=(fedora14 fedora13 fedora12 fedora11)
centos_SYSVERS=(centos7 centos6 centos5 centos4 redhat7 redhat6 redhat5 redhat4) centos_SYSVERS=(centos7 centos6 centos5 centos4 redhat7 redhat6 redhat5 redhat4)
suse_SYSVERS=() suse_SYSVERS=()
gentoo_SYSVERS=() gentoo_SYSVERS=()
SYSVER_ALIASES=( SYSVER_ALIASES=(
9=stretch 8=jessie 7=wheezy 6=squeeze 5=lenny 4=etch 14=forky 13=trixie 12=bookworm 11=bullseye 10=buster 9=stretch 8=jessie 7=wheezy 6=squeeze 5=lenny 4=etch
11.10=oneiric 11.04=natty 10.10=maverick 10.04=lucid 9.10=karmic 9.04=jaunty 8.10=intrepid 8.04=hardy 23.10=mantic 23.04=lunar 22.10=kinetic 22.04=jammy
21.10=impish 21.04=hirsute 20.10=groovy 20.04=focal
19.10=eoan 19.04=disco 18.10=cosmic 18.04=bionic
17.10=artful 17.04=zesty 16.10=yakkety 16.04=xenial
15.10=wily 15.04=vivid 14.10=utopic 14.04=trusty
13.10=saucy 13.04=raring 12.10=quantal 12.04=precise
11.10=oneiric 11.04=natty 10.10=maverick 10.04=lucid
9.10=karmic 9.04=jaunty 8.10=intrepid 8.04=hardy
) )
function __setup_ALL_SYSvars() { function __setup_ALL_SYSvars() {
@ -7502,6 +7765,8 @@ function __compute_sysinfos() {
esac esac
if [ -n "$debian_version" ]; then if [ -n "$debian_version" ]; then
case "$debian_version" in case "$debian_version" in
11*|bullseye*) MYSYSDIST=(debian debianlike); MYSYSVER=(bullseye);;
10*|buster*) MYSYSDIST=(debian debianlike); MYSYSVER=(buster);;
9*|stretch*) MYSYSDIST=(debian debianlike); MYSYSVER=(stretch);; 9*|stretch*) MYSYSDIST=(debian debianlike); MYSYSVER=(stretch);;
8*|jessie*) MYSYSDIST=(debian debianlike); MYSYSVER=(jessie);; 8*|jessie*) MYSYSDIST=(debian debianlike); MYSYSVER=(jessie);;
7*|wheezy*) MYSYSDIST=(debian debianlike); MYSYSVER=(wheezy);; 7*|wheezy*) MYSYSDIST=(debian debianlike); MYSYSVER=(wheezy);;
@ -7515,6 +7780,7 @@ function __compute_sysinfos() {
elif [ -n "$oracle_release" ]; then elif [ -n "$oracle_release" ]; then
MYSYSDIST=(ol rhel redhatlike) MYSYSDIST=(ol rhel redhatlike)
case "$oracle_release" in case "$oracle_release" in
Oracle*Linux*release\ 8*) MYSYSVER=(ol8 rhel8 redhat8);;
Oracle*Linux*release\ 7*) MYSYSVER=(ol7 rhel7 redhat7);; Oracle*Linux*release\ 7*) MYSYSVER=(ol7 rhel7 redhat7);;
Oracle*Linux*release\ 6*) MYSYSVER=(ol6 rhel6 redhat6);; Oracle*Linux*release\ 6*) MYSYSVER=(ol6 rhel6 redhat6);;
esac esac
@ -7530,10 +7796,12 @@ function __compute_sysinfos() {
Fedora*13*) MYSYSVER=(fedora13);; Fedora*13*) MYSYSVER=(fedora13);;
Fedora*12*) MYSYSVER=(fedora12);; Fedora*12*) MYSYSVER=(fedora12);;
Fedora*11*) MYSYSVER=(fedora11);; Fedora*11*) MYSYSVER=(fedora11);;
Red*Hat*Enterprise*Linux*release\ 8*) MYSYSVER=(rhel8 redhat8);;
Red*Hat*Enterprise*Linux*release\ 7*) MYSYSVER=(rhel7 redhat7);; Red*Hat*Enterprise*Linux*release\ 7*) MYSYSVER=(rhel7 redhat7);;
Red*Hat*Enterprise*Linux*release\ 6*) MYSYSVER=(rhel6 redhat6);; Red*Hat*Enterprise*Linux*release\ 6*) MYSYSVER=(rhel6 redhat6);;
Red*Hat*Enterprise*Linux*release\ 5*) MYSYSVER=(rhel5 redhat5);; Red*Hat*Enterprise*Linux*release\ 5*) MYSYSVER=(rhel5 redhat5);;
Red*Hat*Enterprise*Linux*release\ 4*) MYSYSVER=(rhel4 redhat4);; Red*Hat*Enterprise*Linux*release\ 4*) MYSYSVER=(rhel4 redhat4);;
CentOS*release\ 8*) MYSYSVER=(centos8 redhat8);;
CentOS*release\ 7*) MYSYSVER=(centos7 redhat7);; CentOS*release\ 7*) MYSYSVER=(centos7 redhat7);;
CentOS*release\ 6*) MYSYSVER=(centos6 redhat6);; CentOS*release\ 6*) MYSYSVER=(centos6 redhat6);;
CentOS*release\ 5*) MYSYSVER=(centos5 redhat5);; CentOS*release\ 5*) MYSYSVER=(centos5 redhat5);;
@ -7895,6 +8163,29 @@ function on_default() {
fi fi
return 1 return 1
} }
function require_debian() {
set -- -d debian "$@"
if check_sysinfos "$@"; then
urequire debian
return 0
fi
local -a infos; local info
for info in "$@"; do
if ! [[ "$info" == -* ]]; then
infos=("${infos[@]}" "$info")
fi
done
local msg="Ce script n'est pas supporté sur $(get_sysinfos_desc)"
[ -n "$*" ] && msg="$msg
Il faut au moins l'un des systèmes suivants: ${infos[*]}"
[ -n "$UINST" -a -n "$ABORT" ] && touch "$ABORT"
die "$msg"
}
function require_stretch() {
require_debian -v stretch+
}
##@inc]sysinfos ##@inc]sysinfos
##@inc[compat ##@inc[compat
# Code de support pour les architectures autre que Linux # Code de support pour les architectures autre que Linux