scripts/tarball.sh.broken
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jul 02 19:40:54 2007 +0000 (2007-07-02)
changeset 197 9383bf4a2e2e
parent 182 223c84ec2d90
child 335 f0d84f1d4c93
permissions -rwxr-xr-x
Get rid of eclipse fiels once and for all.
Homogenise the references to crosstool-NG:
- the project is named "crosstool-NG"
- the front-end is named "ct-ng"
- don't use shortcuts (such as "ct-ng" to stand for "crosstool-NG")
Default action is to print help.
Don't speak of make rules when dumping help, just speak of actions.
     1 #!/bin/bash
     2 
     3 # This scripts makes a tarball of the configured toolchain
     4 # Pre-requisites:
     5 #  - crosstool-NG is configured
     6 #  - components tarball are available
     7 #  - toolchain is built successfully
     8 
     9 # We need the functions first:
    10 . "${CT_TOP_DIR}/scripts/functions"
    11 
    12 # Don't care about any log file
    13 exec >/dev/null
    14 rm -f "${tmp_log_file}"
    15 
    16 # Parse the configuration file:
    17 . ${CT_TOP_DIR}/.config
    18 
    19 CT_DoBuildTargetTriplet
    20 
    21 # Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR,
    22 # re-parse them:
    23 . "${CT_TOP_DIR}/.config"
    24 
    25 # Build a one-line list of files to include
    26 CT_DoStep DEBUG "Building list of tarballs to add"
    27 CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
    28 CT_TARBALLS=""
    29 for dir in '' tools debug; do
    30     CT_DoStep DEBUG "Scanning directory \"${dir}\""
    31     for script in "${CT_TOP_DIR}/scripts/build/${dir}/"*.sh; do
    32         CT_DoStep DEBUG "Testing component \"${script}\""
    33         [ -n "${script}" ] || continue
    34         unset do_print_file_name
    35         . "${script}"
    36         for file in `do_print_filename`; do
    37             CT_DoLog DEBUG "Finding tarball for \"${file}\""
    38             [ -n "${file}" ] || continue
    39             ext=`CT_GetFileExtension "${file}"`
    40             CT_TestOrAbort "Missing tarball for: \"${file}\"" -f "${CT_TOP_DIR}/targets/tarballs/${file}${ext}"
    41             CT_DoLog DEBUG "Found \"${file}${ext}\""
    42             CT_TARBALLS="${CT_TARBALLS} ${file}${ext}"
    43         done
    44         CT_EndStep
    45     done
    46     CT_EndStep
    47 done    
    48 CT_EndStep
    49 
    50 # We need to emulate a build directory:
    51 CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
    52 mkdir -p "${CT_BUILD_DIR}"
    53 CT_MktempDir tempdir
    54 
    55 # Save crosstool-NG, as it is configured for the current toolchain.
    56 topdir=`basename "${CT_TOP_DIR}"`
    57 CT_Pushd "${CT_TOP_DIR}/.."
    58 
    59 botdir=`pwd`
    60 
    61 # Build the list of files to exclude
    62 CT_DoLog DEBUG "Building list of files to exclude"
    63 exclude_list="${tempdir}/${CT_TARGET}.list"
    64 { echo ".svn";                                                  \
    65   echo "${topdir}/log.*";                                       \
    66   echo "${topdir}/targets/src";                                 \
    67   echo "${topdir}/targets/tst";                                 \
    68   echo "${topdir}/targets/*-*-*-*";                             \
    69   for t in `ls -1 "${topdir}/targets/tarballs/"`; do            \
    70       case " ${CT_TARBALLS} " in                                \
    71           *" ${t} "*) ;;                                        \
    72           *)          echo "${topdir}/targets/tarballs/${t}";;  \
    73       esac;                                                     \
    74   done;                                                         \
    75 } >"${exclude_list}"
    76 
    77 # Render the install directory writable
    78 chmod u+w "${CT_PREFIX_DIR}"
    79 
    80 CT_DoLog INFO "Saving crosstool-NG into the toolchain directory"
    81 tar cvjf "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2"    \
    82     --no-wildcards-match-slash                                  \
    83     -X "${exclude_list}"                                        \
    84     "${topdir}"                                                 2>&1 |CT_DoLog ALL
    85 
    86 CT_Popd
    87 
    88 CT_DoLog INFO "Saving the toolchain"
    89 tar cvjf "${botdir}/${CT_TARGET}.tar.bz2" "${CT_PREFIX_DIR}"    2>&1 |CT_DoLog ALL
    90 
    91 CT_DoLog DEBUG "Getting rid of working directories"
    92 rm -f "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2"
    93 rm -rf "${tempdir}"
    94 
    95 if [ "${CT_INSTALL_DIR_RO}" = "y" ]; then
    96     # Render the install directory non-writable
    97     chmod u-w "${CT_PREFIX_DIR}"
    98 fi