pff: support des filtres à l'intégration
This commit is contained in:
parent
ee3b58354c
commit
13440e2fd9
78
pff
78
pff
|
@ -24,6 +24,7 @@ PFFCONFVARS=(
|
|||
"PROFILES//Profils définis"
|
||||
"ORIGEXTS=//Extensions origines"
|
||||
"MKDIRS//Répertoires qui doivent toujours exister"
|
||||
"FILTERS//Filtres appliqués aux fichiers lors de l'intégration"
|
||||
)
|
||||
|
||||
if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
|
||||
|
@ -110,7 +111,7 @@ complete -F __pff_completion -o bashdefault -o default pff
|
|||
fi
|
||||
|
||||
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
|
||||
urequire DEFAULTS multiconf vcs
|
||||
urequire DEFAULTS multiconf vcs javaproperties
|
||||
|
||||
function display_help() {
|
||||
uecho "$scriptname: gestion de modifications locales
|
||||
|
@ -528,6 +529,37 @@ function autofix() {
|
|||
autoselect "$1"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Filtres
|
||||
|
||||
function pff_filter_normalize_properties() {
|
||||
if [ $# -eq 0 ]; then
|
||||
__norm_properties
|
||||
else
|
||||
local mode r
|
||||
mode="$(fix_mode "$1")"
|
||||
norm_properties "$1"; r=$?
|
||||
unfix_mode "$1" "$mode"
|
||||
return $r
|
||||
fi
|
||||
}
|
||||
|
||||
function apply_filter() {
|
||||
# Appliquer les filtres définis au fichier $1 dans le projet pff $2
|
||||
# retourner 0 si un filtre a été appliqué avec succès, 1 si une erreur s'est
|
||||
# produite, 2 si aucun filtre n'existe pour ce fichier
|
||||
local pfile="$1" pffdir="$2"
|
||||
local rfile ffile filter r=2
|
||||
setx rfile=get_rfile "$pfile" "$pffdir"
|
||||
for filter in "${FILTERS[@]}"; do
|
||||
splitpair "$filter" ffile filter
|
||||
if [ "$ffile" == "$rfile" ]; then
|
||||
"pff_filter_$filter" "$pfile" && r=0 || r=1
|
||||
fi
|
||||
done
|
||||
return $r
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Commandes
|
||||
|
||||
|
@ -756,12 +788,17 @@ function new_cmd() {
|
|||
ebegin "Copie des fichiers"
|
||||
r=0
|
||||
for i in "${creates[@]}"; do
|
||||
mkdirof "$pffdir/$i"; r=$?
|
||||
edot $r "$i"; [ $r == 0 ] || break
|
||||
cp "$srcdir/$i" "$pffdir/$i"; r=$?
|
||||
edot $r "$i"; [ $r == 0 ] || break
|
||||
src="$srcdir/$i"
|
||||
dest="$pffdir/$i"
|
||||
mkdirof "$dest"; r=$?
|
||||
edot $r "mkdirof $i"; [ $r -eq 0 ] || break
|
||||
cp "$src" "$dest"; r=$?
|
||||
edot $r "create $i"; [ $r -eq 0 ] || break
|
||||
apply_filter "$dest" "$pffdir"; r=$?
|
||||
[ $r -eq 0 -o $r -eq 1 ] && edot $r "filter $i"
|
||||
[ $r -eq 2 ] && r=0; [ $r -eq 0 ] || break
|
||||
done
|
||||
[ $r == 0 ] || { eend $r; return 1; }
|
||||
[ $r -eq 0 ] || { eend $r; return 1; }
|
||||
for i in "${updates[@]}"; do
|
||||
src="$srcdir/$i"
|
||||
dest="$pffdir/$i"
|
||||
|
@ -771,14 +808,17 @@ function new_cmd() {
|
|||
continue
|
||||
fi
|
||||
cat "$src" >"$dest"; r=$?
|
||||
edot $r "$i"; [ $r == 0 ] || break
|
||||
edot $r "update $i"; [ $r -eq 0 ] || break
|
||||
apply_filter "$dest" "$pffdir"; r=$?
|
||||
[ $r -eq 0 -o $r -eq 1 ] && edot $r "filter $i"
|
||||
[ $r -eq 2 ] && r=0; [ $r -eq 0 ] || break
|
||||
done
|
||||
[ $r == 0 ] || { eend $r; return 1; }
|
||||
[ $r -eq 0 ] || { eend $r; return 1; }
|
||||
if [ -n "$full" ]; then
|
||||
# ne faire les suppression qu'en mode full
|
||||
for i in "${deletes[@]}"; do
|
||||
rm "$pffdir/$i"; r=$?
|
||||
edot $r "$i"; [ $r == 0 ] || break
|
||||
edot $r "delete $i"; [ $r -eq 0 ] || break
|
||||
done
|
||||
fi
|
||||
eend $r
|
||||
|
@ -847,13 +887,16 @@ function new_cmd() {
|
|||
src="$srcdir/${losrcs[$i]}"
|
||||
dest="$pffdir/$i"
|
||||
mkdirof "$dest"; r=$?
|
||||
edot $r "$i"; [ $r == 0 ] || break
|
||||
edot $r "mkdirof $i"; [ $r -eq 0 ] || break
|
||||
cp "$src" "$dest"; r=$?
|
||||
edot $r "$i"; [ $r == 0 ] || break
|
||||
edot $r "create $i"; [ $r -eq 0 ] || break
|
||||
apply_filter "$dest" "$pffdir"; r=$?
|
||||
[ $r -eq 0 -o $r -eq 1 ] && edot $r "filter $i"
|
||||
[ $r -eq 2 ] && r=0; [ $r -eq 0 ] || break
|
||||
add_global__link "$dest" "$pffdir"
|
||||
edot $r "$i"; [ $r == 0 ] || break
|
||||
edot $r "add_global $i"; [ $r -eq 0 ] || break
|
||||
done
|
||||
[ $r == 0 ] || { eend $r; return 1; }
|
||||
[ $r -eq 0 ] || { eend $r; return 1; }
|
||||
for i in "${updates[@]}"; do
|
||||
# du fait qu'on intègre fdeletes dans fupdates, il est possible que
|
||||
# le fichier n'existe pas dans la source. de plus, l'association
|
||||
|
@ -868,13 +911,16 @@ function new_cmd() {
|
|||
dest="$pffdir/pff/Base/$vlfile"
|
||||
if flexists "$src"; then
|
||||
mkdirof "$dest"; r=$?
|
||||
edot $r "$i"; [ $r == 0 ] || break
|
||||
edot $r "mkdirof $vlfile"; [ $r -eq 0 ] || break
|
||||
cp "$src" "$dest"; r=$?
|
||||
edot $r "$i"; [ $r == 0 ] || break
|
||||
edot $r "create $vlfile"; [ $r -eq 0 ] || break
|
||||
apply_filter "$dest" "$pffdir"; r=$?
|
||||
[ $r -eq 0 -o $r -eq 1 ] && edot $r "filter $vlfile"
|
||||
[ $r -eq 2 ] && r=0; [ $r -eq 0 ] || break
|
||||
array_add vlfiles "$vlfile"
|
||||
fi
|
||||
done
|
||||
[ $r == 0 ] || { eend $r; return 1; }
|
||||
[ $r -eq 0 ] || { eend $r; return 1; }
|
||||
eend $r
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue