tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Feb 14 22:34:19 2008 +0000 (2008-02-14)
changeset 422 dcc13bf07ba6
parent 375 4beb099d5aa4
child 448 08da017ba46b
permissions -rwxr-xr-x
Argh! Kill latest (hopefuly) remnants of core/final gcc versions.
     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 
    13   Valid options for all tools:
    14     --experimental, -x
    15       mark the version as being experimental
    16 
    17     --obsolete, -o
    18       mark the version as being obsolete
    19 
    20   Valid mandatory 'option' for tool==linux is one and only one of:
    21     --install, --sanitised, --copy
    22 
    23   'version' is a valid version for the specified tool.
    24 
    25   Examples:
    26     add version 2.6.19.2 to linux kernel install method:
    27       ${myname} --linux --install 2.6.19.2
    28 
    29     add versions 2.3.5 and 2.3.6 to glibc:
    30       ${myname} --glibc 2.3.5 2.3.6
    31 EOF
    32 }
    33 
    34 cat=
    35 tool=
    36 tool_prefix=
    37 tool_suffix=
    38 VERSION=
    39 EXP=
    40 OBS=
    41 prompt_suffix=
    42 
    43 i=1
    44 while [ $i -le $# ]; do
    45     case "${!i}" in
    46         # Tools:
    47         --gcc)              cat=CC;        tool=gcc;      tool_prefix=cc_;      tool_suffix=;;
    48         --binutils)         cat=BINUTILS;  tool=binutils; tool_prefix=;         tool_suffix=;;
    49         --glibc)            cat=LIBC;      tool=glibc;    tool_prefix=libc_;    tool_suffix=;;
    50         --uClibc)           cat=LIBC;      tool=uClibc;   tool_prefix=libc_;    tool_suffix=;;
    51         --linux)            cat=KERNEL;    tool=linux;    tool_prefix=kernel_;  tool_suffix=;;
    52         --gdb)              cat=GDB;       tool=gdb;      tool_prefix=debug/    tool_suffix=;;
    53         --dmalloc)          cat=DMALLOC;   tool=dmalloc;  tool_prefix=debug/    tool_suffix=;;
    54         --duma)             cat=DUMA;      tool=duma;     tool_prefix=debug/    tool_suffix=;;
    55         --strace)           cat=STRACE;    tool=strace;   tool_prefix=debug/    tool_suffix=;;
    56         --ltrace)           cat=LTRACE;    tool=ltrace;   tool_prefix=debug/    tool_suffix=;;
    57         --libelf)           cat=LIBELF;    tool=libelf;   tool_prefix=tools/    tool_suffix=;;
    58         # Tools options:
    59         -x|--experimental)  EXP=1; OBS=; prompt_suffix=" (EXPERIMENTAL)";;
    60         -o|--obsolete)      OBS=1; EXP=; prompt_suffix=" (OBSOLETE)";;
    61         --install)          tool_suffix=install;;
    62         --sanitised)        tool_suffix=sanitised;;
    63         --copy)             tool_suffix=copy;;
    64         # Misc:
    65         -h|--help)          doHelp; exit 0;;
    66         -*)                 echo "Unknown option: \"${!i}\". (use -h/--help for help"; exit 1;;
    67         *)                  VERSION="${VERSION} ${!i}";;
    68     esac
    69     i=$((i+1))
    70 done
    71 
    72 [ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
    73 
    74 case "${cat}" in
    75     KERNEL) [ -z "${tool_suffix}" ] && { doHelp; exit 1; } ;;
    76     *)      ;;
    77 esac
    78 
    79 for ver in ${VERSION}; do
    80     unset DEP L1 L2 L3 L4 L5 FILE
    81     v=`echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;'`
    82     if [ "${cat}" = "KERNEL" ]; then
    83         TOOL_SUFFIX="`echo \"${tool_suffix}\" |tr [[:lower:]] [[:upper:]]`"
    84         L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
    85         L2="    bool\n"
    86         L3="    prompt \"${ver}${prompt_suffix}\"\n"
    87         # Extra versions are not necessary visible:
    88         case "${tool_suffix},${ver}" in
    89             sanitised,*)    ;; # Sanitised headers always have an extra version
    90             *,*.*.*.*)      DEP="${DEP} && KERNEL_VERSION_SEE_EXTRAVERSION";;
    91         esac
    92         L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
    93         FILE="config/${tool_prefix}${tool}_headers_${tool_suffix}.in"
    94     else
    95         L1="config ${cat}_V_${v}\n"
    96         L2="    bool\n"
    97         L3="    prompt \"${ver}${prompt_suffix}\"\n"
    98         L5="    default \"${ver}\" if ${cat}_V_${v}"
    99         FILE="config/${tool_prefix}${tool}.in"
   100     fi
   101     [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
   102     [ -n "${OBS}" ] && DEP="${DEP} && OBSOLETE"
   103     case "${DEP}" in
   104         "") ;;
   105         *)  L4="    depends on `echo \"${DEP}\" |sed -r -e 's/^ \\&\\& //; s/\\&/\\\\&/g;'`\n"
   106     esac
   107     sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
   108                   s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' "${FILE}"
   109 done