scripts/patch-renumber.sh
author "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Wed Dec 14 16:55:22 2011 +0100 (2011-12-14)
branch1.13
changeset 2848 1ff89596dab0
parent 1622 9ad2a3fd1fcc
child 2838 822af73497bf
permissions -rwxr-xr-x
libc/eglibc: fix localedef 2.14 build

The localedef of eglibc 2.14 requires NOT_IN_libc to be defined in order to
compile intl/l10nflist.c.

This is because localedef is built separately from eglibc and uses some parts of
eglibc that don't compile in standalone without this preprocessor definition.

This fixes the following error:

[ALL ] gcc -g -O2 -DNO_SYSCONF -DNO_UNCOMPRESS
-DLOCALE_PATH='"/usr/lib/locale:/usr/share/i18n"'
-DLOCALEDIR='"/usr/lib/locale"' -DLOCALE_ALIAS_PATH='"/usr/share/locale"'
-DCHARMAP_PATH='"/usr/share/i18n/charmaps"'
-DREPERTOIREMAP_PATH='"/usr/share/i18n/repertoiremaps"'
-DLOCSRCDIR='"/usr/share/i18n/locales"' -Iglibc/locale/programs -Iglibc/locale
-I/<snip>/.build/src/eglibc-localedef-2_14/include
-I/<snip>/.build/src/eglibc-localedef-2_14 -I.
-include /<snip>/.build/src/eglibc-localedef-2_14/include/always.h -Wall
-Wno-format -c -o locarchive.o glibc/locale/programs/locarchive.c
[ALL ] glibc/locale/programs/locarchive.c: In function 'enlarge_archive':
[ALL ] glibc/locale/programs/locarchive.c:303:21: warning: variable
'oldlocrectab' set but not used [-Wunused-but-set-variable]
[ALL ] In file included from glibc/locale/programs/locarchive.c:651:0:
[ALL ] glibc/locale/programs/../../intl/l10nflist.c: In function
'_nl_normalize_codeset':
[ERROR] glibc/locale/programs/../../intl/l10nflist.c:342:9: error:
'_nl_C_locobj_ptr' undeclared (first use in this function)
[ALL ] glibc/locale/programs/../../intl/l10nflist.c:342:9: note: each
undeclared identifier is reported only once for each function it appears in
[ALL ] glibc/locale/programs/locarchive.c: In function
'add_locales_to_archive':
[ALL ] glibc/locale/programs/locarchive.c:1450:7: warning: passing argument
1 of '__xpg_basename' discards 'const' qualifier from pointer target type
[enabled by default]
[ALL ] /usr/include/libgen.h:35:14: note: expected 'char *' but argument is
of type 'const char *'
[ERROR] make[1]: *** [locarchive.o] Error 1

Signed-off-by: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
(transplanted from 4cd9134739b594451794cf61a6e1b137422cdafd)
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@1623
    10
# paths.mk (we can't use  ". paths.mk", 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@1623
    13
. "./paths.mk"
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