Skip to content

Commit 156877f

Browse files
committed
Introduced deb packages building tools.
1 parent eabe25d commit 156877f

39 files changed

+1367
-3
lines changed

docs/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ UNIT= unit-$(VER)
55
DEST= ../build
66
XSLS?= xslscript.pl
77

8-
PACKAGES= unit unit-php unit-python unit-go
8+
PACKAGES= unit \
9+
unit-php \
10+
unit-python unit-python2.7 unit-python3.4 unit-python3.5\
11+
unit-go unit-go1.7 unit-go1.8
912

1013
all: changes changelogs
1114

docs/changes.xml

+65
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,32 @@ Initial release of Go module for NGINX Unit.
1818
</changes>
1919

2020

21+
<changes apply="unit-go1.7" ver="0.2" rev="1"
22+
date="2017-10-19" time="18:00:00 +0300"
23+
packager="Andrei Belov &lt;[email protected]&gt;">
24+
25+
<change>
26+
<para>
27+
Initial release of Go 1.7 module for NGINX Unit.
28+
</para>
29+
</change>
30+
31+
</changes>
32+
33+
34+
<changes apply="unit-go1.8" ver="0.2" rev="1"
35+
date="2017-10-19" time="18:00:00 +0300"
36+
packager="Andrei Belov &lt;[email protected]&gt;">
37+
38+
<change>
39+
<para>
40+
Initial release of Go 1.8 module for NGINX Unit.
41+
</para>
42+
</change>
43+
44+
</changes>
45+
46+
2147
<changes apply="unit-python" ver="0.2" rev="1"
2248
date="2017-10-19" time="18:00:00 +0300"
2349
packager="Andrei Belov &lt;[email protected]&gt;">
@@ -31,6 +57,45 @@ Initial release of Python module for NGINX Unit.
3157
</changes>
3258

3359

60+
<changes apply="unit-python2.7" ver="0.2" rev="1"
61+
date="2017-10-19" time="18:00:00 +0300"
62+
packager="Andrei Belov &lt;[email protected]&gt;">
63+
64+
<change>
65+
<para>
66+
Initial release of Python 2.7 module for NGINX Unit.
67+
</para>
68+
</change>
69+
70+
</changes>
71+
72+
73+
<changes apply="unit-python3.4" ver="0.2" rev="1"
74+
date="2017-10-19" time="18:00:00 +0300"
75+
packager="Andrei Belov &lt;[email protected]&gt;">
76+
77+
<change>
78+
<para>
79+
Initial release of Python 3.4 module for NGINX Unit.
80+
</para>
81+
</change>
82+
83+
</changes>
84+
85+
86+
<changes apply="unit-python3.5" ver="0.2" rev="1"
87+
date="2017-10-19" time="18:00:00 +0300"
88+
packager="Andrei Belov &lt;[email protected]&gt;">
89+
90+
<change>
91+
<para>
92+
Initial release of Python 3.5 module for NGINX Unit.
93+
</para>
94+
</change>
95+
96+
</changes>
97+
98+
3499
<changes apply="unit-php" ver="0.2" rev="1"
35100
date="2017-10-19" time="18:00:00 +0300"
36101
packager="Andrei Belov &lt;[email protected]&gt;">

pkg/Makefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ VERSION ?= $(shell grep 'define NXT_VERSION' ../src/nxt_main.h \
66
RELEASE ?= 1
77

88
default:
9-
@echo "available targets: rpm"
9+
@echo "available targets: rpm deb"
1010

1111
rpm:
1212
@cd rpm && VERSION=$(VERSION) RELEASE=$(RELEASE) make all
1313

14+
deb:
15+
@cd deb && VERSION=$(VERSION) RELEASE=$(RELEASE) make all
16+
1417
clean:
1518
@cd rpm && make clean
19+
@cd deb && make clean
1620

17-
.PHONY: default rpm clean
21+
.PHONY: default rpm deb clean

pkg/deb/Makefile

+198
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
#!/usr/bin/make
2+
3+
DEFAULT_VERSION := $(shell grep 'define NXT_VERSION' ../../src/nxt_main.h \
4+
| sed -e 's/^.*"\(.*\)".*/\1/')
5+
6+
DEFAULT_RELEASE := 1
7+
8+
VERSION ?= $(DEFAULT_VERSION)
9+
RELEASE ?= $(DEFAULT_RELEASE)
10+
11+
SRCDIR= unit-$(VERSION)
12+
13+
CODENAME = $(shell lsb_release -cs)
14+
15+
BUILD_DEPENDS = debhelper devscripts libxml2-utils lintian lsb-release xsltproc
16+
17+
MODULES=
18+
19+
# Ubuntu 17.04
20+
ifeq ($(CODENAME),zesty)
21+
include Makefile.php
22+
include Makefile.python27
23+
include Makefile.python35
24+
include Makefile.go17
25+
include Makefile.go18
26+
endif
27+
28+
# Ubuntu 16.04
29+
ifeq ($(CODENAME),xenial)
30+
include Makefile.php
31+
include Makefile.python27
32+
include Makefile.python35
33+
include Makefile.go
34+
endif
35+
36+
# Ubuntu 14.04
37+
ifeq ($(CODENAME),trusty)
38+
include Makefile.php
39+
include Makefile.python
40+
endif
41+
42+
# Debian 9
43+
ifeq ($(CODENAME),stretch)
44+
include Makefile.php
45+
include Makefile.python27
46+
include Makefile.python35
47+
include Makefile.go17
48+
include Makefile.go18
49+
endif
50+
51+
# Debian 8
52+
ifeq ($(CODENAME),jessie)
53+
include Makefile.php
54+
include Makefile.python27
55+
endif
56+
57+
CONFIGURE_ARGS=\
58+
--prefix=/usr \
59+
--state=/var/lib/unit \
60+
--control="unix:/var/run/control.unit.sock" \
61+
--pid=/var/run/unit.pid \
62+
--log=/var/log/unit.log \
63+
--tests
64+
65+
export CR=\\n
66+
67+
default:
68+
@echo "valid targets: all modules unit $(addprefix unit-, $(MODULES)) clean"
69+
70+
all: check-build-depends unit modules
71+
72+
modules: $(addprefix unit-, $(MODULES))
73+
74+
check-build-depends:
75+
@{ \
76+
not_installed= ; \
77+
for pkg in $(BUILD_DEPENDS); do \
78+
dpkg -s $${pkg} >/dev/null 2>&1 ; \
79+
if [ $$? -ne 0 ]; then \
80+
not_installed="$${not_installed} $${pkg}" ; \
81+
fi ; \
82+
done ; \
83+
if test -n "$${not_installed}" ; then \
84+
echo "" >&2 ; \
85+
echo "The following packages are required in order to proceed:" >&2 ; \
86+
echo "" >&2 ; \
87+
echo $${not_installed} >&2 ; \
88+
echo "" >&2 ; \
89+
exit 1 ; \
90+
fi \
91+
}
92+
93+
debuild/$(SRCDIR)/debian:
94+
@{ \
95+
set -e ; \
96+
mkdir -p debuild/$(SRCDIR) ; \
97+
cp -pr debian debuild/$(SRCDIR) ; \
98+
echo '9' > debuild/$(SRCDIR)/debian/compat ; \
99+
mkdir -p debuild/$(SRCDIR)/debian/source ; \
100+
echo '3.0 (quilt)' > debuild/$(SRCDIR)/debian/source/format ; \
101+
cat debian/rules.in | sed \
102+
-e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \
103+
> debuild/$(SRCDIR)/debian/rules ; \
104+
}
105+
106+
debuild/$(SRCDIR)/debian/changelog: ../../docs/changes.xml | debuild/$(SRCDIR)/debian
107+
cd ../../docs && make ../build/unit.deb-changelog
108+
ifneq ($(DEFAULT_VERSION)$(DEFAULT_RELEASE), $(VERSION)$(RELEASE))
109+
cat ../../build/unit.deb-changelog | sed \
110+
-e "s/unit ($(DEFAULT_VERSION)-$(DEFAULT_RELEASE)~/unit ($(VERSION)-$(RELEASE)~/" \
111+
-e "s#%%CODENAME%%#$(CODENAME)#g" \
112+
> debuild/$(SRCDIR)/debian/changelog
113+
else
114+
cat ../../build/unit.deb-changelog | sed \
115+
-e "s#%%CODENAME%%#$(CODENAME)#g" \
116+
> debuild/$(SRCDIR)/debian/changelog
117+
endif
118+
119+
debuild/unit_$(VERSION).orig.tar.gz: | debuild/$(SRCDIR)/debian
120+
cd ../.. && tar -czf pkg/deb/debuild/$(SRCDIR).tar.gz \
121+
--transform "s#^#$(SRCDIR)/#" \
122+
LICENSE NOTICE CHANGES README configure auto src test
123+
mv debuild/$(SRCDIR).tar.gz debuild/unit_$(VERSION).orig.tar.gz
124+
cd debuild && tar zxf unit_$(VERSION).orig.tar.gz
125+
126+
unit: debuild/unit_$(VERSION).orig.tar.gz debuild/$(SRCDIR)/debian/changelog
127+
@echo "===> Building $@ package"
128+
cd debuild/$(SRCDIR) && debuild -us -uc
129+
mkdir -p debs
130+
find debuild/ -maxdepth 1 -type f -exec cp {} debs/ \;
131+
ln -s debuild/$(SRCDIR)/build $@
132+
133+
debuild-%: debuild/unit_$(VERSION).orig.tar.gz ../../docs/changes.xml
134+
mkdir $@
135+
cp debuild/unit_$(VERSION).orig.tar.gz debuild-$*/unit-$(MODULE_SUFFIX_$*)_$(VERSION).orig.tar.gz
136+
cd $@ && tar zxf unit-$(MODULE_SUFFIX_$*)_$(VERSION).orig.tar.gz
137+
mkdir $@/$(SRCDIR)/debian
138+
echo '9' > $@/$(SRCDIR)/debian/compat
139+
mkdir $@/$(SRCDIR)/debian/source
140+
echo '3.0 (quilt)' > $@/$(SRCDIR)/debian/source/format
141+
cd ../../docs && make ../build/unit-$(MODULE_SUFFIX_$*).deb-changelog
142+
cat ../../build/unit-$(MODULE_SUFFIX_$*).deb-changelog | sed \
143+
-e "s#%%CODENAME%%#$(CODENAME)#g" \
144+
> $@/$(SRCDIR)/debian/changelog
145+
cp debian/copyright debuild-$*/$(SRCDIR)/debian/
146+
@{ \
147+
set -e ; \
148+
for src in $(MODULE_SOURCES_$*); do \
149+
cp debian.module/$${src} $@/$(SRCDIR)/debian/ ; \
150+
done ; \
151+
definitions=`echo "$$MODULE_DEFINITIONS_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
152+
prebuild=`echo "$$MODULE_PREBUILD_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
153+
preinstall=`echo "$$MODULE_PREINSTALL_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
154+
post=`echo "$$MODULE_POST_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
155+
cat debian.module/control.in | sed \
156+
-e "s#%%NAME%%#unit-$(MODULE_SUFFIX_$*)#g" \
157+
-e "s#%%SUMMARY%%#$(MODULE_SUMMARY_$*)#g" \
158+
-e "s#%%CODENAME%%#$(CODENAME)#g" \
159+
-e "s#%%UNIT_VERSION%%#$(VERSION)#g" \
160+
-e "s#%%UNIT_RELEASE%%#$(RELEASE)#g" \
161+
-e "s#%%VERSION%%#$(MODULE_VERSION_$*)#g" \
162+
-e "s#%%RELEASE%%#$(MODULE_RELEASE_$*)#g" \
163+
-e "s#%%MODULE_BUILD_DEPENDS%%#$(MODULE_BUILD_DEPENDS_$*)#g" \
164+
-e "s#%%MODULE_DEPENDS%%#$(MODULE_DEPENDS_$*)#g" \
165+
> $@/$(SRCDIR)/debian/control ; \
166+
cat debian.module/rules.in | sed \
167+
-e "s#%%NAME%%#unit-$(MODULE_SUFFIX_$*)#g" \
168+
-e "s#%%CODENAME%%#$(CODENAME)#g" \
169+
-e "s#%%UNIT_VERSION%%#$(VERSION)#g" \
170+
-e "s#%%UNIT_RELEASE%%#$(RELEASE)#g" \
171+
-e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \
172+
-e "s#%%MODULE_CONFARGS%%#$(MODULE_CONFARGS_$*)#g" \
173+
-e "s#%%MODULE_MAKEARGS%%#$(MODULE_MAKEARGS_$*)#g" \
174+
-e "s#%%MODULE_INSTARGS%%#$(MODULE_INSTARGS_$*)#g" \
175+
-e "s#%%MODULE_DEFINITIONS%%#$${definitions}#g" \
176+
-e "s#%%MODULE_PREBUILD%%#$${prebuild}#g" \
177+
-e "s#%%MODULE_PREINSTALL%%#$${preinstall}#g" \
178+
> $@/$(SRCDIR)/debian/rules ; \
179+
cat debian.module/preinst.in | sed \
180+
-e "s#%%MODULE_POST%%#$$post#g" \
181+
> $@/$(SRCDIR)/debian/preinst ; \
182+
chmod +x $@/$(SRCDIR)/debian/rules ; \
183+
}
184+
185+
unit-%: | debuild-%
186+
@echo "===> Building $@ package"
187+
cd debuild-$*/$(SRCDIR) && debuild -us -uc
188+
mkdir -p debs
189+
find debuild-$*/ -maxdepth 1 -type f -exec cp {} debs/ \;
190+
ln -s debuild-$*/$(SRCDIR)/build $@
191+
192+
clean:
193+
rm -rf debuild debuild-* debs ../../build
194+
find . -maxdepth 1 -type l -delete
195+
196+
.PHONY: default all modules check-build-depends clean
197+
198+
.SECONDARY:

pkg/deb/Makefile.go

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
MODULES+= go
2+
MODULE_SUFFIX_go= go
3+
4+
MODULE_SUMMARY_go= Go module for NGINX Unit
5+
6+
MODULE_VERSION_go= $(VERSION)
7+
MODULE_RELEASE_go= 1
8+
9+
MODULE_CONFARGS_go= go --go-path=\$$(GOROOT)
10+
MODULE_MAKEARGS_go= go
11+
MODULE_INSTARGS_go= go-install
12+
13+
MODULE_SOURCES_go= unit.example-go-app \
14+
unit.example-go-config
15+
16+
BUILD_DEPENDS+= golang
17+
18+
MODULE_BUILD_DEPENDS_go=,golang
19+
MODULE_DEPENDS_go=,golang
20+
21+
define MODULE_DEFINITIONS_go
22+
GOROOT = $(shell go env GOROOT)
23+
endef
24+
export MODULE_DEFINITIONS_go
25+
26+
define MODULE_PREINSTALL_go
27+
mkdir -p debian/unit-go/usr/share/doc/unit-go/examples/go-app
28+
install -m 644 -p debian/unit.example-go-app debian/unit-go/usr/share/doc/unit-go/examples/go-app/let-my-people.go
29+
install -m 644 -p debian/unit.example-go-config debian/unit-go/usr/share/doc/unit-go/examples/unit.config
30+
endef
31+
export MODULE_PREINSTALL_go
32+
33+
define MODULE_POST_go
34+
cat <<BANNER
35+
----------------------------------------------------------------------
36+
37+
The $(MODULE_SUMMARY_go) has been installed.
38+
39+
To check out the sample app, run these commands:
40+
41+
go build -o /tmp/go-app /usr/share/doc/unit-go/examples/go-app/let-my-people.go
42+
sudo service unit restart
43+
sudo service unit loadconfig /usr/share/doc/unit-go/examples/unit.config
44+
curl http://localhost:8500/
45+
46+
Online documentation is available at https://unit.nginx.org
47+
48+
----------------------------------------------------------------------
49+
BANNER
50+
endef
51+
export MODULE_POST_go

0 commit comments

Comments
 (0)