Files
2026-03-06 18:01:24 +07:00

55 lines
2.1 KiB
Bash

#!/bin/bash
. ./scripts/colors.sh
. ./scripts/funcs.sh
. ./scripts/config.sh
nginx_build() {
pkgname=nginx
pkgver=1.29.5
srcurl=https://github.com/nginx/nginx/releases/download/release-${pkgver}/${pkgname}-${pkgver}.tar.gz
print_info "** Building and installing ${pkgname}"
[ -d $build/${pkgname} ] && return 0
mkdir -p $build/${pkgname}
cd $build/${pkgname}
if [ ! -f $root/downloads/${pkgname}-${pkgver}.tar.gz ]; then
print_info "** Downloading $srcurl"
cd $root/downloads
wget $srcurl
check $? "download $srcurl"
cd -
fi
tar -xf $root/downloads/${pkgname}-${pkgver}.tar.gz
check $? "Extract ${pkgname}"
cd ${pkgname}-${pkgver}
./configure \
--prefix=/opt/nginx \
--without-pcre \
--without-http_rewrite_module \
--with-cc-opt="-DNGX_HAVE_EPOLLEXCLUSIVE=0 -DNGX_HAVE_STRERRORDESC_NP=0 -DNGX_HAVE_IP_BIND_ADDRESS_NO_PORT=0 -DNGX_HAVE_GNU_CRYPT_R=0"
check $? "Configure ${pkgname}"
sed -i "/CC =/s/.*/CC=$CROSS_COMPILE-gcc/" objs/Makefile
sed -i "/CPP =/s/.*/CPP=$CROSS_COMPILE-gcc -E/" objs/Makefile
if [ "${ARCH}" = "arm" ]; then
sed -i 's/9223372036854775807/2147483647/g' objs/ngx_auto_config.h
sed -i 's/9223372036854775807LL/2147483647LL/g' objs/ngx_auto_config.h
sed -i 's/9223372036854775807/2147483647/g' src/core/ngx_config.h
sed -i 's/#define NGX_PTR_SIZE 8/#define NGX_PTR_SIZE 4/g' objs/ngx_auto_config.h
fi
make $makeflags
check $? "Build ${pkgname}"
make DESTDIR=$rootfspath install
check $? "Installing to rootfs ${pkgname}"
cat << EOF > $rootfspath/etc/finit.d/available/nginx.conf
run [S] mkdir -p /run/nginx /var/log/nginx /var/cache/nginx
run [S] chown -R nobody:nobody /run/nginx
service [2345] \\
pid:/run/nginx/nginx.pid \\
log:/opt/nginx/logs/error.log \\
/opt/nginx/sbin/nginx -g "daemon off; pid /run/nginx/nginx.pid;" -c /opt/nginx/conf/nginx.conf \\
-- Nginx Web Server
EOF
[ -f $rootfspath/opt/nginx/sbin/nginx.old ] && rm -v $rootfspath/opt/nginx/sbin/nginx.old
}