Skip to content

Commit a3db312

Browse files
committed
feat: add Debian packaging
Produces two binary packages: - libcoraza1: runtime shared library with proper SONAME (libcoraza.so.1) - libcoraza-dev: headers, static lib, and dev symlink Uses patchelf to set SONAME and create the standard versioned symlink chain since go build -buildmode=c-shared doesn't set one natively. Libraries are installed under multiarch paths. Tests honor nocheck. Dependencies are vendored at build time via go mod vendor.
1 parent 469d165 commit a3db312

8 files changed

Lines changed: 128 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ _obj/
3434
.libs/
3535
Doxyfile
3636
.dirstamp
37+
vendor/

debian/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
libcoraza (1.1.1-1) unstable; urgency=low
2+
3+
* Initial Debian packaging.
4+
5+
-- Pierre Pomes <pierre.pomes@gmail.com> Tue, 17 Mar 2026 12:00:00 +0100

debian/control

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Source: libcoraza
2+
Section: libs
3+
Priority: optional
4+
Maintainer: Pierre Pomes <pierre.pomes@gmail.com>
5+
Build-Depends: debhelper-compat (= 13),
6+
autoconf,
7+
automake,
8+
libtool,
9+
golang-go (>= 2:1.24~),
10+
gcc,
11+
make,
12+
patchelf,
13+
pkg-config
14+
Standards-Version: 4.7.0
15+
Homepage: https://github.com/corazawaf/libcoraza
16+
Rules-Requires-Root: no
17+
18+
Package: libcoraza1
19+
Architecture: any
20+
Multi-Arch: same
21+
Depends: ${shlibs:Depends}, ${misc:Depends}
22+
Description: OWASP Coraza WAF C library - runtime
23+
Coraza is an open-source Web Application Firewall engine. libcoraza
24+
provides C bindings to the Coraza engine, allowing integration with
25+
web servers like Nginx and Apache.
26+
27+
Package: libcoraza-dev
28+
Section: libdevel
29+
Architecture: any
30+
Depends: libcoraza1 (= ${binary:Version}), ${misc:Depends}
31+
Description: OWASP Coraza WAF C library - development files
32+
Coraza is an open-source Web Application Firewall engine. This package
33+
contains the header files and static library needed to build modules
34+
that use libcoraza.

debian/copyright

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: libcoraza
3+
Upstream-Contact: https://github.com/corazawaf/libcoraza/issues
4+
Source: https://github.com/corazawaf/libcoraza
5+
6+
Files: *
7+
Copyright: 2022-2026 OWASP Coraza contributors
8+
License: Apache-2.0
9+
10+
License: Apache-2.0
11+
Licensed under the Apache License, Version 2.0 (the "License");
12+
you may not use this file except in compliance with the License.
13+
You may obtain a copy of the License at
14+
.
15+
https://www.apache.org/licenses/LICENSE-2.0
16+
.
17+
Unless required by applicable law or agreed to in writing, software
18+
distributed under the License is distributed on an "AS IS" BASIS,
19+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
See the License for the specific language governing permissions and
21+
limitations under the License.
22+
.
23+
On Debian systems, the complete text of the Apache License, Version 2.0
24+
can be found in "/usr/share/common-licenses/Apache-2.0".

debian/libcoraza-dev.install

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
usr/include/coraza/coraza.h
2+
usr/lib/*/libcoraza.a
3+
usr/lib/*/libcoraza.so

debian/libcoraza1.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
usr/lib/*/libcoraza.so.*

debian/rules

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/make -f
2+
3+
include /usr/share/dpkg/pkg-info.mk
4+
include /usr/share/dpkg/architecture.mk
5+
6+
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
7+
export GOPATH = $(CURDIR)/.gopath
8+
export GOCACHE = $(CURDIR)/.gocache
9+
export GOFLAGS = -mod=vendor
10+
11+
SOMAJOR = 1
12+
SOVER = $(DEB_VERSION_UPSTREAM)
13+
MULTIARCH_LIBDIR = usr/lib/$(DEB_HOST_MULTIARCH)
14+
15+
%:
16+
dh $@
17+
18+
override_dh_autoreconf:
19+
./build.sh
20+
21+
override_dh_auto_configure:
22+
go mod vendor
23+
dh_auto_configure -- --libdir=/usr/lib/$(DEB_HOST_MULTIARCH)
24+
25+
override_dh_auto_build:
26+
$(MAKE) all
27+
28+
override_dh_auto_install:
29+
# Install manually to decouple from the check target
30+
install -d debian/tmp/usr/lib
31+
install -d debian/tmp/usr/include/coraza
32+
install libcoraza.a debian/tmp/usr/lib/
33+
install libcoraza.so debian/tmp/usr/lib/
34+
install coraza/coraza.h debian/tmp/usr/include/coraza/coraza.h
35+
# Upstream installs to /usr/lib; move to multiarch path
36+
mkdir -p debian/tmp/$(MULTIARCH_LIBDIR)
37+
mv debian/tmp/usr/lib/libcoraza.so debian/tmp/$(MULTIARCH_LIBDIR)/
38+
mv debian/tmp/usr/lib/libcoraza.a debian/tmp/$(MULTIARCH_LIBDIR)/
39+
# Set SONAME and create versioned symlink chain
40+
patchelf --set-soname libcoraza.so.$(SOMAJOR) debian/tmp/$(MULTIARCH_LIBDIR)/libcoraza.so
41+
mv debian/tmp/$(MULTIARCH_LIBDIR)/libcoraza.so debian/tmp/$(MULTIARCH_LIBDIR)/libcoraza.so.$(SOVER)
42+
ln -s libcoraza.so.$(SOVER) debian/tmp/$(MULTIARCH_LIBDIR)/libcoraza.so.$(SOMAJOR)
43+
ln -s libcoraza.so.$(SOMAJOR) debian/tmp/$(MULTIARCH_LIBDIR)/libcoraza.so
44+
45+
override_dh_auto_test:
46+
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
47+
$(MAKE) check
48+
endif
49+
50+
override_dh_dwz:
51+
# Skip dwz compression (incompatible with cgo-built shared libraries)
52+
53+
override_dh_strip:
54+
dh_strip --no-automatic-dbgsym
55+
56+
override_dh_auto_clean:
57+
[ ! -f Makefile ] || $(MAKE) distclean
58+
chmod -Rf u+w .gopath .gocache vendor 2>/dev/null || true
59+
rm -rf .gopath .gocache vendor

debian/source/format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0 (quilt)

0 commit comments

Comments
 (0)