chiark / gitweb /
preload-hacks: Some patches to make it work.
[termux-packages] / packages / nginx / build.sh
1 TERMUX_PKG_HOMEPAGE=https://www.nginx.org
2 TERMUX_PKG_DESCRIPTION="Lightweight HTTP server"
3 TERMUX_PKG_VERSION=1.12.2
4 TERMUX_PKG_SHA256=305f379da1d5fb5aefa79e45c829852ca6983c7cd2a79328f8e084a324cf0416
5 TERMUX_PKG_SRCURL=http://nginx.org/download/nginx-$TERMUX_PKG_VERSION.tar.gz
6 TERMUX_PKG_BUILD_IN_SRC=true
7 TERMUX_PKG_DEPENDS="libandroid-glob, libcrypt, pcre, openssl"
8 TERMUX_PKG_CONFFILES="etc/nginx/fastcgi.conf etc/nginx/fastcgi_params etc/nginx/koi-win etc/nginx/koi-utf
9 etc/nginx/mime.types etc/nginx/nginx.conf etc/nginx/scgi_params etc/nginx/uwsgi_params etc/nginx/win-utf"
10 TERMUX_PKG_MAINTAINER="Vishal Biswas @vishalbiswas"
11
12 termux_step_pre_configure () {
13         CPPFLAGS="$CPPFLAGS -DIOV_MAX=1024"
14         LDFLAGS="$LDFLAGS -landroid-glob"
15
16         # remove config from previouse installs
17         rm -rf "$TERMUX_PREFIX/etc/nginx"
18 }
19
20 termux_step_configure () {
21         DEBUG_FLAG=""
22         test -n "$TERMUX_DEBUG" && DEBUG_FLAG="--debug"
23
24         ./configure \
25                 --prefix=$TERMUX_PREFIX \
26                 --crossbuild="Linux:3.16.1:$TERMUX_ARCH" \
27                 --crossfile="$TERMUX_PKG_SRCDIR/auto/cross/Android" \
28                 --with-cc=$CC \
29                 --with-cpp=$CPP \
30                 --with-cc-opt="$CPPFLAGS $CFLAGS" \
31                 --with-ld-opt="$LDFLAGS" \
32                 --with-pcre \
33                 --with-pcre-jit \
34                 --with-file-aio \
35                 --with-threads \
36                 --with-ipv6 \
37                 --sbin-path="$TERMUX_PREFIX/bin/nginx" \
38                 --conf-path="$TERMUX_PREFIX/etc/nginx/nginx.conf" \
39                 --http-log-path="$TERMUX_PREFIX/var/log/nginx/access.log" \
40                 --pid-path="$TERMUX_PREFIX/tmp/nginx.pid" \
41                 --lock-path="$TERMUX_PREFIX/tmp/nginx.lock" \
42                 --error-log-path="$TERMUX_PREFIX/var/log/nginx/error.log" \
43                 --http-client-body-temp-path="$TERMUX_PREFIX/var/lib/nginx/client-body" \
44                 --http-proxy-temp-path="$TERMUX_PREFIX/var/lib/nginx/proxy" \
45                 --http-fastcgi-temp-path="$TERMUX_PREFIX/var/lib/nginx/fastcgi" \
46                 --http-scgi-temp-path="$TERMUX_PREFIX/var/lib/nginx/scgi" \
47                 --http-uwsgi-temp-path="$TERMUX_PREFIX/var/lib/nginx/uwsgi" \
48                 --with-http_auth_request_module \
49                 --with-http_ssl_module \
50                 --with-http_v2_module \
51                 --with-http_gunzip_module \
52                 $DEBUG_FLAG
53 }
54
55 termux_step_post_make_install () {
56         # many parts are taken directly from Arch PKGBUILD
57         # https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/nginx
58
59         # set default port to 8080
60         sed -i "s| 80;| 8080;|" "$TERMUX_PREFIX/etc/nginx/nginx.conf"
61         cp conf/mime.types "$TERMUX_PREFIX/etc/nginx/"
62         rm "$TERMUX_PREFIX"/etc/nginx/*.default
63
64         # move default html dir
65         sed -e "44s|html|$TERMUX_PREFIX/share/nginx/html|" \
66                 -e "54s|html|$TERMUX_PREFIX/share/nginx/html|" \
67                 -i "$TERMUX_PREFIX/etc/nginx/nginx.conf"
68         rm -rf "$TERMUX_PREFIX/share/nginx"
69         mkdir -p "$TERMUX_PREFIX/share/nginx"
70         mv "$TERMUX_PREFIX/html/" "$TERMUX_PREFIX/share/nginx"
71
72         # install vim contrib
73         for i in ftdetect indent syntax; do
74                 install -Dm644 "$TERMUX_PKG_SRCDIR/contrib/vim/${i}/nginx.vim" \
75                         "$TERMUX_PREFIX/share/vim/vimfiles/${i}/nginx.vim"
76         done
77
78         # install man pages
79         mkdir -p "$TERMUX_PREFIX/share/man/man8"
80         cp "$TERMUX_PKG_SRCDIR/man/nginx.8" "$TERMUX_PREFIX/share/man/man8/"
81 }
82
83 termux_step_post_massage () {
84         # keep empty dirs which were deleted in massage
85         mkdir -p "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/var/log/nginx"
86         for dir in client-body proxy fastcgi scgi uwsgi; do
87                 mkdir -p "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/var/lib/nginx/$dir"
88         done
89 }
90