2007-08-14 14:34:41 +01:00
|
|
|
#!/bin/sh
|
2006-07-24 14:24:06 +01:00
|
|
|
#
|
|
|
|
# (c)2006, Laurence Withers. Released under the GNU GPL. See file
|
|
|
|
# COPYING for details.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Used to create a new project. You pass it the template parameters, it
|
|
|
|
# does the rest.
|
2006-07-24 14:49:31 +01:00
|
|
|
[ -z "${VERBOSE}" ] && VERBOSE="0"
|
2006-07-24 14:24:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Sanity checks
|
2007-08-13 19:56:44 +01:00
|
|
|
case "$#" in
|
|
|
|
1)
|
|
|
|
DEST_DIR="$(pwd)"
|
|
|
|
P="$1"
|
|
|
|
;;
|
|
|
|
2)
|
|
|
|
DEST_DIR="$1"
|
|
|
|
P="$2"
|
|
|
|
;;
|
|
|
|
**)
|
2006-07-26 19:57:53 +01:00
|
|
|
echo "Creates a new project using lw-build-system."
|
2007-08-13 19:56:44 +01:00
|
|
|
echo "Usage: $0 [path/to/projects] @P@"
|
2006-07-26 19:57:53 +01:00
|
|
|
echo " path/to/projects directory in which project subdir will be created"
|
|
|
|
echo " @P@ package name"
|
2006-07-24 14:24:06 +01:00
|
|
|
exit 1
|
2007-08-13 19:56:44 +01:00
|
|
|
;;
|
|
|
|
esac
|
2006-07-24 14:24:06 +01:00
|
|
|
|
|
|
|
cd "$(dirname $0)"
|
2006-07-24 14:29:53 +01:00
|
|
|
TEMPLATE="$(pwd)/skel"
|
2006-07-25 19:12:21 +01:00
|
|
|
DEVSCRIPTS="$(pwd)/scripts"
|
2006-07-24 14:24:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get arguments, include standard functions
|
2007-08-14 14:34:41 +01:00
|
|
|
source "${TEMPLATE}/scripts/functions.sh" || exit 1
|
2006-07-24 14:37:44 +01:00
|
|
|
DEST_DIR="${DEST_DIR}/${P}"
|
|
|
|
|
2006-07-24 14:24:06 +01:00
|
|
|
|
|
|
|
|
2006-07-25 18:41:03 +01:00
|
|
|
# Ensure that we have our .lwbuildrc set up correctly.
|
2007-08-14 14:34:41 +01:00
|
|
|
LWBUILDRC="${HOME}/.lwbuildrc"
|
|
|
|
if [ ! -e "${LWBUILDRC}" ]
|
2006-07-25 18:41:03 +01:00
|
|
|
then
|
|
|
|
echo "You don't have a ${LWBUILDRC}, so I'll create a blank one for you."
|
|
|
|
do_cmd cp skel-.lwbuildrc ${LWBUILDRC}
|
|
|
|
echo "Edit this file, and then re-run the build process."
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-07-25 19:19:59 +01:00
|
|
|
do_cmd source ${LWBUILDRC} || exit 1
|
2006-07-25 18:41:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2006-07-24 14:24:06 +01:00
|
|
|
# Copy to destination directory. Deal with the case where the user has
|
|
|
|
# specified the name of the resulting directory, and the case where the
|
|
|
|
# user simply specified where the directory should be created.
|
|
|
|
echo "Copying ${TEMPLATE} directory..."
|
|
|
|
do_cmd cp -rp "${TEMPLATE}" "${DEST_DIR}" || exit 1
|
2006-07-24 22:04:40 +01:00
|
|
|
do_cmd cd "${DEST_DIR}" || exit 1
|
|
|
|
do_cmd mkdir src || exit 1
|
2006-07-24 14:24:06 +01:00
|
|
|
print_success "Done: $(pwd)"
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-07-25 19:12:21 +01:00
|
|
|
# Fixups
|
|
|
|
echo "Installing symlinks, fixing up stuff..."
|
|
|
|
|
|
|
|
# Install devscript symlinks
|
|
|
|
do_cmd ln -s ${DEVSCRIPTS}/* scripts/ || exit 1
|
2006-07-24 14:24:06 +01:00
|
|
|
|
2006-07-25 19:12:21 +01:00
|
|
|
print_success "Done"
|
2006-07-24 14:24:06 +01:00
|
|
|
|
|
|
|
|
2006-07-24 22:04:40 +01:00
|
|
|
|
|
|
|
# Substitute all relevant variables in files
|
|
|
|
echo " Substituting variables in files"
|
|
|
|
YEAR="$(date +%Y)"
|
|
|
|
do_cmd find . -type f -exec sed \
|
|
|
|
-e "s,@P@,${P},g" \
|
|
|
|
-e "s,@AUTHOR@,${AUTHOR},g" \
|
2006-07-25 18:50:00 +01:00
|
|
|
-e "s,@EMAIL@,${EMAIL},g" \
|
2006-07-24 22:10:30 +01:00
|
|
|
-e "s,@YEAR@,${YEAR},g" \
|
2006-07-25 18:50:00 +01:00
|
|
|
-e "s,@KATE_MODELINE@,${KATE_MODELINE},g" \
|
|
|
|
-e "s,@VIM_MODELINE@,${VIM_MODELINE},g" \
|
2006-07-24 22:04:40 +01:00
|
|
|
-i {} \; || exit 1
|
2006-07-24 14:24:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Print the todo list
|
|
|
|
echo
|
|
|
|
echo " ======== TODO list ========"
|
2006-07-24 22:10:30 +01:00
|
|
|
find . -type f -a -not -path './scripts/build.*' -exec grep -Hrn @TODO@ {} \;
|
2006-07-24 14:24:06 +01:00
|
|
|
print_success "Done"
|
2006-07-25 18:41:03 +01:00
|
|
|
|
|
|
|
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
|
|
|
|
# vim: expandtab:ts=4:sw=4
|