scripts/tarball.sh.broken
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Oct 23 13:45:48 2008 +0000 (2008-10-23)
changeset 965 45ddf096def1
parent 394 5e5d02b2d786
permissions -rwxr-xr-x
Push the calculation of the tuple's kernel part down to kernel's build scripts:
- update the kernel script's API with the function CT_DiKernelTupleValues
- update doc accordingly (also with the architecture change, missing in the previous commit)
- small clean-up in the main script, remove useless test

/trunk/scripts/build/kernel/bare-metal.sh | 5 5 0 0 +++++
/trunk/scripts/build/kernel/linux.sh | 5 5 0 0 +++++
/trunk/scripts/crosstool.sh | 31 13 18 0 +++++++++++++------------------
/trunk/scripts/functions | 15 8 7 0 ++++++++-------
/trunk/docs/overview.txt | 13 9 4 0 +++++++++----
5 files changed, 40 insertions(+), 29 deletions(-)
yann@182
     1
#!/bin/bash
yann@182
     2
yann@182
     3
# This scripts makes a tarball of the configured toolchain
yann@182
     4
# Pre-requisites:
yann@182
     5
#  - crosstool-NG is configured
yann@182
     6
#  - components tarball are available
yann@182
     7
#  - toolchain is built successfully
yann@182
     8
yann@182
     9
# We need the functions first:
yann@182
    10
. "${CT_TOP_DIR}/scripts/functions"
yann@182
    11
yann@182
    12
# Don't care about any log file
yann@182
    13
exec >/dev/null
yann@182
    14
rm -f "${tmp_log_file}"
yann@182
    15
yann@182
    16
# Parse the configuration file:
yann@182
    17
. ${CT_TOP_DIR}/.config
yann@182
    18
yann@394
    19
# Parse the architecture-specific functions
yann@394
    20
. "${CT_LIB_DIR}/arch/${CT_ARCH}/functions"
yann@394
    21
yann@394
    22
# Target tuple: CT_TARGET needs a little love:
yann@335
    23
CT_DoBuildTargetTuple
yann@182
    24
yann@182
    25
# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR,
yann@182
    26
# re-parse them:
yann@182
    27
. "${CT_TOP_DIR}/.config"
yann@182
    28
yann@182
    29
# Build a one-line list of files to include
yann@182
    30
CT_DoStep DEBUG "Building list of tarballs to add"
yann@182
    31
CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
yann@182
    32
CT_TARBALLS=""
yann@182
    33
for dir in '' tools debug; do
yann@523
    34
    CT_DoStep DEBUG "Scanning directory '${dir}'"
yann@182
    35
    for script in "${CT_TOP_DIR}/scripts/build/${dir}/"*.sh; do
yann@523
    36
        CT_DoStep DEBUG "Testing component '${script}'"
yann@182
    37
        [ -n "${script}" ] || continue
yann@182
    38
        unset do_print_file_name
yann@182
    39
        . "${script}"
yann@523
    40
        for file in $(do_print_filename); do
yann@523
    41
            CT_DoLog DEBUG "Finding tarball for '${file}'"
yann@182
    42
            [ -n "${file}" ] || continue
yann@523
    43
            ext=$(CT_GetFileExtension "${file}")
yann@523
    44
            CT_TestOrAbort "Missing tarball for: '${file}'" -f "${CT_TOP_DIR}/targets/tarballs/${file}${ext}"
yann@523
    45
            CT_DoLog DEBUG "Found '${file}${ext}'"
yann@182
    46
            CT_TARBALLS="${CT_TARBALLS} ${file}${ext}"
yann@182
    47
        done
yann@182
    48
        CT_EndStep
yann@182
    49
    done
yann@182
    50
    CT_EndStep
yann@182
    51
done    
yann@182
    52
CT_EndStep
yann@182
    53
yann@182
    54
# We need to emulate a build directory:
yann@182
    55
CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
yann@182
    56
mkdir -p "${CT_BUILD_DIR}"
yann@182
    57
CT_MktempDir tempdir
yann@182
    58
yann@197
    59
# Save crosstool-NG, as it is configured for the current toolchain.
yann@523
    60
topdir=$(basename "${CT_TOP_DIR}")
yann@182
    61
CT_Pushd "${CT_TOP_DIR}/.."
yann@182
    62
yann@523
    63
botdir=$(pwd)
yann@182
    64
yann@182
    65
# Build the list of files to exclude
yann@182
    66
CT_DoLog DEBUG "Building list of files to exclude"
yann@182
    67
exclude_list="${tempdir}/${CT_TARGET}.list"
yann@182
    68
{ echo ".svn";                                                  \
yann@182
    69
  echo "${topdir}/log.*";                                       \
yann@182
    70
  echo "${topdir}/targets/src";                                 \
yann@182
    71
  echo "${topdir}/targets/tst";                                 \
yann@182
    72
  echo "${topdir}/targets/*-*-*-*";                             \
yann@523
    73
  for t in $(ls -1 "${topdir}/targets/tarballs/"); do            \
yann@182
    74
      case " ${CT_TARBALLS} " in                                \
yann@182
    75
          *" ${t} "*) ;;                                        \
yann@182
    76
          *)          echo "${topdir}/targets/tarballs/${t}";;  \
yann@182
    77
      esac;                                                     \
yann@182
    78
  done;                                                         \
yann@182
    79
} >"${exclude_list}"
yann@182
    80
yann@182
    81
# Render the install directory writable
yann@182
    82
chmod u+w "${CT_PREFIX_DIR}"
yann@182
    83
yann@197
    84
CT_DoLog INFO "Saving crosstool-NG into the toolchain directory"
yann@182
    85
tar cvjf "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2"    \
yann@182
    86
    --no-wildcards-match-slash                                  \
yann@182
    87
    -X "${exclude_list}"                                        \
yann@182
    88
    "${topdir}"                                                 2>&1 |CT_DoLog ALL
yann@182
    89
yann@182
    90
CT_Popd
yann@182
    91
yann@182
    92
CT_DoLog INFO "Saving the toolchain"
yann@182
    93
tar cvjf "${botdir}/${CT_TARGET}.tar.bz2" "${CT_PREFIX_DIR}"    2>&1 |CT_DoLog ALL
yann@182
    94
yann@182
    95
CT_DoLog DEBUG "Getting rid of working directories"
yann@182
    96
rm -f "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2"
yann@182
    97
rm -rf "${tempdir}"
yann@182
    98
yann@182
    99
if [ "${CT_INSTALL_DIR_RO}" = "y" ]; then
yann@182
   100
    # Render the install directory non-writable
yann@182
   101
    chmod u-w "${CT_PREFIX_DIR}"
yann@182
   102
fi