2006-07-24 14:24:06 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# (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
|
2006-07-24 22:04:40 +01:00
|
|
|
if [ $# -ne 2 ]
|
2006-07-24 14:24:06 +01:00
|
|
|
then
|
|
|
|
echo "Wrong number of arguments. Expecting:"
|
2006-07-24 22:04:40 +01:00
|
|
|
echo " ./install.sh <dest_dir> @P@ "
|
2006-07-24 14:24:06 +01:00
|
|
|
echo " dest_dir directory in which project subdir will be created"
|
2006-07-24 22:04:40 +01:00
|
|
|
echo " @P@ package name)"
|
2006-07-24 14:24:06 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$(dirname $0)"
|
2006-07-24 14:29:53 +01:00
|
|
|
TEMPLATE="$(pwd)/skel"
|
2006-07-24 14:24:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get arguments, include standard functions
|
2006-07-24 14:29:53 +01:00
|
|
|
source ${TEMPLATE}/scripts/functions.sh || exit 1
|
2006-07-24 14:24:06 +01:00
|
|
|
DEST_DIR="$1"; shift
|
|
|
|
P="$1"; shift
|
|
|
|
|
2006-07-24 14:37:44 +01:00
|
|
|
DEST_DIR="${DEST_DIR}/${P}"
|
|
|
|
|
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)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Move the project files to something more sensible
|
|
|
|
mv project.kdevelop ${P}.kdevelop
|
|
|
|
mv project.kdevelop.filelist ${P}.kdevelop.filelist
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-07-24 22:04:40 +01:00
|
|
|
|
|
|
|
# Substitute all relevant variables in files
|
|
|
|
echo " Substituting variables in files"
|
|
|
|
AUTHOR="$(grep ^$(whoami): /etc/passwd | cut -d: -f 5)"
|
|
|
|
YEAR="$(date +%Y)"
|
|
|
|
do_cmd find . -type f -exec sed \
|
|
|
|
-e "s,@P@,${P},g" \
|
|
|
|
-e "s,@AUTHOR@,${AUTHOR},g" \
|
2006-07-24 22:10:30 +01:00
|
|
|
-e "s,@YEAR@,${YEAR},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"
|