tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Feb 17 22:12:59 2008 +0000 (2008-02-17)
changeset 433 9886aa0a9694
parent 375 4beb099d5aa4
child 448 08da017ba46b
permissions -rwxr-xr-x
Robert P. J. DAY says:

According to Mike Frysinger, this patch was removed from Gentoo in the
2.3.x series and didn't seem to cause any adverse effects. So toss it
from the patch directories for glibc 2.5 and up.
yann@375
     1
#!/bin/bash
yann@1
     2
yann@1
     3
# Adds a new version to one of the toolchain component
yann@1
     4
myname="$0"
yann@1
     5
yann@1
     6
doHelp() {
yann@1
     7
    cat <<-EOF
yann@1
     8
Usage: ${myname} <tool> [option] <version>
yann@1
     9
  'tool' in one of:
yann@103
    10
    --gcc, --binutils, --glibc, --uClibc, --linux,
yann@245
    11
    --gdb, --dmalloc, --duma, --strace, --ltrace, --libelf
yann@1
    12
yann@96
    13
  Valid options for all tools:
yann@43
    14
    --experimental, -x
yann@43
    15
      mark the version as being experimental
yann@43
    16
yann@96
    17
    --obsolete, -o
yann@96
    18
      mark the version as being obsolete
yann@96
    19
yann@96
    20
  Valid mandatory 'option' for tool==linux is one and only one of:
yann@1
    21
    --install, --sanitised, --copy
yann@1
    22
yann@1
    23
  'version' is a valid version for the specified tool.
yann@1
    24
yann@1
    25
  Examples:
yann@1
    26
    add version 2.6.19.2 to linux kernel install method:
yann@1
    27
      ${myname} --linux --install 2.6.19.2
yann@1
    28
yann@1
    29
    add versions 2.3.5 and 2.3.6 to glibc:
yann@1
    30
      ${myname} --glibc 2.3.5 2.3.6
yann@1
    31
EOF
yann@1
    32
}
yann@1
    33
yann@96
    34
cat=
yann@1
    35
tool=
yann@1
    36
tool_prefix=
yann@96
    37
tool_suffix=
yann@1
    38
VERSION=
yann@43
    39
EXP=
yann@96
    40
OBS=
yann@322
    41
prompt_suffix=
yann@1
    42
yann@1
    43
i=1
yann@1
    44
while [ $i -le $# ]; do
yann@1
    45
    case "${!i}" in
yann@96
    46
        # Tools:
yann@43
    47
        --gcc)              cat=CC;        tool=gcc;      tool_prefix=cc_;      tool_suffix=;;
yann@43
    48
        --binutils)         cat=BINUTILS;  tool=binutils; tool_prefix=;         tool_suffix=;;
yann@43
    49
        --glibc)            cat=LIBC;      tool=glibc;    tool_prefix=libc_;    tool_suffix=;;
yann@43
    50
        --uClibc)           cat=LIBC;      tool=uClibc;   tool_prefix=libc_;    tool_suffix=;;
yann@96
    51
        --linux)            cat=KERNEL;    tool=linux;    tool_prefix=kernel_;  tool_suffix=;;
yann@96
    52
        --gdb)              cat=GDB;       tool=gdb;      tool_prefix=debug/    tool_suffix=;;
yann@103
    53
        --dmalloc)          cat=DMALLOC;   tool=dmalloc;  tool_prefix=debug/    tool_suffix=;;
yann@236
    54
        --duma)             cat=DUMA;      tool=duma;     tool_prefix=debug/    tool_suffix=;;
yann@239
    55
        --strace)           cat=STRACE;    tool=strace;   tool_prefix=debug/    tool_suffix=;;
yann@245
    56
        --ltrace)           cat=LTRACE;    tool=ltrace;   tool_prefix=debug/    tool_suffix=;;
yann@245
    57
        --libelf)           cat=LIBELF;    tool=libelf;   tool_prefix=tools/    tool_suffix=;;
yann@96
    58
        # Tools options:
yann@322
    59
        -x|--experimental)  EXP=1; OBS=; prompt_suffix=" (EXPERIMENTAL)";;
yann@322
    60
        -o|--obsolete)      OBS=1; EXP=; prompt_suffix=" (OBSOLETE)";;
yann@43
    61
        --install)          tool_suffix=install;;
yann@43
    62
        --sanitised)        tool_suffix=sanitised;;
yann@43
    63
        --copy)             tool_suffix=copy;;
yann@96
    64
        # Misc:
yann@43
    65
        -h|--help)          doHelp; exit 0;;
yann@96
    66
        -*)                 echo "Unknown option: \"${!i}\". (use -h/--help for help"; exit 1;;
yann@96
    67
        *)                  VERSION="${VERSION} ${!i}";;
yann@1
    68
    esac
yann@1
    69
    i=$((i+1))
yann@1
    70
done
yann@1
    71
yann@1
    72
[ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
yann@1
    73
yann@1
    74
case "${cat}" in
yann@422
    75
    KERNEL) [ -z "${tool_suffix}" ] && { doHelp; exit 1; } ;;
yann@422
    76
    *)      ;;
yann@1
    77
esac
yann@1
    78
yann@1
    79
for ver in ${VERSION}; do
yann@43
    80
    unset DEP L1 L2 L3 L4 L5 FILE
yann@96
    81
    v=`echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;'`
yann@1
    82
    if [ "${cat}" = "KERNEL" ]; then
yann@1
    83
        TOOL_SUFFIX="`echo \"${tool_suffix}\" |tr [[:lower:]] [[:upper:]]`"
yann@1
    84
        L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
yann@1
    85
        L2="    bool\n"
yann@322
    86
        L3="    prompt \"${ver}${prompt_suffix}\"\n"
yann@1
    87
        # Extra versions are not necessary visible:
yann@43
    88
        case "${tool_suffix},${ver}" in
yann@43
    89
            sanitised,*)    ;; # Sanitised headers always have an extra version
yann@43
    90
            *,*.*.*.*)      DEP="${DEP} && KERNEL_VERSION_SEE_EXTRAVERSION";;
yann@1
    91
        esac
yann@1
    92
        L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
yann@43
    93
        FILE="config/${tool_prefix}${tool}_headers_${tool_suffix}.in"
yann@96
    94
    else
yann@422
    95
        L1="config ${cat}_V_${v}\n"
yann@96
    96
        L2="    bool\n"
yann@322
    97
        L3="    prompt \"${ver}${prompt_suffix}\"\n"
yann@422
    98
        L5="    default \"${ver}\" if ${cat}_V_${v}"
yann@422
    99
        FILE="config/${tool_prefix}${tool}.in"
yann@1
   100
    fi
yann@43
   101
    [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
yann@96
   102
    [ -n "${OBS}" ] && DEP="${DEP} && OBSOLETE"
yann@43
   103
    case "${DEP}" in
yann@43
   104
        "") ;;
yann@43
   105
        *)  L4="    depends on `echo \"${DEP}\" |sed -r -e 's/^ \\&\\& //; s/\\&/\\\\&/g;'`\n"
yann@43
   106
    esac
yann@43
   107
    sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
yann@43
   108
                  s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' "${FILE}"
yann@1
   109
done