1.1 --- a/scripts/saveSample.sh Sun Feb 01 17:04:00 2009 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,107 +0,0 @@
1.4 -#!/bin/bash
1.5 -
1.6 -# This script is responsible for saving the current configuration into a
1.7 -# sample to be used later on as a pre-configured target.
1.8 -
1.9 -# What we need to save:
1.10 -# - the .config file
1.11 -# - the uClibc .config file if uClibc selected
1.12 -# - info about who reported the sample
1.13 -
1.14 -# We'll need the stdout later, save it
1.15 -exec 7>&1
1.16 -
1.17 -. "${CT_LIB_DIR}/scripts/functions"
1.18 -
1.19 -# Don't care about any log file
1.20 -exec >/dev/null
1.21 -rm -f "${tmp_log_file}"
1.22 -
1.23 -# Parse the configuration file
1.24 -CT_TestOrAbort "Configuration file not found. Please create one." -f .config
1.25 -. .config
1.26 -
1.27 -# Do not use a progress bar
1.28 -unset CT_LOG_PROGRESS_BAR
1.29 -
1.30 -# Parse architecture and kernel specific functions
1.31 -. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh"
1.32 -. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh"
1.33 -
1.34 -# Target tuple: CT_TARGET needs a little love:
1.35 -CT_DoBuildTargetTuple
1.36 -
1.37 -# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR,
1.38 -# re-parse them:
1.39 -. .config
1.40 -
1.41 -# Override log options
1.42 -unset CT_LOG_PROGRESS_BAR CT_LOG_ERROR CT_LOG_INFO CT_LOG_EXTRA CT_LOG_DEBUG LOG_ALL
1.43 -CT_LOG_WARN=y
1.44 -CT_LOG_LEVEL_MAX="WARN"
1.45 -
1.46 -# Create the sample directory
1.47 -if [ ! -d "samples/${CT_TARGET}" ]; then
1.48 - mkdir -p "samples/${CT_TARGET}"
1.49 -fi
1.50 -
1.51 -# Save the crosstool-NG config file
1.52 -sed -r -e 's|^(CT_PREFIX_DIR)=.*|\1="${HOME}/x-tools/${CT_TARGET}"|;' \
1.53 - -e 's|^# CT_LOG_TO_FILE is not set$|CT_LOG_TO_FILE=y|;' \
1.54 - -e 's|^# CT_LOG_FILE_COMPRESS is not set$|CT_LOG_FILE_COMPRESS=y|;' \
1.55 - -e 's|^(CT_LOCAL_TARBALLS_DIR)=.*|\1="${HOME}/src"|;' \
1.56 - <.config \
1.57 - >"samples/${CT_TARGET}/crosstool.config"
1.58 -
1.59 -# Function to copy a file to the sample directory
1.60 -# Needed in case the file is already there (think of a previously available sample)
1.61 -# Usage: CT_DoAddFileToSample <source> <dest>
1.62 -CT_DoAddFileToSample() {
1.63 - source="$1"
1.64 - dest="$2"
1.65 - inode_s=$(ls -i "${source}" |gawk '{ print $1; }')
1.66 - inode_d=$(ls -i "${dest}" 2>/dev/null |gawk '{ print $1; }' || true)
1.67 - if [ "${inode_s}" != "${inode_d}" ]; then
1.68 - cp "${source}" "${dest}"
1.69 - fi
1.70 -}
1.71 -
1.72 -if [ "${CT_TOP_DIR}" = "${CT_LIB_DIR}" ]; then
1.73 - samp_top_dir="\${CT_LIB_DIR}"
1.74 -else
1.75 - samp_top_dir="\${CT_TOP_DIR}"
1.76 -fi
1.77 -
1.78 -# Save the uClibc .config file
1.79 -if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then
1.80 - # We save the file, and then point the saved sample to this file
1.81 - CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"
1.82 - sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \
1.83 - "samples/${CT_TARGET}/crosstool.config"
1.84 -else
1.85 - # remove any dangling files
1.86 - for f in "samples/${CT_TARGET}/${CT_LIBC}-"*.config; do
1.87 - if [ -f "${f}" ]; then rm -f "${f}"; fi
1.88 - done
1.89 -fi
1.90 -
1.91 -# Restore stdout now, to be interactive
1.92 -exec >&7
1.93 -
1.94 -# Fill-in the reported-by info
1.95 -[ -f "samples/${CT_TARGET}/reported.by" ] && . "samples/${CT_TARGET}/reported.by"
1.96 -old_name="${reporter_name}"
1.97 -old_url="${reporter_url}"
1.98 -read -p "Reporter name [${reporter_name}]: " reporter_name
1.99 -read -p "Reporter URL [${reporter_url}]: " reporter_url
1.100 -if [ -n "${reporter_comment}" ]; then
1.101 - echo "Old comment if you need to copy-paste:"
1.102 - printf "${reporter_comment}\n"
1.103 -fi
1.104 -echo "Reporter comment (Ctrl-D to finish):"
1.105 -reporter_comment=$(cat)
1.106 -
1.107 -( echo "reporter_name=\"${reporter_name:=${old_name}}\""
1.108 - echo "reporter_url=\"${reporter_url:=${old_url}}\""
1.109 - printf "reporter_comment=\"${reporter_comment}\"\n"
1.110 -) >"samples/${CT_TARGET}/reported.by"