~alpine/aports

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[alpine-aports] [PATCH] main/nginx: completely rewritten, all nginx-* packages are assembled in this one

Details
Message ID
<1453912177-13498-1-git-send-email-valery.kartel@gmail.com>
Sender timestamp
1453912177
DKIM signature
missing
Download raw message
Patch: +198 -58
- nginx-common - config-files, init-scripts and common data
- nginx - binary without external modules
- nginx-rtmp - binary with rtmp module
- nginx-lua - binary with rtmp and lua modules
- init-script cleaned up to be more openrc-run'ed
- logrotate cleaned up to use new init-script

Packages main/nginx-initscripts and main/nginx-lua no longer needed.
---
 main/nginx/APKBUILD                 | 176 +++++++++++++++++++++++++-----------
 main/nginx/nginx-common.pre-install |   8 ++
 main/nginx/nginx.initd              |  66 ++++++++++++++
 main/nginx/nginx.logrotate          |   6 +-
 4 files changed, 198 insertions(+), 58 deletions(-)
 create mode 100644 main/nginx/nginx-common.pre-install
 create mode 100644 main/nginx/nginx.initd

diff --git a/main/nginx/APKBUILD b/main/nginx/APKBUILD
index d9ad8eb..2586363 100644
--- a/main/nginx/APKBUILD
+++ b/main/nginx/APKBUILD
@@ -4,26 +4,44 @@

pkgname=nginx
pkgver=1.8.1
_nginxrtmpver=1.1.7
pkgrel=0
pkgdesc="lightweight HTTP and reverse proxy server"
url="http://www.nginx.org"
pkgrel=1
pkgdesc="HTTP and reverse proxy server"
url="http://www.nginx.org/en"
arch="all"
license="custom"
pkgusers="nginx"
pkggroups="nginx"
install=""
# the nginx-initscritps provides openrc script, logrotate and user creation
depends="nginx-initscripts"
makedepends="pcre-dev openssl-dev zlib-dev linux-headers"
subpackages="$pkgname-doc $pkgname-vim:vim"
_grp_ngx="nginx"
_grp_www="www-data"
pkggroups="$_grp_ngx $_grp_www"
install="$pkgname-common.pre-install"
depends="$pkgname-common !$pkgname-rtmp !$pkgname-lua"

# Modules
_lua_mod=lua-nginx-module
_lua_dir=$_lua_mod
_lua_ver=0.10.0

_rtmp_mod=nginx-rtmp-module
_rtmp_dir=$_rtmp_mod
_rtmp_ver=1.1.7

_devkit_mod=nginx-devel-kit
_devkit_dir=ngx_devel_kit
_devkit_ver=0.2.19

makedepends="perl-dev pcre-dev openssl-dev zlib-dev luajit-dev paxmark linux-headers"
subpackages="$pkgname-doc $pkgname-common $pkgname-vim $pkgname-rtmp $pkgname-lua"

source="http://nginx.org/download/$pkgname-$pkgver.tar.gz
	nginx-rtmp-module-$_nginxrtmpver.tar.gz::https://github.com/arut/nginx-rtmp-module/archive/v$_nginxrtmpver.tar.gz
	$_lua_mod-$_lua_ver.tar.gz::https://github.com/openresty/$_lua_mod/archive/v$_lua_ver.tar.gz
	$_rtmp_mod-$_rtmp_ver.tar.gz::https://github.com/arut/$_rtmp_mod/archive/v$_rtmp_ver.tar.gz
	$_devkit_mod-$_devkit_ver.tar.gz::https://github.com/simpl/$_devkit_mod/archive/v$_devkit_ver.tar.gz
	$pkgname.logrotate
	$pkgname.initd
	ipv6.patch
	"

_builddir="$srcdir"/$pkgname-$pkgver

prepare() {
	cd "$_builddir"
	for i in $source; do
@@ -33,30 +51,22 @@ prepare() {
	done
}

_rundir=/var/run/$pkgname
_logdir=/var/log/$pkgname
_homedir=/var/lib/$pkgname
_tmpdir=$_homedir/tmp
_datadir=/usr/share/$pkgname
_confdir=/etc/$pkgname

build() {
	cd "$_builddir"
_build() {
	local binary=$1
	shift
	./configure \
		--prefix=$_datadir \
		--prefix=/var/lib/$pkgname \
		--sbin-path=/usr/sbin/$pkgname \
		--conf-path=$_confdir/$pkgname.conf \
		--pid-path=$_rundir/$pkgname.pid \
		--lock-path=$_rundir/$pkgname.lock \
		--error-log-path=$_logdir/error.log \
		--http-log-path=$_logdir/access.log \
		--http-client-body-temp-path=$_tmpdir/client_body \
		--http-proxy-temp-path=$_tmpdir/proxy \
		--http-fastcgi-temp-path=$_tmpdir/fastcgi \
		--http-uwsgi-temp-path=$_tmpdir/uwsgi \
		--http-scgi-temp-path=$_tmpdir/scgi \
		--user=nginx \
		--group=nginx \
		--conf-path=/etc/$pkgname/$pkgname.conf \
		--pid-path=/run/$pkgname/$pkgname.pid \
		--lock-path=/run/$pkgname/$pkgname.lock \
		--http-client-body-temp-path=/var/lib/$pkgname/tmp/client_body \
		--http-proxy-temp-path=/var/lib/$pkgname/tmp/proxy \
		--http-fastcgi-temp-path=/var/lib/$pkgname/tmp/fastcgi \
		--http-uwsgi-temp-path=/var/lib/$pkgname/tmp/uwsgi \
		--http-scgi-temp-path=/var/lib/$pkgname/tmp/scgi \
		--user=$pkgusers \
		--group=$_grp_ngx \
		--with-ipv6 \
		--with-file-aio \
		--with-pcre-jit \
@@ -68,45 +78,105 @@ build() {
		--with-http_auth_request_module \
		--with-mail \
		--with-mail_ssl_module \
		--add-module="$srcdir/nginx-rtmp-module-$_nginxrtmpver" \
		|| return 1
		$@ || return 1
	make || return 1
	mv objs/$pkgname objs/$binary
}

build() {
	cd "$_builddir"

	_build $pkgname-lua --build="rtmp,lua" \
		--add-module="$srcdir/$_devkit_dir-$_devkit_ver" \
		--add-module="$srcdir/$_rtmp_dir-$_rtmp_ver" \
		--add-module="$srcdir/$_lua_dir-$_lua_ver" \
	|| return 1

	_build $pkgname-rtmp --build="rtmp" \
		--add-module="$srcdir/$_rtmp_dir-$_rtmp_ver" \
	|| return 1

	_build $pkgname || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" INSTALLDIRS=vendor install || return 1
	make DESTDIR="$pkgdir" install || return 1

	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
	install -Dm644 objs/$pkgname.8 "$pkgdir"/usr/share/man/man8/$pkgname.8

	install -Dm644 README "$pkgdir"/usr/share/doc/$pkgname/README
	cp -r "$srcdir"/$_lua_dir-$_lua_ver/doc "$pkgdir"/usr/share/doc/$pkgname/$_lua_mod || return 1
	cp -r "$srcdir"/$_rtmp_dir-$_rtmp_ver/doc "$pkgdir"/usr/share/doc/$pkgname/$_rtmp_mod
	cp -r "$srcdir"/$_devkit_dir-$_devkit_ver/docs "$pkgdir"/usr/share/doc/$pkgname/$_devkit_mod

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname

	install -m644 -D LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
	install -m644 -D man/$pkgname.8 "$pkgdir"/usr/share/man/man8/$pkgname.8
	install -dm755 "$pkgdir"/etc/$pkgname/conf.d
	install -dm755 "$pkgdir"/etc/$pkgname/default.d
	
	install -dm750 -o $pkgusers -g $_grp_ngx "$pkgdir"/var/lib/$pkgname
	install -dm700 -o $pkgusers -g $_grp_ngx "$pkgdir"/var/lib/$pkgname/tmp
	install -dm755 -g $_grp_www "$pkgdir"/var/www/localhost/htdocs

	install -d -m0755 "$pkgdir"/$_confdir/conf.d || return 1
	install -d -m0755 "$pkgdir"/$_confdir/default.d || return 1
	install -d -m0755 "$pkgdir"/var/www/localhost/htdocs || return 1
	install -d -m0700 "$pkgdir"/$_homedir || return 1
	install -d -m0700 "$pkgdir"/$_tmpdir || return 1
	install -d -m0700 "$pkgdir"/$_logdir || return 1
	install -dm755 "$pkgdir"/var/log
	mv "$pkgdir"/var/lib/$pkgname/logs "$pkgdir"/var/log/$pkgname
	ln -sf /var/log/$pkgname "$pkgdir"/var/lib/$pkgname/logs
	ln -sf /run/$pkgname "$pkgdir"/var/lib/$pkgname/run

	sed -i -E "s~logs(/nginx.pid.*$)~run\1~" "$pkgdir"/etc/$pkgname/$pkgname.conf

	rm -rf "$pkgdir"/run "$pkgdir"/etc/$pkgname/*.default
}

vim() {
	local t
common() {
	pkgdesc="$pkgdesc (common files)"
	depends=
	arch="noarch"
	mkdir -p "$subpkgdir"
	mv "$pkgdir"/etc "$pkgdir"/var "$subpkgdir"/
}

	depends=""
	pkgdesc="Vim syntax for Nginx"
vim() {
	pkgdesc="$pkgdesc (vim syntax)"
	depends=
	arch="noarch"
	mkdir -p "$subpkgdir"/usr/share/vim
	cp -r "$_builddir"/contrib/vim "$subpkgdir"/usr/share/vim/vimfiles
}

	for t in ftdetect syntax indent; do
		install -Dm644 "$_builddir"/contrib/vim/$t/$pkgname.vim \
			"$subpkgdir"/usr/share/vim/vimfiles/$t/$pkgname.vim
	done
rtmp() {
	pkgdesc="$pkgdesc (rtmp support)"
	depends="$pkgname-common !$pkgname !$pkgname-lua"
	install -Dm755 "$_builddir"/objs/$pkgname-rtmp "$subpkgdir"/usr/sbin/$pkgname
}

lua() {
	pkgdesc="$pkgdesc (rtmp & lua support)"
	depends="$pkgname-common !$pkgname !$pkgname-rtmp"
	install -Dm755 "$_builddir"/objs/$pkgname-lua "$subpkgdir"/usr/sbin/$pkgname
}

md5sums="2e91695074dbdfbf1bcec0ada9fda462  nginx-1.8.1.tar.gz
37d06e0f21bb4b2eedf80736a6aca3a2  lua-nginx-module-0.10.0.tar.gz
8006de2560db3e55bb15d110220076ac  nginx-rtmp-module-1.1.7.tar.gz
09a18178adca7b5674129d8100ce4f68  nginx-devel-kit-0.2.19.tar.gz
db194cf3c6c4be12c70c757e0c9ad995  nginx.logrotate
16dcac0d7a2b406807d3377841d9b480  nginx.initd
801a87f7f9d27f8ad85b41a78b4c4461  ipv6.patch"
sha256sums="8f4b3c630966c044ec72715754334d1fdf741caa1d5795fb4646c27d09f797b7  nginx-1.8.1.tar.gz
cf31c64b107a54999fdf8b68e8b8d52d88a3c95d9307417f049c32c5687ed780  lua-nginx-module-0.10.0.tar.gz
7922b0e3d5f3d9c4b275e4908cfb8f5fb1bfb3ac2df77f4c262cda56df21aab3  nginx-rtmp-module-1.1.7.tar.gz
501f299abdb81b992a980bda182e5de5a4b2b3e275fbf72ee34dd7ae84c4b679  nginx-devel-kit-0.2.19.tar.gz
b063611c6cb2d33bd43c4b17bf4135dda25f209bb77e4e66d1b156cffc37fbe6  nginx.logrotate
3d8a90d2f75b7f24c4d74722b5b3ac11d85f416c2d7641b4280d7c126bfe8395  nginx.initd
a24ef5843ae0afa538b00c37eb7da7870f9d7f146f52a9668678f7296cf71d9b  ipv6.patch"
sha512sums="546eba1749af0034cb8b924d2432be2f0e82a75c545aa929391ef7234103c3f29376235a2ef1363b120e1825cda15aeb085a05f9ce3596c88466e112e82aa882  nginx-1.8.1.tar.gz
8d1b07a040368e236a3473c5e9ed7aac6867743c08b57ffe7c708806ccee87e6dfca5412f37753f2576ca7a518acbd06fa0fd573c75e864c6bcfbed160f7221e  lua-nginx-module-0.10.0.tar.gz
9883462a04683f1e7af175da04b86d259ff6d677864667588fb073143f7130969eb2a5a5a48ddceda7a555b908580f179bdcacb7f0111413d51db5bfe43b396e  nginx-rtmp-module-1.1.7.tar.gz
915954acf16a27fbd3c93c154012d38e864f1d8dfd51cde401bba26e46eb3e3c778ec4c92f4f8ed83ac001e96cee72765554d0e4da06acf6a4be5184b23b3657  nginx-devel-kit-0.2.19.tar.gz
09b110693e3f4377349ccea3c43cb8199c8579ee351eae34283299be99fdf764b0c1bddd552e13e4d671b194501618b29c822e1ad53b34101a73a63954363dbb  nginx.logrotate
1ea032cf88021ec8aa1401d284ea738364511cdb9f8c01670deb8e59aae570f5bbe17f0cbab73c0e08d6b342a621b6a9c014832168ed41f6028ecfa4211b60cf  nginx.initd
68d64a84568ec2df0366925ab282a05ebe21a85044b6c7844a47573cfd8cc8ed119cc772358bc3fff36e2d4fdf583a730592825f5f98632993ca86d1f8438d5f  ipv6.patch"
diff --git a/main/nginx/nginx-common.pre-install b/main/nginx/nginx-common.pre-install
new file mode 100644
index 0000000..823de3a
--- /dev/null
+++ b/main/nginx/nginx-common.pre-install
@@ -0,0 +1,8 @@
#!/bin/sh

addgroup -Sg 82 www-data 2>/dev/null
addgroup -S nginx 2>/dev/null
adduser -h /var/lib/nginx -g "nginx" -s /sbin/nologin -SDHG nginx nginx 2>/dev/null
addgroup nginx www-data 2>/dev/null

exit 0
diff --git a/main/nginx/nginx.initd b/main/nginx/nginx.initd
new file mode 100644
index 0000000..992d5fd
--- /dev/null
+++ b/main/nginx/nginx.initd
@@ -0,0 +1,66 @@
#!/sbin/openrc-run

description="Nginx http and reverse proxy server"
extra_started_commands="reload reopen upgrade"

cfgfile=${cfgfile:-/etc/nginx/nginx.conf}
pidfile=/run/nginx/nginx.pid
command=/usr/sbin/nginx
command_args="-c $cfgfile"
required_files="$cfgfile"

depend() {
	need net
	use dns logger netmount
}

start_pre() {
	ebegin
	checkpath --directory --owner nginx:nginx ${pidfile%/*}
	$command $command_args -t -q
	eend $?
}

reload() {
	ebegin "Reloading ${SVCNAME} configuration"
	start_pre && start-stop-daemon --signal HUP --pidfile $pidfile
	eend $?
}

reopen() {
	ebegin "Reopening ${SVCNAME} log files"
	start-stop-daemon --signal USR1 --pidfile $pidfile
	eend $?
}

upgrade() {
	start_pre || return 1

	ebegin "Upgrading ${SVCNAME} binary"

	einfo "Sending USR2 to old binary"
	start-stop-daemon --signal USR2 --pidfile $pidfile

	einfo "Sleeping 3 seconds before pid-files checking"
	sleep 3

	if [ ! -f $pidfile.oldbin ]; then
		eerror "File with old pid ($pidfile.oldbin) not found"
		return 1
	fi

	if [ ! -f $pidfile ]; then
		eerror "New binary failed to start"
		return 1
	fi

	einfo "Sleeping 3 seconds before WINCH"
	sleep 3 ; start-stop-daemon --signal 28 --pidfile $pidfile.oldbin

	einfo "Sending QUIT to old binary"
	start-stop-daemon --signal QUIT --pidfile $pidfile.oldbin

	einfo "Upgrade completed"

	eend $? "Upgrade failed"
}
diff --git a/main/nginx/nginx.logrotate b/main/nginx/nginx.logrotate
index 00e5a94..c07e6bc 100644
--- a/main/nginx/nginx.logrotate
+++ b/main/nginx/nginx.logrotate
@@ -1,12 +1,8 @@
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/nginx/files/nginx.logrotate,v 1.1 2010/01/03 20:29:40 djc Exp $

/var/log/nginx/*.log {
	missingok
	sharedscripts
	postrotate
		test -r /var/run/nginx.pid && kill -USR1 `cat /var/run/nginx.pid`
		/etc/init.d/nginx --quiet --ifstarted reopen
	endscript
}

-- 
2.7.0



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Natanael Copa <ncopa@alpinelinux.org>
Details
Message ID
<20160603160432.0c5d1f29@ncopa-desktop.alpinelinux.org>
In-Reply-To
<1453912177-13498-1-git-send-email-valery.kartel@gmail.com> (view parent)
Sender timestamp
1464962672
DKIM signature
missing
Download raw message
On Wed, 27 Jan 2016 18:29:37 +0200
Valery Kartel <valery.kartel@gmail.com> wrote:

> - nginx-common - config-files, init-scripts and common data
> - nginx - binary without external modules
> - nginx-rtmp - binary with rtmp module
> - nginx-lua - binary with rtmp and lua modules
> - init-script cleaned up to be more openrc-run'ed
> - logrotate cleaned up to use new init-script
> 
> Packages main/nginx-initscripts and main/nginx-lua no longer needed.

Valery,

Could you please help me figure what causes this problem:
http://bugs.alpinelinux.org/issues/5671

My guess is that we only need a replaces=... something in nginx-common.
Thanks!


---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Reply to thread Export thread (mbox)