scripts/saveSample.sh
changeset 63 89b41dbffe8d
child 64 7dab8d1a2426
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/saveSample.sh	Mon May 07 09:04:02 2007 +0000
     1.3 @@ -0,0 +1,70 @@
     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 kernel .config file if specified
    1.12 +#  - the uClibc .config file if uClibc selected
    1.13 +
    1.14 +. "${CT_TOP_DIR}/scripts/functions"
    1.15 +
    1.16 +# Log to a temporary file until we have built our environment
    1.17 +CT_ACTUAL_LOG_FILE="${CT_TOP_DIR}/$$.log"
    1.18 +CT_LOG_INFO=y
    1.19 +CT_LOG_LEVEL_MAX="INFO"
    1.20 +
    1.21 +# Parse the configuration file
    1.22 +CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
    1.23 +. "${CT_TOP_DIR}/.config"
    1.24 +
    1.25 +# Override log level
    1.26 +unset CT_LOG_ERROR CT_LOG_WARN CT_LOG_EXTRA CT_LOG_DEBUG 
    1.27 +CT_LOG_INFO=y
    1.28 +CT_LOG_LEVEL_MAX="INFO"
    1.29 +
    1.30 +# Target triplet: CT_TARGET needs a little love:
    1.31 +CT_DoBuildTargetTriplet
    1.32 +
    1.33 +# Create the sample directory
    1.34 +[ -d "${CT_TOP_DIR}/samples/${CT_TARGET}" ] || svn mkdir "${CT_TOP_DIR}/samples/${CT_TARGET}" >/dev/null 2>&1
    1.35 +
    1.36 +# Save the crosstool-NG config file
    1.37 +cp "${CT_TOP_DIR}/.config" "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config"
    1.38 +
    1.39 +# Save the kernel .config file
    1.40 +if [ -n "${CT_KERNEL_LINUX_CONFIG_FILE}" ]; then
    1.41 +    # We save the file, and then point the saved sample to this file
    1.42 +    cp "${CT_KERNEL_LINUX_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"
    1.43 +    svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config" >/dev/null 2>&1
    1.44 +    sed -r -i -e 's|^(CT_KERNEL_LINUX_CONFIG_FILE=).+$|\1"${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"|;' \
    1.45 +        "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config"
    1.46 +else
    1.47 +    # remove any dangling files
    1.48 +    for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-"*.config; do
    1.49 +        if [ -f "${f}" ]; then svn rm --force "${f}" >/dev/null 2>&1; fi
    1.50 +    done
    1.51 +fi
    1.52 +
    1.53 +# Save the uClibc .config file
    1.54 +if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then
    1.55 +    # We save the file, and then point the saved sample to this file
    1.56 +    cp "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"
    1.57 +    svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config" >/dev/null 2>&1
    1.58 +    sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \
    1.59 +        "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config"
    1.60 +else
    1.61 +    # remove any dangling files
    1.62 +    for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-"*.config; do
    1.63 +        if [ -f "${f}" ]; then svn rm --force "${f}" >/dev/null 2>&1; fi
    1.64 +    done
    1.65 +fi
    1.66 +
    1.67 +# We could svn add earlier, but it's better to
    1.68 +# add a frozen file than modifying it later
    1.69 +svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" >/dev/null 2>&1
    1.70 +
    1.71 +svn stat "${CT_TOP_DIR}/samples/${CT_TARGET}" 2>/dev/null |CT_DoLog INFO
    1.72 +
    1.73 +rm -f "${CT_ACTUAL_LOG_FILE}"