summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2017-10-19 18:23:32 +0300
committerAndrei Belov <defan@nginx.com>2017-10-19 18:23:32 +0300
commit156877f3c99b54c78e3cae111542f5519a97a68a (patch)
tree2c21edccede53614245118f927f0a2aea8d3e944
parenteabe25d98e6805221025daf7bc60d881af1af6b1 (diff)
downloadunit-156877f3c99b54c78e3cae111542f5519a97a68a.tar.gz
unit-156877f3c99b54c78e3cae111542f5519a97a68a.tar.bz2
Introduced deb packages building tools.0.2
-rw-r--r--docs/Makefile5
-rw-r--r--docs/changes.xml65
-rw-r--r--pkg/Makefile8
-rw-r--r--pkg/deb/Makefile198
-rw-r--r--pkg/deb/Makefile.go51
-rw-r--r--pkg/deb/Makefile.go1751
-rw-r--r--pkg/deb/Makefile.go1851
-rw-r--r--pkg/deb/Makefile.php50
-rw-r--r--pkg/deb/Makefile.python44
-rw-r--r--pkg/deb/Makefile.python2744
-rw-r--r--pkg/deb/Makefile.python3444
-rw-r--r--pkg/deb/Makefile.python3544
-rw-r--r--pkg/deb/debian.module/control.in32
-rw-r--r--pkg/deb/debian.module/preinst.in21
-rwxr-xr-xpkg/deb/debian.module/rules.in95
-rw-r--r--pkg/deb/debian.module/unit.example-go-app20
-rw-r--r--pkg/deb/debian.module/unit.example-go-config15
-rw-r--r--pkg/deb/debian.module/unit.example-go1.7-config15
-rw-r--r--pkg/deb/debian.module/unit.example-go1.8-config15
-rw-r--r--pkg/deb/debian.module/unit.example-php-app1
-rw-r--r--pkg/deb/debian.module/unit.example-php-config17
-rw-r--r--pkg/deb/debian.module/unit.example-python-app16
-rw-r--r--pkg/deb/debian.module/unit.example-python-config17
-rw-r--r--pkg/deb/debian.module/unit.example-python2.7-config17
-rw-r--r--pkg/deb/debian.module/unit.example-python3.4-config17
-rw-r--r--pkg/deb/debian.module/unit.example-python3.5-config17
-rw-r--r--pkg/deb/debian/control30
-rw-r--r--pkg/deb/debian/copyright21
-rw-r--r--pkg/deb/debian/dirs4
-rw-r--r--pkg/deb/debian/rules.in105
-rw-r--r--pkg/deb/debian/unit.default1
-rw-r--r--pkg/deb/debian/unit.example-go-app20
-rw-r--r--pkg/deb/debian/unit.example-php-app1
-rw-r--r--pkg/deb/debian/unit.example-python-app16
-rw-r--r--pkg/deb/debian/unit.example.config39
-rw-r--r--pkg/deb/debian/unit.init104
-rwxr-xr-xpkg/deb/debian/unit.postinst11
-rw-r--r--pkg/deb/debian/unit.preinst34
-rw-r--r--pkg/deb/debian/unit.service14
39 files changed, 1367 insertions, 3 deletions
diff --git a/docs/Makefile b/docs/Makefile
index b5494fd2..8aed8618 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -5,7 +5,10 @@ UNIT= unit-$(VER)
DEST= ../build
XSLS?= xslscript.pl
-PACKAGES= unit unit-php unit-python unit-go
+PACKAGES= unit \
+ unit-php \
+ unit-python unit-python2.7 unit-python3.4 unit-python3.5\
+ unit-go unit-go1.7 unit-go1.8
all: changes changelogs
diff --git a/docs/changes.xml b/docs/changes.xml
index 09358398..d2d28e42 100644
--- a/docs/changes.xml
+++ b/docs/changes.xml
@@ -18,6 +18,32 @@ Initial release of Go module for NGINX Unit.
</changes>
+<changes apply="unit-go1.7" 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 1.7 module for NGINX Unit.
+</para>
+</change>
+
+</changes>
+
+
+<changes apply="unit-go1.8" 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 1.8 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;">
@@ -31,6 +57,45 @@ Initial release of Python module for NGINX Unit.
</changes>
+<changes apply="unit-python2.7" 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 2.7 module for NGINX Unit.
+</para>
+</change>
+
+</changes>
+
+
+<changes apply="unit-python3.4" 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 3.4 module for NGINX Unit.
+</para>
+</change>
+
+</changes>
+
+
+<changes apply="unit-python3.5" 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 3.5 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;">
diff --git a/pkg/Makefile b/pkg/Makefile
index 4500684d..3fa96632 100644
--- a/pkg/Makefile
+++ b/pkg/Makefile
@@ -6,12 +6,16 @@ VERSION ?= $(shell grep 'define NXT_VERSION' ../src/nxt_main.h \
RELEASE ?= 1
default:
- @echo "available targets: rpm"
+ @echo "available targets: rpm deb"
rpm:
@cd rpm && VERSION=$(VERSION) RELEASE=$(RELEASE) make all
+deb:
+ @cd deb && VERSION=$(VERSION) RELEASE=$(RELEASE) make all
+
clean:
@cd rpm && make clean
+ @cd deb && make clean
-.PHONY: default rpm clean
+.PHONY: default rpm deb clean
diff --git a/pkg/deb/Makefile b/pkg/deb/Makefile
new file mode 100644
index 00000000..fb31ad2b
--- /dev/null
+++ b/pkg/deb/Makefile
@@ -0,0 +1,198 @@
+#!/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)
+
+SRCDIR= unit-$(VERSION)
+
+CODENAME = $(shell lsb_release -cs)
+
+BUILD_DEPENDS = debhelper devscripts libxml2-utils lintian lsb-release xsltproc
+
+MODULES=
+
+# Ubuntu 17.04
+ifeq ($(CODENAME),zesty)
+include Makefile.php
+include Makefile.python27
+include Makefile.python35
+include Makefile.go17
+include Makefile.go18
+endif
+
+# Ubuntu 16.04
+ifeq ($(CODENAME),xenial)
+include Makefile.php
+include Makefile.python27
+include Makefile.python35
+include Makefile.go
+endif
+
+# Ubuntu 14.04
+ifeq ($(CODENAME),trusty)
+include Makefile.php
+include Makefile.python
+endif
+
+# Debian 9
+ifeq ($(CODENAME),stretch)
+include Makefile.php
+include Makefile.python27
+include Makefile.python35
+include Makefile.go17
+include Makefile.go18
+endif
+
+# Debian 8
+ifeq ($(CODENAME),jessie)
+include Makefile.php
+include Makefile.python27
+endif
+
+CONFIGURE_ARGS=\
+ --prefix=/usr \
+ --state=/var/lib/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)) clean"
+
+all: check-build-depends unit modules
+
+modules: $(addprefix unit-, $(MODULES))
+
+check-build-depends:
+ @{ \
+ not_installed= ; \
+ for pkg in $(BUILD_DEPENDS); do \
+ dpkg -s $${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 \
+ }
+
+debuild/$(SRCDIR)/debian:
+ @{ \
+ set -e ; \
+ mkdir -p debuild/$(SRCDIR) ; \
+ cp -pr debian debuild/$(SRCDIR) ; \
+ echo '9' > debuild/$(SRCDIR)/debian/compat ; \
+ mkdir -p debuild/$(SRCDIR)/debian/source ; \
+ echo '3.0 (quilt)' > debuild/$(SRCDIR)/debian/source/format ; \
+ cat debian/rules.in | sed \
+ -e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \
+ > debuild/$(SRCDIR)/debian/rules ; \
+ }
+
+debuild/$(SRCDIR)/debian/changelog: ../../docs/changes.xml | debuild/$(SRCDIR)/debian
+ cd ../../docs && make ../build/unit.deb-changelog
+ifneq ($(DEFAULT_VERSION)$(DEFAULT_RELEASE), $(VERSION)$(RELEASE))
+ cat ../../build/unit.deb-changelog | sed \
+ -e "s/unit ($(DEFAULT_VERSION)-$(DEFAULT_RELEASE)~/unit ($(VERSION)-$(RELEASE)~/" \
+ -e "s#%%CODENAME%%#$(CODENAME)#g" \
+ > debuild/$(SRCDIR)/debian/changelog
+else
+ cat ../../build/unit.deb-changelog | sed \
+ -e "s#%%CODENAME%%#$(CODENAME)#g" \
+ > debuild/$(SRCDIR)/debian/changelog
+endif
+
+debuild/unit_$(VERSION).orig.tar.gz: | debuild/$(SRCDIR)/debian
+ cd ../.. && tar -czf pkg/deb/debuild/$(SRCDIR).tar.gz \
+ --transform "s#^#$(SRCDIR)/#" \
+ LICENSE NOTICE CHANGES README configure auto src test
+ mv debuild/$(SRCDIR).tar.gz debuild/unit_$(VERSION).orig.tar.gz
+ cd debuild && tar zxf unit_$(VERSION).orig.tar.gz
+
+unit: debuild/unit_$(VERSION).orig.tar.gz debuild/$(SRCDIR)/debian/changelog
+ @echo "===> Building $@ package"
+ cd debuild/$(SRCDIR) && debuild -us -uc
+ mkdir -p debs
+ find debuild/ -maxdepth 1 -type f -exec cp {} debs/ \;
+ ln -s debuild/$(SRCDIR)/build $@
+
+debuild-%: debuild/unit_$(VERSION).orig.tar.gz ../../docs/changes.xml
+ mkdir $@
+ cp debuild/unit_$(VERSION).orig.tar.gz debuild-$*/unit-$(MODULE_SUFFIX_$*)_$(VERSION).orig.tar.gz
+ cd $@ && tar zxf unit-$(MODULE_SUFFIX_$*)_$(VERSION).orig.tar.gz
+ mkdir $@/$(SRCDIR)/debian
+ echo '9' > $@/$(SRCDIR)/debian/compat
+ mkdir $@/$(SRCDIR)/debian/source
+ echo '3.0 (quilt)' > $@/$(SRCDIR)/debian/source/format
+ cd ../../docs && make ../build/unit-$(MODULE_SUFFIX_$*).deb-changelog
+ cat ../../build/unit-$(MODULE_SUFFIX_$*).deb-changelog | sed \
+ -e "s#%%CODENAME%%#$(CODENAME)#g" \
+ > $@/$(SRCDIR)/debian/changelog
+ cp debian/copyright debuild-$*/$(SRCDIR)/debian/
+ @{ \
+ set -e ; \
+ for src in $(MODULE_SOURCES_$*); do \
+ cp debian.module/$${src} $@/$(SRCDIR)/debian/ ; \
+ done ; \
+ definitions=`echo "$$MODULE_DEFINITIONS_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
+ prebuild=`echo "$$MODULE_PREBUILD_$*" | 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"` ; \
+ post=`echo "$$MODULE_POST_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
+ cat debian.module/control.in | sed \
+ -e "s#%%NAME%%#unit-$(MODULE_SUFFIX_$*)#g" \
+ -e "s#%%SUMMARY%%#$(MODULE_SUMMARY_$*)#g" \
+ -e "s#%%CODENAME%%#$(CODENAME)#g" \
+ -e "s#%%UNIT_VERSION%%#$(VERSION)#g" \
+ -e "s#%%UNIT_RELEASE%%#$(RELEASE)#g" \
+ -e "s#%%VERSION%%#$(MODULE_VERSION_$*)#g" \
+ -e "s#%%RELEASE%%#$(MODULE_RELEASE_$*)#g" \
+ -e "s#%%MODULE_BUILD_DEPENDS%%#$(MODULE_BUILD_DEPENDS_$*)#g" \
+ -e "s#%%MODULE_DEPENDS%%#$(MODULE_DEPENDS_$*)#g" \
+ > $@/$(SRCDIR)/debian/control ; \
+ cat debian.module/rules.in | sed \
+ -e "s#%%NAME%%#unit-$(MODULE_SUFFIX_$*)#g" \
+ -e "s#%%CODENAME%%#$(CODENAME)#g" \
+ -e "s#%%UNIT_VERSION%%#$(VERSION)#g" \
+ -e "s#%%UNIT_RELEASE%%#$(RELEASE)#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_PREBUILD%%#$${prebuild}#g" \
+ -e "s#%%MODULE_PREINSTALL%%#$${preinstall}#g" \
+ > $@/$(SRCDIR)/debian/rules ; \
+ cat debian.module/preinst.in | sed \
+ -e "s#%%MODULE_POST%%#$$post#g" \
+ > $@/$(SRCDIR)/debian/preinst ; \
+ chmod +x $@/$(SRCDIR)/debian/rules ; \
+ }
+
+unit-%: | debuild-%
+ @echo "===> Building $@ package"
+ cd debuild-$*/$(SRCDIR) && debuild -us -uc
+ mkdir -p debs
+ find debuild-$*/ -maxdepth 1 -type f -exec cp {} debs/ \;
+ ln -s debuild-$*/$(SRCDIR)/build $@
+
+clean:
+ rm -rf debuild debuild-* debs ../../build
+ find . -maxdepth 1 -type l -delete
+
+.PHONY: default all modules check-build-depends clean
+
+.SECONDARY:
diff --git a/pkg/deb/Makefile.go b/pkg/deb/Makefile.go
new file mode 100644
index 00000000..d960a68d
--- /dev/null
+++ b/pkg/deb/Makefile.go
@@ -0,0 +1,51 @@
+MODULES+= go
+MODULE_SUFFIX_go= 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
+
+MODULE_BUILD_DEPENDS_go=,golang
+MODULE_DEPENDS_go=,golang
+
+define MODULE_DEFINITIONS_go
+GOROOT = $(shell go env GOROOT)
+endef
+export MODULE_DEFINITIONS_go
+
+define MODULE_PREINSTALL_go
+ mkdir -p debian/unit-go/usr/share/doc/unit-go/examples/go-app
+ install -m 644 -p debian/unit.example-go-app debian/unit-go/usr/share/doc/unit-go/examples/go-app/let-my-people.go
+ install -m 644 -p debian/unit.example-go-config debian/unit-go/usr/share/doc/unit-go/examples/unit.config
+endef
+export MODULE_PREINSTALL_go
+
+define MODULE_POST_go
+cat <<BANNER
+----------------------------------------------------------------------
+
+The $(MODULE_SUMMARY_go) has been installed.
+
+To check out 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 restart
+ 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
diff --git a/pkg/deb/Makefile.go17 b/pkg/deb/Makefile.go17
new file mode 100644
index 00000000..7fbfd360
--- /dev/null
+++ b/pkg/deb/Makefile.go17
@@ -0,0 +1,51 @@
+MODULES+= go17
+MODULE_SUFFIX_go17= go1.7
+
+MODULE_SUMMARY_go17= Go 1.7 module for NGINX Unit
+
+MODULE_VERSION_go17= $(VERSION)
+MODULE_RELEASE_go17= 1
+
+MODULE_CONFARGS_go17= go --go=/usr/lib/go-1.7/bin/go --go-path=\$$(GOROOT)
+MODULE_MAKEARGS_go17= /usr/lib/go-1.7/bin/go
+MODULE_INSTARGS_go17= /usr/lib/go-1.7/bin/go-install
+
+MODULE_SOURCES_go17= unit.example-go-app \
+ unit.example-go1.7-config
+
+BUILD_DEPENDS+= golang-1.7
+
+MODULE_BUILD_DEPENDS_go=,golang-1.7
+MODULE_DEPENDS_go=,golang-1.7
+
+define MODULE_DEFINITIONS_go17
+GOROOT = \$$(shell /usr/lib/go-1.7/bin/go env GOROOT)
+endef
+export MODULE_DEFINITIONS_go17
+
+define MODULE_PREINSTALL_go17
+ mkdir -p debian/unit-go1.7/usr/share/doc/unit-go1.7/examples/go-app
+ install -m 644 -p debian/unit.example-go-app debian/unit-go1.7/usr/share/doc/unit-go1.7/examples/go-app/let-my-people.go
+ install -m 644 -p debian/unit.example-go1.7-config debian/unit-go1.7/usr/share/doc/unit-go1.7/examples/unit.config
+endef
+export MODULE_PREINSTALL_go17
+
+define MODULE_POST_go17
+cat <<BANNER
+----------------------------------------------------------------------
+
+The $(MODULE_SUMMARY_go17) has been installed.
+
+To check out the sample app, run these commands:
+
+ /usr/lib/go-1.7/bin/go build -o /tmp/go1.7-app /usr/share/doc/unit-go1.7/examples/go-app/let-my-people.go
+ sudo service unit restart
+ sudo service unit loadconfig /usr/share/doc/unit-go1.7/examples/unit.config
+ curl http://localhost:8500/
+
+Online documentation is available at https://unit.nginx.org
+
+----------------------------------------------------------------------
+BANNER
+endef
+export MODULE_POST_go17
diff --git a/pkg/deb/Makefile.go18 b/pkg/deb/Makefile.go18
new file mode 100644
index 00000000..4f15bbc9
--- /dev/null
+++ b/pkg/deb/Makefile.go18
@@ -0,0 +1,51 @@
+MODULES+= go18
+MODULE_SUFFIX_go18= go1.8
+
+MODULE_SUMMARY_go18= Go 1.8 module for NGINX Unit
+
+MODULE_VERSION_go18= $(VERSION)
+MODULE_RELEASE_go18= 1
+
+MODULE_CONFARGS_go18= go --go=/usr/lib/go-1.8/bin/go --go-path=\$$(GOROOT)
+MODULE_MAKEARGS_go18= /usr/lib/go-1.8/bin/go
+MODULE_INSTARGS_go18= /usr/lib/go-1.8/bin/go-install
+
+MODULE_SOURCES_go18= unit.example-go-app \
+ unit.example-go1.8-config
+
+BUILD_DEPENDS+= golang-1.8
+
+MODULE_BUILD_DEPENDS_go=,golang-1.8
+MODULE_DEPENDS_go=,golang-1.8
+
+define MODULE_DEFINITIONS_go18
+GOROOT = \$$(shell /usr/lib/go-1.8/bin/go env GOROOT)
+endef
+export MODULE_DEFINITIONS_go18
+
+define MODULE_PREINSTALL_go18
+ mkdir -p debian/unit-go1.8/usr/share/doc/unit-go1.8/examples/go-app
+ install -m 644 -p debian/unit.example-go-app debian/unit-go1.8/usr/share/doc/unit-go1.8/examples/go-app/let-my-people.go
+ install -m 644 -p debian/unit.example-go1.8-config debian/unit-go1.8/usr/share/doc/unit-go1.8/examples/unit.config
+endef
+export MODULE_PREINSTALL_go18
+
+define MODULE_POST_go18
+cat <<BANNER
+----------------------------------------------------------------------
+
+The $(MODULE_SUMMARY_go18) has been installed.
+
+To check out the sample app, run these commands:
+
+ /usr/lib/go-1.8/bin/go build -o /tmp/go1.8-app /usr/share/doc/unit-go1.8/examples/go-app/let-my-people.go
+ sudo service unit restart
+ sudo service unit loadconfig /usr/share/doc/unit-go1.8/examples/unit.config
+ curl http://localhost:8500/
+
+Online documentation is available at https://unit.nginx.org
+
+----------------------------------------------------------------------
+BANNER
+endef
+export MODULE_POST_go18
diff --git a/pkg/deb/Makefile.php b/pkg/deb/Makefile.php
new file mode 100644
index 00000000..305bd970
--- /dev/null
+++ b/pkg/deb/Makefile.php
@@ -0,0 +1,50 @@
+MODULES+= php
+MODULE_SUFFIX_php= 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
+
+ifneq (,$(findstring $(CODENAME),trusty jessie))
+BUILD_DEPENDS+= php5-dev libphp5-embed
+MODULE_BUILD_DEPENDS_php=,php5-dev,libphp5-embed
+MODULE_DEPENDS_php=,libphp5-embed
+else
+BUILD_DEPENDS+= php-dev libphp-embed
+MODULE_BUILD_DEPENDS_php=,php-dev,libphp-embed
+MODULE_DEPENDS_php=,libphp-embed
+endif
+
+define MODULE_PREINSTALL_php
+ mkdir -p debian/unit-php/usr/share/doc/unit-php/examples/phpinfo-app
+ install -m 644 -p debian/unit.example-php-app debian/unit-php/usr/share/doc/unit-php/examples/phpinfo-app/index.php
+ install -m 644 -p debian/unit.example-php-config debian/unit-php/usr/share/doc/unit-php/examples/unit.config
+endef
+export MODULE_PREINSTALL_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 restart
+ 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
diff --git a/pkg/deb/Makefile.python b/pkg/deb/Makefile.python
new file mode 100644
index 00000000..d9274ad6
--- /dev/null
+++ b/pkg/deb/Makefile.python
@@ -0,0 +1,44 @@
+MODULES+= python
+MODULE_SUFFIX_python= 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-dev
+
+MODULE_BUILD_DEPENDS_python=,python-dev
+
+define MODULE_PREINSTALL_python
+ mkdir -p debian/unit-python/usr/share/doc/unit-python/examples/python-app
+ install -m 644 -p debian/unit.example-python-app debian/unit-python/usr/share/doc/unit-python/examples/python-app/wsgi.py
+ install -m 644 -p debian/unit.example-python-config debian/unit-python/usr/share/doc/unit-python/examples/unit.config
+endef
+export MODULE_PREINSTALL_python
+
+define MODULE_POST_python
+cat <<BANNER
+----------------------------------------------------------------------
+
+The $(MODULE_SUMMARY_python) has been installed.
+
+To check out the sample app, run these commands:
+
+ sudo service unit restart
+ 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
diff --git a/pkg/deb/Makefile.python27 b/pkg/deb/Makefile.python27
new file mode 100644
index 00000000..397678ca
--- /dev/null
+++ b/pkg/deb/Makefile.python27
@@ -0,0 +1,44 @@
+MODULES+= python27
+MODULE_SUFFIX_python27= python2.7
+
+MODULE_SUMMARY_python27= Python 2.7 module for NGINX Unit
+
+MODULE_VERSION_python27= $(VERSION)
+MODULE_RELEASE_python27= 1
+
+MODULE_CONFARGS_python27= python --config=python2.7-config
+MODULE_MAKEARGS_python27= python2.7
+MODULE_INSTARGS_python27= python2.7-install
+
+MODULE_SOURCES_python27= unit.example-python-app \
+ unit.example-python2.7-config
+
+BUILD_DEPENDS+= python2.7-dev
+
+MODULE_BUILD_DEPENDS_python27=,python2.7-dev
+
+define MODULE_PREINSTALL_python27
+ mkdir -p debian/unit-python2.7/usr/share/doc/unit-python2.7/examples/python-app
+ install -m 644 -p debian/unit.example-python-app debian/unit-python2.7/usr/share/doc/unit-python2.7/examples/python-app/wsgi.py
+ install -m 644 -p debian/unit.example-python2.7-config debian/unit-python2.7/usr/share/doc/unit-python2.7/examples/unit.config
+endef
+export MODULE_PREINSTALL_python27
+
+define MODULE_POST_python27
+cat <<BANNER
+----------------------------------------------------------------------
+
+The $(MODULE_SUMMARY_python27) has been installed.
+
+To check out the sample app, run these commands:
+
+ sudo service unit restart
+ sudo service unit loadconfig /usr/share/doc/unit-python2.7/examples/unit.config
+ curl http://localhost:8400/
+
+Online documentation is available at https://unit.nginx.org
+
+----------------------------------------------------------------------
+BANNER
+endef
+export MODULE_POST_python27
diff --git a/pkg/deb/Makefile.python34 b/pkg/deb/Makefile.python34
new file mode 100644
index 00000000..fc501a7c
--- /dev/null
+++ b/pkg/deb/Makefile.python34
@@ -0,0 +1,44 @@
+MODULES+= python34
+MODULE_SUFFIX_python34= python3.4
+
+MODULE_SUMMARY_python34= Python 3.4 module for NGINX Unit
+
+MODULE_VERSION_python34= $(VERSION)
+MODULE_RELEASE_python34= 1
+
+MODULE_CONFARGS_python34= python --config=python3.4-config
+MODULE_MAKEARGS_python34= python3.4
+MODULE_INSTARGS_python34= python3.4-install
+
+MODULE_SOURCES_python34= unit.example-python-app \
+ unit.example-python3.4-config
+
+BUILD_DEPENDS+= python3.4-dev
+
+MODULE_BUILD_DEPENDS_python34=,python3.4-dev
+
+define MODULE_PREINSTALL_python34
+ mkdir -p debian/unit-python3.4/usr/share/doc/unit-python3.4/examples/python-app
+ install -m 644 -p debian/unit.example-python-app debian/unit-python3.4/usr/share/doc/unit-python3.4/examples/python-app/wsgi.py
+ install -m 644 -p debian/unit.example-python3.4-config debian/unit-python3.4/usr/share/doc/unit-python3.4/examples/unit.config
+endef
+export MODULE_PREINSTALL_python34
+
+define MODULE_POST_python34
+cat <<BANNER
+----------------------------------------------------------------------
+
+The $(MODULE_SUMMARY_python34) has been installed.
+
+To check out the sample app, run these commands:
+
+ sudo service unit restart
+ sudo service unit loadconfig /usr/share/doc/unit-python3.4/examples/unit.config
+ curl http://localhost:8400/
+
+Online documentation is available at https://unit.nginx.org
+
+----------------------------------------------------------------------
+BANNER
+endef
+export MODULE_POST_python34
diff --git a/pkg/deb/Makefile.python35 b/pkg/deb/Makefile.python35
new file mode 100644
index 00000000..a23c99c8
--- /dev/null
+++ b/pkg/deb/Makefile.python35
@@ -0,0 +1,44 @@
+MODULES+= python35
+MODULE_SUFFIX_python35= python3.5
+
+MODULE_SUMMARY_python35= Python 3.5 module for NGINX Unit
+
+MODULE_VERSION_python35= $(VERSION)
+MODULE_RELEASE_python35= 1
+
+MODULE_CONFARGS_python35= python --config=python3.5-config
+MODULE_MAKEARGS_python35= python3.5
+MODULE_INSTARGS_python35= python3.5-install
+
+MODULE_SOURCES_python35= unit.example-python-app \
+ unit.example-python3.5-config
+
+BUILD_DEPENDS+= python3.5-dev
+
+MODULE_BUILD_DEPENDS_python35=,python3.5-dev
+
+define MODULE_PREINSTALL_python35
+ mkdir -p debian/unit-python3.5/usr/share/doc/unit-python3.5/examples/python-app
+ install -m 644 -p debian/unit.example-python-app debian/unit-python3.5/usr/share/doc/unit-python3.5/examples/python-app/wsgi.py
+ install -m 644 -p debian/unit.example-python3.5-config debian/unit-python3.5/usr/share/doc/unit-python3.5/examples/unit.config
+endef
+export MODULE_PREINSTALL_python35
+
+define MODULE_POST_python35
+cat <<BANNER
+----------------------------------------------------------------------
+
+The $(MODULE_SUMMARY_python35) has been installed.
+
+To check out the sample app, run these commands:
+
+ sudo service unit restart
+ sudo service unit loadconfig /usr/share/doc/unit-python3.5/examples/unit.config
+ curl http://localhost:8400/
+
+Online documentation is available at https://unit.nginx.org
+
+----------------------------------------------------------------------
+BANNER
+endef
+export MODULE_POST_python35
diff --git a/pkg/deb/debian.module/control.in b/pkg/deb/debian.module/control.in
new file mode 100644
index 00000000..e9b8b8e2
--- /dev/null
+++ b/pkg/deb/debian.module/control.in
@@ -0,0 +1,32 @@
+Source: %%NAME%%
+Section: admin
+Priority: extra
+Maintainer: Andrei Belov <defan@nginx.com>
+Build-Depends: debhelper (>= 9),
+ linux-libc-dev%%MODULE_BUILD_DEPENDS%%
+Standards-Version: 3.9.5
+Homepage: https://unit.nginx.org
+
+Package: %%NAME%%
+Section: admin
+Architecture: any
+Depends: lsb-base,
+ ${misc:Depends}, ${shlibs:Depends},
+ unit (= %%UNIT_VERSION%%-%%UNIT_RELEASE%%~%%CODENAME%%)%%MODULE_DEPENDS%%
+Description: %%SUMMARY%%
+ 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%%.
+
+Package: %%NAME%%-dbg
+Section: debug
+Architecture: any
+Priority: extra
+Depends: %%NAME%% (= ${binary:Version}),
+ ${misc:Depends}
+Description: %%SUMMARY%% (debug symbols)
+ This package contains the debugging symbols for %%NAME%%
diff --git a/pkg/deb/debian.module/preinst.in b/pkg/deb/debian.module/preinst.in
new file mode 100644
index 00000000..51bdfc93
--- /dev/null
+++ b/pkg/deb/debian.module/preinst.in
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ install)
+%%MODULE_POST%%
+ ;;
+ upgrade)
+ ;;
+ abort-upgrade)
+ ;;
+ *)
+ echo "preinst called with unknown argument \`$1'" >&2
+ exit 0
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/pkg/deb/debian.module/rules.in b/pkg/deb/debian.module/rules.in
new file mode 100755
index 00000000..4498cdca
--- /dev/null
+++ b/pkg/deb/debian.module/rules.in
@@ -0,0 +1,95 @@
+#!/usr/bin/make -f
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+BUILDDIR_unit = $(CURDIR)/debian/build-unit
+BUILDDIR_unit_debug = $(CURDIR)/debian/build-unit-debug
+INSTALLDIR = $(CURDIR)/debian/%%NAME%%
+BASEDIR = $(CURDIR)
+
+%%MODULE_DEFINITIONS%%
+
+config.env.%:
+ dh_testdir
+ mkdir -p $(BUILDDIR_$*)
+ cp -Pa $(CURDIR)/auto $(BUILDDIR_$*)/
+ cp -Pa $(CURDIR)/configure $(BUILDDIR_$*)/
+ cp -Pa $(CURDIR)/src $(BUILDDIR_$*)/
+ cp -Pa $(CURDIR)/test $(BUILDDIR_$*)/
+ touch $@
+
+configure.unit: config.env.unit
+ cd $(BUILDDIR_unit) && \
+ ./configure \
+ %%CONFIGURE_ARGS%% \
+ --modules=/usr/lib/unit/modules && \
+ ./configure %%MODULE_CONFARGS%%
+ touch $@
+
+configure.unit_debug: config.env.unit_debug
+ cd $(BUILDDIR_unit_debug) && \
+ ./configure \
+ %%CONFIGURE_ARGS%% \
+ --modules=/usr/lib/unit/debug-modules \
+ --debug && \
+ ./configure %%MODULE_CONFARGS%%
+ touch $@
+
+build-arch.%: configure.%
+ dh_testdir
+ $(MAKE) -C $(BUILDDIR_$*) %%MODULE_MAKEARGS%%
+ touch $@
+
+build-indep:
+ dh_testdir
+ touch $@
+
+build-arch: build-arch.unit build-arch.unit_debug
+ dh_testdir
+ touch $@
+
+build: build-arch build-indep
+ dh_testdir
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ dh_clean
+ find $(CURDIR) -maxdepth 1 -size 0 -delete
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_prep
+ dh_installdirs
+ dh_installinit
+ dh_installlogrotate
+%%MODULE_PREINSTALL%%
+ cd $(BUILDDIR_unit) && \
+ DESTDIR=$(INSTALLDIR) make %%MODULE_INSTARGS%%
+ cd $(BUILDDIR_unit_debug) && \
+ DESTDIR=$(INSTALLDIR) make %%MODULE_INSTARGS%%
+
+binary-indep: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_installchangelogs
+ dh_link
+ dh_strip --dbg-package=%%NAME%%-dbg
+ dh_shlibdeps
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_perl
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary-arch: install
+
+binary: binary-indep binary-arch
+
+.PHONY: clean binary-indep binary-arch binary install build
diff --git a/pkg/deb/debian.module/unit.example-go-app b/pkg/deb/debian.module/unit.example-go-app
new file mode 100644
index 00000000..ef2568ec
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-go-app
@@ -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)
+}
diff --git a/pkg/deb/debian.module/unit.example-go-config b/pkg/deb/debian.module/unit.example-go-config
new file mode 100644
index 00000000..6ee4d001
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-go-config
@@ -0,0 +1,15 @@
+{
+ "applications": {
+ "example_go": {
+ "type": "go",
+ "user": "nobody",
+ "executable": "/tmp/go-app"
+ }
+ },
+
+ "listeners": {
+ "*:8500": {
+ "application": "example_go"
+ }
+ }
+}
diff --git a/pkg/deb/debian.module/unit.example-go1.7-config b/pkg/deb/debian.module/unit.example-go1.7-config
new file mode 100644
index 00000000..1b1943e0
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-go1.7-config
@@ -0,0 +1,15 @@
+{
+ "applications": {
+ "example_go": {
+ "type": "go",
+ "user": "nobody",
+ "executable": "/tmp/go1.7-app"
+ }
+ },
+
+ "listeners": {
+ "*:8500": {
+ "application": "example_go"
+ }
+ }
+}
diff --git a/pkg/deb/debian.module/unit.example-go1.8-config b/pkg/deb/debian.module/unit.example-go1.8-config
new file mode 100644
index 00000000..6cfa0cec
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-go1.8-config
@@ -0,0 +1,15 @@
+{
+ "applications": {
+ "example_go": {
+ "type": "go",
+ "user": "nobody",
+ "executable": "/tmp/go1.8-app"
+ }
+ },
+
+ "listeners": {
+ "*:8500": {
+ "application": "example_go"
+ }
+ }
+}
diff --git a/pkg/deb/debian.module/unit.example-php-app b/pkg/deb/debian.module/unit.example-php-app
new file mode 100644
index 00000000..147cebcd
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-php-app
@@ -0,0 +1 @@
+<?php phpinfo(); ?>
diff --git a/pkg/deb/debian.module/unit.example-php-config b/pkg/deb/debian.module/unit.example-php-config
new file mode 100644
index 00000000..026b8f20
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-php-config
@@ -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"
+ }
+ }
+}
diff --git a/pkg/deb/debian.module/unit.example-python-app b/pkg/deb/debian.module/unit.example-python-app
new file mode 100644
index 00000000..4146fb52
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-python-app
@@ -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 [s.encode('utf8') for s in output]
diff --git a/pkg/deb/debian.module/unit.example-python-config b/pkg/deb/debian.module/unit.example-python-config
new file mode 100644
index 00000000..e0d8c439
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-python-config
@@ -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"
+ }
+ }
+}
diff --git a/pkg/deb/debian.module/unit.example-python2.7-config b/pkg/deb/debian.module/unit.example-python2.7-config
new file mode 100644
index 00000000..eab51a6f
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-python2.7-config
@@ -0,0 +1,17 @@
+{
+ "applications": {
+ "example_python": {
+ "type": "python",
+ "user": "nobody",
+ "workers": 2,
+ "path": "/usr/share/doc/unit-python2.7/examples/python-app",
+ "module": "wsgi"
+ }
+ },
+
+ "listeners": {
+ "*:8400": {
+ "application": "example_python"
+ }
+ }
+}
diff --git a/pkg/deb/debian.module/unit.example-python3.4-config b/pkg/deb/debian.module/unit.example-python3.4-config
new file mode 100644
index 00000000..37efc0b4
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-python3.4-config
@@ -0,0 +1,17 @@
+{
+ "applications": {
+ "example_python": {
+ "type": "python",
+ "user": "nobody",
+ "workers": 2,
+ "path": "/usr/share/doc/unit-python3.4/examples/python-app",
+ "module": "wsgi"
+ }
+ },
+
+ "listeners": {
+ "*:8400": {
+ "application": "example_python"
+ }
+ }
+}
diff --git a/pkg/deb/debian.module/unit.example-python3.5-config b/pkg/deb/debian.module/unit.example-python3.5-config
new file mode 100644
index 00000000..7154f93c
--- /dev/null
+++ b/pkg/deb/debian.module/unit.example-python3.5-config
@@ -0,0 +1,17 @@
+{
+ "applications": {
+ "example_python": {
+ "type": "python",
+ "user": "nobody",
+ "workers": 2,
+ "path": "/usr/share/doc/unit-python3.5/examples/python-app",
+ "module": "wsgi"
+ }
+ },
+
+ "listeners": {
+ "*:8400": {
+ "application": "example_python"
+ }
+ }
+}
diff --git a/pkg/deb/debian/control b/pkg/deb/debian/control
new file mode 100644
index 00000000..4e18f03d
--- /dev/null
+++ b/pkg/deb/debian/control
@@ -0,0 +1,30 @@
+Source: unit
+Section: admin
+Priority: extra
+Maintainer: Andrei Belov <defan@nginx.com>
+Build-Depends: debhelper (>= 9),
+ linux-libc-dev
+Standards-Version: 3.9.5
+Homepage: https://unit.nginx.org
+
+Package: unit
+Section: admin
+Architecture: any
+Depends: lsb-base,
+ ${misc:Depends}, ${shlibs:Depends}
+Description: NGINX Unit
+ 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.
+
+Package: unit-dbg
+Section: debug
+Architecture: any
+Priority: extra
+Depends: unit (= ${binary:Version}),
+ ${misc:Depends}
+Description: NGINX Unit (debug symbols)
+ This package contains the debugging symbols for NGINX Unit.
diff --git a/pkg/deb/debian/copyright b/pkg/deb/debian/copyright
new file mode 100644
index 00000000..08072b45
--- /dev/null
+++ b/pkg/deb/debian/copyright
@@ -0,0 +1,21 @@
+
+ NGINX Unit.
+
+ Copyright 2017 NGINX, Inc.
+ Copyright 2017 Igor Sysoev
+ Copyright 2017 Valentin V. Bartenev
+ Copyright 2017 Max Romanov
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ /usr/share/common-licenses/Apache-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/pkg/deb/debian/dirs b/pkg/deb/debian/dirs
new file mode 100644
index 00000000..fdcb4340
--- /dev/null
+++ b/pkg/deb/debian/dirs
@@ -0,0 +1,4 @@
+usr/sbin
+etc/unit
+usr/lib/unit
+var/lib/unit
diff --git a/pkg/deb/debian/rules.in b/pkg/deb/debian/rules.in
new file mode 100644
index 00000000..5f087a7c
--- /dev/null
+++ b/pkg/deb/debian/rules.in
@@ -0,0 +1,105 @@
+#!/usr/bin/make -f
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+BUILDDIR_unit = $(CURDIR)/debian/build-unit
+BUILDDIR_unit_debug = $(CURDIR)/debian/build-unit-debug
+INSTALLDIR = $(CURDIR)/debian/unit
+BASEDIR = $(CURDIR)
+
+DOTESTS = 0
+
+config.env.%:
+ dh_testdir
+ mkdir -p $(BUILDDIR_$*)
+ cp -Pa $(CURDIR)/auto $(BUILDDIR_$*)/
+ cp -Pa $(CURDIR)/configure $(BUILDDIR_$*)/
+ cp -Pa $(CURDIR)/src $(BUILDDIR_$*)/
+ cp -Pa $(CURDIR)/test $(BUILDDIR_$*)/
+ touch $@
+
+configure.unit: config.env.unit
+ cd $(BUILDDIR_unit) && \
+ ./configure \
+ %%CONFIGURE_ARGS%% \
+ --modules=/usr/lib/unit/modules
+ touch $@
+
+configure.unit_debug: config.env.unit_debug
+ cd $(BUILDDIR_unit_debug) && \
+ ./configure \
+ %%CONFIGURE_ARGS%% \
+ --modules=/usr/lib/unit/debug-modules \
+ --debug
+ touch $@
+
+build-arch.%: configure.%
+ dh_testdir
+ $(MAKE) -C $(BUILDDIR_$*)
+ifeq ($(DOTESTS), 1)
+ $(MAKE) -C $(BUILDDIR_$*) tests
+endif
+ touch $@
+
+do.tests: build
+ dh_testdir
+ifeq ($(DOTESTS), 1)
+ cd $(BUILDDIR_unit) && ./build/tests
+ cd $(BUILDDIR_unit_debug) && ./build/tests
+endif
+ touch $@
+
+build-indep:
+ dh_testdir
+ touch $@
+
+build-arch: build-arch.unit build-arch.unit_debug
+ dh_testdir
+ touch $@
+
+build: build-arch build-indep
+ dh_testdir
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ dh_clean
+ find $(CURDIR) -maxdepth 1 -size 0 -delete
+
+install: build do.tests
+ dh_testdir
+ dh_testroot
+ dh_prep
+ dh_installdirs
+ dh_installinit
+ dh_installlogrotate
+ cd $(BUILDDIR_unit) && DESTDIR=$(INSTALLDIR) make install
+ install -m 755 $(BUILDDIR_unit_debug)/build/unitd $(INSTALLDIR)/usr/sbin/unitd-debug
+ mkdir -p $(INSTALLDIR)/usr/share/doc/unit/examples
+ install -m 644 debian/unit.example.config $(INSTALLDIR)/usr/share/doc/unit/examples/example.config
+ install -m 644 CHANGES $(INSTALLDIR)/usr/share/doc/unit/
+ install -m 644 README $(INSTALLDIR)/usr/share/doc/unit/
+
+binary-indep: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_installchangelogs
+ dh_link
+ dh_strip --dbg-package=unit-dbg
+ dh_shlibdeps
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_perl
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary-arch: install
+
+binary: binary-indep binary-arch
+
+.PHONY: clean binary-indep binary-arch binary install build
diff --git a/pkg/deb/debian/unit.default b/pkg/deb/debian/unit.default
new file mode 100644
index 00000000..b0f0f72d
--- /dev/null
+++ b/pkg/deb/debian/unit.default
@@ -0,0 +1 @@
+DAEMON_ARGS="--log /var/log/unit.log --pid /run/unit.pid"
diff --git a/pkg/deb/debian/unit.example-go-app b/pkg/deb/debian/unit.example-go-app
new file mode 100644
index 00000000..ef2568ec
--- /dev/null
+++ b/pkg/deb/debian/unit.example-go-app
@@ -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)
+}
diff --git a/pkg/deb/debian/unit.example-php-app b/pkg/deb/debian/unit.example-php-app
new file mode 100644
index 00000000..147cebcd
--- /dev/null
+++ b/pkg/deb/debian/unit.example-php-app
@@ -0,0 +1 @@
+<?php phpinfo(); ?>
diff --git a/pkg/deb/debian/unit.example-python-app b/pkg/deb/debian/unit.example-python-app
new file mode 100644
index 00000000..756de77e
--- /dev/null
+++ b/pkg/deb/debian/unit.example-python-app
@@ -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')
diff --git a/pkg/deb/debian/unit.example.config b/pkg/deb/debian/unit.example.config
new file mode 100644
index 00000000..8f1a7a75
--- /dev/null
+++ b/pkg/deb/debian/unit.example.config
@@ -0,0 +1,39 @@
+{
+ "applications": {
+ "example_php": {
+ "type": "php",
+ "user": "nobody",
+ "workers": 2,
+ "root": "/usr/share/doc/unit/examples/php-app",
+ "index": "index.php"
+ },
+
+ "example_python": {
+ "type": "python",
+ "user": "nobody",
+ "workers": 2,
+ "path": "/usr/share/doc/unit/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"
+ }
+ }
+}
diff --git a/pkg/deb/debian/unit.init b/pkg/deb/debian/unit.init
new file mode 100644
index 00000000..b328476a
--- /dev/null
+++ b/pkg/deb/debian/unit.init
@@ -0,0 +1,104 @@
+#!/bin/sh
+#
+# unitd NGINX Unit
+#
+### BEGIN INIT INFO
+# Provides: unitd
+# Required-Start: $network $remote_fs
+# Required-Stop: $network $remote_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: NGINX Unit
+# Description: NGINX Unit
+### END INIT INFO
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/unitd
+NAME=unitd
+DESC=unitd
+CONFIG=/etc/unit/config
+
+[ -r /etc/default/${NAME} ] && . /etc/default/${NAME}
+
+if [ -n "$2" ]; then
+ CONFIG=$2
+fi
+
+#includes lsb functions
+. /lib/lsb/init-functions
+
+test -f $DAEMON || exit 0
+
+umask 022
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+case "$1" in
+ start)
+ log_daemon_msg "Starting $DESC" "$NAME"
+ if start-stop-daemon --start --quiet --pidfile /run/$NAME.pid \
+ --exec $DAEMON -- $DAEMON_ARGS; then
+ log_end_msg 0
+ else
+ log_end_msg 1
+ fi
+ ;;
+ status)
+ status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ stop)
+ log_daemon_msg "Stopping $DESC" "$NAME"
+ if start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
+ --exec $DAEMON; then
+ log_end_msg 0
+ else
+ log_end_msg 1
+ fi
+ ;;
+ reload|force-reload)
+ echo "Not implemented." >&2
+ exit 1
+ ;;
+ restart)
+ log_action_begin_msg "Restarting $DESC" "$NAME"
+
+ start-stop-daemon --stop --quiet --pidfile \
+ /var/run/$NAME.pid --exec $DAEMON || true
+ sleep 1
+ if start-stop-daemon --start --quiet --pidfile \
+ /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_ARGS; then
+ log_end_msg 0
+ else
+ log_end_msg 1
+ fi
+ ;;
+ 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: /etc/init.d/$NAME {start|status|stop|restart|reload|force-reload|saveconfig|loadconfig}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/pkg/deb/debian/unit.postinst b/pkg/deb/debian/unit.postinst
new file mode 100755
index 00000000..76375a2b
--- /dev/null
+++ b/pkg/deb/debian/unit.postinst
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" != "configure" ]; then
+ exit 0
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/pkg/deb/debian/unit.preinst b/pkg/deb/debian/unit.preinst
new file mode 100644
index 00000000..d4be468d
--- /dev/null
+++ b/pkg/deb/debian/unit.preinst
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ install)
+ cat <<BANNER
+----------------------------------------------------------------------
+
+Thank you for installing NGINX Unit!
+
+Additional modules are available in standalone packages.
+To see the available modules, run: apt search --names-only '^unit-'
+
+Online documentation is available at https://unit.nginx.org/
+
+----------------------------------------------------------------------
+BANNER
+ ;;
+ upgrade)
+ ;;
+
+ abort-upgrade)
+ ;;
+
+ *)
+ echo "preinst called with unknown argument \`$1'" >&2
+ exit 0
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/pkg/deb/debian/unit.service b/pkg/deb/debian/unit.service
new file mode 100644
index 00000000..445851a5
--- /dev/null
+++ b/pkg/deb/debian/unit.service
@@ -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/default/unit
+ExecStart=/usr/sbin/unitd $DAEMON_ARGS
+ExecReload=
+
+[Install]
+WantedBy=multi-user.target