Parameterise author and copyright year.
This commit is contained in:
parent
98a21838c8
commit
4667dab403
26 changed files with 40 additions and 61 deletions
49
install.sh
49
install.sh
|
|
@ -13,14 +13,12 @@
|
|||
|
||||
|
||||
# Sanity checks
|
||||
if [ $# -ne 4 ]
|
||||
if [ $# -ne 2 ]
|
||||
then
|
||||
echo "Wrong number of arguments. Expecting:"
|
||||
echo " ./install.sh <dest_dir> @P@ @PC@ @HEADER_NAME@"
|
||||
echo " ./install.sh <dest_dir> @P@ "
|
||||
echo " dest_dir directory in which project subdir will be created"
|
||||
echo " @P@ package name (e.g. \"libnmc\")"
|
||||
echo " @PC@ C identifier version of @P@, used in header etc."
|
||||
echo " @HEADER_NAME@ name of header (e.g. \"lw-support\" or \"nmc\")"
|
||||
echo " @P@ package name)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -33,11 +31,8 @@ TEMPLATE="$(pwd)/skel"
|
|||
source ${TEMPLATE}/scripts/functions.sh || exit 1
|
||||
DEST_DIR="$1"; shift
|
||||
P="$1"; shift
|
||||
PC="$1"; shift
|
||||
HEADER_NAME="$1"; shift
|
||||
|
||||
DEST_DIR="${DEST_DIR}/${P}"
|
||||
PMINUSL="-l$(echo ${P} | sed -e 's,^lib,,')"
|
||||
|
||||
|
||||
|
||||
|
|
@ -46,7 +41,8 @@ PMINUSL="-l$(echo ${P} | sed -e 's,^lib,,')"
|
|||
# user simply specified where the directory should be created.
|
||||
echo "Copying ${TEMPLATE} directory..."
|
||||
do_cmd cp -rp "${TEMPLATE}" "${DEST_DIR}" || exit 1
|
||||
cd "${DEST_DIR}"
|
||||
do_cmd cd "${DEST_DIR}" || exit 1
|
||||
do_cmd mkdir src || exit 1
|
||||
print_success "Done: $(pwd)"
|
||||
|
||||
|
||||
|
|
@ -57,28 +53,16 @@ mv project.kdevelop.filelist ${P}.kdevelop.filelist
|
|||
|
||||
|
||||
|
||||
# Build sed script
|
||||
echo "Changing variables..."
|
||||
echo -n " Building script ( "
|
||||
SED_SCRIPT="script.sed"
|
||||
for param in P PC HEADER_NAME PMINUSL
|
||||
do
|
||||
echo "s,@${param}@,${!param},g" >> "${SED_SCRIPT}"
|
||||
echo -n "${PARAM} "
|
||||
done
|
||||
echo ")"
|
||||
|
||||
# Create a list of all the files.
|
||||
echo " Building list of files"
|
||||
ALL_FILES=$(find . -type f -not -name script.sed)
|
||||
|
||||
# Run sed script on all files.
|
||||
echo " Running script"
|
||||
for f in ${ALL_FILES}
|
||||
do
|
||||
do_cmd sed -f "${SED_SCRIPT}" -i "${f}" || exit 1
|
||||
done
|
||||
print_success "Done"
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
|
|
@ -87,8 +71,3 @@ echo
|
|||
echo " ======== TODO list ========"
|
||||
grep -Hn @TODO@ ${ALL_FILES}
|
||||
print_success "Done"
|
||||
|
||||
|
||||
|
||||
# Clean up
|
||||
rm "${SED_SCRIPT}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue