lw-build-system/update.sh

95 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
#
# (c)2006, Laurence Withers. Released under the GNU GPL. See file
# COPYING for details.
#
if [ $# -ne 1 ]
then
echo "Updates an existing project to newer lw-build-system files."
echo "Usage: $0 path/to/project/root"
exit 1
fi
#
# Sort out directories, checking that we're looking at a real project,
# and eventually include the standard functions
#
X=$(pwd)
cd $1 || exit 1
if [ ! -e make.sh -o ! -L scripts ]
then
echo "This doesn't look like an lw-build-system project to me."
exit 1
fi
PROJECT_ROOT=$(pwd)
P=$(basename ${PROJECT_ROOT})
cd ${X}
cd $(basename $0) || exit 1
SCRIPT_ROOT=$(pwd)
source skel/scripts/functions.sh || exit 1
do_cmd cd ${PROJECT_ROOT} || exit 1
#
# Prepare a 'new' project installation
#
echo "Beginning upgrade..."
if [ -e upgrade.tmp -o -e upgrade.diff ]
then
print_failure "upgrade.tmp or upgrade.diff exist -- not overwriting"
exit 1
fi
cleanup() {
cd ${PROJECT_ROOT}
rm -rf upgrade.tmp upgrade.diff
print_failure "Removed upgrade temporary files."
exit 1
}
do_cmd mkdir upgrade.tmp || cleanup
do_cmd ${SCRIPT_ROOT}/create.sh upgrade.tmp ${P} || cleanup
for module in src/*
do
M=$(basename ${module})
echo " Upgrading ${module}"
if [ ! -e ${module}/.params ]
then
FAILED="${FAILED}
- ${module}/.params missing (custom module?)"
continue
fi
upgrade.tmp/${P}/scripts/module-create.sh $(cat ${module}/.params) > /dev/null
if [ $? -ne 0 ]
then
FAILED="${FAILED}
- ${module} could not be recreated (invalid params?)"
continue
fi
done
do_cmd_redir upgrade.diff \
diff -ru --exclude='*.c' --exclude='*.cpp' --exclude='*.h' \
./ upgrade.tmp/${P} | grep -v '^Only in' || cleanup
rm -rf upgrade.tmp
print_success "Upgrade complete. See upgrade.diff for diff."
if [ ! -z ${FAILED} ]
then
print_failure "Upgrading of these modules failed: ${FAILED}"
fi
true
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4