Stop install script on error and check memory in addition to ncpu

This commit is contained in:
Daniel Winzen
2020-08-30 10:40:16 +02:00
parent a72733c2af
commit 1a531c6ccf

View File

@ -1,55 +1,111 @@
#!/bin/sh
git clone https://github.com/libssh2/libssh2
set -e
# initial repository clones
if [ ! -e libssh2 ]; then
git clone https://github.com/libssh2/libssh2
fi
if [ ! -e ImageMagick ]; then
git clone https://github.com/ImageMagick/ImageMagick
fi
if [ ! -e nginx ]; then
git clone https://github.com/nginx/nginx
fi
cd nginx
if [ ! -e ngx_brotli ]; then
git clone https://github.com/google/ngx_brotli
fi
if [ ! -e ngx_devel_kit ]; then
git clone https://github.com/vision5/ngx_devel_kit
fi
if [ ! -e luajit2 ]; then
git clone https://github.com/openresty/luajit2
fi
if [ ! -e lua-resty-core ]; then
git clone https://github.com/openresty/lua-resty-core
fi
if [ ! -e lua-resty-lrucache ]; then
git clone https://github.com/openresty/lua-resty-lrucache
fi
if [ ! -e lua-nginx-module ]; then
git clone https://github.com/openresty/lua-nginx-module
fi
if [ ! -e stream-lua-nginx-module ]; then
git clone https://github.com/openresty/stream-lua-nginx-module
fi
if [ ! -e lua-resty-mysql ]; then
git clone https://github.com/openresty/lua-resty-mysql
fi
if [ ! -e rds-json-nginx-module ]; then
git clone https://github.com/openresty/rds-json-nginx-module
fi
if [ ! -e set-misc-nginx-module ]; then
git clone https://github.com/openresty/set-misc-nginx-module
fi
if [ ! -e libatomic_ops ]; then
git clone https://github.com/ivmai/libatomic_ops/
fi
cd ..
if [ ! -e php-src ]; then
git clone https://github.com/php/php-src
fi
cd php-src/ext
if [ ! -e apcu ]; then
git clone https://github.com/krakjoe/apcu
fi
if [ ! -e php-ext-brotli ]; then
git clone https://github.com/kjdev/php-ext-brotli
fi
if [ ! -e imagick ]; then
git clone https://github.com/Imagick/imagick
fi
if [ ! -e php-gnupg ]; then
git clone https://github.com/php-gnupg/php-gnupg --recurse-submodules
fi
if [ ! -e php-rar ]; then
git clone https://github.com/cataphract/php-rar
fi
cd ../..
export PROC_LIMIT=`free -g | grep Mem | awk -v nproc=$(nproc) '{print (($2 + 1) < nproc) ? ($2 + 1) : nproc;}'`
#start build
cd libssh2
git pull
autoreconf -fi
CFLAGS="-O3 -march=native -mtune=native" ./configure
make -j $(nproc) install
make -j $PROC_LIMIT install
cd ..
git clone https://github.com/ImageMagick/ImageMagick
cd ImageMagick
git pull
CXXFLAGS='-O3 -mtune=native -march=native' CFLAGS='-O3 -mtune=native -march=native' ./configure --without-perl --without-magick-plus-plus --with-rsvg=yes
make -j $(nproc) install
make -j $PROC_LIMIT install
cd ..
ldconfig
git clone https://github.com/nginx/nginx
cd nginx
git pull
git clone https://github.com/google/ngx_brotli
cd ngx_brotli && git pull && cd ..
git clone https://github.com/vision5/ngx_devel_kit
cd ngx_devel_kit && git pull && cd ..
git clone https://github.com/openresty/luajit2
cd luajit2 && git pull && cd ..
git clone https://github.com/openresty/lua-resty-core
cd lua-resty-core && git pull && cd ..
git clone https://github.com/openresty/lua-resty-lrucache
cd lua-resty-lrucache && git pull && cd ..
git clone https://github.com/openresty/lua-nginx-module
cd lua-nginx-module && git pull && cd ..
git clone https://github.com/openresty/stream-lua-nginx-module
cd stream-lua-nginx-module && git pull && cd ..
git clone https://github.com/openresty/lua-resty-mysql
cd lua-resty-mysql && git pull && cd ..
git clone https://github.com/openresty/rds-json-nginx-module
cd rds-json-nginx-module && git pull && cd ..
git clone https://github.com/openresty/set-misc-nginx-module
cd set-misc-nginx-module && git pull && cd ..
git clone https://github.com/ivmai/libatomic_ops/
cd libatomic_ops
git pull
./autogen.sh
ln -sf .libs/libatomic_ops.a src/libatomic_ops.a
cd ..
cd luajit2
XCFLAGS="-O3 -march=native -mtune=native" make -j $(nproc) install
XCFLAGS="-O3 -march=native -mtune=native" make -j $PROC_LIMIT install
cd ../lua-resty-core
make -j $(nproc) install
make -j $PROC_LIMIT install
cd ../lua-resty-lrucache
make -j $(nproc) install
make -j $PROC_LIMIT install
cd ../lua-resty-mysql
make -j $(nproc) install
make -j $PROC_LIMIT install
cd ..
# apply dynamic TLS record and HTTP2 HPACK patch by CloudFlare
cat <<EOF | git apply -
@ -1276,32 +1332,26 @@ index 7d49803f..b9ee2048 100644
EOF
LUAJIT_LIB="/usr/local/lib" LUAJIT_INC="/usr/local/include/luajit-2.1/" ./auto/configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/tmp/body --http-fastcgi-temp-path=/tmp/fastcgi --http-proxy-temp-path=/tmp/proxy --with-threads --with-file-aio --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-http_v2_hpack_enc --with-http_gzip_static_module --without-http_ssi_module --without-http_userid_module --without-http_access_module --without-http_mirror_module --without-http_geo_module --without-http_split_clients_module --without-http_uwsgi_module --without-http_scgi_module --without-http_grpc_module --without-http_memcached_module --without-http_limit_conn_module --without-http_limit_req_module --without-http_empty_gif_module --without-http_browser_module --without-http_upstream_hash_module --without-http_upstream_ip_hash_module --without-http_upstream_least_conn_module --without-http_upstream_keepalive_module --without-http_upstream_zone_module --with-stream --with-stream_ssl_module --without-stream_limit_conn_module --without-stream_access_module --without-stream_geo_module --without-stream_map_module --without-stream_split_clients_module --without-stream_return_module --without-stream_upstream_hash_module --without-stream_upstream_least_conn_module --without-stream_upstream_zone_module --with-libatomic=./libatomic_ops --with-cc-opt='-O3 -march=native -mtune=native -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -fPIC' --add-module=ngx_brotli --add-module=ngx_devel_kit --add-module=lua-nginx-module --add-module=stream-lua-nginx-module --add-module=rds-json-nginx-module --add-module=set-misc-nginx-module
make -j $(nproc) install
make -j $PROC_LIMIT install
make clean
git reset --hard
cd ..
ln -fs /usr/include/qdbm/depot.h /usr/include/depot.h
git clone https://github.com/php/php-src
cd php-src
git checkout PHP-7.4
git pull
cd ext
git clone https://github.com/krakjoe/apcu
cd apcu && git pull && cd ..
git clone https://github.com/kjdev/php-ext-brotli
cd php-ext-brotli && git pull && cd ..
git clone https://github.com/Imagick/imagick
cd imagick && git pull && cd ..
git clone https://github.com/php-gnupg/php-gnupg && cd php-gnupg && git submodule update --init && cd ..
cd php-gnupg && git pull && cd ..
git clone https://github.com/cataphract/php-rar
cd php-rar && git pull && cd ..
rm -rf ssh2-*
curl -sSf https://pecl.php.net/get/ssh2 | tar xzvf - --exclude package.xml
cd ..
./buildconf
LIBS='-lgpg-error' CXXFLAGS='-O3 -mtune=native -march=native' CFLAGS='-O3 -mtune=native -march=native' ./configure -C --enable-re2c-cgoto --prefix=/usr --with-config-file-scan-dir=/etc/php/7.4/fpm/conf.d --libdir=/usr/lib/php --libexecdir=/usr/lib/php --datadir=/usr/share/php/7.4 --program-suffix=7.4 --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --enable-fpm --enable-cli --disable-cgi --disable-phpdbg --with-fpm-systemd --with-fpm-user=www-data --with-fpm-group=www-data --with-layout=GNU --disable-dtrace --disable-short-tags --without-valgrind --disable-shared --disable-debug --disable-rpath --without-pear --with-openssl --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-dba --with-qdbm --with-lmdb --enable-exif --enable-ftp --enable-gd --with-external-gd --with-jpeg --with-webp --with-xpm --with-freetype --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --with-imap --with-imap-ssl --with-kerberos --enable-intl --with-ldap --with-ldap-sasl --enable-mbstring --with-mysqli --with-pdo-mysql --enable-mysqlnd --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-zlib --with-libedit --with-readline --enable-shmop --enable-soap --enable-sockets --with-sodium --with-password-argon2 --with-tidy --with-xmlrpc --with-xsl --with-enchant --with-pspell --with-zip --with-ffi --enable-apcu --enable-brotli --with-libbrotli --with-imagick --with-ssh2 --with-gnupg --enable-rar
make -j $(nproc) install
make -j $PROC_LIMIT install
make distclean
git reset --hard
git checkout PHP-7.3
@ -1364,7 +1414,7 @@ EOF
./buildconf
LIBS='-lgpg-error' CXXFLAGS='-O3 -mtune=native -march=native' CFLAGS='-O3 -mtune=native -march=native' ./configure -C --enable-re2c-cgoto --prefix=/usr --with-config-file-scan-dir=/etc/php/7.3/fpm/conf.d --libdir=/usr/lib/php --libexecdir=/usr/lib/php --datadir=/usr/share/php/7.3 --program-suffix=7.3 --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --enable-fpm --enable-cli --disable-cgi --disable-phpdbg --with-fpm-systemd --with-fpm-user=www-data --with-fpm-group=www-data --with-layout=GNU --disable-dtrace --disable-short-tags --without-valgrind --disable-shared --disable-debug --disable-rpath --without-pear --with-openssl --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-dba --with-qdbm --with-lmdb --enable-exif --enable-ftp --with-gd=/usr --with-jpeg-dir=/usr --with-webp-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --with-imap --with-imap-ssl --with-kerberos --enable-intl --with-ldap --with-ldap-sasl --enable-mbstring --with-mysqli --with-pdo-mysql --enable-mysqlnd --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-zlib --with-libedit --with-readline --enable-shmop --enable-soap --enable-sockets --with-sodium --with-password-argon2 --with-tidy --with-xmlrpc --with-xsl --with-enchant --with-pspell --enable-zip --enable-apcu --enable-brotli --with-libbrotli --with-imagick --with-ssh2 --with-pcre-regex --with-pcre-jit --with-gnupg --enable-rar
make -j $(nproc) install
make -j $PROC_LIMIT install
make distclean
git reset --hard
git checkout PHP-7.2
@ -1427,7 +1477,7 @@ EOF
./buildconf
LIBS='-lgpg-error' CXXFLAGS='-O3 -mtune=native -march=native' CFLAGS='-O3 -mtune=native -march=native' ./configure -C --enable-re2c-cgoto --prefix=/usr --with-config-file-scan-dir=/etc/php/7.2/fpm/conf.d --libdir=/usr/lib/php --libexecdir=/usr/lib/php --datadir=/usr/share/php/7.2 --program-suffix=7.2 --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --enable-fpm --enable-cli --disable-cgi --disable-phpdbg --with-fpm-systemd --with-fpm-user=www-data --with-fpm-group=www-data --with-layout=GNU --disable-dtrace --disable-short-tags --without-valgrind --disable-shared --disable-debug --disable-rpath --without-pear --with-openssl --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-dba --with-qdbm --with-lmdb --enable-exif --enable-ftp --with-gd=/usr --with-jpeg-dir=/usr --with-webp-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --with-imap --with-imap-ssl --with-kerberos --enable-intl --with-ldap --with-ldap-sasl --enable-mbstring --with-mysqli --with-pdo-mysql --enable-mysqlnd --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-zlib --with-libedit --with-readline --enable-shmop --enable-soap --enable-sockets --with-sodium --with-password-argon2 --with-tidy --with-xmlrpc --with-xsl --with-enchant --with-pspell --enable-zip --enable-apcu --enable-brotli --with-libbrotli --with-imagick --with-ssh2 --with-pcre-regex --with-pcre-jit --with-gnupg --enable-rar
make -j $(nproc) install
make -j $PROC_LIMIT install
make distclean
git reset --hard
ln -fs /usr/bin/php7.4 /usr/bin/php