scripts/saveSample.sh
changeset 935 e175e3538310
parent 928 df15727c73d7
child 944 a6e9767c8ef9
     1.1 --- a/scripts/saveSample.sh	Tue Oct 14 16:54:20 2008 +0000
     1.2 +++ b/scripts/saveSample.sh	Tue Oct 14 21:30:27 2008 +0000
     1.3 @@ -5,8 +5,11 @@
     1.4  
     1.5  # What we need to save:
     1.6  #  - the .config file
     1.7 -#  - the kernel .config file if specified
     1.8  #  - the uClibc .config file if uClibc selected
     1.9 +#  - info about who reported the sample
    1.10 +
    1.11 +# We'll need the stdout later, save it
    1.12 +exec 7>&1
    1.13  
    1.14  . "${CT_LIB_DIR}/scripts/functions"
    1.15  
    1.16 @@ -15,8 +18,8 @@
    1.17  rm -f "${tmp_log_file}"
    1.18  
    1.19  # Parse the configuration file
    1.20 -CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
    1.21 -. "${CT_TOP_DIR}/.config"
    1.22 +CT_TestOrAbort "Configuration file not found. Please create one." -f .config
    1.23 +. .config
    1.24  
    1.25  # Do not use a progress bar
    1.26  unset CT_LOG_PROGRESS_BAR
    1.27 @@ -29,7 +32,7 @@
    1.28  
    1.29  # Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR,
    1.30  # re-parse them:
    1.31 -. "${CT_TOP_DIR}/.config"
    1.32 +. .config
    1.33  
    1.34  # Override log options
    1.35  unset CT_LOG_PROGRESS_BAR CT_LOG_ERROR CT_LOG_INFO CT_LOG_EXTRA CT_LOG_DEBUG LOG_ALL
    1.36 @@ -37,8 +40,8 @@
    1.37  CT_LOG_LEVEL_MAX="WARN"
    1.38  
    1.39  # Create the sample directory
    1.40 -if [ ! -d "${CT_TOP_DIR}/samples/${CT_TARGET}" ]; then
    1.41 -    mkdir -p "${CT_TOP_DIR}/samples/${CT_TARGET}"
    1.42 +if [ ! -d "samples/${CT_TARGET}" ]; then
    1.43 +    mkdir -p "samples/${CT_TARGET}"
    1.44  fi
    1.45  
    1.46  # Save the crosstool-NG config file
    1.47 @@ -46,8 +49,8 @@
    1.48         -e 's|^# CT_LOG_TO_FILE is not set$|CT_LOG_TO_FILE=y|;'              \
    1.49         -e 's|^# CT_LOG_FILE_COMPRESS is not set$|CT_LOG_FILE_COMPRESS=y|;'  \
    1.50         -e 's|^(CT_LOCAL_TARBALLS_DIR)=.*|\1="${HOME}/src"|;'                \
    1.51 -    <"${CT_TOP_DIR}/.config"                                                \
    1.52 -    >"${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config"
    1.53 +    <.config                                                                \
    1.54 +    >"samples/${CT_TARGET}/crosstool.config"
    1.55  
    1.56  # Function to copy a file to the sample directory
    1.57  # Needed in case the file is already there (think of a previously available sample)
    1.58 @@ -71,12 +74,33 @@
    1.59  # Save the uClibc .config file
    1.60  if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then
    1.61      # We save the file, and then point the saved sample to this file
    1.62 -    CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"
    1.63 +    CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"
    1.64      sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \
    1.65 -        "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config"
    1.66 +        "samples/${CT_TARGET}/crosstool.config"
    1.67  else
    1.68      # remove any dangling files
    1.69 -    for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-"*.config; do
    1.70 +    for f in "samples/${CT_TARGET}/${CT_LIBC}-"*.config; do
    1.71          if [ -f "${f}" ]; then rm -f "${f}"; fi
    1.72      done
    1.73  fi
    1.74 +
    1.75 +# Restore stdout now, to be interactive
    1.76 +exec >&7
    1.77 +
    1.78 +# Fill-in the reported-by info
    1.79 +[ -f "samples/${CT_TARGET}/reported.by" ] && . "samples/${CT_TARGET}/reported.by"
    1.80 +old_name="${reporter_name}"
    1.81 +old_url="${reporter_url}"
    1.82 +read -p "Reporter name [${reporter_name}]: " reporter_name
    1.83 +read -p "Reporter URL [${reporter_url}]: " reporter_url
    1.84 +if [ -n "${reporter_comment}" ]; then
    1.85 +  echo "Old comment if you need to copy-paste:"
    1.86 +  printf "${reporter_comment}"
    1.87 +fi
    1.88 +echo "Reporter comment (Ctrl-D to finish):"
    1.89 +reporter_comment=$(cat)
    1.90 +
    1.91 +( echo "reporter_name=\"${reporter_name:=${old_name}}\""
    1.92 +  echo "reporter_url=\"${reporter_url:=${old_url}}\""
    1.93 +  printf "reporter_comment=\"${reporter_comment}\"\n"
    1.94 +) >"samples/${CT_TARGET}/reported.by"