tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri May 02 17:49:29 2008 +0000 (2008-05-02)
changeset 473 731718e6ffdc
parent 466 7f9bbf94b0bb
child 523 010f6f4e4dd6
permissions -rwxr-xr-x
Eye-candy in the addToolVersion.sh script.

/trunk/tools/addToolVersion.sh | 2 1 1 0 +-
1 file changed, 1 insertion(+), 1 deletion(-)
     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     unset DEP L1 L2 L3 L4 L5 FILE
    84     v=`echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;'`
    85     if [ "${cat}" = "KERNEL" ]; then
    86         TOOL_SUFFIX="`echo \"${tool_suffix}\" |tr [[:lower:]] [[:upper:]]`"
    87         L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
    88         L2="    bool\n"
    89         L3="    prompt \"${ver}${prompt_suffix}\"\n"
    90         # Extra versions are not necessary visible:
    91         case "${tool_suffix},${ver}" in
    92             sanitised,*)    ;; # Sanitised headers always have an extra version
    93             *,*.*.*.*)      DEP="${DEP} && KERNEL_VERSION_SEE_EXTRAVERSION";;
    94         esac
    95         L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
    96         FILE="config/${tool_prefix}/${tool}_headers_${tool_suffix}.in"
    97     else
    98         L1="config ${cat}_V_${v}\n"
    99         L2="    bool\n"
   100         L3="    prompt \"${ver}${prompt_suffix}\"\n"
   101         L5="    default \"${ver}\" if ${cat}_V_${v}"
   102         FILE="config/${tool_prefix}/${tool}.in"
   103     fi
   104     [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
   105     [ -n "${OBS}" ] && DEP="${DEP} && OBSOLETE"
   106     case "${DEP}" in
   107         "") ;;
   108         *)  L4="    depends on `echo \"${DEP}\" |sed -r -e 's/^ \\&\\& //; s/\\&/\\\\&/g;'`\n"
   109     esac
   110     sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
   111                   s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' "${FILE}"
   112 done