This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[CT-NG:patch 06/19] Update CT_DoSaveState and CT_DoRestoreState to check for existence


In some configuration not all directories that are saved by
CT_DoSaveState exist, add a check so only existing directories
are saved.

Same applies when Restoring, check wheter the save files has
been created during an previous DoSave.

Signed-off-by: Bart vdr. Meulen <bartvdrmeulen@gmail.com>
---
 scripts/functions |   93 +++++++++++++++++++++++++++++++-----------------------
 1 file changed, 55 insertions(+), 38 deletions(-)

Index: crosstool-ng/scripts/functions
===================================================================
--- crosstool-ng.orig/scripts/functions
+++ crosstool-ng/scripts/functions
@@ -934,29 +934,38 @@ CT_DoSaveState() {
                            /^(UID|EUID)=/d;
                            /^(FUNCNAME|GROUPS|PPID|SHELLOPTS)=/d;' >"${state_dir}/env.sh"
 
-    CT_DoLog DEBUG "  Saving CT_CONFIG_DIR='${CT_CONFIG_DIR}'"
-    CT_Pushd "${CT_CONFIG_DIR}"
-    CT_DoExecLog DEBUG tar cv${tar_opt}f "${state_dir}/config_dir.tar${tar_ext}" .
-    CT_Popd
-
-    CT_DoLog DEBUG "  Saving CT_CC_CORE_STATIC_PREFIX_DIR='${CT_CC_CORE_STATIC_PREFIX_DIR}'"
-    CT_Pushd "${CT_CC_CORE_STATIC_PREFIX_DIR}"
-    CT_DoExecLog DEBUG tar cv${tar_opt}f "${state_dir}/cc_core_static_prefix_dir.tar${tar_ext}" .
-    CT_Popd
-
-    CT_DoLog DEBUG "  Saving CT_CC_CORE_SHARED_PREFIX_DIR='${CT_CC_CORE_SHARED_PREFIX_DIR}'"
-    CT_Pushd "${CT_CC_CORE_SHARED_PREFIX_DIR}"
-    CT_DoExecLog DEBUG tar cv${tar_opt}f "${state_dir}/cc_core_shared_prefix_dir.tar${tar_ext}" .
-    CT_Popd
-
-    CT_DoLog DEBUG "  Saving CT_PREFIX_DIR='${CT_PREFIX_DIR}'"
-    CT_Pushd "${CT_PREFIX_DIR}"
-    CT_DoExecLog DEBUG tar cv${tar_opt}f "${state_dir}/prefix_dir.tar${tar_ext}" --exclude '*.log' .
-    CT_Popd
+    if [ -d ${CT_CONFIG_DIR} ]; then
+	    CT_DoLog DEBUG "  Saving CT_CONFIG_DIR='${CT_CONFIG_DIR}'"
+	    CT_Pushd "${CT_CONFIG_DIR}"
+	    CT_DoExecLog DEBUG tar cv${tar_opt}f "${state_dir}/config_dir.tar${tar_ext}" .
+	    CT_Popd
+    fi
+
+    if [ -d ${CT_CC_CORE_STATIC_PREFIX_DIR} ]; then
+	    CT_DoLog DEBUG "  Saving CT_CC_CORE_STATIC_PREFIX_DIR='${CT_CC_CORE_STATIC_PREFIX_DIR}'"
+	    CT_Pushd "${CT_CC_CORE_STATIC_PREFIX_DIR}"
+	    CT_DoExecLog DEBUG tar cv${tar_opt}f "${state_dir}/cc_core_static_prefix_dir.tar${tar_ext}" .
+	    CT_Popd
+    fi
+
+    if [ -d ${CT_CC_CORE_SHARED_PREFIX_DIR} ]; then
+	    CT_DoLog DEBUG "  Saving CT_CC_CORE_SHARED_PREFIX_DIR='${CT_CC_CORE_SHARED_PREFIX_DIR}'"
+	    CT_Pushd "${CT_CC_CORE_SHARED_PREFIX_DIR}"
+	    CT_DoExecLog DEBUG tar cv${tar_opt}f "${state_dir}/cc_core_shared_prefix_dir.tar${tar_ext}" .
+	    CT_Popd
+    fi
+
+    if [ -d ${CT_PREFIX_DIR} ]; then
+        CT_DoLog DEBUG "  Saving CT_PREFIX_DIR='${CT_PREFIX_DIR}'"
+        CT_Pushd "${CT_PREFIX_DIR}"
+        CT_DoExecLog DEBUG tar cv${tar_opt}f "${state_dir}/prefix_dir.tar${tar_ext}" --exclude '*.log' .
+        CT_Popd
+    fi
 
     if [ "${CT_LOG_TO_FILE}" = "y" ]; then
         CT_DoLog DEBUG "  Saving log file"
         exec >/dev/null
+
         case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
             y)  gzip -3 -c "${CT_LOG_FILE}"  >"${state_dir}/log.gz";;
             *)  cat "${CT_LOG_FILE}" >"${state_dir}/log";;
@@ -992,25 +1001,33 @@ CT_DoLoadState(){
     CT_DoForceRmdir             "${CT_PREFIX_DIR}" "${CT_CC_CORE_SHARED_PREFIX_DIR}" "${CT_CC_CORE_STATIC_PREFIX_DIR}" "${CT_CONFIG_DIR}"
     CT_DoExecLog DEBUG mkdir -p "${CT_PREFIX_DIR}" "${CT_CC_CORE_SHARED_PREFIX_DIR}" "${CT_CC_CORE_STATIC_PREFIX_DIR}" "${CT_CONFIG_DIR}"
 
-    CT_DoLog DEBUG "  Restoring CT_PREFIX_DIR='${CT_PREFIX_DIR}'"
-    CT_Pushd "${CT_PREFIX_DIR}"
-    CT_DoExecLog DEBUG tar xv${tar_opt}f "${state_dir}/prefix_dir.tar${tar_ext}"
-    CT_Popd
-
-    CT_DoLog DEBUG "  Restoring CT_CC_CORE_SHARED_PREFIX_DIR='${CT_CC_CORE_SHARED_PREFIX_DIR}'"
-    CT_Pushd "${CT_CC_CORE_SHARED_PREFIX_DIR}"
-    CT_DoExecLog DEBUG tar xv${tar_opt}f "${state_dir}/cc_core_shared_prefix_dir.tar${tar_ext}"
-    CT_Popd
-
-    CT_DoLog DEBUG "  Restoring CT_CC_CORE_STATIC_PREFIX_DIR='${CT_CC_CORE_STATIC_PREFIX_DIR}'"
-    CT_Pushd "${CT_CC_CORE_STATIC_PREFIX_DIR}"
-    CT_DoExecLog DEBUG tar xv${tar_opt}f "${state_dir}/cc_core_static_prefix_dir.tar${tar_ext}"
-    CT_Popd
-
-    CT_DoLog DEBUG "  Restoring CT_CONFIG_DIR='${CT_CONFIG_DIR}'"
-    CT_Pushd "${CT_CONFIG_DIR}"
-    CT_DoExecLog DEBUG tar xv${tar_opt}f "${state_dir}/config_dir.tar${tar_ext}"
-    CT_Popd
+    if [ -f "${state_dir}/prefix_dir.tar${tar_ext}" ]; then
+        CT_DoLog DEBUG "  Restoring CT_PREFIX_DIR='${CT_PREFIX_DIR}'"
+        CT_Pushd "${CT_PREFIX_DIR}"
+        CT_DoExecLog DEBUG tar xv${tar_opt}f "${state_dir}/prefix_dir.tar${tar_ext}"
+        CT_Popd
+    fi
+
+    if [ -f "${state_dir}/cc_core_shared_prefix_dir.tar${tar_ext}" ]; then
+        CT_DoLog DEBUG "  Restoring CT_CC_CORE_SHARED_PREFIX_DIR='${CT_CC_CORE_SHARED_PREFIX_DIR}'"
+        CT_Pushd "${CT_CC_CORE_SHARED_PREFIX_DIR}"
+        CT_DoExecLog DEBUG tar xv${tar_opt}f "${state_dir}/cc_core_shared_prefix_dir.tar${tar_ext}"
+        CT_Popd
+    fi
+
+    if [ -f "${state_dir}/cc_core_static_prefix_dir.tar${tar_ext}" ]; then
+        CT_DoLog DEBUG "  Restoring CT_CC_CORE_STATIC_PREFIX_DIR='${CT_CC_CORE_STATIC_PREFIX_DIR}'"
+        CT_Pushd "${CT_CC_CORE_STATIC_PREFIX_DIR}"
+        CT_DoExecLog DEBUG tar xv${tar_opt}f "${state_dir}/cc_core_static_prefix_dir.tar${tar_ext}"
+        CT_Popd
+    fi
+
+    if [ -f "${state_dir}/config_dir.tar${tar_ext}" ]; then
+        CT_DoLog DEBUG "  Restoring CT_CONFIG_DIR='${CT_CONFIG_DIR}'"
+        CT_Pushd "${CT_CONFIG_DIR}"
+        CT_DoExecLog DEBUG tar xv${tar_opt}f "${state_dir}/config_dir.tar${tar_ext}"
+        CT_Popd
+    fi
 
     # Restore the environment, discarding any error message
     # (for example, read-only bash internals)

-- 


--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]