install: add --additional-nginx-configure-arguments option (#1344)

Instead of requiring people to answer a prompt to specify which additional
arguments they would like nginx to be built with, allow people to specify
arguments like this on the command line.  The quoting is not ideal, since
it's important to pass spaces etc properly all the way through to the
underlying commands, but I give an example in the help text.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1340
This commit is contained in:
Jeff Kaufman
2017-01-03 07:07:50 -05:00
committed by GitHub
parent cb56136fe1
commit 8a0b080229
+31 -13
View File
@@ -80,6 +80,13 @@ Options:
Assume the answer to all prompts is 'yes, please continue'. Intended for Assume the answer to all prompts is 'yes, please continue'. Intended for
automated usage, such as buildbots. automated usage, such as buildbots.
-a, --additional-nginx-configure-arguments
When running ./configure for nginx, you may want to specify additional
arguments, such as --with-http_ssl_module. By default this script will
pause and prompt you for them, but this option lets you pass them in. For
example, you might do:
-a '--with-http_ssl_module --with-cc-opt=\"-I /usr/local/include\"'
-d, --dryrun -d, --dryrun
Don't make any changes to the system, just print what changes you Don't make any changes to the system, just print what changes you
would have made. would have made.
@@ -302,10 +309,10 @@ function build_ngx_pagespeed() {
fail "Your version of getopt is too old. Exiting with no changes made." fail "Your version of getopt is too old. Exiting with no changes made."
fi fi
opts=$(getopt -o v:n:mb:pslt:ydh \ opts=$(getopt -o v:n:mb:pslt:ya:dh \
--longoptions ngx-pagespeed-version:,nginx-version:,dynamic-module \ --longoptions ngx-pagespeed-version:,nginx-version:,dynamic-module \
--longoptions buildir:,no-deps-check,psol-from-source,devel,build-type: \ --longoptions buildir:,no-deps-check,psol-from-source,devel,build-type: \
--longoptions assume-yes,dryrun,help \ --longoptions assume-yes,additional-nginx-configure-arguments:,dryrun,help \
-n "$(basename "$0")" -- "$@") -n "$(basename "$0")" -- "$@")
if [ $? != 0 ]; then if [ $? != 0 ]; then
usage usage
@@ -356,6 +363,10 @@ function build_ngx_pagespeed() {
-y | --assume-yes) shift -y | --assume-yes) shift
ASSUME_YES="true" ASSUME_YES="true"
;; ;;
-a | --additional-nginx-configure-arguments) shift
ADDITIONAL_NGINX_CONFIGURE_ARGUMENTS="$1"
shift
;;
-d | --dryrun) shift -d | --dryrun) shift
DRYRUN="true" DRYRUN="true"
;; ;;
@@ -721,19 +732,26 @@ Not deleting $directory; name is suspiciously short. Something is wrong."
run cd "$nginx_dir" run cd "$nginx_dir"
configure=("$configure_location/configure" "${configure_args[@]}") configure=("$configure_location/configure" "${configure_args[@]}")
if ! "$ASSUME_YES"; then additional_configure_args=""
echo "About to build nginx. Do you have any additional ./configure" if [ -z "${ADDITIONAL_NGINX_CONFIGURE_ARGUMENTS+x}" ]; then
echo "arguments you would like to set? For example, if you would like" if ! "$ASSUME_YES"; then
echo "to build nginx with https support give --with-http_ssl_module" echo "About to build nginx. Do you have any additional ./configure"
echo "If you don't have any, just press enter." echo "arguments you would like to set? For example, if you would like"
read -p "> " additional_configure_args echo "to build nginx with https support give --with-http_ssl_module"
if [ -n "$additional_configure_args" ]; then echo "If you don't have any, just press enter."
# Split additional_configure_args respecting any internal quotation. read -p "> " additional_configure_args
# Otherwise things like --with-cc-opt='-foo -bar' won't work.
eval additional_configure_args=("$additional_configure_args")
configure=("${configure[@]}" "${additional_configure_args[@]}")
fi fi
else
additional_configure_args="$ADDITIONAL_NGINX_CONFIGURE_ARGUMENTS"
fi fi
if [ -n "$additional_configure_args" ]; then
# Split additional_configure_args respecting any internal quotation.
# Otherwise things like --with-cc-opt='-foo -bar' won't work.
eval additional_configure_args=("$additional_configure_args")
configure=("${configure[@]}" "${additional_configure_args[@]}")
fi
echo "About to configure nginx with:" echo "About to configure nginx with:"
echo " $(quote_arguments "${configure[@]}")" echo " $(quote_arguments "${configure[@]}")"
continue_or_exit "Does this look right?" continue_or_exit "Does this look right?"