From 156877f3c99b54c78e3cae111542f5519a97a68a Mon Sep 17 00:00:00 2001 From: Andrei Belov Date: Thu, 19 Oct 2017 18:23:32 +0300 Subject: Introduced deb packages building tools. --- pkg/deb/debian.module/control.in | 32 ++++++++ pkg/deb/debian.module/preinst.in | 21 +++++ pkg/deb/debian.module/rules.in | 95 ++++++++++++++++++++++ pkg/deb/debian.module/unit.example-go-app | 20 +++++ pkg/deb/debian.module/unit.example-go-config | 15 ++++ pkg/deb/debian.module/unit.example-go1.7-config | 15 ++++ pkg/deb/debian.module/unit.example-go1.8-config | 15 ++++ pkg/deb/debian.module/unit.example-php-app | 1 + pkg/deb/debian.module/unit.example-php-config | 17 ++++ pkg/deb/debian.module/unit.example-python-app | 16 ++++ pkg/deb/debian.module/unit.example-python-config | 17 ++++ .../debian.module/unit.example-python2.7-config | 17 ++++ .../debian.module/unit.example-python3.4-config | 17 ++++ .../debian.module/unit.example-python3.5-config | 17 ++++ 14 files changed, 315 insertions(+) create mode 100644 pkg/deb/debian.module/control.in create mode 100644 pkg/deb/debian.module/preinst.in create mode 100755 pkg/deb/debian.module/rules.in create mode 100644 pkg/deb/debian.module/unit.example-go-app create mode 100644 pkg/deb/debian.module/unit.example-go-config create mode 100644 pkg/deb/debian.module/unit.example-go1.7-config create mode 100644 pkg/deb/debian.module/unit.example-go1.8-config create mode 100644 pkg/deb/debian.module/unit.example-php-app create mode 100644 pkg/deb/debian.module/unit.example-php-config create mode 100644 pkg/deb/debian.module/unit.example-python-app create mode 100644 pkg/deb/debian.module/unit.example-python-config create mode 100644 pkg/deb/debian.module/unit.example-python2.7-config create mode 100644 pkg/deb/debian.module/unit.example-python3.4-config create mode 100644 pkg/deb/debian.module/unit.example-python3.5-config (limited to 'pkg/deb/debian.module') 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 +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 @@ + 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" + } + } +} -- cgit