diff -r c4d124ed9f8e -r 5e5d1e6f55d3 scripts/functions --- a/scripts/functions Sun Apr 19 16:17:11 2009 +0000 +++ b/scripts/functions Sun May 03 09:50:16 2009 +0000 @@ -288,103 +288,6 @@ return 0 } -# Set environment for proxy access -# Usage: CT_DoSetProxy -# where proxy_type is one of 'http', 'sockssys', 'socks4' or 'socks5', -# or empty (to not change proxy settings). -CT_DoSetProxy() { - case "${1}" in - http) - http_proxy="http://" - case "${CT_PROXY_USER}:${CT_PROXY_PASS}" in - :) ;; - :*) http_proxy="${http_proxy}:${CT_PROXY_PASS}@";; - *:) http_proxy="${http_proxy}${CT_PROXY_USER}@";; - *:*) http_proxy="${http_proxy}${CT_PROXY_USER}:${CT_PROXY_PASS}@";; - esac - export http_proxy="${http_proxy}${CT_PROXY_HOST}:${CT_PROXY_PORT}/" - export https_proxy="${http_proxy}" - export ftp_proxy="${http_proxy}" - CT_DoLog DEBUG "http_proxy='${http_proxy}'" - ;; - sockssys) - CT_HasOrAbort tsocks - . tsocks -on - ;; - socks*) - # Remove any lingering config file from any previous run - rm -f "${CT_BUILD_DIR}/tsocks.conf" - # Find all interfaces and build locally accessible networks - server_ip=$(ping -c 1 -W 2 "${CT_PROXY_HOST}" |head -n 1 |sed -r -e 's/^[^\(]+\(([^\)]+)\).*$/\1/;' || true) - CT_TestOrAbort "SOCKS proxy '${CT_PROXY_HOST}' has no IP." -n "${server_ip}" - /sbin/ifconfig |"${awk}" -v server_ip="${server_ip}" ' - BEGIN { - split( server_ip, tmp, "\\." ); - server_ip_num = tmp[1] * 2^24 + tmp[2] * 2^16 + tmp[3] * 2^8 + tmp[4] * 2^0; - pairs = 0; - } - - $0 ~ /^[[:space:]]*inet addr:/ { - split( $2, tmp, ":|\\." ); - if( ( tmp[2] == 127 ) && ( tmp[3] == 0 ) && ( tmp[4] == 0 ) && ( tmp[5] == 1 ) ) { - /* Skip 127.0.0.1, it'\''s taken care of by tsocks itself */ - next; - } - ip_num = tmp[2] * 2^24 + tmp[3] * 2^16 + tmp[4] * 2 ^8 + tmp[5] * 2^0; - i = 32; - do { - i--; - mask = 2^32 - 2^i; - } while( (i!=0) && ( and( server_ip_num, mask ) == and( ip_num, mask ) ) ); - mask = and( 0xFFFFFFFF, lshift( mask, 1 ) ); - if( (i!=0) && (mask!=0) ) { - masked_ip = and( ip_num, mask ); - for( i=0; i"${CT_BUILD_DIR}/tsocks.conf" - ( echo "server = ${server_ip}"; - echo "server_port = ${CT_PROXY_PORT}"; - [ -n "${CT_PROXY_USER}" ] && echo "default_user=${CT_PROXY_USER}"; - [ -n "${CT_PROXY_PASS}" ] && echo "default_pass=${CT_PROXY_PASS}"; - ) >>"${CT_BUILD_DIR}/tsocks.conf" - case "${CT_PROXY_TYPE/socks}" in - 4|5) proxy_type="${CT_PROXY_TYPE/socks}";; - auto) - reply=$(inspectsocks "${server_ip}" "${CT_PROXY_PORT}" 2>&1 || true) - case "${reply}" in - *"server is a version 4 socks server") proxy_type=4;; - *"server is a version 5 socks server") proxy_type=5;; - *) CT_Abort "Unable to determine SOCKS proxy type for '${CT_PROXY_HOST}:${CT_PROXY_PORT}'" - esac - ;; - esac - echo "server_type = ${proxy_type}" >> "${CT_BUILD_DIR}/tsocks.conf" - CT_HasOrAbort tsocks - # If tsocks was found, then validateconf is present (distributed with tsocks). - CT_DoExecLog DEBUG validateconf -f "${CT_BUILD_DIR}/tsocks.conf" - export TSOCKS_CONF_FILE="${CT_BUILD_DIR}/tsocks.conf" - . tsocks -on - ;; - esac -} - # Download an URL using wget # Usage: CT_DoGetFileWget CT_DoGetFileWget() { @@ -506,10 +409,9 @@ # Add URLs on the LAN mirror LAN_URLS= if [ "${CT_USE_MIRROR}" = "y" ]; then - CT_TestOrAbort "Please set the LAN mirror hostname" -n "${CT_MIRROR_HOSTNAME}" - CT_TestOrAbort "Please tell me where to find tarballs on the LAN mirror '${CT_MIRROR_HOSTNAME}'" -n "${CT_MIRROR_BASE}" - LAN_URLS="${LAN_URLS} ${CT_MIRROR_SCHEME}://${CT_MIRROR_HOSTNAME}/${CT_MIRROR_BASE}/${file%-*}" - LAN_URLS="${LAN_URLS} ${CT_MIRROR_SCHEME}://${CT_MIRROR_HOSTNAME}/${CT_MIRROR_BASE}" + CT_TestOrAbort "Please set the mirror base URL" -n "${CT_MIRROR_BASE_URL}" + LAN_URLS="${LAN_URLS} ${CT_MIRROR_BASE_URL}/${file%-*}" + LAN_URLS="${LAN_URLS} ${CT_MIRROR_BASE_URL}" if [ "${CT_PREFER_MIRROR}" = "y" ]; then CT_DoLog DEBUG "Pre-pending LAN mirror URLs" @@ -521,7 +423,6 @@ fi # Scan all URLs in turn, and try to grab a tarball from there - CT_DoSetProxy ${CT_PROXY_TYPE} for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do # Try all urls in turn for url in ${URLS}; do @@ -567,7 +468,6 @@ CT_MktempDir tmp_dir CT_Pushd "${tmp_dir}" - CT_DoSetProxy ${CT_PROXY_TYPE} CT_DoExecLog ALL cvs -z 9 -d "${uri}" co -P ${tag} "${module}" [ -n "${dirname}" ] && CT_DoExecLog ALL mv "${module}" "${dirname}" CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${dirname:-${module}}" @@ -600,7 +500,6 @@ CT_MktempDir tmp_dir CT_Pushd "${tmp_dir}" - CT_DoSetProxy ${CT_PROXY_TYPE} CT_DoExecLog ALL svn export ${rev:+-r ${rev}} "${uri}" "${basename}" CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${basename}" CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}.tar.bz2" @@ -844,8 +743,8 @@ CT_DoLog DEBUG " Saving environment and aliases" # We must omit shell functions, and some specific bash variables # that break when restoring the environment, later. We could do - # all the processing in the gawk script, but a sed is easier... - set |"${awk}" ' + # all the processing in the awk script, but a sed is easier... + set |awk ' BEGIN { _p = 1; } $0~/^[^ ]+ \(\)/ { _p = 0; } _p == 1