Fix removing existing directories by chmod'ing them to be user-writeable.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jan 12 21:35:23 2009 +0000 (2009-01-12)
changeset 1138ae135a73e338
parent 1137 4a8b036e4bc2
child 1139 48e6a184e28e
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(-)
scripts/crosstool.sh
scripts/functions
     1.1 --- a/scripts/crosstool.sh	Mon Jan 12 21:34:11 2009 +0000
     1.2 +++ b/scripts/crosstool.sh	Mon Jan 12 21:35:23 2009 +0000
     1.3 @@ -141,7 +141,7 @@
     1.4  
     1.5  # Ah! The build directory shall be eradicated, even if we restart!
     1.6  if [ -d "${CT_BUILD_DIR}" ]; then
     1.7 -    CT_DoExecLog ALL rm -rf "${CT_BUILD_DIR}"
     1.8 +    CT_DoForceRmdir "${CT_BUILD_DIR}"
     1.9  fi
    1.10  
    1.11  # Don't eradicate directories if we need to restart
    1.12 @@ -150,20 +150,20 @@
    1.13      # We need to do that _before_ we can safely log, because the log file will
    1.14      # most probably be in the toolchain directory.
    1.15      if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
    1.16 -        CT_DoExecLog ALL rm -rf "${CT_TARBALLS_DIR}"
    1.17 +        CT_DoForceRmdir "${CT_TARBALLS_DIR}"
    1.18      fi
    1.19      if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
    1.20 -        CT_DoExecLog ALL rm -rf "${CT_SRC_DIR}"
    1.21 +        CT_DoForceRmdir "${CT_SRC_DIR}"
    1.22      fi
    1.23      if [ -d "${CT_INSTALL_DIR}" ]; then
    1.24 -        CT_DoExecLog ALL rm -rf "${CT_INSTALL_DIR}"
    1.25 +        CT_DoForceRmdir "${CT_INSTALL_DIR}"
    1.26      fi
    1.27      if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
    1.28 -        CT_DoExecLog ALL rm -rf "${CT_DEBUG_INSTALL_DIR}"
    1.29 +        CT_DoForceRmdir "${CT_DEBUG_INSTALL_DIR}"
    1.30      fi
    1.31      # In case we start anew, get rid of the previously saved state directory
    1.32      if [ -d "${CT_STATE_DIR}" ]; then
    1.33 -        CT_DoExecLog ALL rm -rf "${CT_STATE_DIR}"
    1.34 +        CT_DoForceRmdir "${CT_STATE_DIR}"
    1.35      fi
    1.36  fi
    1.37  
    1.38 @@ -408,8 +408,7 @@
    1.39  
    1.40      if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
    1.41          if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
    1.42 -            mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.force.$$"
    1.43 -            CT_DoExecLog ALL rm -rf "${CT_SRC_DIR}.force.$$"
    1.44 +            CT_DoForceRmdir "${CT_SRC_DIR}"
    1.45              CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
    1.46          fi
    1.47          CT_DoStep INFO "Extracting and patching toolchain components"
    1.48 @@ -491,9 +490,9 @@
    1.49      # Remove the generated documentation files
    1.50      if [ "${CT_REMOVE_DOCS}" = "y" ]; then
    1.51      	CT_DoLog INFO "Removing installed documentation"
    1.52 -        CT_DoExecLog ALL rm -rf "${CT_PREFIX_DIR}/"{,usr/}{man,info}
    1.53 -        CT_DoExecLog ALL rm -rf "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
    1.54 -        CT_DoExecLog ALL rm -rf "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
    1.55 +        CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
    1.56 +        CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
    1.57 +        CT_DoForceRmdir "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
    1.58      fi
    1.59  fi
    1.60  
     2.1 --- a/scripts/functions	Mon Jan 12 21:34:11 2009 +0000
     2.2 +++ b/scripts/functions	Mon Jan 12 21:35:23 2009 +0000
     2.3 @@ -242,6 +242,13 @@
     2.4      return 0
     2.5  }
     2.6  
     2.7 +# Removes one or more directories, even if it is read-only
     2.8 +# Usage: CT_DoForceRmdir dir [...]
     2.9 +CT_DoForceRmdir() {
    2.10 +    CT_DoExecLog ALL chmod -R u+w "${@}"
    2.11 +    CT_DoExecLog ALL rm -rf "${@}"
    2.12 +}
    2.13 +
    2.14  # Echoes the specified string on stdout until the pipe breaks.
    2.15  # Doesn't fail
    2.16  # $1: string to echo