scripts/tarball.sh.broken
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Aug 15 16:18:35 2007 +0000 (2007-08-15)
changeset 335 f0d84f1d4c93
parent 197 9383bf4a2e2e
child 394 5e5d02b2d786
permissions -rwxr-xr-x
Change "triplet" (target triplet) to "tuple". That sounds better!
Document overriding the number of // jobs.
Some small documentation fixes.
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@335
    19
CT_DoBuildTargetTuple
yann@182
    20
yann@182
    21
# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR,
yann@182
    22
# re-parse them:
yann@182
    23
. "${CT_TOP_DIR}/.config"
yann@182
    24
yann@182
    25
# Build a one-line list of files to include
yann@182
    26
CT_DoStep DEBUG "Building list of tarballs to add"
yann@182
    27
CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
yann@182
    28
CT_TARBALLS=""
yann@182
    29
for dir in '' tools debug; do
yann@182
    30
    CT_DoStep DEBUG "Scanning directory \"${dir}\""
yann@182
    31
    for script in "${CT_TOP_DIR}/scripts/build/${dir}/"*.sh; do
yann@182
    32
        CT_DoStep DEBUG "Testing component \"${script}\""
yann@182
    33
        [ -n "${script}" ] || continue
yann@182
    34
        unset do_print_file_name
yann@182
    35
        . "${script}"
yann@182
    36
        for file in `do_print_filename`; do
yann@182
    37
            CT_DoLog DEBUG "Finding tarball for \"${file}\""
yann@182
    38
            [ -n "${file}" ] || continue
yann@182
    39
            ext=`CT_GetFileExtension "${file}"`
yann@182
    40
            CT_TestOrAbort "Missing tarball for: \"${file}\"" -f "${CT_TOP_DIR}/targets/tarballs/${file}${ext}"
yann@182
    41
            CT_DoLog DEBUG "Found \"${file}${ext}\""
yann@182
    42
            CT_TARBALLS="${CT_TARBALLS} ${file}${ext}"
yann@182
    43
        done
yann@182
    44
        CT_EndStep
yann@182
    45
    done
yann@182
    46
    CT_EndStep
yann@182
    47
done    
yann@182
    48
CT_EndStep
yann@182
    49
yann@182
    50
# We need to emulate a build directory:
yann@182
    51
CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
yann@182
    52
mkdir -p "${CT_BUILD_DIR}"
yann@182
    53
CT_MktempDir tempdir
yann@182
    54
yann@197
    55
# Save crosstool-NG, as it is configured for the current toolchain.
yann@182
    56
topdir=`basename "${CT_TOP_DIR}"`
yann@182
    57
CT_Pushd "${CT_TOP_DIR}/.."
yann@182
    58
yann@182
    59
botdir=`pwd`
yann@182
    60
yann@182
    61
# Build the list of files to exclude
yann@182
    62
CT_DoLog DEBUG "Building list of files to exclude"
yann@182
    63
exclude_list="${tempdir}/${CT_TARGET}.list"
yann@182
    64
{ echo ".svn";                                                  \
yann@182
    65
  echo "${topdir}/log.*";                                       \
yann@182
    66
  echo "${topdir}/targets/src";                                 \
yann@182
    67
  echo "${topdir}/targets/tst";                                 \
yann@182
    68
  echo "${topdir}/targets/*-*-*-*";                             \
yann@182
    69
  for t in `ls -1 "${topdir}/targets/tarballs/"`; do            \
yann@182
    70
      case " ${CT_TARBALLS} " in                                \
yann@182
    71
          *" ${t} "*) ;;                                        \
yann@182
    72
          *)          echo "${topdir}/targets/tarballs/${t}";;  \
yann@182
    73
      esac;                                                     \
yann@182
    74
  done;                                                         \
yann@182
    75
} >"${exclude_list}"
yann@182
    76
yann@182
    77
# Render the install directory writable
yann@182
    78
chmod u+w "${CT_PREFIX_DIR}"
yann@182
    79
yann@197
    80
CT_DoLog INFO "Saving crosstool-NG into the toolchain directory"
yann@182
    81
tar cvjf "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2"    \
yann@182
    82
    --no-wildcards-match-slash                                  \
yann@182
    83
    -X "${exclude_list}"                                        \
yann@182
    84
    "${topdir}"                                                 2>&1 |CT_DoLog ALL
yann@182
    85
yann@182
    86
CT_Popd
yann@182
    87
yann@182
    88
CT_DoLog INFO "Saving the toolchain"
yann@182
    89
tar cvjf "${botdir}/${CT_TARGET}.tar.bz2" "${CT_PREFIX_DIR}"    2>&1 |CT_DoLog ALL
yann@182
    90
yann@182
    91
CT_DoLog DEBUG "Getting rid of working directories"
yann@182
    92
rm -f "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2"
yann@182
    93
rm -rf "${tempdir}"
yann@182
    94
yann@182
    95
if [ "${CT_INSTALL_DIR_RO}" = "y" ]; then
yann@182
    96
    # Render the install directory non-writable
yann@182
    97
    chmod u-w "${CT_PREFIX_DIR}"
yann@182
    98
fi