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