123 lines
2.3 KiB
Bash
Executable File
123 lines
2.3 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
|
|
|
|
[ -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
|
|
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}
|
|
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
|
|
echo "DEBUG START"
|
|
ls
|
|
ls upgrade.tmp
|
|
echo "DEBUG END"
|
|
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
|
|
|
|
diff -ru --exclude='*.c' --exclude='*.cpp' --exclude='*.h' \
|
|
./ upgrade.tmp/${P} \
|
|
| grep -v '^Only in' \
|
|
> upgrade.diff
|
|
if [ $? -eq 2 ]
|
|
then
|
|
print_failure "diff failed."
|
|
cleanup
|
|
fi
|
|
|
|
case $? in
|
|
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
|
|
|
|
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
|