Hash :
67c142b1
Author :
Thomas de Grivel
Date :
2019-10-06T17:25:35
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/bin/sh
set -e
DIR="$PWD"
NAME="$1"
cd "$(dirname "$0")"
cd ..
ROL_DIR="$PWD"
cd skel
ROL_SKEL_DIR="$PWD"
mkdir -p "$DIR/$NAME"
cd "$DIR/$NAME"
DIR="$PWD"
VARS=""
VARS="$VARS -e s:@{NAME}:$NAME:g"
VARS="$VARS -e s:@{ROL_DIR}:$ROL_DIR:g"
cd "$ROL_SKEL_DIR/skel"
find | while read SKEL; do
if [ -d "$SKEL" ]; then
echo "D $SKEL"
mkdir -p "$DIR/$SKEL"
elif [ -f "$SKEL" ]; then
echo "F $SKEL"
sed $VARS < "$SKEL" > "$DIR/$SKEL.tmp"
if [ -f "$DIR/$SKEL" ]; then
if cmp "$DIR/$SKEL.tmp" "$DIR/$SKEL"; then
rm "$DIR/$SKEL.tmp"
else
diff -u "$DIR/$SKEL" "$DIR/$SKEL.tmp"
fi
else
mv "$DIR/$SKEL.tmp" "$DIR/$SKEL"
fi
elif [ -h "$SKEL" ]; then
TARGET="$(readlink "$SKEL" | sed $VARS)"
echo "L $SKEL -> $TARGET"
ln -s "$TARGET" "$DIR/$SKEL"
else
echo "? $SKEL"
fi
done