lw-build-system/update.sh

113 lines
2.2 KiB
Bash
Raw Normal View History

#!/bin/bash
#
2009-01-03 22:55:04 +00:00
# (c)2009, 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
2006-07-26 20:31:20 +01:00
[ -z "${VERBOSE}" ] && VERBOSE="0"
#
# Sort out directories, checking that we're looking at a real project,
# and eventually include the standard functions
#
X=$(pwd)
cd $1 || exit 1
2006-07-26 20:31:20 +01:00
if [ ! -e make.sh -o ! -L scripts/module-create.sh ]
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}
2006-07-26 20:31:20 +01:00
cd $(dirname $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
2006-07-26 20:31:20 +01:00
do_cmd_redir /dev/null ${SCRIPT_ROOT}/create.sh ${PROJECT_ROOT}/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
2006-07-26 20:31:20 +01:00
diff -ru --exclude='*.c' --exclude='*.cpp' --exclude='*.h' \
./ upgrade.tmp/${P} \
> upgrade.diff
2006-07-26 20:33:24 +01:00
case "$?" in
2006-07-26 20:31:20 +01:00
0)
print_success "Already up to date."
rm upgrade.diff
;;
1)
print_success "Upgrade complete. See upgrade.diff for diff."
;;
2)
print_failure "Diff failed."
cleanup
;;
esac
rm -rf upgrade.tmp
2006-07-26 20:31:20 +01:00
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