2006-07-25 19:00:04 +01:00
|
|
|
#!/bin/bash
|
2006-07-25 19:19:59 +01:00
|
|
|
# lw-build-system/scripts/module-rename.sh
|
2006-07-25 19:00:04 +01:00
|
|
|
#
|
2006-07-25 19:19:59 +01:00
|
|
|
# (c)2006, Laurence Withers, <l@lwithers.me.uk>.
|
2006-07-25 19:00:04 +01:00
|
|
|
# Released under the GNU GPLv2. See file COPYING or
|
|
|
|
# http://www.gnu.org/copyleft/gpl.html for details.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Renames a source module (e.g. "src/oldlib" -> "src/newlib") by running
|
|
|
|
# a sed script on all files to change filenames / headers.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get the directory of the repository (needed to include functions file)
|
|
|
|
cd $(dirname $0)
|
|
|
|
cd $(dirname $(pwd))
|
|
|
|
[ -z "${VERBOSE}" ] && VERBOSE="0"
|
|
|
|
source scripts/functions.sh || exit 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get version etc.
|
|
|
|
if [ $# -ne 2 ]
|
|
|
|
then
|
|
|
|
echo "Usage: scripts/module-rename.sh <old> <new>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
OLD="src/$1"
|
|
|
|
NEW="src/$2"
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -e ${OLD} ]
|
|
|
|
then
|
|
|
|
print_failure "${OLD} does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e ${NEW} ]
|
|
|
|
then
|
|
|
|
print_failure "${NEW} already exists"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Moving ${OLD} -> ${NEW}"
|
|
|
|
do_cmd mv ${OLD} ${NEW} || exit 1
|
|
|
|
do_cmd find ${NEW} -type f -exec sed -e "s,${OLD},${NEW},g" -i {} \; || exit 1
|
|
|
|
print_success "Done"
|
|
|
|
|
|
|
|
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
|
|
|
|
# vim: expandtab:ts=4:sw=4
|