Fix and enhance the STOP/RESTART facility.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon May 28 21:33:35 2007 +0000 (2007-05-28)
changeset 143420f814f1871
parent 142 471ded821b6c
child 144 27a0abfd46d1
Fix and enhance the STOP/RESTART facility.
scripts/crosstool.sh
     1.1 --- a/scripts/crosstool.sh	Mon May 28 21:32:43 2007 +0000
     1.2 +++ b/scripts/crosstool.sh	Mon May 28 21:33:35 2007 +0000
     1.3 @@ -54,13 +54,6 @@
     1.4  # Some sanity checks in the environment and needed tools
     1.5  CT_DoLog INFO "Checking environment sanity"
     1.6  
     1.7 -# First of really first of really all, **must not** move lower than here!
     1.8 -if [ -n "${CT_RESTART}" -a -z "${CT_DEBUG_CT_SAVE_STEPS}" ]; then
     1.9 -    CT_DoLog ERROR "You asked to restart a non-restartable build"
    1.10 -    CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS in the config options"
    1.11 -    CT_Abort "I will stop here to avoid any carnage"
    1.12 -fi
    1.13 -
    1.14  # Enable known ordering of files in directory listings:
    1.15  CT_Test "Crosstool-NG might not work as expected with LANG=\"${LANG}\"" -n "${LANG}"
    1.16  case "${LC_COLLATE},${LC_ALL}" in
    1.17 @@ -112,7 +105,7 @@
    1.18  
    1.19  # Where will we work?
    1.20  CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
    1.21 -CT_SRC_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/src"
    1.22 +CT_SRC_DIR="${CT_TOP_DIR}/targets/src"
    1.23  CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
    1.24  CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
    1.25  # Note: we'll always install the core compiler in its own directory, so as to
    1.26 @@ -122,6 +115,14 @@
    1.27  CT_CC_CORE_SHARED_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-shared"
    1.28  CT_STATE_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/state"
    1.29  
    1.30 +# We must ensure that we can restart if asked for!
    1.31 +if [ -n "${CT_RESTART}" -a ! -d "${CT_STATE_DIR}"  ]; then
    1.32 +    CT_DoLog ERROR "You asked to restart a non-restartable build"
    1.33 +    CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS"
    1.34 +    CT_DoLog ERROR "in the config options for the previous build"
    1.35 +    CT_Abort "I will stop here to avoid any carnage"
    1.36 +fi
    1.37 +
    1.38  # Make all path absolute, it so much easier!
    1.39  CT_LOCAL_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_LOCAL_TARBALLS_DIR}\"`"
    1.40  
    1.41 @@ -394,6 +395,8 @@
    1.42  # Now for the job by itself. Go have a coffee!
    1.43  if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
    1.44      # Because of CT_RESTART, this becomes quite complex
    1.45 +    do_stop=0
    1.46 +    prev_step=
    1.47      [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1
    1.48      for step in libc_check_config       \
    1.49                  kernel_check_config     \
    1.50 @@ -413,20 +416,25 @@
    1.51              if [ "${CT_RESTART}" = "${step}" ]; then
    1.52                  CT_DoLoadState "${step}"
    1.53                  do_it=1
    1.54 +                do_stop=0
    1.55              fi
    1.56          else
    1.57              CT_DoSaveState ${step}
    1.58 +            if [ ${do_stop} -eq 1 ]; then
    1.59 +                CT_DoLog ERROR "Stopping just after step \"${prev_step}\", as requested."
    1.60 +                exit 0
    1.61 +            fi
    1.62          fi
    1.63          if [ ${do_it} -eq 1 ]; then
    1.64              do_${step}
    1.65              if [ "${CT_STOP}" = "${step}" ]; then
    1.66 -                CT_DoLog ERROR "Stopping just after step \"${step}\", as requested."
    1.67 -                exit 0
    1.68 +                do_stop=1
    1.69              fi
    1.70              if [ "${CTDEBUG_CT_PAUSE_STEPS}" = "y" ]; then
    1.71                  CT_DoPause "Step \"${step}\" finished"
    1.72              fi
    1.73          fi
    1.74 +        prev_step="${step}"
    1.75      done
    1.76  
    1.77      # Create the aliases to the target tools