diff --git a/lib/default/runs b/lib/default/runs index d92fb23..5036122 100644 --- a/lib/default/runs +++ b/lib/default/runs @@ -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é diff --git a/lib/ulib/runs b/lib/ulib/runs index 7b3b0b1..4fa2f06 100644 --- a/lib/ulib/runs +++ b/lib/ulib/runs @@ -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" diff --git a/lib/ulib/runsmod b/lib/ulib/runsmod index 4f8b491..05949c1 100644 --- a/lib/ulib/runsmod +++ b/lib/ulib/runsmod @@ -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=: } diff --git a/lib/ulib/runsmod.defaults b/lib/ulib/runsmod.defaults index cdf6fb7..d75b162 100644 --- a/lib/ulib/runsmod.defaults +++ b/lib/ulib/runsmod.defaults @@ -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" +) diff --git a/lib/ssh-wrapper/rsync b/lib/ulib/support/ssh-wrapper/rsync similarity index 100% rename from lib/ssh-wrapper/rsync rename to lib/ulib/support/ssh-wrapper/rsync diff --git a/lib/ssh-wrapper/ssh b/lib/ulib/support/ssh-wrapper/ssh similarity index 100% rename from lib/ssh-wrapper/ssh rename to lib/ulib/support/ssh-wrapper/ssh diff --git a/lib/ulib/vcs b/lib/ulib/vcs index 6c41d9c..e9923dd 100644 --- a/lib/ulib/vcs +++ b/lib/ulib/vcs @@ -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 diff --git a/rruns b/rruns index 0920594..cddb3d1 100755 --- a/rruns +++ b/rruns @@ -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 diff --git a/runs b/runs index 329c09c..89423ba 100755 --- a/runs +++ b/runs @@ -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 diff --git a/uproject b/uproject index 900a815..9d0e14d 100755 --- a/uproject +++ b/uproject @@ -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