diff --git a/dk b/dk index fda926e..1bd7046 100755 --- a/dk +++ b/dk @@ -806,21 +806,39 @@ function build_update_apps() { if [ -d "$SRC" ]; then [ -n "$have_RSYNC_OPTS" ] || RSYNC_OPTS=(--delete --delete-excluded) local -a rsync_opts; rsync_opts=(-a --exclude .git/ "${RSYNC_OPTS[@]}") + SRC="${SRC%/}/" - DEST="${DEST%/}/" + DEST="${DEST%/}" + if [ ! -d "$DEST" ]; then + # s'assurer que le répertoire parent existe + mkdir -p "$(dirname -- "$DEST")" || { eend; return 1; } + fi + DEST="$DEST/" + estep "Synchro $SRC --> $DEST" rsync "${rsync_opts[@]}" "$SRC" "$DEST" || { eend; return 1; } + elif [ -f "$SRC" ]; then [ -n "$have_RSYNC_OPTS" ] || RSYNC_OPTS=() local -a rsync_opts; rsync_opts=(-a "${RSYNC_OPTS[@]}") - if [ "${DEST%/}" != "$DEST" -o -d "$DEST" ]; then - DEST="${DEST%/}/" - estep "Synchro $SRC --> $DEST" - rsync "${rsync_opts[@]}" "$SRC" "$DEST" || { eend; return 1; } - else - estep "Synchro $SRC --> $DEST" - rsync "${rsync_opts[@]}" "$SRC" "$DEST" || { eend; return 1; } + + if [ "${DEST%/}" != "$DEST" -a ! -d "$DEST" ]; then + # on demande à ce que DEST soit un répertoire mais il + # n'existe pas: le créer + DEST="${DEST%/}" + mkdir -p "$DEST" || { eend; return 1; } fi + + if [ -d "$DEST" ]; then + DEST="$DEST/" + elif [ ! -f "$DEST" ]; then + # la destination n'existe pas: s'assurer que le répertoire + # parent existe + mkdir -p "$(dirname -- "$DEST")" || { eend; return 1; } + fi + estep "Synchro $SRC --> $DEST" + rsync "${rsync_opts[@]}" "$SRC" "$DEST" || { eend; return 1; } + else eerror "$app: $SRC: répertoire/fichier introuvable" eend; return 1