Fix removing existing directories by chmod'ing them to be user-writeable.

/trunk/scripts/crosstool.sh |   21    10    11     0 ++++++++++-----------
 /trunk/scripts/functions    |    7     7     0     0 +++++++
 2 files changed, 17 insertions(+), 11 deletions(-)
This commit is contained in:
Yann E. MORIN" 2009-01-12 21:35:23 +00:00
parent 25c6b869cf
commit 83f0bec915
2 changed files with 17 additions and 11 deletions

View File

@ -141,7 +141,7 @@ CT_DoLog EXTRA "Preparing working directories"
# Ah! The build directory shall be eradicated, even if we restart! # Ah! The build directory shall be eradicated, even if we restart!
if [ -d "${CT_BUILD_DIR}" ]; then if [ -d "${CT_BUILD_DIR}" ]; then
CT_DoExecLog ALL rm -rf "${CT_BUILD_DIR}" CT_DoForceRmdir "${CT_BUILD_DIR}"
fi fi
# Don't eradicate directories if we need to restart # Don't eradicate directories if we need to restart
@ -150,20 +150,20 @@ if [ -z "${CT_RESTART}" ]; then
# We need to do that _before_ we can safely log, because the log file will # We need to do that _before_ we can safely log, because the log file will
# most probably be in the toolchain directory. # most probably be in the toolchain directory.
if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
CT_DoExecLog ALL rm -rf "${CT_TARBALLS_DIR}" CT_DoForceRmdir "${CT_TARBALLS_DIR}"
fi fi
if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
CT_DoExecLog ALL rm -rf "${CT_SRC_DIR}" CT_DoForceRmdir "${CT_SRC_DIR}"
fi fi
if [ -d "${CT_INSTALL_DIR}" ]; then if [ -d "${CT_INSTALL_DIR}" ]; then
CT_DoExecLog ALL rm -rf "${CT_INSTALL_DIR}" CT_DoForceRmdir "${CT_INSTALL_DIR}"
fi fi
if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
CT_DoExecLog ALL rm -rf "${CT_DEBUG_INSTALL_DIR}" CT_DoForceRmdir "${CT_DEBUG_INSTALL_DIR}"
fi fi
# In case we start anew, get rid of the previously saved state directory # In case we start anew, get rid of the previously saved state directory
if [ -d "${CT_STATE_DIR}" ]; then if [ -d "${CT_STATE_DIR}" ]; then
CT_DoExecLog ALL rm -rf "${CT_STATE_DIR}" CT_DoForceRmdir "${CT_STATE_DIR}"
fi fi
fi fi
@ -408,8 +408,7 @@ if [ -z "${CT_RESTART}" ]; then
if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
if [ "${CT_FORCE_EXTRACT}" = "y" ]; then if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.force.$$" CT_DoForceRmdir "${CT_SRC_DIR}"
CT_DoExecLog ALL rm -rf "${CT_SRC_DIR}.force.$$"
CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}" CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
fi fi
CT_DoStep INFO "Extracting and patching toolchain components" CT_DoStep INFO "Extracting and patching toolchain components"
@ -491,9 +490,9 @@ if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
# Remove the generated documentation files # Remove the generated documentation files
if [ "${CT_REMOVE_DOCS}" = "y" ]; then if [ "${CT_REMOVE_DOCS}" = "y" ]; then
CT_DoLog INFO "Removing installed documentation" CT_DoLog INFO "Removing installed documentation"
CT_DoExecLog ALL rm -rf "${CT_PREFIX_DIR}/"{,usr/}{man,info} CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
CT_DoExecLog ALL rm -rf "${CT_SYSROOT_DIR}/"{,usr/}{man,info} CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
CT_DoExecLog ALL rm -rf "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info} CT_DoForceRmdir "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
fi fi
fi fi

View File

@ -242,6 +242,13 @@ CT_MktempDir() {
return 0 return 0
} }
# Removes one or more directories, even if it is read-only
# Usage: CT_DoForceRmdir dir [...]
CT_DoForceRmdir() {
CT_DoExecLog ALL chmod -R u+w "${@}"
CT_DoExecLog ALL rm -rf "${@}"
}
# Echoes the specified string on stdout until the pipe breaks. # Echoes the specified string on stdout until the pipe breaks.
# Doesn't fail # Doesn't fail
# $1: string to echo # $1: string to echo