Intégration de la branche uenv-modifs
This commit is contained in:
commit
8286b2974f
2
bashrc
2
bashrc
|
@ -2,5 +2,5 @@
|
|||
|
||||
function uprovide() { :; }
|
||||
source @@dest@@/lib/ulib/uenv || return
|
||||
__uenv_source_dirs @@dest@@/bashrc.d "$HOME/etc/bashrc.d"
|
||||
__uenv_source_dirs @@dest@@/bashrc.d "$HOME/etc/bashrc.d" "$HOME/etc/${HOSTNAME%%.*}-bashrc.d"
|
||||
__uenv_cleanup
|
||||
|
|
|
@ -13,7 +13,7 @@ function __uenv_check_file() {
|
|||
|
||||
# ignorer les fichiers qui ont l'extension .ignore
|
||||
[ "${file%%.ignore}" != "$file" ] && return 1
|
||||
|
||||
|
||||
# tester si le fichier est spécifique à une plateforme
|
||||
local system
|
||||
system="$(expr "$file" : ".*\\.\\[\\([^.]*\\)\\]")"
|
||||
|
@ -23,16 +23,16 @@ function __uenv_check_file() {
|
|||
|
||||
# tester si le fichier est spécifique à une machine
|
||||
local host
|
||||
host="$(expr "$file" : ".*\\.on_\\([^.]*\\)")"
|
||||
host="$(expr "$file" : ".*\\.host-\\([^.]*\\)")"
|
||||
[ -n "$host" -a "$host" != "$__myhostname" ] && return 1
|
||||
host="$(expr "$file" : ".*\\.noton_\\([^.]*\\)")"
|
||||
host="$(expr "$file" : ".*\\.nothost-\\([^.]*\\)")"
|
||||
[ -n "$host" -a "$host" == "$__myhostname" ] && return 1
|
||||
|
||||
# tester si le fichier est spécifique à un utilisateur
|
||||
local user
|
||||
user="$(expr "$file" : ".*\\.for_\\([^.]*\\)")"
|
||||
user="$(expr "$file" : ".*\\.user-\\([^.]*\\)")"
|
||||
[ -n "$user" -a "$user" != "$USER" ] && return 1
|
||||
user="$(expr "$file" : ".*\\.notfor_\\([^.]*\\)")"
|
||||
user="$(expr "$file" : ".*\\.notuser-\\([^.]*\\)")"
|
||||
[ -n "$user" -a "$user" == "$USER" ] && return 1
|
||||
|
||||
return 0
|
||||
|
@ -57,7 +57,7 @@ function __uenv_source_dirs() {
|
|||
source "$sio"
|
||||
else
|
||||
for file in "$dir/"*; do
|
||||
if __uenv_check_file "$(dirname "$file")" "$(basename "$file")"; then
|
||||
if __uenv_check_file "$(dirname -- "$file")" "$(basename -- "$file")"; then
|
||||
source "$file"
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -119,6 +119,7 @@ function uenv_update_dir() {
|
|||
local __myhostname="$MYHOSTNAME"
|
||||
>"$sio"
|
||||
for file in "$dir/"*; do
|
||||
[ -f "$file" ] || continue
|
||||
file="$(basename "$file")"
|
||||
files=("${files[@]}" "$file")
|
||||
__uenv_check_file "$dir" "$file" && echo "$file" >>"$sio"
|
||||
|
@ -156,9 +157,13 @@ function uenv_update_dir() {
|
|||
}
|
||||
|
||||
function uenv_set_destdirs() {
|
||||
profiledestdir="$HOME/etc/profile.d"
|
||||
bashrcdestdir="$HOME/etc/bashrc.d"
|
||||
defaultdestdir="$HOME/etc/default"
|
||||
local hostname="${HOSTNAME%%.*}"
|
||||
shared_profiledestdir="$HOME/etc/profile.d"
|
||||
shared_bashrcdestdir="$HOME/etc/bashrc.d"
|
||||
shared_defaultdestdir="$HOME/etc/default"
|
||||
profiledestdir="$HOME/etc/${hostname}-profile.d"
|
||||
bashrcdestdir="$HOME/etc/${hostname}-bashrc.d"
|
||||
defaultdestdir="$HOME/etc/${hostname}-default"
|
||||
}
|
||||
|
||||
function uenv_sourced_in() {
|
||||
|
@ -227,23 +232,40 @@ function uenv_install_profiles() {
|
|||
for prefix in profile bashrc default; do
|
||||
envsrcdir="${prefix}dir"; envsrcdir="$projdir/${!envsrcdir}"
|
||||
envdestdir="${prefix}destdir"; envdestdir="${!envdestdir}"
|
||||
shadestdir="shared_${prefix}destdir"; shadestdir="${!shadestdir}"
|
||||
[ -n "$envsrcdir" -a -d "$envsrcdir" ] || continue
|
||||
|
||||
array_from_lines envfiles "$(list_files "$envsrcdir")"
|
||||
for envfile in "${envfiles[@]}"; do
|
||||
envsrc="$envsrcdir/$envfile"
|
||||
envdest="$envdestdir/$envfile"
|
||||
shadest="$shadestdir/$envfile"
|
||||
|
||||
mkdir -p "$envdestdir"
|
||||
mkdir -p "$envdestdir" "$shadestdir"
|
||||
if [ ! -f "$envdest" -a -f "$shadest" ]; then
|
||||
# Si déjà installé en partagé, continuer à mettre à jour ce
|
||||
# fichier-là
|
||||
envdest="$shadest"
|
||||
fi
|
||||
if [ ! -f "$envdest" ]; then
|
||||
estep "Installation du profil par défaut $envfile dans $(ppath "$envdestdir")"
|
||||
/bin/cp -f "$envsrc" "$envdestdir"
|
||||
elif [ "$prefix" != "default" ] && ! endswith "$envfile" ".userconf" && testdiff "$envdest" "$envsrc"; then
|
||||
elif [ "$prefix" == "default" ]; then
|
||||
# ne jamais mettre à jour dans default
|
||||
if testdiff "$envdest" "$envsrc"; then
|
||||
estepi "Le profil $(ppath "$envdest") a été conservé"
|
||||
fi
|
||||
elif endswith "$envfile" ".userconf"; then
|
||||
# ne jamais mettre à jour les fichiers .userconf
|
||||
if testdiff "$envdest" "$envsrc"; then
|
||||
estepi "Le profil $(ppath "$envdest") a été conservé"
|
||||
fi
|
||||
elif testdiff "$envdest" "$envsrc"; then
|
||||
estep "Le profil par défaut $envfile dans $(ppath "$envdestdir") a été modifié"
|
||||
if show_info; then
|
||||
eecho "Voici les différences détectées:"
|
||||
eecho ""
|
||||
diff -u "$envdest" "$envsrcdir" 1>&2
|
||||
diff -u "$envdest" "$envsrc" 1>&2
|
||||
eecho ""
|
||||
fi
|
||||
|
||||
|
|
2
profile
2
profile
|
@ -4,5 +4,5 @@
|
|||
|
||||
function uprovide() { :; }
|
||||
source @@dest@@/lib/ulib/uenv || return
|
||||
__uenv_source_dirs @@dest@@/profile.d "$HOME/etc/profile.d"
|
||||
__uenv_source_dirs @@dest@@/profile.d "$HOME/etc/profile.d" "$HOME/etc/${HOSTNAME%%.*}-profile.d"
|
||||
__uenv_cleanup
|
||||
|
|
4
uenv
4
uenv
|
@ -73,7 +73,7 @@ if [ -n "$update" ]; then
|
|||
continue
|
||||
fi
|
||||
|
||||
etitle -s "$(ppath "$projdir")"
|
||||
etitle "$(ppath "$projdir")"
|
||||
|
||||
install_profiles=false
|
||||
profiledir=lib/profile.d
|
||||
|
@ -100,7 +100,7 @@ if [ -n "$update" ]; then
|
|||
else
|
||||
## Mettre uniquement à jour l'ordre de chargement des fichiers
|
||||
## ~/etc/{profile.d,bashrc.d}
|
||||
for dir in "$profiledestdir" "$bashrcdestdir"; do
|
||||
for dir in "$shared_profiledestdir" "$shared_bashrcdestdir" "$profiledestdir" "$bashrcdestdir"; do
|
||||
[ -d "$dir" ] || continue
|
||||
estep "Mise à jour de $(ppath "$dir")"
|
||||
uenv_update_dir "$dir" "$envsetup_tmpfile"
|
||||
|
|
Loading…
Reference in New Issue