tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Jul 29 16:48:20 2008 +0000 (2008-07-29)
changeset 750 0cbd1eb86f68
parent 546 0bf5637e0afd
child 858 e815b1a5057c
permissions -rwxr-xr-x
Pretyy-up the WiKi table with the date of last update for each sample.

/trunk/scripts/showSamples.sh | 15 12 3 0 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
     1 #!/bin/bash
     2 
     3 # Adds a new version to one of the toolchain component
     4 myname="$0"
     5 
     6 doHelp() {
     7     cat <<-EOF
     8 Usage: ${myname} <tool> [option] <version>
     9   'tool' in one of:
    10     --gcc, --binutils, --glibc, --uClibc, --linux,
    11     --gdb, --dmalloc, --duma, --strace, --ltrace, --libelf
    12     --gmp, --mpfr
    13 
    14   Valid options for all tools:
    15     --experimental, -x
    16       mark the version as being experimental
    17 
    18     --obsolete, -o
    19       mark the version as being obsolete
    20 
    21   Valid mandatory 'option' for tool==linux is one and only one of:
    22     --install, --sanitised, --copy
    23 
    24   'version' is a valid version for the specified tool.
    25 
    26   Examples:
    27     add version 2.6.19.2 to linux kernel install method:
    28       ${myname} --linux --install 2.6.19.2
    29 
    30     add versions 2.3.5 and 2.3.6 to glibc:
    31       ${myname} --glibc 2.3.5 2.3.6
    32 EOF
    33 }
    34 
    35 cat=
    36 tool=
    37 tool_prefix=
    38 tool_suffix=
    39 VERSION=
    40 EXP=
    41 OBS=
    42 prompt_suffix=
    43 
    44 i=1
    45 while [ $i -le $# ]; do
    46     case "${!i}" in
    47         # Tools:
    48         --gcc)              cat=CC;        tool=gcc;      tool_prefix=cc;      tool_suffix=;;
    49         --binutils)         cat=BINUTILS;  tool=binutils; tool_prefix=;        tool_suffix=;;
    50         --glibc)            cat=LIBC;      tool=glibc;    tool_prefix=libc;    tool_suffix=;;
    51         --uClibc)           cat=LIBC;      tool=uClibc;   tool_prefix=libc;    tool_suffix=;;
    52         --linux)            cat=KERNEL;    tool=linux;    tool_prefix=kernel;  tool_suffix=;;
    53         --gdb)              cat=GDB;       tool=gdb;      tool_prefix=debug    tool_suffix=;;
    54         --dmalloc)          cat=DMALLOC;   tool=dmalloc;  tool_prefix=debug    tool_suffix=;;
    55         --duma)             cat=DUMA;      tool=duma;     tool_prefix=debug    tool_suffix=;;
    56         --strace)           cat=STRACE;    tool=strace;   tool_prefix=debug    tool_suffix=;;
    57         --ltrace)           cat=LTRACE;    tool=ltrace;   tool_prefix=debug    tool_suffix=;;
    58         --libelf)           cat=LIBELF;    tool=libelf;   tool_prefix=tools    tool_suffix=;;
    59         --gmp)              cat=GMP;       tool=gmp;      tool_prefix=cc;      tool_suffix=;;
    60         --mpfr)             cat=MPFR;      tool=mpfr;     tool_prefix=cc;      tool_suffix=;;
    61         # Tools options:
    62         -x|--experimental)  EXP=1; OBS=; prompt_suffix=" (EXPERIMENTAL)";;
    63         -o|--obsolete)      OBS=1; EXP=; prompt_suffix=" (OBSOLETE)";;
    64         --install)          tool_suffix=install;;
    65         --sanitised)        tool_suffix=sanitised;;
    66         --copy)             tool_suffix=copy;;
    67         # Misc:
    68         -h|--help)          doHelp; exit 0;;
    69         -*)                 echo "Unknown option: '${!i}' (use -h/--help for help)."; exit 1;;
    70         *)                  VERSION="${VERSION} ${!i}";;
    71     esac
    72     i=$((i+1))
    73 done
    74 
    75 [ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
    76 
    77 case "${cat}" in
    78     KERNEL) [ -z "${tool_suffix}" ] && { doHelp; exit 1; } ;;
    79     *)      ;;
    80 esac
    81 
    82 for ver in ${VERSION}; do
    83     # Split VERSION into MAJOR MINOR PATCHLEVEL EXTRAVERSION 
    84     ver_M=$(echo "${ver}...." |cut -d . -f 1)
    85     ver_m=$(echo "${ver}...." |cut -d . -f 2)
    86     ver_P=$(echo "${ver}...." |cut -d . -f 3)
    87     ver_E=$(echo "${ver}...." |cut -d . -f 4)
    88     unset DEP L1 L2 L3 L4 L5 L6 FILE
    89     v=$(echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;')
    90     if [ "${cat}" = "KERNEL" ]; then
    91         TOOL_SUFFIX=$(echo "${tool_suffix}" |tr [[:lower:]] [[:upper:]])
    92         L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
    93         L2="    bool\n"
    94         L3="    prompt \"${ver}${prompt_suffix}\"\n"
    95         # Extra versions are not necessary visible:
    96         case "${tool_suffix},${ver}" in
    97             sanitised,*)    ;; # Sanitised headers always have an extra version
    98             *,*.*.*.*)      DEP="${DEP} && KERNEL_VERSION_SEE_EXTRAVERSION";;
    99         esac
   100         L6="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
   101         FILE="config/${tool_prefix}/${tool}_headers_${tool_suffix}.in"
   102     else
   103         L1="config ${cat}_V_${v}\n"
   104         L2="    bool\n"
   105         L3="    prompt \"${ver}${prompt_suffix}\"\n"
   106         L6="    default \"${ver}\" if ${cat}_V_${v}"
   107         case "${tool}" in
   108             gcc)
   109                 if [ ${ver_M} -gt 4 -o \( ${ver_M} -eq 4 -a ${ver_m} -ge 3 \) ]; then
   110                     L5="    select CC_GCC_4_3_or_later\n"
   111                 fi
   112                 ;;
   113         esac
   114         FILE="config/${tool_prefix}/${tool}.in"
   115     fi
   116     [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
   117     [ -n "${OBS}" ] && DEP="${DEP} && OBSOLETE"
   118     case "${DEP}" in
   119         "") ;;
   120         *)  L4="    depends on "$(echo "${DEP}" |sed -r -e 's/^ \&\& //; s/\&/\\&/g;')"\n"
   121     esac
   122     sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}${L5}"'\n\1/;
   123                   s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L6}"'\n\1/;' "${FILE}"
   124 done