Introduced rpm packages building tools.

This commit is contained in:
Andrei Belov
2017-10-19 18:23:31 +03:00
parent c8a8a7c212
commit eabe25d98e
21 changed files with 932 additions and 1 deletions

View File

@@ -5,7 +5,7 @@ UNIT= unit-$(VER)
DEST= ../build
XSLS?= xslscript.pl
PACKAGES= unit
PACKAGES= unit unit-php unit-python unit-go
all: changes changelogs

View File

@@ -5,6 +5,45 @@
<change_log title="unit">
<changes apply="unit-go" ver="0.2" rev="1"
date="2017-10-19" time="18:00:00 +0300"
packager="Andrei Belov &lt;defan@nginx.com&gt;">
<change>
<para>
Initial release of Go module for NGINX Unit.
</para>
</change>
</changes>
<changes apply="unit-python" ver="0.2" rev="1"
date="2017-10-19" time="18:00:00 +0300"
packager="Andrei Belov &lt;defan@nginx.com&gt;">
<change>
<para>
Initial release of Python module for NGINX Unit.
</para>
</change>
</changes>
<changes apply="unit-php" ver="0.2" rev="1"
date="2017-10-19" time="18:00:00 +0300"
packager="Andrei Belov &lt;defan@nginx.com&gt;">
<change>
<para>
Initial release of PHP module for NGINX Unit.
</para>
</change>
</changes>
<changes apply="unit" ver="0.2" rev="1"
date="2017-10-19" time="18:00:00 +0300"
packager="Andrei Belov &lt;defan@nginx.com&gt;">

17
pkg/Makefile Normal file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/make
VERSION ?= $(shell grep 'define NXT_VERSION' ../src/nxt_main.h \
| sed -e 's/^.*"\(.*\)".*/\1/')
RELEASE ?= 1
default:
@echo "available targets: rpm"
rpm:
@cd rpm && VERSION=$(VERSION) RELEASE=$(RELEASE) make all
clean:
@cd rpm && make clean
.PHONY: default rpm clean

137
pkg/rpm/Makefile Normal file
View File

@@ -0,0 +1,137 @@
#!/usr/bin/make
DEFAULT_VERSION := $(shell grep 'define NXT_VERSION' ../../src/nxt_main.h \
| sed -e 's/^.*"\(.*\)".*/\1/')
DEFAULT_RELEASE := 1
VERSION ?= $(DEFAULT_VERSION)
RELEASE ?= $(DEFAULT_RELEASE)
BUILD_DEPENDS = libxml2 libxslt rpm-build rpmlint
MODULES=
-include Makefile.*
CONFIGURE_ARGS=\
--prefix=/usr \
--state=%{_sharedstatedir}/unit \
--control="unix:/var/run/control.unit.sock" \
--pid=/var/run/unit.pid \
--log=/var/log/unit.log \
--tests
export CR=\\n
default:
@echo "valid targets: all modules unit $(addprefix unit-, $(MODULES)) rpmlint specs clean"
all: check-build-depends unit modules
modules: $(addprefix unit-, $(MODULES))
specs: $(addsuffix .spec, $(addprefix rpmbuild/SPECS/unit-, $(MODULES)))
check-build-depends:
@{ \
not_installed= ; \
for pkg in $(BUILD_DEPENDS); do \
rpm -qi $${pkg} >/dev/null 2>&1 ; \
if [ $$? -ne 0 ]; then \
not_installed="$${not_installed} $${pkg}" ; \
fi ; \
done ; \
if test -n "$${not_installed}" ; then \
echo "" >&2 ; \
echo "The following packages are required in order to proceed:" >&2 ; \
echo "" >&2 ; \
echo $${not_installed} >&2 ; \
echo "" >&2 ; \
exit 1 ; \
fi \
}
rpmbuild/SPECS:
mkdir -p rpmbuild/SPECS
rpmbuild/SPECS/unit.spec: unit.spec.in ../../docs/changes.xml | rpmbuild/SPECS
cat unit.spec.in | \
sed -e "s#%%VERSION%%#$(VERSION)#g" \
-e "s#%%RELEASE%%#$(RELEASE)#g" \
-e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \
> rpmbuild/SPECS/unit.spec
cd ../../docs && make ../build/unit.rpm-changelog
ifneq ($(DEFAULT_VERSION)$(DEFAULT_RELEASE), $(VERSION)$(RELEASE))
cat ../../build/unit.rpm-changelog | sed -e \
"s/> - $(DEFAULT_VERSION)-$(DEFAULT_RELEASE)/> - $(VERSION)-$(RELEASE)/" \
>> rpmbuild/SPECS/unit.spec
else
cat ../../build/unit.rpm-changelog >> rpmbuild/SPECS/unit.spec
endif
rpmbuild/SOURCES/unit-$(VERSION).tar.gz:
cd ../.. && tar -czf pkg/rpm/rpmbuild/SOURCES/unit-$(VERSION).tar.gz \
--transform "s#^#unit-$(VERSION)/#" \
LICENSE NOTICE CHANGES README configure auto src test
unit: rpmbuild/SPECS/unit.spec rpmbuild/SOURCES/unit-$(VERSION).tar.gz
@echo "===> Building $@ package" ; \
rpmbuild -D "_topdir `pwd`/rpmbuild" -ba rpmbuild/SPECS/unit.spec && \
ln -s rpmbuild/BUILD/$@-$(VERSION)/build $@
rpmlint:
find rpmbuild/ -name "*.rpm" -print -exec rpmlint {} \;
rpmbuild/SPECS/unit-%.spec: unit.module.spec.in ../../docs/changes.xml | rpmbuild/SPECS
@echo "===> Creating $@"
@{ \
set -e ; \
i=100 ; \
sources= ; \
for src in $(MODULE_SOURCES_$*); do \
s="`printf "Source%d: %s\n" $${i} $${src}`" ; \
sources="$${sources}\n$${s}" ; \
i=$$(($${i}+1)) ; \
done ; \
pkgname=$(shell echo $@ | cut -d '/' -f 3 | cut -d '.' -f 1) ; \
definitions=`echo "$$MODULE_DEFINITIONS_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
preinstall=`echo "$$MODULE_PREINSTALL_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
files=`echo "$$MODULE_FILES_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
post=`echo "$$MODULE_POST_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
cat unit.module.spec.in | sed \
-e "s#%%NAME%%#$${pkgname}#g" \
-e "s#%%SUMMARY%%#$(MODULE_SUMMARY_$*)#g" \
-e "s#%%VERSION%%#$(MODULE_VERSION_$*)#g" \
-e "s#%%RELEASE%%#$(MODULE_RELEASE_$*)#g" \
-e "s#%%UNIT_VERSION%%#$(VERSION)#g" \
-e "s#%%UNIT_RELEASE%%#$(RELEASE)#g" \
-e "s#%%MODULE_SOURCES%%#$${sources}#g" \
-e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \
-e "s#%%MODULE_CONFARGS%%#$(MODULE_CONFARGS_$*)#g" \
-e "s#%%MODULE_MAKEARGS%%#$(MODULE_MAKEARGS_$*)#g" \
-e "s#%%MODULE_INSTARGS%%#$(MODULE_INSTARGS_$*)#g" \
-e "s#%%MODULE_DEFINITIONS%%#$${definitions}#g" \
-e "s#%%MODULE_PREINSTALL%%#$${preinstall}#g" \
-e "s#%%MODULE_FILES%%#$${files}#g" \
-e "s#%%MODULE_POST%%#$${post}#g" \
> $@.tmp ; \
}
cd ../../docs && make ../build/unit-$*.rpm-changelog
cat ../../build/unit-$*.rpm-changelog | sed -e \
"s/> - $(DEFAULT_VERSION)-$(DEFAULT_RELEASE)/> - $(MODULE_VERSION_$*)-$(MODULE_RELEASE_$*)/" \
>> $@.tmp
mv $@.tmp $@
unit-%: rpmbuild/SPECS/unit-%.spec rpmbuild/SOURCES/unit-$(VERSION).tar.gz
@echo "===> Building $@ package" ; \
rpmbuild -D "_topdir `pwd`/rpmbuild" -ba rpmbuild/SPECS/$@.spec && \
ln -s rpmbuild/BUILD/$@-$(VERSION)/build $@
clean:
rm -rf rpmbuild/SPECS rpmbuild/BUILD rpmbuild/BUILDROOT rpmbuild/RPMS rpmbuild/SRPMS ../../build
rm -f rpmbuild/SOURCES/unit-*.tar.gz unit
find . -maxdepth 1 -type l -delete
.PHONY: default all modules specs check-build-depends rpmlint clean
.SECONDARY:

63
pkg/rpm/Makefile.go Normal file
View File

@@ -0,0 +1,63 @@
MODULES+= go
MODULE_SUMMARY_go= Go module for NGINX Unit
MODULE_VERSION_go= $(VERSION)
MODULE_RELEASE_go= 1
MODULE_CONFARGS_go= go --go-path=%{goroot}
MODULE_MAKEARGS_go= go
MODULE_INSTARGS_go= go-install
MODULE_SOURCES_go= unit.example-go-app \
unit.example-go-config
BUILD_DEPENDS+= golang
define MODULE_DEFINITIONS_go
%define goroot %(go env GOROOT)
%define goos %(go env GOOS)
%define goarch %(go env GOARCH)
BuildRequires: golang
endef
export MODULE_DEFINITIONS_go
define MODULE_PREINSTALL_go
QA_SKIP_BUILD_ROOT=1
export QA_SKIP_BUILD_ROOT
%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit-go/examples/go-app
%{__install} -m 644 -p %{SOURCE100} \
%{buildroot}%{_datadir}/doc/unit-go/examples/go-app/let-my-people.go
%{__install} -m 644 -p %{SOURCE101} \
%{buildroot}%{_datadir}/doc/unit-go/examples/unit.config
endef
export MODULE_PREINSTALL_go
define MODULE_FILES_go
%dir %{goroot}/src/unit
%{goroot}/src/unit/*
%{goroot}/pkg/%{goos}_%{goarch}/unit.a
endef
export MODULE_FILES_go
define MODULE_POST_go
cat <<BANNER
----------------------------------------------------------------------
The $(MODULE_SUMMARY_go) has been installed.
To check the sample app, run these commands:
go build -o /tmp/go-app /usr/share/doc/unit-go/examples/go-app/let-my-people.go
sudo service unit start
sudo service unit loadconfig /usr/share/doc/unit-go/examples/unit.config
curl http://localhost:8500/
Online documentation is available at https://unit.nginx.org
----------------------------------------------------------------------
BANNER
endef
export MODULE_POST_go

49
pkg/rpm/Makefile.php Normal file
View File

@@ -0,0 +1,49 @@
MODULES+= php
MODULE_SUMMARY_php= PHP module for NGINX Unit
MODULE_VERSION_php= $(VERSION)
MODULE_RELEASE_php= 1
MODULE_CONFARGS_php= php
MODULE_MAKEARGS_php= php
MODULE_INSTARGS_php= php-install
MODULE_SOURCES_php= unit.example-php-app \
unit.example-php-config
BUILD_DEPENDS+= php-devel php-embedded
define MODULE_PREINSTALL_php
%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit-php/examples/phpinfo-app
%{__install} -m 644 -p %{SOURCE100} \
%{buildroot}%{_datadir}/doc/unit-php/examples/phpinfo-app/index.php
%{__install} -m 644 -p %{SOURCE101} \
%{buildroot}%{_datadir}/doc/unit-php/examples/unit.config
endef
export MODULE_PREINSTALL_php
define MODULE_FILES_php
%{_libdir}/unit/modules/*
%{_libdir}/unit/debug-modules/*
endef
export MODULE_FILES_php
define MODULE_POST_php
cat <<BANNER
----------------------------------------------------------------------
The $(MODULE_SUMMARY_php) has been installed.
To check out the sample app, run these commands:
sudo service unit start
sudo service unit loadconfig /usr/share/doc/unit-php/examples/unit.config
curl http://localhost:8300/
Online documentation is available at https://unit.nginx.org
----------------------------------------------------------------------
BANNER
endef
export MODULE_POST_php

49
pkg/rpm/Makefile.python Normal file
View File

@@ -0,0 +1,49 @@
MODULES+= python
MODULE_SUMMARY_python= Python module for NGINX Unit
MODULE_VERSION_python= $(VERSION)
MODULE_RELEASE_python= 1
MODULE_CONFARGS_python= python
MODULE_MAKEARGS_python= python
MODULE_INSTARGS_python= python-install
MODULE_SOURCES_python= unit.example-python-app \
unit.example-python-config
BUILD_DEPENDS+= python-devel
define MODULE_PREINSTALL_python
%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit-python/examples/python-app
%{__install} -m 644 -p %{SOURCE100} \
%{buildroot}%{_datadir}/doc/unit-python/examples/python-app/wsgi.py
%{__install} -m 644 -p %{SOURCE101} \
%{buildroot}%{_datadir}/doc/unit-python/examples/unit.config
endef
export MODULE_PREINSTALL_python
define MODULE_FILES_python
%{_libdir}/unit/modules/*
%{_libdir}/unit/debug-modules/*
endef
export MODULE_FILES_python
define MODULE_POST_python
cat <<BANNER
----------------------------------------------------------------------
The $(MODULE_SUMMARY_python) has been installed.
To check the sample app, run these commands:
sudo service unit start
sudo service unit loadconfig /usr/share/doc/unit-python/examples/unit.config
curl http://localhost:8400/
Online documentation is available at https://unit.nginx.org
----------------------------------------------------------------------
BANNER
endef
export MODULE_POST_python

View File

@@ -0,0 +1,20 @@
package main
import (
"fmt"
"net/http"
"unit"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/plain");
fmt.Fprintf(w, "Method : %s\n", r.Method)
fmt.Fprintf(w, "URL : %s\n", r.URL.Path)
fmt.Fprintf(w, "Host : %s\n", r.Host)
}
func main() {
http.HandleFunc("/", handler)
unit.ListenAndServe("8000", nil)
}

View File

@@ -0,0 +1,15 @@
{
"applications": {
"example_go": {
"type": "go",
"user": "nobody",
"executable": "/tmp/go-app"
}
},
"listeners": {
"*:8500": {
"application": "example_go"
}
}
}

View File

@@ -0,0 +1 @@
<?php phpinfo(); ?>

View File

@@ -0,0 +1,17 @@
{
"applications": {
"example_php": {
"type": "php",
"user": "nobody",
"workers": 2,
"root": "/usr/share/doc/unit-php/examples/phpinfo-app",
"index": "index.php"
}
},
"listeners": {
"*:8300": {
"application": "example_php"
}
}
}

View File

@@ -0,0 +1,16 @@
import os
import datetime
import sys
def application(environ, start_response):
output = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
output += "\n\nPython: "
output += sys.version
output += "\n\nENV Variables:\n\n"
for param in os.environ.keys():
output += param
output += "\t"
output += os.environ[param]
output += "\n"
start_response('200 OK', [('Content-type', 'text/plain')])
return output.encode('utf8')

View File

@@ -0,0 +1,17 @@
{
"applications": {
"example_python": {
"type": "python",
"user": "nobody",
"workers": 2,
"path": "/usr/share/doc/unit-python/examples/python-app",
"module": "wsgi"
}
},
"listeners": {
"*:8400": {
"application": "example_python"
}
}
}

View File

@@ -0,0 +1,39 @@
{
"applications": {
"example_php": {
"type": "php",
"user": "nobody",
"workers": 2,
"root": "/usr/share/doc/unit-php/examples/phpinfo-app",
"index": "index.php"
},
"example_python": {
"type": "python",
"user": "nobody",
"workers": 2,
"path": "/usr/share/doc/unit-python/examples/python-app",
"module": "wsgi"
},
"example_go": {
"type": "go",
"user": "nobody",
"executable": "/tmp/go-app"
}
},
"listeners": {
"*:8300": {
"application": "example_php"
},
"*:8400": {
"application": "example_python"
},
"*:8500": {
"application": "example_go"
}
}
}

View File

@@ -0,0 +1,116 @@
#!/bin/sh
#
# unitd NGINX Unit
#
# chkconfig: - 86 14
# description: NGINX Unit
### BEGIN INIT INFO
# Provides: unitd
# Required-Start: $local_fs $network $named $syslog
# Required-Stop: $local_fs $network $named $syslog
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: NGINX Unit
# Description: NGINX Unit
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
exec="/usr/sbin/unitd"
prog="unitd"
config="/etc/unit/unit.conf"
if [ -n "$2" ]; then
config=$2
fi
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
echo -n $"Starting $prog: "
daemon $exec $UNITD_OPTIONS
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status &>/dev/null
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload|force-reload)
echo "Not implemented." >&2
exit 1
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
saveconfig)
curl -sS --unix-socket /var/run/control.unit.sock localhost >${config}.new
if [ $? -ne 0 ]; then
echo "Could not retreive configuration" >&2
rm -f ${config}.new
exit 1
fi
mv ${config}.new ${config}
echo "The following configuration has been saved to ${config}:"
cat ${config}
;;
loadconfig)
if [ ! -e ${config} ]; then
echo "Could not find ${config} for loading" >&2
exit 1
fi
echo "Loading configuration from ${config}..."
curl -sS -X PUT --data-binary @${config} --unix-socket /var/run/control.unit.sock localhost
if [ $? -ne 0 ]; then
echo "Loading failed!" >&2
exit 1
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|saveconfig|loadconfig}"
exit 2
esac
exit $?

View File

@@ -0,0 +1,25 @@
#!/bin/sh
#
# Legacy action script for "service unit loadconfig"
CONFIG=/etc/unit/config
if [ -n "$1" ] ; then
CONFIG=$1
fi
if [ ! -e ${CONFIG} ]; then
echo "Could not find ${CONFIG} for loading" >&2
exit 1
fi
echo "Loading configuration from ${CONFIG}..."
curl -sS -X PUT --data-binary @${CONFIG} --unix-socket /var/run/control.unit.sock localhost
if [ $? -ne 0 ]; then
echo "Loading failed!" >&2
exit 1
fi
exit 0

View File

@@ -0,0 +1,24 @@
#!/bin/sh
#
# Legacy action script for "service unit saveconfig"
CONFIG=/etc/unit/config
if [ -n "$1" ] ; then
CONFIG=$1
fi
curl -sS --unix-socket /var/run/control.unit.sock localhost >${CONFIG}.new
if [ $? -ne 0 ]; then
echo "Could not retreive configuration" >&2
rm -f ${CONFIG}.new
exit 1
fi
mv ${CONFIG}.new ${CONFIG}
echo "The following configuration has been saved to ${CONFIG}:"
cat ${CONFIG}
exit 0

View File

@@ -0,0 +1,14 @@
[Unit]
Description=NGINX Unit
Wants=network-online.target
After=network-online.target
[Service]
Type=forking
PIDFile=/run/unit.pid
EnvironmentFile=-/etc/sysconfig/unitd
ExecStart=/usr/sbin/unitd $UNITD_OPTIONS
ExecReload=
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1 @@
UNITD_OPTIONS="--log /var/log/unitd.log --pid /run/unitd.pid"

View File

@@ -0,0 +1,90 @@
# distribution specific definitions
%define bdir %{_builddir}/%{name}-%{version}
%%MODULE_DEFINITIONS%%
%if 0%{?rhel} == 7
%define dist .el7
%endif
%define unit_version %%UNIT_VERSION%%
%define unit_release %%UNIT_RELEASE%%%{?dist}.ngx
%define CONFIGURE_ARGS $(echo "%%CONFIGURE_ARGS%%")
Name: %%NAME%%
Summary: %%SUMMARY%%
Version: %%VERSION%%
Release: %%RELEASE%%%{?dist}.ngx
License: ASL 2.0
Vendor: Nginx Software, Inc.
URL: https://unit.nginx.org/
Packager: Nginx Software, Inc. <https://www.nginx.com>
Group: System Environment/Daemons
Source0: unit-%{version}.tar.gz
%%MODULE_SOURCES%%
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: unit == %%UNIT_VERSION%%-%%UNIT_RELEASE%%%{?dist}.ngx
%description
NGINX Unit is a runtime and delivery environment for modern distributed
applications. It runs the application code in multiple languages
(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
in and out of the application. Take this application server and proxy
directly in the cloud / container environments and fully control your app
dynamically via an API.
This package contains %%SUMMARY%%.
%if 0%{?suse_version}
%debug_package
%endif
%prep
%setup -qcTn %{name}-%{unit_version}
tar --strip-components=1 -zxf %{SOURCE0}
%build
./configure \
%{CONFIGURE_ARGS} \
--modules=%{_libdir}/unit/debug-modules \
--debug
./configure %%MODULE_CONFARGS%%
make %%MODULE_MAKEARGS%%
%{__mv} build build-debug
./configure \
%{CONFIGURE_ARGS} \
--modules=%{_libdir}/unit/modules
./configure %%MODULE_CONFARGS%%
make %%MODULE_MAKEARGS%%
%install
%{__rm} -rf %{buildroot}
%{__mkdir} -p %{buildroot}%{_datadir}/doc/%%NAME%%
%{__install} -m 644 -p NOTICE \
%{buildroot}%{_datadir}/doc/%%NAME%%/COPYRIGHT
%%MODULE_PREINSTALL%%
DESTDIR=%{buildroot} make %%MODULE_INSTARGS%%
%{__rm} -rf build
%{__mv} build-debug build
DESTDIR=%{buildroot} make %%MODULE_INSTARGS%%
%check
%clean
%{__rm} -rf %{buildroot}
%post
if [ $1 -eq 1 ]; then
%%MODULE_POST%%
fi
%files
%defattr(-,root,root,-)
%dir %{_datadir}/doc/%%NAME%%
%{_datadir}/doc/%%NAME%%/*
%%MODULE_FILES%%
%changelog

182
pkg/rpm/unit.spec.in Normal file
View File

@@ -0,0 +1,182 @@
# distribution specific definitions
%define use_systemd (0%{?rhel} && 0%{?rhel} >= 7) || (0%{?suse_version} == 1315)
%define bdir %{_builddir}/%{name}-%{version}
%define dotests 0
%if ( 0%{?rhel} == 5 || 0%{?rhel} == 6 )
Requires: initscripts >= 8.36
%endif
%if 0%{?rhel} == 7
Requires: systemd
BuildRequires: systemd-units
%define dist .el7
%endif
%if 0%{?suse_version} == 1315
BuildRequires: systemd
Requires: systemd
%endif
%define CONFIGURE_ARGS $(echo "%%CONFIGURE_ARGS%%")
Provides: nginx-unit
Name: unit
Summary: NGINX Unit
Version: %%VERSION%%
Release: %%RELEASE%%%{?dist}.ngx
License: ASL 2.0
Vendor: Nginx Software, Inc.
URL: https://unit.nginx.org/
Packager: Nginx Software, Inc. <https://www.nginx.com>
Group: System Environment/Daemons
Source0: unit-%{version}.tar.gz
Source1: unit.service
Source2: unit.init
Source3: unit.sysconf
Source4: unit.saveconfig.sh
Source5: unit.loadconfig.sh
Source6: unit.example.config
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
NGINX Unit is a runtime and delivery environment for modern distributed
applications. It runs the application code in multiple languages
(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
in and out of the application. Take this application server and proxy
directly in the cloud / container environments and fully control your app
dynamically via an API.
%if 0%{?suse_version}
%debug_package
%endif
%prep
%setup -q
%build
./configure \
%{CONFIGURE_ARGS} \
--modules=%{_libdir}/unit/debug-modules \
--debug
%{__make} %{?_smp_mflags}
%{__mv} build build-debug
./configure \
%{CONFIGURE_ARGS} \
--modules=%{_libdir}/unit/modules
%{__make} %{?_smp_mflags}
%install
%{__rm} -rf %{buildroot}
DESTDIR=%{buildroot} make unitd-install
%{__install} -m755 %{bdir}/build-debug/unitd \
%{buildroot}%{_sbindir}/unitd-debug
%{__mkdir} -p %{buildroot}%{_libdir}/unit/modules
%{__mkdir} -p %{buildroot}%{_libdir}/unit/debug-modules
%{__mkdir} -p %{buildroot}%{_sharedstatedir}/unit
%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
%{__install} -m 644 -p %{SOURCE3} \
%{buildroot}%{_sysconfdir}/sysconfig/unit
%{__mkdir} -p %{buildroot}%{_sysconfdir}/unit
%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples
%{__install} -m 644 -p %{SOURCE6} \
%{buildroot}%{_datadir}/doc/unit/examples/example.config
%{__install} -m 644 -p CHANGES \
%{buildroot}%{_datadir}/doc/unit/
%{__install} -m 644 -p NOTICE \
%{buildroot}%{_datadir}/doc/unit/COPYRIGHT
%{__install} -m 644 -p README \
%{buildroot}%{_datadir}/doc/unit/
# init scripts
%if %{use_systemd}
%{__rm} -rf %{buildroot}%{_initrddir}/
%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/unit.service
%{__mkdir} -p %{buildroot}%{_libexecdir}/initscripts/legacy-actions/unit
%{__install} -m755 %SOURCE4 \
%{buildroot}%{_libexecdir}/initscripts/legacy-actions/unit/saveconfig
%{__install} -m755 %SOURCE5 \
%{buildroot}%{_libexecdir}/initscripts/legacy-actions/unit/loadconfig
%else
%{__mkdir} -p %{buildroot}%{_initrddir}
%{__install} -p -D -m 0755 %{SOURCE2} %{buildroot}%{_initrddir}/unit
%endif
QA_SKIP_BUILD_ROOT=1
export QA_SKIP_BUILD_ROOT
%check
%if %{dotests}
cd %{bdir} && make tests && ./build/tests
%endif
%clean
%{__rm} -rf %{buildroot}
%post
if [ $1 -eq 1 ]; then
%if %{use_systemd}
/usr/bin/systemctl preset unit.service >/dev/null 2>&1 ||:
%else
/sbin/chkconfig --add unit
%endif
cat <<BANNER
----------------------------------------------------------------------
Thank you for installing NGINX Unit!
Additional modules are available in standalone packages.
To see the available modules, run "yum list available unit-\*".
Online documentation is available at https://unit.nginx.org/
----------------------------------------------------------------------
BANNER
fi
%preun
if [ $1 -eq 0 ]; then
%if %{use_systemd}
/usr/bin/systemctl --no-reload disable unit.service >/dev/null 2>&1 ||:
/usr/bin/systemctl stop unit.service >/dev/null 2>&1 ||:
%else
/sbin/service unit stop >/dev/null 2>&1
/sbin/chkconfig --del unit
%endif
fi
%postun
%if %{use_systemd}
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||:
%endif
if [ $1 -ge 1 ]; then
%if %{use_systemd}
/usr/bin/systemctl try-restart unit.service >/dev/null 2>&1 ||:
%else
/sbin/service unit condrestart >/dev/null 2>&1 ||:
%endif
fi
%files
%defattr(-,root,root,-)
%attr(0755,root,root) %{_sbindir}/unitd
%attr(0755,root,root) %{_sbindir}/unitd-debug
%config(noreplace) %{_sysconfdir}/sysconfig/unit
%dir %{_sysconfdir}/unit
%if %{use_systemd}
%{_unitdir}/unit.service
%dir %{_libexecdir}/initscripts/legacy-actions/unit
%{_libexecdir}/initscripts/legacy-actions/unit/*
%else
%{_initrddir}/unit
%endif
%dir %{_datadir}/doc/unit
%{_datadir}/doc/unit/*
%dir %{_libdir}/unit/modules
%dir %{_libdir}/unit/debug-modules
%dir %{_sharedstatedir}/unit
%changelog