lw-build-system/install.sh

74 lines
1.6 KiB
Bash
Executable File

#!/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.
[ -z "${VERBOSE}" ] && VERBOSE="0"
# Sanity checks
if [ $# -ne 2 ]
then
echo "Wrong number of arguments. Expecting:"
echo " ./install.sh <dest_dir> @P@ "
echo " dest_dir directory in which project subdir will be created"
echo " @P@ package name)"
exit 1
fi
cd "$(dirname $0)"
TEMPLATE="$(pwd)/skel"
# Get arguments, include standard functions
source ${TEMPLATE}/scripts/functions.sh || exit 1
DEST_DIR="$1"; shift
P="$1"; shift
DEST_DIR="${DEST_DIR}/${P}"
# 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
do_cmd cd "${DEST_DIR}" || exit 1
do_cmd mkdir src || exit 1
print_success "Done: $(pwd)"
# Move the project files to something more sensible
mv project.kdevelop ${P}.kdevelop
mv project.kdevelop.filelist ${P}.kdevelop.filelist
# 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" \
-e "s,@YEAR@,${YEAR},g"
-i {} \; || exit 1
# Print the todo list
echo
echo " ======== TODO list ========"
grep -Hn @TODO@ ${ALL_FILES}
print_success "Done"