scripts/functions: Fix CT_ExtractGit function.
Change CT_ExtractGit so that it clones the repository, instead of just
symlinking it. After cloning, any given ref is checked out, or if no
ref is given, the HEAD of the repository is checked out.
This makes CT_Extract behave similar for git repositories as it does
for tarballs, so that it for example can be used for passing glibc-ports
as a git repository.
Signed-off-by: "Esben Haabendal" <esben.haabendal@prevas.dk>
[yann.morin.1998@anciens.enib.fr: fix incomplete var rename]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
4 # Adds a new version to one of the toolchain component
7 # Parse the tools' paths configuration
8 # It is expected that this script is only to be run from the
9 # source directory of crosstool-NG, so it is trivial to find
10 # paths.mk (we can't use ". paths.mk", as POSIX states that
11 # $PATH should be searched for, and $PATH most probably doe
12 # not include "."), hence the "./".
17 Usage: ${myname} <--tool> <[options] version [...]> ...
19 gcc, binutils, glibc, eglibc, uClibc, newlib, linux, gdb, dmalloc,
20 duma, strace, ltrace, libelf, gmp, mpfr, ppl, cloog, mpc
22 Valid options for all tools:
23 --stable, -s, +x (default)
24 mark the version as being stable (as opposed to experimental, below)
26 --experimental, -x, +s
27 mark the version as being experimental (as opposed to stable, above)
29 --current, -c, +o (default)
30 mark the version as being cuurent (as opposed to obsolete, below)
33 mark the version as being obsolete (as opposed to current, above)
35 Note: setting a new tool resets to the defaults: 'stable' and 'current'.
37 'version' is a valid version for the specified tool.
40 add stable current version 2.6.19.2 to linux kernel:
41 ${myname} --linux 2.6.19.2
43 add experimental obsolete version 2.3.5 and stable current versions 2.6.1
44 and 2.6.2 to glibc, add stable obsolete version 3.3.3 to gcc:
45 ${myname} --glibc -x -o 2.3.5 -s -c 2.6.1 2.6.2 --gcc -o 3.3.3
49 # Extract field $3 from version $1 with separator $2
55 echo "${version}${sep}${sep}${sep}${sep}" |cut -d ${sep} -f ${field}
58 # Effectively add a version to the specified tool
59 # $cat : tool category
61 # $tool_prefix : tool directory prefix
62 # $EXP : set to non empty if experimental, to empty otherwise
63 # #OBS : set to non empty if obsolete, to empty otherwise
64 # $1 : version string to add
68 local config_ver_option
70 local deps v ver_M ver_m ver_p
71 local SedExpr1 SedExpr2
73 [ -f "${file}" ] || return 0
75 v=$(echo "${version}" |"${sed}" -r -e 's/-/_/g; s/\./_/g;')
77 config_ver_option="${cat}_V_${v}"
79 # Check for existing version: it can be legitimitate for an end-user
80 # to try adding a new version if the one he/she wants is not listed.
81 # But it can be the case where the version is hidden behind either one
82 # of EXPERIMENTAL or OBSOLETE, so warn if the version is already listed.
83 if grep -E "^config ${config_ver_option}$" "${file}" >/dev/null 2>&1; then
84 echo "'${tool}': version '${version}' already present:"
86 -E "^(config ${config_ver_option}| {4}prompt \"${version}\")$" \
91 SedExpr1="${SedExpr1}config ${config_ver_option}\n"
92 SedExpr1="${SedExpr1} bool\n"
93 SedExpr1="${SedExpr1} prompt \"${version}"
94 case "${EXP},${OBS}" in
96 ,*) exp_obs_prompt=" (OBSOLETE)"
97 deps=" depends on OBSOLETE"
99 *,) exp_obs_prompt=" (EXPERIMENTAL)"
100 deps=" depends on EXPERIMENTAL"
102 *) exp_obs_prompt=" (EXPERIMENTAL, OBSOLETE)"
103 deps=" depends on EXPERIMENTAL \\&\\& OBSOLETE"
106 [ -n "${exp_obs_prompt}" ] && SedExpr1="${SedExpr1}${exp_obs_prompt}"
107 SedExpr1="${SedExpr1}\""
108 [ -n "${deps}" ] && SedExpr1="${SedExpr1}\n${deps}"
111 # Extract 'M'ajor and 'm'inor from version string
112 ver_M=$(getVersionField "${version}" . 1)
113 ver_m=$(getVersionField "${version}" . 2)
114 if [ \( ${ver_M} -eq 4 -a ${ver_m} -eq 6 \) ]; then
115 SedExpr1="${SedExpr1}\n select CC_GCC_4_6"
116 elif [ \( ${ver_M} -eq 4 -a ${ver_m} -eq 5 \) ]; then
117 SedExpr1="${SedExpr1}\n select CC_GCC_4_5"
118 elif [ \( ${ver_M} -eq 4 -a ${ver_m} -eq 4 \) ]; then
119 SedExpr1="${SedExpr1}\n select CC_GCC_4_4"
120 elif [ \( ${ver_M} -eq 4 -a ${ver_m} -eq 3 \) ]; then
121 SedExpr1="${SedExpr1}\n select CC_GCC_4_3"
122 elif [ \( ${ver_M} -eq 4 -a ${ver_m} -eq 2 \) ]; then
123 SedExpr1="${SedExpr1}\n select CC_GCC_4_2"
127 # Extract 'M'ajor and 'm'inor from version string
128 ver_M=$(getVersionField "${version}" . 1)
129 ver_m=$(getVersionField "${version}" . 2)
130 if [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 21 \) ]; then
131 SedExpr1="${SedExpr1}\n select BINUTILS_2_21_or_later"
132 elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 20 \) ]; then
133 SedExpr1="${SedExpr1}\n select BINUTILS_2_20_or_later"
134 elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 19 \) ]; then
135 SedExpr1="${SedExpr1}\n select BINUTILS_2_19_or_later"
136 elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 18 \) ]; then
137 SedExpr1="${SedExpr1}\n select BINUTILS_2_18_or_later"
141 # Extract 'M'ajor and 'm'inor from version string
142 ver_M=$(getVersionField "${version}" . 1)
143 ver_m=$(getVersionField "${version}" . 2)
144 if [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 13 \) ]; then
145 SedExpr1="${SedExpr1}\n select LIBC_EGLIBC_2_13_or_later"
146 elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 12 \) ]; then
147 SedExpr1="${SedExpr1}\n select LIBC_EGLIBC_2_12_or_later"
148 elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 11 \) ]; then
149 SedExpr1="${SedExpr1}\n select LIBC_EGLIBC_2_11_or_later"
150 elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 10 \) ]; then
151 SedExpr1="${SedExpr1}\n select LIBC_EGLIBC_2_10_or_later"
152 elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 9 \) ]; then
153 SedExpr1="${SedExpr1}\n select LIBC_EGLIBC_2_9_or_later"
157 # uClibc-0.9.30 and above need some love
158 ver_M=$(getVersionField "${version}" . 1)
159 ver_m=$(getVersionField "${version}" . 2)
160 ver_p=$(getVersionField "${version}" . 3)
161 if [ ${ver_M} -eq 0 -a ${ver_m} -eq 9 -a ${ver_p} -eq 30 \
162 -o ${ver_M} -eq 0 -a ${ver_m} -eq 9 -a ${ver_p} -eq 31 ]; then
163 SedExpr1="${SedExpr1}\n select LIBC_UCLIBC_0_9_30_or_later"
164 elif [ ${ver_M} -eq 0 -a ${ver_m} -eq 9 -a ${ver_p} -eq 32 ]; then
165 SedExpr1="${SedExpr1}\n select LIBC_UCLIBC_0_9_32_or_later"
169 # gdb-7.0 and above have special handling
170 ver_M=$(getVersionField "${version}" . 1)
171 if [ ${ver_M} -ge 7 ]; then
172 SedExpr1="${SedExpr1}\n select GDB_7_0_or_later"
176 SedExpr2=" default \"${version}\" if ${config_ver_option}"
177 "${sed}" -r -i -e 's/^(# CT_INSERT_VERSION_BELOW)$/\1\n\n'"${SedExpr1}"'/;' "${file}"
178 "${sed}" -r -i -e 's/^(# CT_INSERT_VERSION_STRING_BELOW)$/\1\n'"${SedExpr2}"'/;' "${file}"
188 if [ $# -eq 0 ]; then
193 while [ $# -gt 0 ]; do
196 --gcc) EXP=; OBS=; cat=CC; tool=gcc; tool_prefix=cc;;
197 --binutils) EXP=; OBS=; cat=BINUTILS; tool=binutils; tool_prefix=binutils;;
198 --glibc) EXP=; OBS=; cat=LIBC_GLIBC; tool=glibc; tool_prefix=libc;;
199 --eglibc) EXP=; OBS=; cat=LIBC_EGLIBC; tool=eglibc; tool_prefix=libc;;
200 --uClibc) EXP=; OBS=; cat=LIBC_UCLIBC; tool=uClibc; tool_prefix=libc;;
201 --newlib) EXP=; OBS=; cat=LIBC_NEWLIB; tool=newlib; tool_prefix=libc;;
202 --linux) EXP=; OBS=; cat=KERNEL; tool=linux; tool_prefix=kernel;;
203 --gdb) EXP=; OBS=; cat=GDB; tool=gdb; tool_prefix=debug;;
204 --dmalloc) EXP=; OBS=; cat=DMALLOC; tool=dmalloc; tool_prefix=debug;;
205 --duma) EXP=; OBS=; cat=DUMA; tool=duma; tool_prefix=debug;;
206 --strace) EXP=; OBS=; cat=STRACE; tool=strace; tool_prefix=debug;;
207 --ltrace) EXP=; OBS=; cat=LTRACE; tool=ltrace; tool_prefix=debug;;
208 --gmp) EXP=; OBS=; cat=GMP; tool=gmp; tool_prefix=companion_libs;;
209 --mpfr) EXP=; OBS=; cat=MPFR; tool=mpfr; tool_prefix=companion_libs;;
210 --ppl) EXP=; OBS=; cat=PPL; tool=ppl; tool_prefix=companion_libs;;
211 --cloog) EXP=; OBS=; cat=CLOOG; tool=cloog; tool_prefix=companion_libs;;
212 --mpc) EXP=; OBS=; cat=MPC; tool=mpc; tool_prefix=companion_libs;;
213 --libelf) EXP=; OBS=; cat=LIBELF; tool=libelf; tool_prefix=companion_libs;;
216 -x|--experimental|+s) EXP=1;;
217 -s|--stable|+x) EXP=;;
218 -o|--obsolete|+c) OBS=1;;
219 -c|--current|+o) OBS=;;
222 -h|--help) doHelp; exit 0;;
223 -*) echo "Unknown option: '$1' (use -h/--help for help)."; exit 1;;
226 *) [ -n "${tool}" ] || { doHelp; exit 1; }
227 file_base="config/${tool_prefix}/${tool}.in"
228 # Components have their version selection either
229 # in the .in or the .in.2 file. Handle both.
230 addToolVersion "$1" "${file_base}"
231 addToolVersion "$1" "${file_base}.2"