From 7f225e2e70ad57927d6b8dd42895985c95132982 Mon Sep 17 00:00:00 2001 From: hillsp Date: Tue, 6 Dec 2016 13:16:29 -0500 Subject: [PATCH] Add format_binary_url.sh (#1331) --- PSOL_BINARY_URL | 2 +- config | 3 ++- scripts/build_ngx_pagespeed.sh | 2 +- scripts/format_binary_url.sh | 24 ++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100755 scripts/format_binary_url.sh diff --git a/PSOL_BINARY_URL b/PSOL_BINARY_URL index 07e34fc50..3663eb12c 100644 --- a/PSOL_BINARY_URL +++ b/PSOL_BINARY_URL @@ -1,4 +1,4 @@ In a release this file would contain the URL to download the pre-compiled PSOL binary, but on development branches (like this one) you have to build PSOL from source yourself. See: - https://github.com/pagespeed/ngx_pagespeed/wiki/Building-PSOL-From-Source \ No newline at end of file + https://github.com/pagespeed/ngx_pagespeed/wiki/Building-PSOL-From-Source diff --git a/config b/config index bbe570fa0..2efec199d 100644 --- a/config +++ b/config @@ -26,7 +26,8 @@ if [ "$mod_pagespeed_dir" = "unset" ] ; then if [ ! -e "$mod_pagespeed_dir" ] ; then echo "ngx_pagespeed: pagespeed optimization library not found:" - psol_binary_url="$(cat $ngx_addon_dir/PSOL_BINARY_URL)" + psol_binary_url="$($ngx_addon_dir/scripts/format_binary_url.sh \ + $ngx_addon_dir/PSOL_BINARY_URL)" if [[ "$psol_binary_url" != https://* ]]; then echo " This is a development branch of ngx_pagespeed, which means there is no diff --git a/scripts/build_ngx_pagespeed.sh b/scripts/build_ngx_pagespeed.sh index 5a005617b..338d8b74c 100755 --- a/scripts/build_ngx_pagespeed.sh +++ b/scripts/build_ngx_pagespeed.sh @@ -614,7 +614,7 @@ Not deleting $directory; name is suspiciously short. Something is wrong." elif [ -e PSOL_BINARY_URL ]; then # Releases after 1.11.33.4 there is a PSOL_BINARY_URL file that tells us # where to look. - psol_url="$(cat PSOL_BINARY_URL)" + psol_url="$(scripts/format_binary_url.sh PSOL_BINARY_URL)" if [[ "$psol_url" != https://* ]]; then fail "Got bad psol binary location information: $psol_url" fi diff --git a/scripts/format_binary_url.sh b/scripts/format_binary_url.sh new file mode 100755 index 000000000..d56286da0 --- /dev/null +++ b/scripts/format_binary_url.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e +set -u + +if [ $# -ne 1 ]; then + echo "Usage: $(basename $0) " >&2 + exit 1 +fi + +url_file=$1 + +if [ ! -e "$url_file" ]; then + echo "Url file '$url_file' missing!" >&2 +fi + +# The size names must match install/build_psol.sh in mod_pagespeed +if [ "$(uname -m)" = x86_64 ]; then + bit_size_name=x64 +else + bit_size_name=ia32 +fi + +sed -e 's/$BIT_SIZE_NAME\b/'$bit_size_name'/g' $url_file