Branch
Hash :
caa04c73
Author :
Thomas de Grivel
Date :
2019-10-14T19:38:39
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 47 48
#!/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"
echo "Creating $NAME"
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
TARGET="$(echo "$SKEL" | sed $VARS)"
echo "F $TARGET"
sed $VARS < "$SKEL" > "$DIR/$TARGET.tmp"
if [ -f "$DIR/$TARGET" ]; then
if cmp "$DIR/$TARGET" "$DIR/$TARGET.tmp"; then
rm "$DIR/$TARGET.tmp"
else
diff -u "$DIR/$TARGET" "$DIR/$TARGET.tmp"
fi
else
mv "$DIR/$TARGET.tmp" "$DIR/$TARGET"
fi
elif [ -h "$SKEL" ]; then
TARGET="$(readlink "$SKEL" | sed $VARS)"
echo "L $SKEL -> $TARGET"
ln -sf "$TARGET" "$DIR/$SKEL"
else
echo "? $SKEL"
fi
done