scripts/build/tools/sstrip.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Apr 26 21:31:05 2008 +0000 (2008-04-26)
changeset 454 372b2f397baa
parent 393 4e27d82d5c5d
permissions -rw-r--r--
Configure tsocks with a simple heuristic.

Consider the proxy has to be in a 'local' network. It means it is directly
reachable by the local machine, even if the local machine has to hop through
one or more gates to reach the proxy (often the case in enterprise networks
where class A 10.0.0.0/8 is in fact sub-divided into smaller networks, each
one of them in a different location, eg. 10.1.0.0/16 in a place, while
10.2.0.0/16 would be on the other side of the world). Not being in the same
subnet does not mean the proxy is not available.

So we will build a mask with at most high bits set, which defines a network
that has both the local machine and the proxy. Because a machine may have
more than one interface, build a mask for each of them, removing 127.0.0.1
which is added automagically by tsocks, and removing duplicate masks.

If all of this does not work, then it means the local machine can NOT in fact
reach the proxy, which in turn means the user mis-configured something (most
probably a typo...).

/trunk/scripts/crosstool.sh | 61 52 9 0 +++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 52 insertions(+), 9 deletions(-)
yann@149
     1
# This will build and install sstrip to run on host and sstrip target files
yann@149
     2
yann@149
     3
is_enabled="${CT_SSTRIP}"
yann@149
     4
yann@149
     5
case "${CT_SSTRIP_FROM}" in
yann@149
     6
    ELFkickers)
yann@161
     7
        do_print_filename() {
yann@161
     8
            echo "ELFkickers-${CT_SSTRIP_ELFKICKERS_VERSION}"
yann@161
     9
        }
yann@149
    10
        do_tools_sstrip_get() {
yann@149
    11
            CT_GetFile "ELFkickers-${CT_SSTRIP_ELFKICKERS_VERSION}"     \
yann@149
    12
                       http://www.muppetlabs.com/~breadbox/pub/software
yann@149
    13
        }
yann@149
    14
        do_tools_sstrip_extract() {
yann@149
    15
            CT_ExtractAndPatch "ELFkickers-${CT_SSTRIP_ELFKICKERS_VERSION}"
yann@149
    16
        }
yann@149
    17
        do_tools_sstrip_build() {
yann@149
    18
            CT_DoStep INFO "Installing sstrip"
yann@149
    19
            mkdir -p "${CT_BUILD_DIR}/build-strip"
yann@149
    20
            cd "${CT_BUILD_DIR}/build-strip"
yann@149
    21
            ( cd "${CT_SRC_DIR}/ELFkickers-${CT_SSTRIP_ELFKICKERS_VERSION}/sstrip"; tar cf - . ) |tar xf -
yann@149
    22
yann@149
    23
            CT_DoLog EXTRA "Building sstrip"
yann@149
    24
            make CC="${CT_CC_NATIVE}" sstrip 2>&1 |CT_DoLog ALL
yann@149
    25
            
yann@149
    26
            CT_DoLog EXTRA "Installing sstrip"
yann@149
    27
            install -m 755 sstrip "${CT_PREFIX_DIR}/bin/${CT_TARGET}-sstrip" 2>&1 |CT_DoLog ALL
yann@149
    28
yann@149
    29
            CT_EndStep
yann@149
    30
        }
yann@149
    31
    ;;
yann@149
    32
yann@149
    33
    buildroot)
yann@149
    34
        sstrip_url='http://buildroot.uclibc.org/cgi-bin/viewcvs.cgi/trunk/buildroot/toolchain/sstrip/sstrip.c'
yann@161
    35
        do_print_filename() {
yann@161
    36
            echo "sstrip.c"
yann@161
    37
        }
yann@149
    38
        do_tools_sstrip_get() {
yann@149
    39
            # With this one, we must handle the download by ourselves,
yann@149
    40
            # we can't leave the job to the classic CT_GetFile.
yann@161
    41
            if [ -f "${CT_TARBALLS_DIR}/sstrip.c" ]; then
yann@149
    42
                return 0
yann@149
    43
            fi
yann@204
    44
            if [ -f "${CT_LOCAL_TARBALLS_DIR}/sstrip.c" ]; then
yann@393
    45
                CT_DoLog EXTRA "Using \"sstrip\" from local storage"
yann@393
    46
                ln -sf "${CT_LOCAL_TARBALLS_DIR}/sstrip.c"  \
yann@393
    47
                       "${CT_TARBALLS_DIR}/sstrip.c"        2>&1 |CT_DoLog ALL
yann@204
    48
                return 0
yann@204
    49
            fi
yann@161
    50
            CT_Pushd "${CT_TARBALLS_DIR}"
yann@443
    51
            CT_DoLog EXTRA "Retrieving \"sstrip\" from network"
yann@149
    52
            http_data=`lynx -dump "${sstrip_url}"`
yann@149
    53
            link=`echo -en "${http_data}"                           \
yann@149
    54
                  |egrep '\[[[:digit:]]+\]download'                 \
yann@149
    55
                  |sed -r -e 's/.*\[([[:digit:]]+)\]download.*/\1/;'`
yann@149
    56
            rev_url=`echo -en "${http_data}"                        \
yann@149
    57
                     |egrep '^ *8\.'                                \
yann@149
    58
                     |sed -r -e 's/^ *'${link}'\. +(.+)$/\1/;'`
yann@149
    59
            CT_DoGetFile "${rev_url}" 2>&1 |CT_DoLog ALL
yann@278
    60
            mv -v sstrip.c?* sstrip.c 2>&1 |CT_DoLog DEBUG
yann@278
    61
            if [ "${CT_SAVE_TARBALLS}" = "y" ]; then
yann@355
    62
                CT_DoLog EXTRA "Saving \"sstrip.c\" to local storage"
yann@278
    63
                cp -v sstrip.c "${CT_LOCAL_TARBALLS_DIR}" 2>&1 |CT_DoLog DEBUG
yann@278
    64
            fi
yann@149
    65
            CT_Popd
yann@149
    66
        }
yann@149
    67
        do_tools_sstrip_extract() {
yann@149
    68
            # We'll let buildroot guys take care of sstrip maintenance and patching.
yann@161
    69
            mkdir -p "${CT_SRC_DIR}/sstrip"
yann@161
    70
            cp -v "${CT_TARBALLS_DIR}/sstrip.c" "${CT_SRC_DIR}/sstrip" |CT_DoLog ALL
yann@149
    71
        }
yann@149
    72
        do_tools_sstrip_build() {
yann@149
    73
            CT_DoStep INFO "Installing sstrip"
yann@149
    74
            mkdir -p "${CT_BUILD_DIR}/build-sstrip"
yann@149
    75
            cd "${CT_BUILD_DIR}/build-sstrip"
yann@149
    76
yann@149
    77
            CT_DoLog EXTRA "Building sstrip"
yann@149
    78
            ${CT_CC_NATIVE} -Wall -o sstrip "${CT_SRC_DIR}/sstrip/sstrip.c" 2>&1 |CT_DoLog ALL
yann@149
    79
yann@149
    80
            CT_DoLog EXTRA "Installing sstrip"
yann@149
    81
            install -m 755 sstrip "${CT_PREFIX_DIR}/bin/${CT_TARGET}-sstrip" 2>&1 |CT_DoLog ALL
yann@149
    82
yann@149
    83
            CT_EndStep
yann@149
    84
        }
yann@149
    85
    ;;
yann@161
    86
yann@161
    87
    *)  do_print_filename() {
yann@161
    88
            :
yann@161
    89
        }
yann@161
    90
        do_tools_sstrip_get() {
yann@161
    91
            :
yann@161
    92
        }
yann@161
    93
        do_tools_sstrip_extract() {
yann@161
    94
            :
yann@161
    95
        }
yann@161
    96
        do_tools_sstrip_build() {
yann@161
    97
            :
yann@161
    98
        }
yann@161
    99
    ;;
yann@149
   100
esac