Make it easy to create new packages

This commit is contained in:
Justine Tunney 2020-06-15 19:59:12 -07:00
parent b4269930f7
commit d23bb6612e
6 changed files with 90 additions and 36 deletions

View file

@ -10,6 +10,7 @@
DIR=${1:?need directory arg}
VAR=$(echo "$DIR" | tr a-z A-Z | tr / _)
DIRNAME=${DIR%/*}
BASENAME=${DIR##*/}
FILENAME="$DIR/$BASENAME"
MAKEFILE="$DIR/$BASENAME.mk"
@ -20,14 +21,20 @@ if [ -d "$DIR" ]; then
fi
mkdir -p "$DIR" &&
cp -R examples/package/new/* "$DIR" &&
cp -R examples/package/* "$DIR" &&
rm -f "$DIR/new.sh" &&
find "$DIR" -type f |
xargs sed -i -e "
s/EXAMPLES_PACKAGE/$VAR/g
s/examples\/package\/package/$FILENAME/g
s/examples\/package/$DIR/g
s~EXAMPLES_PACKAGE~$VAR~g
s~examples/package/package~$FILENAME~g
s~examples/package~$DIR~g
s~%AUTHOR%~$(git config user.name) <$(git config user.email)>~g
" &&
sed -i -e "
s~include $DIR/build.mk~# XXX: include $DIR/build.mk~
s~include $DIR/lib/build.mk~# XXX: include $DIR/lib/build.mk~
/#-φ-examples\/package\/new\.sh/i\
include $MAKEFILE
include $DIR/lib/build.mk
/#-φ-examples\/package\/new\.sh/i\
include $DIR/build.mk
" Makefile