2020-06-16 02:01:28 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# SYNOPSIS
|
|
|
|
#
|
|
|
|
# Creates new package in repository.
|
|
|
|
#
|
|
|
|
# EXAMPLE
|
|
|
|
#
|
|
|
|
# examples/package/new.sh com/github/user/project
|
|
|
|
|
|
|
|
DIR=${1:?need directory arg}
|
|
|
|
VAR=$(echo "$DIR" | tr a-z A-Z | tr / _)
|
2020-06-16 02:59:12 +00:00
|
|
|
DIRNAME=${DIR%/*}
|
2020-06-16 02:01:28 +00:00
|
|
|
BASENAME=${DIR##*/}
|
|
|
|
FILENAME="$DIR/$BASENAME"
|
|
|
|
MAKEFILE="$DIR/$BASENAME.mk"
|
|
|
|
|
|
|
|
if [ -d "$DIR" ]; then
|
|
|
|
echo "already exists: $DIR" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "$DIR" &&
|
2020-06-16 02:59:12 +00:00
|
|
|
cp -R examples/package/* "$DIR" &&
|
|
|
|
rm -f "$DIR/new.sh" &&
|
2020-06-16 02:01:28 +00:00
|
|
|
find "$DIR" -type f |
|
|
|
|
xargs sed -i -e "
|
2020-06-16 02:59:12 +00:00
|
|
|
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
|
2020-06-16 02:01:28 +00:00
|
|
|
" &&
|
|
|
|
sed -i -e "
|
2020-06-16 02:59:12 +00:00
|
|
|
s~include $DIR/build.mk~# XXX: include $DIR/build.mk~
|
|
|
|
s~include $DIR/lib/build.mk~# XXX: include $DIR/lib/build.mk~
|
2020-06-16 02:01:28 +00:00
|
|
|
/#-φ-examples\/package\/new\.sh/i\
|
2020-06-16 02:59:12 +00:00
|
|
|
include $DIR/lib/build.mk
|
|
|
|
/#-φ-examples\/package\/new\.sh/i\
|
|
|
|
include $DIR/build.mk
|
2020-06-16 02:01:28 +00:00
|
|
|
" Makefile
|