diff --git a/lib/ulib/runsmod b/lib/ulib/runsmod index 4f8b491..89642d5 100644 --- a/lib/ulib/runsmod +++ b/lib/ulib/runsmod @@ -364,9 +364,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 repolist reposuffixes reponames repourls local RUNSMOD_PROFILE baseurl repopath repolistfile local vprefix repospec reposuffix reponame repourl repodir module moduledir local r=0 @@ -392,6 +391,21 @@ function runsmod_clone_or_pull() { 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 reposuffix= fi @@ -422,12 +436,13 @@ function runsmod_clone_or_pull() { array_contains REPODIRS "$repodir" && continue array_addu REPODIRS "$repodir" - repodir="$repodir$reposuffix" - case "$vprefix" in - SCRIPTS) array_addu SCRIPTSDIRS "$repodir";; - MODULES) array_addu MODULESDIRS "$repodir";; - HOSTS) array_addu HOSTSDIRS "$repodir";; - esac + 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 @@ -471,6 +486,21 @@ function runsmod_clone_or_pull() { 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 reposuffix= fi @@ -517,15 +547,16 @@ function runsmod_clone_or_pull() { 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