Intégration de la branche release-5.2.0

This commit is contained in:
Jephté Clain 2016-08-31 22:30:44 +04:00
commit f253728463
15 changed files with 886 additions and 245 deletions

View File

@ -1,3 +1,20 @@
## Version 5.2.0 du 31/08/2016-22:30
+ 361f1b2 Intégration de la branche runsmod-goodies
| 8854469 maj de la config par défaut
| f0a71e4 bug avec la génération de sysinfos.conf
| 830a33b rruns calcule aussi les chemins d'hôtes automatiquement
| 40f5347 préparer le calcul automatique des chemins
| 2fbc599 bug avec git clone lors du basculement sur la branche develop
| 5bef9b1 utiliser la même logique que uproject pour cloner en mode devel
| 96afb2a mapping des répertoires de destination
| 4b212d8 ne pas utiliser %n tout de suite
| 30e5dda runs et rruns: améliorer le calcul des chemins
| 55c5755 support de //...%h...
| 409e406 préparer implémentation de %n
+ 208f30d Intégration de la branche better-fndate
| f388f27 ajouter des liens pour les fonctions courantes de fndate. En mode automatique, si le fichier contient déjà une mention de date, ne pas la modifier. rajouter l'option -@ pour forcer la modification de la date
## Version 5.1.0 du 25/08/2016-15:36
8a33418 ulib/ldif: support de l'opération modrdn

View File

@ -1 +1 @@
5.1.0
5.2.0

218
fndate
View File

@ -1,5 +1,16 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
TOOLS=(ddir dfile dcopy dmove dcmd)
if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
# créer les liens
scriptname="$(basename "$0")"
for tool in "${TOOLS[@]}"; do
ln -s "$scriptname" "$tool"
done
exit 0
fi
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
@ -41,10 +52,17 @@ OPTIONS
arguments, alors ajouter la date à la fin de la commande. Par exemple,
voici comment émuler l'option -k
$scriptname -c cp src dest/~~
--string
Remplacer dans chaque argument le placeholder par la date et afficher le
résultat.
-P, --placeholder PLACEHOLDER
Dans le nom spécifié, remplacer PLACEHOLDER par la date. Par défaut,
PLACEHOLDER vaut ~~. Si le nom spécifié ne contient pas le PLACEHOLDER,
il est placé au début.
-@, --force-date DATE
Dans le nom spécifié, si la date est déjà présente, forcer son
remplacement par la valeur spécifiée. Par défaut, le fichier n'est pas
modifié si la date est déjà présente.
-F, --format FORMAT
Spécifier le format de la date à insérer dans le nom du fichier. Par
défaut, FORMAT vaut 'YYMMDD-'
@ -53,7 +71,13 @@ OPTIONS
YY année sur 2 chiffres
MM mois sur 2 chiffres
DD jour sur 2 chiffres
Tous les autres caractères sont pris tels-quels"
Tous les autres caractères sont pris tels-quels
-s, --short
Equivalent à -F YYMMDD --autof
-l, --long
Equivalent à -F YYYMMDD --autof
--autof
Option non (pas encore) documentée"
}
function create() {
@ -66,13 +90,43 @@ function have_ph() {
[[ "$1" == *"$placeholder"* ]]
}
function replace_ph() {
awkrun ph="$placeholder" format="$format" autof:int="$autof" '
local fy fm fd
if [ -n "$force_date" ]; then
fd="${force_date:0:2}"
fm="${force_date:3:2}"
fy="${force_date:6:4}"
fi
awkrun ph="$placeholder" \
force_date="$force_date" fy:str="$fy" fm:str="$fm" fd:str="$fd" \
format="$format" autof:int="$autof" '
function short2long(s, cy, py, sy, ly) {
cy = strftime("%Y") + 0
cy = cy - cy % 100
py = cy - 100
sy = substr(s, 1, 2) + 0
if (sy >= 80) ly = py + sy
else ly = cy + sy
return ly substr(s, 3)
}
BEGIN {
gsub(/%/, "%%", format)
gsub(/YYYY/, "%Y", format)
gsub(/YY/, "%y", format)
gsub(/MM/, "%m", format)
gsub(/DD/, "%d", format)
if (format ~ /YYYYMMDD/) type = "long"
else if (format ~ /YYMMDD/) type = "short"
else type = "custom"
if (force_date != "") {
gsub(/%/, "%%", format)
gsub(/YYYY/, fy, format)
gsub(/YY/, substr(fy, 3, 2), format)
gsub(/MM/, fm, format)
gsub(/DD/, fd, format)
} else {
gsub(/%/, "%%", format)
gsub(/YYYY/, "%Y", format)
gsub(/YY/, "%y", format)
gsub(/MM/, "%m", format)
gsub(/DD/, "%d", format)
}
date = strftime(format)
}
{
@ -88,7 +142,43 @@ BEGIN {
if (autof) {
pos = index(name, ph)
if (pos == 0) {
print dir date "-" name
if (force_date != "") {
if (type == "long") {
if (name ~ /^[0-9]{8}/) {
name = substr(name, 9)
print dir date name
} else if (name ~ /^[0-9]{6}/) {
name = substr(name, 7)
print dir date name
} else {
print dir date "-" name
}
} else if (type == "short") {
if (name ~ /^[0-9]{8}/) {
name = substr(name, 9)
print dir date name
} else if (name ~ /^[0-9]{6}/) {
name = substr(name, 7)
print dir date name
} else {
print dir date "-" name
}
} else if (type == "custom") {
print dir date "-" name
}
} else {
if (type == "long") {
if (name ~ /^[0-9]{8}/) print dir name
else if (name ~ /^[0-9]{6}/) print dir short2long(name)
else print dir date "-" name
} else if (type == "short") {
if (name ~ /^[0-9]{8}/) print dir substr(name, 3)
else if (name ~ /^[0-9]{6}/) print dir name
else print dir date "-" name
} else if (type == "custom") {
print dir date "-" name
}
}
} else if (pos == 1) {
print dir date "-" substr(name, length(ph) + 1)
} else if (pos == length(name) - length(ph) + 1) {
@ -99,7 +189,27 @@ BEGIN {
} else {
pos = index(name, ph)
if (pos == 0) {
print dir date name
if (force_date != "") {
if (type == "long") {
if (name ~ /^[0-9]{8}/) name = substr(name, 9)
print dir date name
} else if (type == "short") {
if (name ~ /^[0-9]{6}/) name = substr(name, 7)
print dir date name
} else if (type == "custom") {
print dir date name
}
} else {
if (type == "long") {
if (name ~ /^[0-9]{8}/) print dir name
else print dir date name
} else if (type == "short") {
if (name ~ /^[0-9]{6}/) print dir name
else print dir date name
} else if (type == "custom") {
print dir date name
}
}
} else {
print dir substr(name, 1, pos - 1) date substr(name, pos + length(ph))
}
@ -109,8 +219,17 @@ BEGIN {
action=create
create=
case "$scriptname" in
ddir) action=create; create=dir;;
dfile) action=create; create=file;;
dcopy) action=copy;;
dmove) action=move;;
dcmd) action=cmd;;
esac
placeholder=
force_date=
format=
autof=
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
--create-or-rename action=create \
@ -119,16 +238,19 @@ parse_opts "${PRETTYOPTS[@]}" \
-k,--copy action=copy \
-m,--move action=move \
-c,--cmd action=cmd \
--string action=string \
-P:,--placeholder: placeholder= \
-@:,--force-date: force_date= \
-F:,--format: format= \
-s,--short '$format=YYMMDD; autof=1' \
-l,--long '$format=YYYYMMDD; autof=1' \
--autof autof=1 \
@ args -- "$@" && set -- "${args[@]}" || die "$args"
[ -n "$create" ] || create=file
[ -n "$placeholder" ] || placeholder="~~"
if [ -n "$format" ]; then
autof=
else
[ -n "$force_date" ] && setx force_date=parse_date "$force_date"
if [ -z "$format" ]; then
format=YYMMDD
autof=1
fi
@ -141,20 +263,20 @@ if [ "$action" == cmd ]; then
for arg in "$@"; do
if have_ph "$arg"; then
check_interaction -c && evalx qvals "${args[@]}" "$arg" // estepi "Commande:"
setx arg=replace_ph "$arg"
setx arg=replace_ph "$arg" "$force_date"
read_value "Veuillez confirmer le nom" arg "$arg"
found=1
fi
args=("${args[@]}" "$arg")
done
if [ -z "$found" ]; then
setx arg=replace_ph
setx arg=replace_ph "" "$force_date"
read_value "Veuillez entrer le nom du fichier" arg "$arg"
args=("${args[@]}" "$arg")
fi
if show_debug; then
evalx qvals "${args[@]}" // edebug "Commande:"
evalx qvals "${args[@]}" // edebug "Commande effective:"
ask_yesno "Voulez-vous continuer?" X || die
fi
"${args[@]}"
@ -184,12 +306,17 @@ elif [ "$action" == copy -o "$action" == move ]; then
cmd=(mv -i)
fi
for src in "${srcs[@]}"; do
setx src=abspath "$src"
setx srcname=basename -- "$src"
if [ -e "$src" ]; then
einfo "$cmdinfo de $(ppath "$src")"
setx destname=replace_ph "$srcname"
estep "$cmdinfo de $(ppath "$src")"
setx destname=replace_ph "$srcname" "$force_date"
setx dest=abspath "$destdir/$destname"
[ "$src" != "$dest" ] || ewarn "La source et la destination sont identiques"
read_value "Veuillez confirmer le nom" destname "$destname"
"${cmd[@]}" "$src" "$destdir/$destname"
setx dest=abspath "$destdir/$destname"
[ "$src" != "$dest" ] && "${cmd[@]}" "$src" "$destdir/$destname"
else
ewarn "$src: fichier introuvable"
fi
@ -198,30 +325,63 @@ elif [ "$action" == copy -o "$action" == move ]; then
elif [ "$action" == create ]; then
if [ $# -gt 0 ]; then
for src in "$@"; do
setx src=abspath "$src"
setx dir=dirname -- "$src"
setx srcname=basename -- "$src"
if [ -e "$src" ]; then
einfo "Renommage de $(ppath "$src")"
setx destname=replace_ph "$srcname"
estep "Renommage de $(ppath "$src")"
setx destname=replace_ph "$srcname" "$force_date"
setx dest=abspath "$dir/$destname"
[ "$src" != "$dest" ] || ewarn "La source et la destination sont identiques"
read_value "Veuillez confirmer le nom" destname "$destname"
mv -i "$src" "$dir/$destname"
setx dest=abspath "$dir/$destname"
[ "$src" != "$dest" ] && mv -i "$src" "$dir/$destname"
else
einfo "Création de $(ppath "$src")"
setx destname=replace_ph "$srcname"
setx destname=replace_ph "$srcname" "$force_date"
setx dest=abspath "$dir/$destname"
if [ -d "$dest" ]; then
ewarn "$srcname --> $(ppath "$dest"): répertoire existant"
elif [ -e "$dest" ]; then
ewarn "$srcname --> $(ppath "$dest"): fichier existant"
else
estep "$srcname --> Création de $(ppath "$dest")"
fi
read_value "Veuillez confirmer le nom" destname "$destname"
setx dest=abspath "$dir/$destname"
create "$dir/$destname"
fi
done
else
case "$create" in
file) einfo "Création d'un nouveau fichier";;
dir) einfo "Création d'un nouveau répertoire";;
esac
setx destname=replace_ph
read_value "Veuillez entrer le nom" destname "$destname"
setx destname=replace_ph "" "$force_date"
confirm_action=entrer
if [ -d "$destname" ]; then
ewarn "$destname: répertoire existant"
confirm_action=confirmer
elif [ -e "$destname" ]; then
ewarn "$destname: fichier existant"
confirm_action=confirmer
else
case "$create" in
file) estep "Création d'un nouveau fichier";;
dir) estep "Création d'un nouveau répertoire";;
esac
fi
read_value "Veuillez $confirm_action le nom" destname "$destname"
create "$destname"
fi
elif [ "$action" == string ]; then
if [ $# -gt 0 ]; then
for string in "$@"; do
replace_ph "$string" "$force_date"
done
else
replace_ph "" "$force_date"
fi
else
die "$action: action non implémentée"
fi

View File

@ -2,12 +2,15 @@
# Liste des répertoires à considérer pour la recherche de scripts runs
#RUNSSCRIPTSPATH=
#RUNSSCRIPTSDIRS=()
# Liste des répertoires à considérer pour la recherche de modules installables
#RUNSMODULESPATH=
#RUNSMODULESDIRS=()
# Liste des répertoires à considérer pour la recherche de répertoires d'hôtes
#RUNSHOSTSPATH=
#RUNSHOSTSDIRS=()
# Liste des domaines à rechercher, si un hôte déjà configuré est donné sans
# domaine. Si cette liste est vide, le fichier /etc/resolv.conf est consulté

View File

@ -34,6 +34,7 @@ done
./udist --nutools-makelinks
./ulink --nutools-makelinks
./doinplace --nutools-makelinks
./fndate --nutools-makelinks
# complétion programmable
rm -f ~/etc/bashrc.d/bash_completion.nutools # renommé

View File

@ -1 +1 @@
013001000
013002000

View File

@ -141,7 +141,8 @@ function runs_initdir() {
estep "Création de $(ppath "$runshostdir/runs.conf")"
echo "$runsconft" >"$runshostdir/runs.conf"
fi
if [ ! -f "$runshostdir/sysinfos.conf" ]; then
[ -f "$runshostdir/sysinfos.conf" ] || touch "$runshostdir/sysinfos.conf"
if [ -z "$(<"$runshostdir/sysinfos.conf" filter_comment)" ]; then
estep "Création de $(ppath "$runshostdir/sysinfos.conf")"
echo "$sysinfost" >"$runshostdir/sysinfos.conf"
fi
@ -747,6 +748,39 @@ RUNSHOST=$RUNSHOST"
################################################################################
# Moteur de script
function runs_before_parse_args() {
RUNSSCRIPTSPATH=
RUNSSCRIPTSDIRS=()
RUNSMODULESPATH=
RUNSMODULESDIRS=()
RUNSHOSTSPATH=
RUNSHOSTSDIRS=()
RUNSDOMAINS=()
RUNSDOMAIN=
set_defaults runs
[ -n "$RUNSSCRIPTSPATH" ] && RUNSSCRIPTSDIRS=("$RUNSSCRIPTSPATH" "${RUNSSCRIPTSDIRS[@]}")
array_fix_paths RUNSSCRIPTSDIRS; setx RUNSSCRIPTSPATH=array_to_path RUNSSCRIPTSDIRS
[ -n "$RUNSMODULESPATH" ] && RUNSMODULESDIRS=("$RUNSMODULESPATH" "${RUNSMODULESDIRS[@]}")
array_fix_paths RUNSMODULESDIRS; setx RUNSMODULESPATH=array_to_path RUNSMODULESDIRS
[ -n "$RUNSHOSTSPATH" ] && RUNSHOSTSDIRS=("$RUNSHOSTSPATH" "${RUNSHOSTSDIRS[@]}")
array_fix_paths RUNSHOSTSDIRS; setx RUNSHOSTSPATH=array_to_path RUNSHOSTSDIRS
}
function runs_after_parse_args() {
[ -n "$runsscriptspath" ] && runsscriptsdirs=("$runsscriptspath" "${runsscriptsdirs[@]}")
array_fix_paths runsscriptsdirs; setx runsscriptspath=array_to_path runsscriptsdirs
[ -n "$runsscriptspath" ] && RUNSSCRIPTSPATH="$runsscriptspath"
[ -n "$runsmodulespath" ] && runsmodulesdirs=("$runsmodulespath" "${runsmodulesdirs[@]}")
array_fix_paths runsmodulesdirs; setx runsmodulespath=array_to_path runsmodulesdirs
[ -n "$runsmodulespath" ] && RUNSMODULESPATH="$runsmodulespath"
[ -n "$runshostspath" ] && runshostsdirs=("$runshostspath" "${runshostsdirs[@]}")
array_fix_paths runshostsdirs; setx runshostspath=array_to_path runshostsdirs
[ -n "$runshostspath" ] && RUNSHOSTSPATH="$runshostspath"
[ -n "$RUNSSCRIPTSPATH" ] || RUNSSCRIPTSPATH=:
[ -n "$RUNSMODULESPATH" ] || RUNSMODULESPATH=:
[ -n "$RUNSHOSTSPATH" ] || RUNSHOSTSPATH=:
}
function runs_init() {
RUNSSRCDIR="${1:-$scriptdir}" # répertoire d'où sont copiés les scripts
RUNSACTION=runs_action_run
@ -900,6 +934,7 @@ exit 0
set_var "$runspath" "$(array_join runsdirs :)"
done
# XXX quelles autres variables doivent être corrigées?
# XXX ==> il faut rajouter rscripts et recipes
fi
elif [ -n "$runsworkdir" ]; then
RUNSWORKDIR="$runsworkdir"

View File

@ -3,7 +3,7 @@
##@cooked nocomments
##@require base
uprovide runsmod
urequire base
urequire base vcs
function __runsmod_loadconf() {
# Charger le fichier de configuration $1. Les paramètres RUNSMOD_MODE,
@ -137,6 +137,29 @@ function __runsmod_fixurl() {
echo "$url$1"
}
function __runsmod_mapdir() {
# mapper le répertoire $1, avec $2 est le répertoire de base à partir
# desquels les mappings sont définis
# retourner vrai si un mapping a eu lieu
local dir="$1" basedir="$2"
local -a maps
local map from to
[ -n "$basedir" ] && dir="${dir#$basedir/}"
__runsmod_get -a maps MAP
for map in "${maps[@]}"; do
splitpair "$map" from to
if [ "$dir" == "$from" ]; then
echo "$to"
return 0
elif [ "${dir#$from/}" != "$dir" ]; then
echo "$to/${dir#$from/}"
return 0
fi
done
echo "$dir"
return 1
}
function __runsmod_getpath_from_baseurl() {
# obtenir le nom correspond à un url de base, utilisable dans un chemin
local url="$1" scheme path userhost user host dummy
@ -196,13 +219,28 @@ function __runsmod_fixinfo() {
sed -n '3,$p' | sed 's/^.*\t//g'
}
function runsmod_autoconf() {
if __runsmod_loadconf && runsmod_checkenv --check-only; then
runsmod_setup_vars
runsmod_update_vars "${1:-self}"
runsmod_teardown_vars
if show_debug; then
etitle SCRIPTSDIRS array_each SCRIPTSDIRS ppath
etitle MODULESDIRS array_each MODULESDIRS ppath
etitle HOSTSDIRS array_each HOSTSDIRS ppath
fi
fi
}
function runsmod_checkenv() {
# vérifier l'environement. créer les répertoires nécessaires.
local check_only
[ "$1" == --check-only ] && check_only=1
if [ -z "$RUNSMOD_BASEDIR" ]; then
eerror "Vous devez définir RUNSMOD_BASEDIR"
[ -z "$check_only" ] && eerror "Vous devez définir RUNSMOD_BASEDIR"
return 1
fi
if [ ! -d "$RUNSMOD_BASEDIR" ]; then
if [ ! -d "$RUNSMOD_BASEDIR" -a -z "$check_only" ]; then
estep "Création de $(ppath "$RUNSMOD_BASEDIR")"
mkdir -p "$RUNSMOD_BASEDIR" || return 1
fi
@ -220,18 +258,23 @@ function runsmod_should_update_repolists() {
# tester s'il faut mettre à jour au moins un des fichiers contenant les
# listes des dépôts
local RUNSMOD_PROFILE
local now baseurl repobase repopath repolistfile mtime
local -a urls
local now baseurl have_repolistfile repolistfile mtime
local -a baseurls
setx now=date +%s
for RUNSMOD_PROFILE in "${RUNSMOD_PROFILES[@]}"; do
setx baseurl=__runsmod_get BASEURL || continue
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
# si le fichier n'existe pas, il faut mettre à jour
[ -f "$repolistfile" ] || return 0
# si le fichier a été modifié depuis plus de 24 heures, mettre à jour
setx mtime=stat -c %Y "$repolistfile"
[ $(($now - $mtime)) -lt 86400 ] || return 0
__runsmod_get -a baseurls BASEURL
have_repolistfile=
for baseurl in "${baseurls[@]}"; do
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
if [ -f "$repolistfile" ]; then
have_repolistfile=1
# si le fichier a été modifié depuis plus de 24 heures, mettre à jour
setx mtime=stat -c %Y "$repolistfile"
[ $(($now - $mtime)) -lt 86400 ] || return 0
fi
done
# si aucun des fichiers n'existe, il faut mettre à jour
[ -n "$have_repolistfile" ] || return 0
done
return 1
}
@ -241,34 +284,42 @@ function runsmod_update_repolists() {
# Si $1 n'est pas vide, forcer la mise à jour de tous les fichiers
local force="$1"; shift
local RUNSMOD_PROFILE
local now baseurl repobase repopath repo mtime update
local -a urls
local now baseurl repobase repopath repo mtime update error
local -a baseurls
setx now=date +%s
for RUNSMOD_PROFILE in "${RUNSMOD_PROFILES[@]}"; do
setx baseurl=__runsmod_get BASEURL || continue
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
__runsmod_get -a baseurls BASEURL
for baseurl in "${baseurls[@]}"; do
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
update="$force"
if [ -z "$update" ]; then
# si le fichier n'existe pas, il faut mettre à jour
[ -f "$repolistfile" ] || update=1
fi
if [ -z "$update" ]; then
# si le fichier a été modifié depuis plus de 24 heures, mettre à jour
setx mtime=stat -c %Y "$repolistfile"
[ $(($now - $mtime)) -lt 86400 ] || update=1
fi
if [ -n "$update" ]; then
local list
ebegin "$baseurl"
if setx list=__runsmod_getinfo "$baseurl"; then
echo "$list" | __runsmod_fixinfo >"$repolistfile"
edot 0
else
edot 1
update="$force"
if [ -z "$update" ]; then
# si le fichier n'existe pas, il faut mettre à jour
[ -f "$repolistfile" ] || update=1
fi
eend
fi
if [ -z "$update" ]; then
# si le fichier a été modifié depuis plus de 24 heures, mettre à jour
setx mtime=stat -c %Y "$repolistfile"
[ $(($now - $mtime)) -lt 86400 ] || update=1
fi
error=
if [ -n "$update" ]; then
local list
ebegin "$baseurl"
if setx list=__runsmod_getinfo "$baseurl"; then
echo "$list" | __runsmod_fixinfo >"$repolistfile"
edot 0
else
error=1
edot 1
fi
eend
fi
[ -n "$error" ] && continue
break
done
done
}
@ -326,7 +377,6 @@ function __runsmod_match_repo_add() {
function __runsmod_clone_or_pull() {
local repourl="$1" repodir="$2"
mkdirof "$repodir"
if [ -d "$repodir" ]; then
if [ -n "$RUNSMOD_PULL" ]; then
estepi "pull $(ppath "$repodir") [$repourl]"
@ -339,8 +389,18 @@ function __runsmod_clone_or_pull() {
else
if [ -n "$RUNSMOD_CLONE" ]; then
estepi "clone $(ppath "$repodir") [$repourl]"
git clone ${RUNSMOD_SHALLOW:+--depth 1} "$repourl" "$repodir"
return $?
mkdirof "$repodir"
git clone ${RUNSMOD_SHALLOW:+--depth 1} "$repourl" "$repodir" || return $?
if [ "$RUNSMOD_MODE" == devel ]; then
(
cd "$repodir"
if git_have_rbranch develop; then
git checkout develop || exit 1
fi
) || return $?
fi
git_annex_initial "$repodir" || return $?
return 0
else
estepe "noclone $(ppath "$repodir")"
return 1
@ -364,9 +424,8 @@ function runsmod_clone_or_pull() {
host="$host.$RUNSDOMAIN"
enote "Autocorrection du nom d'hôte en $host"
fi
#XXX implémenter all_hosts=1
local -a repolist reponames repourls
local -a baseurls repolist reposuffixes reponames repourls
local RUNSMOD_PROFILE baseurl repopath repolistfile
local vprefix repospec reposuffix reponame repourl repodir module moduledir
local r=0
@ -374,60 +433,80 @@ function runsmod_clone_or_pull() {
# Tout d'abord, traiter les dépôts sans variable %m
edebug "Traitement des dépôts sans vmodule"
for RUNSMOD_PROFILE in "${RUNSMOD_PROFILES[@]}"; do
setx baseurl=__runsmod_get BASEURL || continue
setx repopath=__runsmod_getpath_from_baseurl "$baseurl"
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
[ -f "$repolistfile" ] || continue
array_from_lines repolist "$(<"$repolistfile")"
__runsmod_get -a baseurls BASEURL
for baseurl in "${baseurls[@]}"; do
setx repopath=__runsmod_getpath_from_baseurl "$baseurl"
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
[ -f "$repolistfile" ] || continue
array_from_lines repolist "$(<"$repolistfile")"
edebug ".. baseurl=$baseurl, repopath=$repopath"
for vprefix in SCRIPTS MODULES HOSTS; do
__runsmod_get -a repourls "${vprefix}_URLS"
edebug ".... vprefix=$vprefix, repourls=(${repourls[*]})"
edebug ".. baseurl=$baseurl, repopath=$repopath"
for vprefix in SCRIPTS MODULES HOSTS; do
__runsmod_get -a repourls "${vprefix}_URLS"
edebug ".... vprefix=$vprefix, repourls=(${repourls[*]})"
for repospec in "${repourls[@]}"; do
edebug "...... repospec=$repospec"
__runsmod_has_vmodule "$repospec" && continue
if [[ "$repospec" == *//* ]]; then
reposuffix="${repospec#*//}"
[ -n "$reposuffix" ] && reposuffix="/$reposuffix"
repospec="${repospec%%//*}"
else
reposuffix=
fi
reponames=()
if __runsmod_has_vhost "$repospec"; then
if [ -n "$all_hosts" ]; then
setx repospec=__runsmod_replace1 "$repospec" "*"
__runsmod_match_repo_add repolist "$repospec" reponames
elif [ -n "$host" ]; then
setx reponame=__runsmod_replace1 "$repospec" "$host"
array_contains repolist "$reponame" && array_add reponames "$reponame"
setx reponame=__runsmod_replace2 "$repospec" "$host"
array_contains repolist "$reponame" && array_add reponames "$reponame"
for repospec in "${repourls[@]}"; do
edebug "...... repospec=$repospec"
__runsmod_has_vmodule "$repospec" && continue
if [[ "$repospec" == *//* ]]; then
reposuffixes=()
reposuffix="${repospec#*//}"
[ -n "$reposuffix" ] && reposuffix="/$reposuffix"
repospec="${repospec%%//*}"
if __runsmod_has_vhost "$reposuffix"; then
if [ -n "$all_hosts" -o -z "$host" ]; then
reposuffix="${reposuffix//%h\//}"
reposuffix="${reposuffix//\/%h/}"
reposuffixes=("$reposuffix")
elif [ -n "$host" ]; then
local rs1 rs2
setx rs1=__runsmod_replace1 "$reposuffix" "$host"
setx rs2=__runsmod_replace2 "$reposuffix" "$host"
reposuffixes=("$rs1")
[ "$rs2" != "$rs1" ] && array_add reposuffixes "$rs2"
fi
else
reposuffixes=("$reposuffix")
fi
else
reposuffixes=("")
fi
else
array_contains repolist "$repospec" && array_add reponames "$repospec"
fi
edebug "...... reponames=(${reponames[*]})"
for reponame in "${reponames[@]}"; do
repodir="$RUNSMOD_BASEDIR/$repopath/$reponame"
reponames=()
if __runsmod_has_vhost "$repospec"; then
if [ -n "$all_hosts" ]; then
setx rs1=__runsmod_replace1 "$repospec" "*"
__runsmod_match_repo_add repolist "$rs1" reponames
elif [ -n "$host" ]; then
setx rs1=__runsmod_replace1 "$repospec" "$host"
array_contains repolist "$rs1" && array_add reponames "$rs1"
setx rs2=__runsmod_replace2 "$repospec" "$host"
array_contains repolist "$rs2" && array_add reponames "$rs2"
fi
else
array_contains repolist "$repospec" && array_add reponames "$repospec"
fi
setx repourl=__runsmod_fixurl "$reponame" "$baseurl"
__runsmod_clone_or_pull "$repourl" "$repodir" || r=1
edebug "...... reponames=(${reponames[*]})"
for reponame in "${reponames[@]}"; do
repodir="$RUNSMOD_BASEDIR/$repopath/$reponame"
[ -d "$repodir" ] || continue
array_contains REPODIRS "$repodir" && continue
array_addu REPODIRS "$repodir"
setx repourl=__runsmod_fixurl "$reponame" "$baseurl"
setx repodir=__runsmod_mapdir "$repodir" "$RUNSMOD_BASEDIR/$repopath"
__runsmod_clone_or_pull "$repourl" "$repodir" || r=1
repodir="$repodir$reposuffix"
case "$vprefix" in
SCRIPTS) array_addu SCRIPTSDIRS "$repodir";;
MODULES) array_addu MODULESDIRS "$repodir";;
HOSTS) array_addu HOSTSDIRS "$repodir";;
esac
[ -d "$repodir" ] || continue
array_contains REPODIRS "$repodir" && continue
array_addu REPODIRS "$repodir"
for reposuffix in "${reposuffixes[@]}"; do
case "$vprefix" in
SCRIPTS) array_addu SCRIPTSDIRS "$repodir$reposuffix";;
MODULES) array_addu MODULESDIRS "$repodir$reposuffix";;
HOSTS) array_addu HOSTSDIRS "$repodir$reposuffix";;
esac
done
done
done
done
done
@ -443,89 +522,109 @@ function runsmod_clone_or_pull() {
modules=("$@")
for RUNSMOD_PROFILE in "${RUNSMOD_PROFILES[@]}"; do
setx baseurl=__runsmod_get BASEURL || continue
setx repopath=__runsmod_getpath_from_baseurl "$baseurl"
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
[ -f "$repolistfile" ] || continue
array_from_lines repolist "$(<"$repolistfile")"
__runsmod_get -a baseurls BASEURL
for baseurl in "${baseurls[@]}"; do
setx repopath=__runsmod_getpath_from_baseurl "$baseurl"
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
[ -f "$repolistfile" ] || continue
array_from_lines repolist "$(<"$repolistfile")"
edebug ".. baseurl=$baseurl, repopath=$repopath"
for module in "${modules[@]}"; do
if [ "$module" == "*" ]; then
module=
all_modules=1
else
array_contains foundmodules "$module" && continue
all_modules=
fi
edebug ".... module=$module"
edebug ".. baseurl=$baseurl, repopath=$repopath"
for module in "${modules[@]}"; do
if [ "$module" == "*" ]; then
module=
all_modules=1
else
array_contains foundmodules "$module" && continue
all_modules=
fi
edebug ".... module=$module"
for vprefix in SCRIPTS MODULES HOSTS; do
__runsmod_get -a repourls "${vprefix}_URLS"
edebug "...... vprefix=$vprefix, repourls=(${repourls[*]})"
for vprefix in SCRIPTS MODULES HOSTS; do
__runsmod_get -a repourls "${vprefix}_URLS"
edebug "...... vprefix=$vprefix, repourls=(${repourls[*]})"
for repospec in "${repourls[@]}"; do
edebug "........ repospec=$repospec"
__runsmod_has_vmodule "$repospec" || continue
if [[ "$repospec" == *//* ]]; then
reposuffix="${repospec#*//}"
[ -n "$reposuffix" ] && reposuffix="/$reposuffix"
repospec="${repospec%%//*}"
else
reposuffix=
fi
reponames=()
if [ -n "$all_modules" ]; then
if __runsmod_has_vhost "$repospec"; then
if [ -n "$all_hosts" ]; then
setx repospec=__runsmod_replace1 "$repospec" "*" "*"
__runsmod_match_repo_add repolist "$repospec" reponames
elif [ -n "$host" ]; then
setx repospec=__runsmod_replace1 "$repospec" "$host" "*"
__runsmod_match_repo_add repolist "$repospec" reponames
setx repospec=__runsmod_replace2 "$repospec" "$host" "*"
__runsmod_match_repo_add repolist "$repospec" reponames
for repospec in "${repourls[@]}"; do
edebug "........ repospec=$repospec"
__runsmod_has_vmodule "$repospec" || continue
if [[ "$repospec" == *//* ]]; then
reposuffixes=()
reposuffix="${repospec#*//}"
[ -n "$reposuffix" ] && reposuffix="/$reposuffix"
repospec="${repospec%%//*}"
if __runsmod_has_vhost "$reposuffix"; then
if [ -n "$all_hosts" -o -z "$host" ]; then
reposuffix="${reposuffix//%h\//}"
reposuffix="${reposuffix//\/%h/}"
reposuffixes=("$reposuffix")
elif [ -n "$host" ]; then
local rs1 rs2
setx rs1=__runsmod_replace1 "$reposuffix" "$host"
setx rs2=__runsmod_replace2 "$reposuffix" "$host"
reposuffixes=("$rs1")
[ "$rs2" != "$rs1" ] && array_add reposuffixes "$rs2"
fi
else
reposuffixes=("$reposuffix")
fi
else
setx repospec=__runsmod_replace1 "$repospec" "" "*"
__runsmod_match_repo_add repolist "$repospec" reponames
reposuffixes=("")
fi
else
if __runsmod_has_vhost "$repospec"; then
if [ -n "$host" ]; then
setx reponame=__runsmod_replace1 "$repospec" "$host" "$module"
array_contains repolist "$reponame" && array_add reponames "$reponame"
setx reponame=__runsmod_replace2 "$repospec" "$host" "$module"
array_contains repolist "$reponame" && array_add reponames "$reponame"
reponames=()
if [ -n "$all_modules" ]; then
if __runsmod_has_vhost "$repospec"; then
if [ -n "$all_hosts" ]; then
setx rs1=__runsmod_replace1 "$repospec" "*" "*"
__runsmod_match_repo_add repolist "$rs1" reponames
elif [ -n "$host" ]; then
setx rs1=__runsmod_replace1 "$repospec" "$host" "*"
__runsmod_match_repo_add repolist "$rs1" reponames
setx rs2=__runsmod_replace2 "$repospec" "$host" "*"
__runsmod_match_repo_add repolist "$rs2" reponames
fi
else
setx rs1=__runsmod_replace1 "$repospec" "" "*"
__runsmod_match_repo_add repolist "$rs1" reponames
fi
else
setx reponame=__runsmod_replace1 "$repospec" "" "$module"
array_contains repolist "$reponame" && array_add reponames "$reponame"
if __runsmod_has_vhost "$repospec"; then
if [ -n "$host" ]; then
setx rs1=__runsmod_replace1 "$repospec" "$host" "$module"
array_contains repolist "$rs1" && array_add reponames "$rs1"
setx rs2=__runsmod_replace2 "$repospec" "$host" "$module"
array_contains repolist "$rs2" && array_add reponames "$rs2"
fi
else
setx rs1=__runsmod_replace1 "$repospec" "" "$module"
array_contains repolist "$rs1" && array_add reponames "$rs1"
fi
fi
fi
edebug "........ reponames=(${reponames[*]})"
for reponame in "${reponames[@]}"; do
repodir="$RUNSMOD_BASEDIR/$repopath/$reponame"
edebug "........ reponames=(${reponames[*]})"
for reponame in "${reponames[@]}"; do
repodir="$RUNSMOD_BASEDIR/$repopath/$reponame"
setx repourl=__runsmod_fixurl "$reponame" "$baseurl"
__runsmod_clone_or_pull "$repourl" "$repodir" || r=1
setx repourl=__runsmod_fixurl "$reponame" "$baseurl"
setx repodir=__runsmod_mapdir "$repodir" "$RUNSMOD_BASEDIR/$repopath"
__runsmod_clone_or_pull "$repourl" "$repodir" || r=1
[ -d "$repodir" ] || continue
array_contains REPODIRS "$repodir" && continue
array_addu REPODIRS "$repodir"
[ -z "$all_modules" ] && array_addu foundmodules "$module"
[ -d "$repodir" ] || continue
array_contains REPODIRS "$repodir" && continue
array_addu REPODIRS "$repodir"
[ -z "$all_modules" ] && array_addu foundmodules "$module"
repodir="$repodir$reposuffix"
case "$vprefix" in
SCRIPTS) array_addu SCRIPTSDIRS "$repodir";;
MODULES)
setx moduledir=dirname -- "$repodir"
array_addu MODULESDIRS "$moduledir"
;;
HOSTS) array_addu HOSTSDIRS "$repodir";;
esac
for reposuffix in "${reposuffixes[@]}"; do
case "$vprefix" in
SCRIPTS) array_addu SCRIPTSDIRS "$repodir$reposuffix";;
MODULES)
setx moduledir=dirname -- "$repodir$reposuffix"
array_addu MODULESDIRS "$moduledir"
;;
HOSTS) array_addu HOSTSDIRS "$repodir$reposuffix";;
esac
done
done
done
done
done
@ -540,8 +639,228 @@ function runsmod_clone_or_pull() {
return $r
}
function runsmod_update_vars() {
local all_hosts host_mode="$1" host="$2"
case "$host_mode" in
none) host=;;
all) host=; all_hosts=1;;
self) host="${RUNSHOST:-$MYHOST}";;
esac
# le nom d'hôte doit être avec un domaine
[ -n "$host" -a "${host%%.*}" == "$host" -a -n "$RUNSDOMAIN" ] && host="$host.$RUNSDOMAIN"
# Calcul des répertoires d'hôte
for RUNSMOD_PROFILE in "${RUNSMOD_PROFILES[@]}"; do
__runsmod_get -a baseurls BASEURL
for baseurl in "${baseurls[@]}"; do
setx repopath=__runsmod_getpath_from_baseurl "$baseurl"
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
[ -f "$repolistfile" ] || continue
#edebug ".. baseurl=$baseurl, repopath=$repopath"
for vprefix in SCRIPTS MODULES HOSTS; do
__runsmod_get -a repourls "${vprefix}_URLS"
#edebug ".... vprefix=$vprefix, repourls=(${repourls[*]})"
for repospec in "${repourls[@]}"; do
#edebug "...... repospec=$repospec"
if [ "$vprefix" == HOSTS ]; then :
elif __runsmod_has_vhost "$repospec"; then
repospec="${repospec%%/%h*}"
else continue
fi
reposuffixes=("")
if [[ "$repospec" == *//* ]]; then
reposuffix="${repospec#*//}"
[ -n "$reposuffix" ] && reposuffix="/$reposuffix"
repospec="${repospec%%//*}"
reposuffixes=("$reposuffix")
fi
if setx repospec=__runsmod_mapdir "$repospec"; then
repodirs=("$repospec")
else
array_lsdirs repodirs "$RUNSMOD_BASEDIR/$repopath" "$repospec"
fi
for repodir in "${repodirs[@]}"; do
#edebug "........ repodir=$repodir"
[ -d "$repodir" ] || continue
for reposuffix in "${reposuffixes[@]}"; do
array_addu HOSTSDIRS "$repodir$reposuffix"
done
done
done
done
done
done
# Calcul des répertoires de module
for RUNSMOD_PROFILE in "${RUNSMOD_PROFILES[@]}"; do
__runsmod_get -a baseurls BASEURL
for baseurl in "${baseurls[@]}"; do
setx repopath=__runsmod_getpath_from_baseurl "$baseurl"
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
[ -f "$repolistfile" ] || continue
#edebug ".. baseurl=$baseurl, repopath=$repopath"
for vprefix in MODULES HOSTS; do
if [ "$vprefix" == HOSTS ]; then
__runsmod_get -a tmprepourls "${vprefix}_URLS"
repourls=()
for repourl in "${tmprepourls[@]}"; do
if __runsmod_has_vmodule "$repourl"; then
array_add repourls "$repourl"
else
array_add repourls "$repourl/%h/modules"
array_add repourls "$repourl/%h"
fi
done
else
__runsmod_get -a repourls "${vprefix}_URLS"
fi
#edebug ".... vprefix=$vprefix, repourls=(${repourls[*]})"
for repospec in "${repourls[@]}"; do
#edebug "...... repospec=$repospec"
repospec="${repospec%%/%m*}"
reposuffixes=("")
if [[ "$repospec" == *//* ]]; then
reposuffix="${repospec#*//}"
[ -n "$reposuffix" ] && reposuffix="/$reposuffix"
repospec="${repospec%%//*}"
if __runsmod_has_vhost "$reposuffix"; then
if [ -n "$all_hosts" -o -z "$host" ]; then
reposuffix="${reposuffix//%h\//}"
reposuffix="${reposuffix//\/%h/}"
reposuffixes=("$reposuffix")
elif [ -n "$host" ]; then
local rs1 rs2
setx rs1=__runsmod_replace1 "$reposuffix" "$host"
setx rs2=__runsmod_replace2 "$reposuffix" "$host"
reposuffixes=("$rs1")
[ "$rs2" != "$rs1" ] && array_add reposuffixes "$rs2"
fi
else
reposuffixes=("$reposuffix")
fi
fi
repospecs=()
if __runsmod_has_vhost "$repospec"; then
if [ -n "$all_hosts" ]; then
setx rs1=__runsmod_replace1 "$repospec" "*"
array_addu repospecs "$rs1"
elif [ -n "$host" ]; then
setx rs1=__runsmod_replace1 "$repospec" "$host"
array_addu repospecs "$rs1"
setx rs2=__runsmod_replace2 "$repospec" "$host"
array_addu repospecs "$rs2"
fi
else
array_addu repospecs "$repospec"
fi
#edebug "...... repospecs=(${repospecs[*]})"
for repospec in "${repospecs[@]}"; do
if setx repospec=__runsmod_mapdir "$repospec"; then
repodirs=("$repospec")
else
array_lsdirs repodirs "$RUNSMOD_BASEDIR/$repopath" "$repospec"
fi
for repodir in "${repodirs[@]}"; do
#edebug "........ repodir=$repodir"
[ -d "$repodir" ] || continue
for reposuffix in "${reposuffixes[@]}"; do
array_addu MODULESDIRS "$repodir$reposuffix"
done
done
done
done
done
done
done
# Calcul des répertoires de script
for RUNSMOD_PROFILE in "${RUNSMOD_PROFILES[@]}"; do
__runsmod_get -a baseurls BASEURL
for baseurl in "${baseurls[@]}"; do
setx repopath=__runsmod_getpath_from_baseurl "$baseurl"
setx repolistfile=__runsmod_get_repolistfile "$baseurl"
[ -f "$repolistfile" ] || continue
#edebug ".. baseurl=$baseurl, repopath=$repopath"
for vprefix in SCRIPTS HOSTS; do
__runsmod_get -a repourls "${vprefix}_URLS"
#edebug ".... vprefix=$vprefix, repourls=(${repourls[*]})"
for repospec in "${repourls[@]}"; do
#edebug "...... repospec=$repospec"
if [ "$vprefix" == HOSTS ]; then
__runsmod_has_vhost "$repospec" || repospec="$repospec/%h/runs"
fi
reposuffixes=("")
if [[ "$repospec" == *//* ]]; then
reposuffix="${repospec#*//}"
[ -n "$reposuffix" ] && reposuffix="/$reposuffix"
repospec="${repospec%%//*}"
if __runsmod_has_vhost "$reposuffix"; then
if [ -n "$all_hosts" -o -z "$host" ]; then
reposuffix="${reposuffix//%h\//}"
reposuffix="${reposuffix//\/%h/}"
reposuffixes=("$reposuffix")
elif [ -n "$host" ]; then
local rs1 rs2
setx rs1=__runsmod_replace1 "$reposuffix" "$host"
setx rs2=__runsmod_replace2 "$reposuffix" "$host"
reposuffixes=("$rs1")
[ "$rs2" != "$rs1" ] && array_add reposuffixes "$rs2"
fi
else
reposuffixes=("$reposuffix")
fi
fi
repospecs=()
if __runsmod_has_vhost "$repospec"; then
if [ -n "$all_hosts" ]; then
setx rs1=__runsmod_replace1 "$repospec" "*"
array_addu repospecs "$rs1"
elif [ -n "$host" ]; then
setx rs1=__runsmod_replace1 "$repospec" "$host"
array_addu repospecs "$rs1"
setx rs2=__runsmod_replace2 "$repospec" "$host"
array_addu repospecs "$rs2"
fi
else
array_addu repospecs "$repospec"
fi
#edebug "...... repospecs=(${repospecs[*]})"
for repospec in "${repospecs[@]}"; do
if setx repospec=__runsmod_mapdir "$repospec"; then
repodirs=("$repospec")
else
array_lsdirs repodirs "$RUNSMOD_BASEDIR/$repopath" "$repospec"
fi
for repodir in "${repodirs[@]}"; do
#edebug "........ repodir=$repodir"
[ -d "$repodir" ] || continue
for reposuffix in "${reposuffixes[@]}"; do
array_addu SCRIPTSDIRS "$repodir$reposuffix"
done
done
done
done
done
done
done
}
function runsmod_teardown_vars() {
setx RUNSSCRIPTSPATH=array_join SCRIPTSDIRS :
setx RUNSMODULESPATH=array_join MODULESDIRS :
setx RUNSHOSTSPATH=array_join HOSTSDIRS :
[ -n "$RUNSSCRIPTSPATH" ] || RUNSSCRIPTSPATH=:
[ -n "$RUNSMODULESPATH" ] || RUNSMODULESPATH=:
[ -n "$RUNSHOSTSPATH" ] || RUNSHOSTSPATH=:
}

View File

@ -11,11 +11,36 @@ RUNSMOD_SHALLOW=auto
RUNSMOD_UPDATE=auto
RUNSMOD_IDENTITY=
RUNSMOD_BASEURL=
RUNSMOD_SCRIPTS_URLS=(hosts/%h/runs hosts/%h/all//runs runss)
RUNSMOD_MODULES_URLS=(hosts/%h/modules/%m hosts/%h/all modules/%m)
RUNSMOD_HOSTS_URLS=(runsh)
RUNSMOD_SCRIPTS_URLS=(
hosts/%h/runs
hosts/%h/all//runs
runss
)
RUNSMOD_MODULES_URLS=(
hosts/%h/modules/%m
hosts/%h/%m
hosts/%h/all//modules
hosts/%h/all
# quand on supportera %n
#hosts/all/%n/%m
modules/%m
)
RUNSMOD_HOSTS_URLS=(
runsh
)
RUNSMOD_BASEDIR="$HOME/runs"
RUNSMOD_PROFILES=(pvcs vcs jclain)
RUNSMOD_MAP=(
# mapping par défaut
runss:"$HOME/wop/runs"
modules:"$HOME/wop/modules"
hosts:"$HOME/wop/hosts"
runsh:"$HOME/wop/hosts/all/hosts"
)
RUNSMOD_PROFILES=(
pvcs
vcs
jclain
)
# pvcs
RUNSMOD_pvcs_BASEURL=(http://pvcs.univ.run/anongit http://pvcs.univ-reunion.fr/anongit)
@ -23,6 +48,13 @@ RUNSMOD_pvcs_devel_BASEURL=pgit@vcs.univ.run
RUNSMOD_pvcs_SCRIPTS_URLS=("${RUNSMOD_SCRIPTS_URLS[@]}" si/base-runs)
RUNSMOD_pvcs_MODULES_URLS=("${RUNSMOD_MODULES_URLS[@]}")
RUNSMOD_pvcs_HOSTS_URLS=("${RUNSMOD_HOSTS_URLS[@]}")
RUNSMOD_pvcs_MAP=(
si/base-runs:"$HOME/wop/legacy-runs"
runss:"$HOME/wop/runs"
modules:"$HOME/wop/pmodules"
hosts:"$HOME/wop/hosts"
runsh:"$HOME/wop/hosts/all/hosts"
)
# vcs
RUNSMOD_vcs_BASEURL=(http://vcs.univ.run/anongit http://vcs.univ-reunion.fr/anongit)
@ -30,9 +62,21 @@ RUNSMOD_vcs_devel_BASEURL=git@vcs.univ.run
RUNSMOD_vcs_SCRIPTS_URLS=("${RUNSMOD_SCRIPTS_URLS[@]}")
RUNSMOD_vcs_MODULES_URLS=("${RUNSMOD_MODULES_URLS[@]}")
RUNSMOD_vcs_HOSTS_URLS=("${RUNSMOD_HOSTS_URLS[@]}")
RUNSMOD_vcs_MAP=(
runss:"$HOME/wop/pruns"
modules:"$HOME/wop/modules"
hosts:"$HOME/wop/hosts"
runsh:"$HOME/wop/hosts/all/phosts"
)
# jclain
RUNSMOD_jclain_BASEURL=git@jclain.fr
RUNSMOD_jclain_SCRIPTS_URLS=("${RUNSMOD_SCRIPTS_URLS[@]}")
RUNSMOD_jclain_MODULES_URLS=("${RUNSMOD_MODULES_URLS[@]}")
RUNSMOD_jclain_HOSTS_URLS=("${RUNSMOD_HOSTS_URLS[@]}")
RUNSMOD_jclain_MAP=(
runss:"$HOME/wop/j/runs"
modules:"$HOME/wop/j/modules"
hosts:"$HOME/wop/j/hosts"
runsh:"$HOME/wop/j/hosts/all/hosts"
)

View File

@ -3,7 +3,7 @@
##@cooked nocomments
##@require base
uprovide vcs
urequire base
urequire ulib base
################################################################################
# Général
@ -772,6 +772,14 @@ function git_is_merged() {
}
# fonctions pour git annex
function git_annex_use_ssh_wrapper() {
__UTOOLS_FORCE_PATH="$PATH"
__UTOOLS_FORCE_SSH="${GIT_SSH:-ssh}"
export __UTOOLS_FORCE_PATH __UTOOLS_FORCE_SSH
udelpath "$ULIBDIR/support/ssh-wrapper" __UTOOLS_FORCE_PATH
uinspath "$ULIBDIR/support/ssh-wrapper" PATH
}
function git_annex_initial() {
# sur le dépôt $1 fraichement cloné, vérifier s'il faut faire git annex
# init. Si oui, l'initialiser avec le nom d'hôte, et récupérer tous les

67
rruns
View File

@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS runs
urequire DEFAULTS runs runsmod
function display_help() {
uecho "$scriptname: Déploiement distant avec runs
@ -74,8 +74,9 @@ OPTIONS
argument (hors options)."
}
set_defaults runs
runs_before_parse_args
auto_runsmod=1
action=deploy
confuser=
tmproot=
@ -89,10 +90,14 @@ init=auto
init_sysinfos=
sysinfos_data=
runsscriptspath=
runsscriptsdirs=()
runsmodulespath=
runsmodulesdirs=()
runshostspath=
runshostsdirs=()
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
--no-auto-runsmod auto_runsmod= \
-C action=configure \
--configure: '$set@ confuser;action=configure' \
-T:,--tmproot: tmproot= \
@ -107,13 +112,14 @@ parse_opts "${PRETTYOPTS[@]}" \
--no-init init= \
--sysinfos init_sysinfos=1 \
--runsscriptspath: runsscriptspath= \
--runsscriptsdir: runsscriptsdirs \
--runsmodulespath: runsmodulespath= \
--runsmodulesdir: runsmodulesdirs \
--runshostspath: runshostspath= \
--runshostsdir: runshostsdirs \
@ args -- "$@" && set -- "${args[@]}" || die "$args"
[ -n "$runsscriptspath" ] && RUNSSCRIPTSPATH="$runsscriptspath"
[ -n "$runsmodulespath" ] && RUNSMODULESPATH="$runsmodulespath"
[ -n "$runshostspath" ] && RUNSHOSTSPATH="$runshostspath"
runs_after_parse_args
__PARSED_HOSTS=()
__PARSED_FILES=()
@ -178,6 +184,17 @@ function fix_hosts() {
array_map hosts __dot_is_localhost
}
function save_initial_paths() {
RUNSSCRIPTSPATH_BACKUP="$RUNSSCRIPTSPATH"
RUNSMODULESPATH_BACKUP="$RUNSMODULESPATH"
RUNSHOSTSPATH_BACKUP="$RUNSHOSTSPATH"
}
function restore_initial_paths() {
RUNSSCRIPTSPATH="$RUNSSCRIPTSPATH_BACKUP"
RUNSMODULESPATH="$RUNSMODULESPATH_BACKUP"
RUNSHOSTSPATH="$RUNSHOSTSPATH_BACKUP"
}
################################################################################
# Configuration de l'accès par clé aux hôtes
@ -204,12 +221,16 @@ if [ "$action" == "configure" ]; then
${tmproot:+--tmproot "$tmproot"} ${SSH:+-S "$SSH"} \
${force_make_archive:+--force-make-archive} \
-h "$user@$host" || continue
save_initial_paths
[ -n "$auto_runsmod" ] && runsmod_autoconf
etitle "Configuration initiale pour runs" \
"$scriptdir/runs" \
${runsscriptspath:+--runsscriptspath "$runsscriptspath"} \
${runsmodulespath:+--runsmodulespath "$runsmodulespath"} \
${runshostspath:+--runshostspath "$runshostspath"} \
--init -h "$host"
"$scriptdir/runs" --no-auto-runsmod \
--runsscriptspath "$RUNSSCRIPTSPATH" \
--runsmodulespath "$RUNSMODULESPATH" \
--runshostspath "$RUNSHOSTSPATH" \
--init -h "$host"
restore_initial_paths
done
exit 0
fi
@ -222,6 +243,8 @@ make_archive=
## Hôtes sur lesquels faire le déploiement
if array_isempty hosts; then
save_initial_paths
[ -n "$auto_runsmod" ] && runsmod_autoconf all
array_split hostsdirs "$RUNSHOSTSPATH" :
cwd="$(pwd)"
for hostsdir in "${hostsdirs[@]}"; do
@ -234,6 +257,7 @@ if array_isempty hosts; then
break
fi
done
restore_initial_paths
fi
if array_isempty hosts; then
read_value "Entrez une liste d'hôtes séparés par ':'" hosts "localhost"
@ -290,6 +314,9 @@ for userhost in "${hosts[@]}"; do
enote "Le nom d'hôte utilisé est $host"
fi
save_initial_paths
[ -n "$auto_runsmod" ] && runsmod_autoconf one "$host"
if [ "$host" != "localhost" ]; then
if [ -n "$init" ]; then
action=--init
@ -298,10 +325,10 @@ for userhost in "${hosts[@]}"; do
fi
estep "Vérification de la configuration de l'hôte pour runs"
"$scriptdir/runs" \
${runsscriptspath:+--runsscriptspath "$runsscriptspath"} \
${runsmodulespath:+--runsmodulespath "$runsmodulespath"} \
${runshostspath:+--runshostspath "$runshostspath"} \
"$scriptdir/runs" --no-auto-runsmod \
--runsscriptspath "$RUNSSCRIPTSPATH" \
--runsmodulespath "$RUNSMODULESPATH" \
--runshostspath "$RUNSHOSTSPATH" \
$action -h "$host" || { eend; continue; }
fi
@ -317,10 +344,12 @@ for userhost in "${hosts[@]}"; do
# Création de l'export
etitle "Préparation de l'export"
args=(--export --runsexportdir "$exportdir"
${runsscriptspath:+--runsscriptspath "$runsscriptspath"}
${runsmodulespath:+--runsmodulespath "$runsmodulespath"}
${runshostspath:+--runshostspath "$runshostspath"}
args=(
--no-auto-runsmod
--export --runsexportdir "$exportdir"
--runsscriptspath "$RUNSSCRIPTSPATH"
--runsmodulespath "$RUNSMODULESPATH"
--runshostspath "$RUNSHOSTSPATH"
)
[ "$host" != "localhost" ] && args=("${args[@]}" -h "$host")
[ -n "$runsreset" ] && args=("${args[@]}" -z)
@ -424,5 +453,7 @@ bits=$MYBITS"'
eend
fi
restore_initial_paths
eend
done

64
runs
View File

@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS runs
urequire DEFAULTS runs runsmod
function display_help() {
uecho "$scriptname: Lancer un script avec le protocole runs
@ -58,12 +58,16 @@ Gestion des scripts
-z Forcer la réinstallation des scripts qui se basent sur shouldrun/setdone"
}
set_defaults runs
function runs_path_required() {
die "Vous devez définir $1 dans ~/etc/default/runs"
}
function runs_path_undefined() {
ewarn "La variable $1 n'est pas définie dans ~/etc/default/runs"
}
runs_before_parse_args
auto_runsmod=1
action=runs
create_verbose=
init_sysinfos=--NOT-SET--
@ -77,14 +81,18 @@ runssysdist=
runssysver=
runsbits=
runsscriptspath=
runsscriptsdirs=()
runsmodulespath=
runsmodulesdirs=()
runshostspath=
runshostsdirs=()
runsexportdir= # répertoire dans lequel exporter les fichiers
runsworkdir= # si runsexportdir n'est pas spécifié, répertoire de travail
runsvarsfile= # fichier contenant des définitions à charger
runs_init "$scriptdir"
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
--no-auto-runsmod auto_runsmod= \
--i '$action=init;create_verbose=false' \
--init '$action=init;create_verbose=true' \
--verify action=verify \
@ -106,17 +114,18 @@ parse_opts "${PRETTYOPTS[@]}" \
--sysver: runssysver= \
--bits: runsbits= \
--runsscriptspath: runsscriptspath= \
--runsscriptsdir: runsscriptsdirs \
--runsmodulespath: runsmodulespath= \
--runsmodulesdir: runsmodulesdirs \
--runshostspath: runshostspath= \
--runshostsdir: runshostsdirs \
--runsexportdir: runsexportdir= \
--runsworkdir: runsworkdir= \
--runsvarsfile: runsvarsfile= \
-z RUNSRESET=1 \
@ args -- "$@" && set -- "${args[@]}" || die "$args"
[ -n "$runsscriptspath" ] && RUNSSCRIPTSPATH="$runsscriptspath"
[ -n "$runsmodulespath" ] && RUNSMODULESPATH="$runsmodulespath"
[ -n "$runshostspath" ] && RUNSHOSTSPATH="$runshostspath"
runs_after_parse_args
if [ "$action" == runs \
-o "$action" == init -o "$action" == verify \
@ -141,9 +150,11 @@ if [ "$action" == runs \
fi
fi
[ -n "$auto_runsmod" ] && runsmod_autoconf
if ! is_root && [ -n "$run_as_root" ]; then
# reconstruire la ligne de commande
args=()
args=(--no-auto-runsmod)
if [ "$action" == "init" ]; then
args=("${args[@]}" --init)
elif [ "$action" == "verify" ]; then
@ -210,8 +221,8 @@ bits=$MYBITS"
resolv_ips __runs_ips "$runshost"
if [ -z "${__runs_ips[*]}" ]; then
eerror "$runshost ne semble pas être une adresse valide."
ask_yesno "Voulez-vous réellement utiliser cette adresse, bien qu'elle n'existe pas dans le DNS?" N || die
check_interaction -c && eerror "$runshost ne semble pas être une adresse valide."
ask_yesno "Voulez-vous réellement utiliser cette adresse, bien qu'elle n'existe pas dans le DNS?" C || die
fi
if [ "$action" == "init" ]; then
@ -220,8 +231,8 @@ bits=$MYBITS"
################################################################################
elif [ "$action" == "create" ]; then
__runs_setpath
if [ -n "$runshost" ]; then
__runs_setpath
[ -n "${RUNSHOSTSDIRS[*]}" ] || runs_path_required RUNSHOSTSPATH
etitle "$runshost" runs_initdir "$runshost" "$create_verbose"
fi
@ -267,9 +278,9 @@ elif [ "$action" == "list" ]; then
}
__runs_setpath
[ -n "${RUNSSCRIPTSDIRS[*]}" ] || runs_path_required RUNSSCRIPTSPATH
[ -n "${RUNSMODULESDIRS[*]}" ] || runs_path_required RUNSMODULESPATH
[ -z "$runshost" -o -n "${RUNSHOSTSDIRS[*]}" ] || runs_path_required RUNSHOSTSPATH
[ -n "${RUNSSCRIPTSDIRS[*]}" ] || runs_path_undefined RUNSSCRIPTSPATH
[ -n "${RUNSMODULESDIRS[*]}" ] || runs_path_undefined RUNSMODULESPATH
[ -z "$runshost" -o -n "${RUNSHOSTSDIRS[*]}" ] || runs_path_undefined RUNSHOSTSPATH
splithost "$runshost" hostname domain
@ -310,12 +321,27 @@ elif [ "$action" == "list" ]; then
################################################################################
elif [ "$action" == "runs" ]; then
if [ -n "${rscripts[*]}" ]; then
# sans l'option -f, il faut définir RUNS*PATH
__runs_setpath
[ -n "${RUNSSCRIPTSDIRS[*]}" ] || runs_path_required RUNSSCRIPTSPATH
[ -n "${RUNSMODULESDIRS[*]}" ] || runs_path_required RUNSMODULESPATH
[ -z "$runshost" -o -n "${RUNSHOSTSDIRS[*]}" ] || runs_path_required RUNSHOSTSPATH
__runs_setpath
if [ -z "${rscripts[*]}" -a -z "${recipes[*]}" ]; then
# sans les options -f et -r, prendre par défaut le répertoire courant
# comme répertoire de script, de module et d'hôtes
refix=
[ -n "${RUNSSCRIPTSDIRS[*]}" ] || {
runs_path_undefined RUNSSCRIPTSPATH
setx RUNSSCRIPTSPATH=pwd
refix=1
}
[ -n "${RUNSMODULESDIRS[*]}" ] || {
runs_path_undefined RUNSMODULESPATH
setx RUNSMODULESPATH=pwd
refix=1
}
[ -z "$runshost" -o -n "${RUNSHOSTSDIRS[*]}" ] || {
runs_path_undefined RUNSHOSTSPATH
setx RUNSHOSTSPATH=pwd
refix=1
}
[ -n "$refix" ] && __runs_setpath
fi
# initialisation

View File

@ -217,14 +217,6 @@ done
################################################################################
# Traiter les commandes
function use_ssh_wrapper() {
__UTOOLS_FORCE_PATH="$PATH"
__UTOOLS_FORCE_SSH="${GIT_SSH:-ssh}"
export __UTOOLS_FORCE_PATH __UTOOLS_FORCE_SSH
udelpath "$scriptdir/lib/ssh-wrapper" __UTOOLS_FORCE_PATH
uinspath "$scriptdir/lib/ssh-wrapper" PATH
}
if [ "$CMD" == "grep" ]; then
## grep
if [ $# -eq 1 -a "$1" == "--help" ]; then
@ -259,7 +251,7 @@ elif array_contains GITANNEX_CMDS "$CMD"; then
git annex sync
fi
}
use_ssh_wrapper
git_annex_use_ssh_wrapper
case "$CMD" in
annex) git annex "$@";;
xsync) xsync;;
@ -280,9 +272,14 @@ elif [ "$CMD" == clone ]; then
fi
[ -d "$destdir" ] && die "$(ppath "$destdir"): répertoire existant"
use_ssh_wrapper
git_annex_use_ssh_wrapper
git clone "$repourl" "$destdir" || die
( cd "$destdir"; git_have_rbranch develop && git checkout develop ) || die
(
cd "$destdir"
if git_have_rbranch develop; then
git checkout develop || exit 1
fi
) || die
git_annex_initial "$destdir" || die
elif [ "$CMD" == crone ]; then
@ -307,7 +304,7 @@ elif [ "$CMD" == crone ]; then
userhost="$user@$host"
[ -n "$path" ] || die "Vous devez spécifier le chemin du dépôt git"
use_ssh_wrapper
git_annex_use_ssh_wrapper
ssh "$userhost" create "$path" || die
if [ -n "$tmpdestdir" ]; then
setxx destname=abspath "$destdir" // basename