summaryrefslogtreecommitdiff
path: root/scripts/tarball.sh.broken
blob: c26ac0a0ddeb2d71fbe4280863d72315ad5417ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash

# This scripts makes a tarball of the configured toolchain
# Pre-requisites:
#  - crosstool-NG is configured
#  - components tarball are available
#  - toolchain is built successfully

# We need the functions first:
. "${CT_TOP_DIR}/scripts/functions"

# Don't care about any log file
exec >/dev/null
rm -f "${tmp_log_file}"

# Parse the configuration file:
. ${CT_TOP_DIR}/.config

# Parse the architecture-specific functions
. "${CT_LIB_DIR}/arch/${CT_ARCH}/functions"

# Target tuple: CT_TARGET needs a little love:
CT_DoBuildTargetTuple

# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR,
# re-parse them:
. "${CT_TOP_DIR}/.config"

# Build a one-line list of files to include
CT_DoStep DEBUG "Building list of tarballs to add"
CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
CT_TARBALLS=""
for dir in '' tools debug; do
    CT_DoStep DEBUG "Scanning directory '${dir}'"
    for script in "${CT_TOP_DIR}/scripts/build/${dir}/"*.sh; do
        CT_DoStep DEBUG "Testing component '${script}'"
        [ -n "${script}" ] || continue
        unset do_print_file_name
        . "${script}"
        for file in $(do_print_filename); do
            CT_DoLog DEBUG "Finding tarball for '${file}'"
            [ -n "${file}" ] || continue
            ext=$(CT_GetFileExtension "${file}")
            CT_TestOrAbort "Missing tarball for: '${file}'" -f "${CT_TOP_DIR}/targets/tarballs/${file}${ext}"
            CT_DoLog DEBUG "Found '${file}${ext}'"
            CT_TARBALLS="${CT_TARBALLS} ${file}${ext}"
        done
        CT_EndStep
    done
    CT_EndStep
done    
CT_EndStep

# We need to emulate a build directory:
CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
mkdir -p "${CT_BUILD_DIR}"
CT_MktempDir tempdir

# Save crosstool-NG, as it is configured for the current toolchain.
topdir=$(basename "${CT_TOP_DIR}")
CT_Pushd "${CT_TOP_DIR}/.."

botdir=$(pwd)

# Build the list of files to exclude
CT_DoLog DEBUG "Building list of files to exclude"
exclude_list="${tempdir}/${CT_TARGET}.list"
{ echo ".svn";                                                  \
  echo "${topdir}/log.*";                                       \
  echo "${topdir}/targets/src";                                 \
  echo "${topdir}/targets/tst";                                 \
  echo "${topdir}/targets/*-*-*-*";                             \
  for t in $(ls -1 "${topdir}/targets/tarballs/"); do            \
      case " ${CT_TARBALLS} " in                                \
          *" ${t} "*) ;;                                        \
          *)          echo "${topdir}/targets/tarballs/${t}";;  \
      esac;                                                     \
  done;                                                         \
} >"${exclude_list}"

# Render the install directory writable
chmod u+w "${CT_PREFIX_DIR}"

CT_DoLog INFO "Saving crosstool-NG into the toolchain directory"
tar cvjf "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2"    \
    --no-wildcards-match-slash                                  \
    -X "${exclude_list}"                                        \
    "${topdir}"                                                 2>&1 |CT_DoLog ALL

CT_Popd

CT_DoLog INFO "Saving the toolchain"
tar cvjf "${botdir}/${CT_TARGET}.tar.bz2" "${CT_PREFIX_DIR}"    2>&1 |CT_DoLog ALL

CT_DoLog DEBUG "Getting rid of working directories"
rm -f "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2"
rm -rf "${tempdir}"

if [ "${CT_INSTALL_DIR_RO}" = "y" ]; then
    # Render the install directory non-writable
    chmod u-w "${CT_PREFIX_DIR}"
fi