scripts/patch-renumber.sh
author Cody P Schafer <dev@codyps.com>
Mon May 12 00:02:13 2014 +0200 (2014-05-12)
changeset 3322 eb13867a034c
parent 1623 f935634ef900
permissions -rwxr-xr-x
arch/powerpc: add powerpc64le support

Technically, I don't forbid powerpcle support either, but I'm not sure that
there is any library/compiler support for that at the moment (though the hw
technically makes it possible).

powerpc64le needs glibc 2.19 and gcc 4.9. I haven't looked into the support
tools, but at least gdb 7.5 is too old (7.7.1 definitely has support).

Also make powerpc64 non-experimental. It's practically old at this point.

Signed-off-by: Cody P Schafer <dev@codyps.com>
[yann.morin.1998@free.fr: use ${target_endian_le} and ${target_bits_64}]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <64bfbbced9dd8f62e0d6.1399801945@gun>
Patchwork-Id: 347775
yann@756
     1
#!/bin/sh
yann@756
     2
# Yes, this intends to be a true POSIX script file.
yann@1175
     3
set -e
yann@756
     4
yann@756
     5
myname="$0"
yann@756
     6
yann@1175
     7
# Parse the tools' paths configuration
yann@1623
     8
# It is expected that this script is only to be run from the
yann@1623
     9
# source directory of crosstool-NG, so it is trivial to find
yann@2838
    10
# paths.sh (we can't use  ". paths.sh", as POSIX states that
yann@1623
    11
# $PATH should be searched for, and $PATH most probably doe
yann@1623
    12
# not include "."), hence the "./".
yann@2838
    13
. "./paths.sh"
yann@1175
    14
yann@756
    15
doUsage() {
yann@756
    16
  cat <<_EOF_
yann@1622
    17
Usage: ${myname} <src_dir> <dst_dir> <base> <inc> [sed_re]
yann@1622
    18
    Renumbers all patches found in 'src_dir', starting at 'base', with an
yann@1622
    19
    increment of 'inc', and puts the renumbered patches in 'dst_dir'.
yann@1622
    20
    Leading digits are replaced with the new indexes, and a subsequent '_'
yann@1622
    21
    is replaced with a '-'.
yann@1608
    22
    If 'sed_re' is given, it is interpreted as a valid sed expression, and
yann@1622
    23
    is be applied to the patch name.
yann@1622
    24
    If the environment variable FAKE is set to 'y', then nothing gets done,
yann@1622
    25
    the command to run is only be printed, and not executed (so you can
yann@1622
    26
    check beforehand).
yann@1622
    27
    'dst_dir' must not yet exist.
yann@1608
    28
    Eg.:
yann@1622
    29
      patch-renumber.sh patches/gcc/4.2.3 patches/gcc/4.2.4 100 10
yann@1622
    30
      patch-renumber.sh /some/dir/my-patches patches/gcc/4.3.1 100 10 's/(all[_-])*(gcc[-_])*//;'
yann@756
    31
_EOF_
yann@756
    32
}
yann@756
    33
yann@1622
    34
[ $# -lt 4 -o $# -gt 5 ] && { doUsage; exit 1; }
yann@756
    35
yann@1622
    36
src="${1}"
yann@1622
    37
dst="${2}"
yann@1622
    38
cpt="${3}"
yann@1622
    39
inc="${4}"
yann@1622
    40
sed_re="${5}"
yann@1622
    41
if [ ! -d "${src}" ]; then
yann@1622
    42
    printf "%s: '%s': not a directory\n" "${myname}" "${src}"
yann@1622
    43
    exit 1
yann@1622
    44
fi
yann@1622
    45
if [ -d "${dst}" ]; then
yann@1622
    46
    printf "%s: '%s': directory already exists\n" "${myname}" "${dst}"
yann@1622
    47
    exit 1
yann@1608
    48
fi
yann@1608
    49
yann@1622
    50
Q=
yann@1622
    51
if [ -n "${FAKE}" ]; then
yann@1622
    52
    printf "%s: won't do anything: FAKE='%s'\n" "${myname}" "${FAKE}"
yann@1622
    53
    Q="echo"
yann@1622
    54
fi
yann@1622
    55
yann@1622
    56
${Q} mkdir -pv "${dst}"
yann@1622
    57
for p in "${src}/"*.patch*; do
yann@756
    58
    [ -e "${p}" ] || { echo "No such file '${p}'"; exit 1; }
yann@1608
    59
    newname="$(printf "%03d-%s"                                     \
yann@1608
    60
                      "${cpt}"                                      \
yann@1608
    61
                      "$( basename "${p}"                           \
yann@1608
    62
                          |"${sed}" -r -e 's/^[[:digit:]]+[-_]//'   \
yann@1608
    63
                                       -e "${sed_re}"               \
yann@1608
    64
                        )"                                          \
yann@1192
    65
              )"
yann@1622
    66
    ${Q} cp -v "${p}" "${dst}/${newname}"
yann@756
    67
    cpt=$((cpt+inc))
yann@756
    68
done