Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 8a0b080

Browse files
authored
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 #1340
1 parent cb56136 commit 8a0b080

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

scripts/build_ngx_pagespeed.sh

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ Options:
8080
Assume the answer to all prompts is 'yes, please continue'. Intended for
8181
automated usage, such as buildbots.
8282
83+
-a, --additional-nginx-configure-arguments
84+
When running ./configure for nginx, you may want to specify additional
85+
arguments, such as --with-http_ssl_module. By default this script will
86+
pause and prompt you for them, but this option lets you pass them in. For
87+
example, you might do:
88+
-a '--with-http_ssl_module --with-cc-opt=\"-I /usr/local/include\"'
89+
8390
-d, --dryrun
8491
Don't make any changes to the system, just print what changes you
8592
would have made.
@@ -302,10 +309,10 @@ function build_ngx_pagespeed() {
302309
fail "Your version of getopt is too old. Exiting with no changes made."
303310
fi
304311

305-
opts=$(getopt -o v:n:mb:pslt:ydh \
312+
opts=$(getopt -o v:n:mb:pslt:ya:dh \
306313
--longoptions ngx-pagespeed-version:,nginx-version:,dynamic-module \
307314
--longoptions buildir:,no-deps-check,psol-from-source,devel,build-type: \
308-
--longoptions assume-yes,dryrun,help \
315+
--longoptions assume-yes,additional-nginx-configure-arguments:,dryrun,help \
309316
-n "$(basename "$0")" -- "$@")
310317
if [ $? != 0 ]; then
311318
usage
@@ -356,6 +363,10 @@ function build_ngx_pagespeed() {
356363
-y | --assume-yes) shift
357364
ASSUME_YES="true"
358365
;;
366+
-a | --additional-nginx-configure-arguments) shift
367+
ADDITIONAL_NGINX_CONFIGURE_ARGUMENTS="$1"
368+
shift
369+
;;
359370
-d | --dryrun) shift
360371
DRYRUN="true"
361372
;;
@@ -721,19 +732,26 @@ Not deleting $directory; name is suspiciously short. Something is wrong."
721732
run cd "$nginx_dir"
722733

723734
configure=("$configure_location/configure" "${configure_args[@]}")
724-
if ! "$ASSUME_YES"; then
725-
echo "About to build nginx. Do you have any additional ./configure"
726-
echo "arguments you would like to set? For example, if you would like"
727-
echo "to build nginx with https support give --with-http_ssl_module"
728-
echo "If you don't have any, just press enter."
729-
read -p "> " additional_configure_args
730-
if [ -n "$additional_configure_args" ]; then
731-
# Split additional_configure_args respecting any internal quotation.
732-
# Otherwise things like --with-cc-opt='-foo -bar' won't work.
733-
eval additional_configure_args=("$additional_configure_args")
734-
configure=("${configure[@]}" "${additional_configure_args[@]}")
735+
additional_configure_args=""
736+
if [ -z "${ADDITIONAL_NGINX_CONFIGURE_ARGUMENTS+x}" ]; then
737+
if ! "$ASSUME_YES"; then
738+
echo "About to build nginx. Do you have any additional ./configure"
739+
echo "arguments you would like to set? For example, if you would like"
740+
echo "to build nginx with https support give --with-http_ssl_module"
741+
echo "If you don't have any, just press enter."
742+
read -p "> " additional_configure_args
735743
fi
744+
else
745+
additional_configure_args="$ADDITIONAL_NGINX_CONFIGURE_ARGUMENTS"
736746
fi
747+
748+
if [ -n "$additional_configure_args" ]; then
749+
# Split additional_configure_args respecting any internal quotation.
750+
# Otherwise things like --with-cc-opt='-foo -bar' won't work.
751+
eval additional_configure_args=("$additional_configure_args")
752+
configure=("${configure[@]}" "${additional_configure_args[@]}")
753+
fi
754+
737755
echo "About to configure nginx with:"
738756
echo " $(quote_arguments "${configure[@]}")"
739757
continue_or_exit "Does this look right?"

0 commit comments

Comments
 (0)