From f0cf5533a39107d586c75a6de3d71fd83c5b42c1 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Sat, 23 Feb 2019 13:27:00 -0800
Subject: [PATCH] Remaining nginx dependencies, plus the nginx build itself

---
 scripts/build.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 77 insertions(+), 6 deletions(-)
 mode change 100755 => 100644 scripts/build.sh

diff --git a/scripts/build.sh b/scripts/build.sh
old mode 100755
new mode 100644
index 6e0965e..c5ccc0e
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -10,18 +10,89 @@ export OG_DIR
 echo "$OG_DIR"
 echo ""
 
-# Organization
-mkdir "$OG_DIR/src"
-
 # Common directories.
+NGINX_SRC_DIR="$OG_DIR/src/nginx"
+export NGINX_SRC_DIR
+mkdir -p "$NGINX_SRC_DIR"
+
+NGINX_SRC_ARCHIVE="$OG_DIR/src/nginx-src.tar.gz"
+EXPORT NGINX_SRC_ARCHIVE
+
 OPENSSL_DIR="$OG_DIR/src/openssl"
 export OPENSSL_DIR
 
+NGX_BROTLI_DIR="$OG_DIR/src/ngx_brotli"
+export NGX_BROTLI_DIR
+
+NGINX_CT_DIR="$OG_DIR/src/nginx_ct"
+export NGINX_CT_DIR
+
 # Dependency: OpenSSL
-echo "DEPENDENCY: OPENSSL"
-git clone -q https://github.com/openssl/openssl.git -b "$OPENSSL_TAG" "$OPENSSL_DIR"
+echo "DEPENDENCY: OpenSSL"
+git clone -q --recursive --depth 1 https://github.com/openssl/openssl.git -b "$OPENSSL_TAG" "$OPENSSL_DIR"
 cd "$OPENSSL_DIR" || exit
 ./config
 
-# Dependency: ngx_brotli
+# Dependency: ngx_brotli (no tagged releases)
+echo ""
+echo "DEPENDENCY: ngx_brotli"
+git clone -q --recursive --depth 1 https://github.com/google/ngx_brotli.git "$NGX_BROTLI_DIR"
+
 # Dependency: nginx-ct
+echo ""
+echo "DEPENDENCY: nginx-ct"
+git clone -q --recursive --depth 1 https://github.com/grahamedgecombe/nginx-ct.git -b "$NGINX_CT_TAG" "$NGINX_CT_DIR"
+
+# Configure nginx
+echo ""
+echo "DOWNLOADING NGINX RELEASE"
+cd "$OG_DIR" || exit
+curl -o "$NGINX_SRC_ARCHIVE" "$NGINX_SRC"
+tar -zxvf "$NGINX_SRC_ARCHIVE" -C "$NGINX_SRC_DIR" --strip 1
+cd "$NGINX_SRC_DIR" || exit
+./configure \
+    --prefix=/etc/nginx \
+    --sbin-path=/usr/sbin/nginx \
+    --conf-path=/etc/nginx/nginx.conf \
+    --error-log-path=/var/log/nginx/error.log \
+    --http-log-path=/var/log/nginx/access.log \
+    --pid-path=/var/run/nginx.pid \
+    --lock-path=/var/run/nginx.lock \
+    --http-client-body-temp-path=/var/cache/nginx/client_temp \
+    --http-proxy-temp-path=/var/cache/nginx/proxy_temp \
+    --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
+    --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
+    --http-scgi-temp-path=/var/cache/nginx/scgi_temp \
+    --user=www-data \
+    --group=www-data \
+    --with-http_ssl_module \
+    --with-http_realip_module \
+    --with-http_addition_module \
+    --with-http_sub_module \
+    --with-http_dav_module \
+    --with-http_flv_module \
+    --with-http_mp4_module \
+    --with-http_gunzip_module \
+    --with-http_gzip_static_module \
+    --with-http_random_index_module \
+    --with-http_secure_link_module \
+    --with-http_stub_status_module \
+    --with-http_auth_request_module \
+    --with-threads \
+    --with-stream \
+    --with-stream_ssl_module \
+    --with-http_slice_module \
+    --with-mail \
+    --with-mail_ssl_module \
+    --with-file-aio \
+    --with-http_v2_module \
+    --with-openssl="$OPENSSL_DIR" \
+    --add-module="$NGX_BROTLI_DIR" \
+    --add-module="$NGINX_CT_DIR"
+
+# Build nginx
+echo ""
+echo "BUILDING NGINX"
+echo "Using $(nproc) jobs"
+make -j$(nproc)
+"$NGINX_SRC_DIR/objs/nginx -V"
-- 
GitLab