Skip to content

Commit 851e522

Browse files
authored
Merge pull request #72 from ppomes/debian/packaging
feat: add Debian packaging
2 parents 469d165 + 555c8d9 commit 851e522

10 files changed

Lines changed: 182 additions & 1 deletion

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/

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ AM_LDFLAGS = -framework CoreFoundation -framework Security -lresolv
4242
endif
4343

4444
if LINUX
45-
AM_LDFLAGS = -fPIC -m64 -pthread -fno-common
45+
AM_LDFLAGS = -fPIC -pthread -fno-common
4646
endif
4747

4848
tests_simple_get_LDFLAGS = $(AM_LDFLAGS)

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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
Multi-Arch: same
31+
Depends: libcoraza1 (= ${binary:Version}), ${misc:Depends}
32+
Description: OWASP Coraza WAF C library - development files
33+
Coraza is an open-source Web Application Firewall engine. This package
34+
contains the header files and static library needed to build modules
35+
that use libcoraza.

debian/copyright

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
Files: debian/*
11+
Copyright: 2026 Pierre Pomes <pierre.pomes@gmail.com>
12+
License: Apache-2.0
13+
14+
License: Apache-2.0
15+
Licensed under the Apache License, Version 2.0 (the "License");
16+
you may not use this file except in compliance with the License.
17+
You may obtain a copy of the License at
18+
.
19+
https://www.apache.org/licenses/LICENSE-2.0
20+
.
21+
Unless required by applicable law or agreed to in writing, software
22+
distributed under the License is distributed on an "AS IS" BASIS,
23+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24+
See the License for the specific language governing permissions and
25+
limitations under the License.
26+
.
27+
On Debian systems, the complete text of the Apache License, Version 2.0
28+
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/make-orig-tarball.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# Build a vendored orig tarball for Debian packaging.
3+
#
4+
# Launchpad and other Debian build hosts have no network access, so the
5+
# orig tarball must ship everything needed to build offline:
6+
# - autotools generated files (configure, Makefile.in, ...)
7+
# - Go vendor/ directory (all Go module dependencies)
8+
#
9+
# The tarball is created from the current git HEAD, not from a GitHub
10+
# release download (which lacks both autotools files and vendor/).
11+
#
12+
# Output: ../libcoraza_<version>.orig.tar.gz
13+
#
14+
# Prerequisites: git, dpkg-parsechangelog, autoconf, automake, libtool, go
15+
#
16+
# Usage: debian/make-orig-tarball.sh
17+
# Run from the top-level source directory (must be a git repo).
18+
19+
set -euo pipefail
20+
21+
VERSION=$(dpkg-parsechangelog -S Version | sed 's/-.*//')
22+
TARBALL="libcoraza_${VERSION}.orig.tar.gz"
23+
DISTNAME="libcoraza-${VERSION}"
24+
WORKDIR=$(mktemp -d)
25+
26+
trap 'rm -rf "$WORKDIR"' EXIT
27+
28+
echo "==> Exporting git tree..."
29+
git archive --prefix="${DISTNAME}/" HEAD | tar xf - -C "$WORKDIR"
30+
31+
echo "==> Generating autotools files..."
32+
(
33+
cd "$WORKDIR/${DISTNAME}"
34+
echo "$VERSION" > .tarball-version
35+
./build.sh
36+
)
37+
38+
echo "==> Running go mod vendor..."
39+
(
40+
cd "$WORKDIR/${DISTNAME}"
41+
go mod vendor
42+
)
43+
44+
echo "==> Creating tarball..."
45+
tar czf "../${TARBALL}" -C "$WORKDIR" "${DISTNAME}"
46+
47+
echo "==> Created ../${TARBALL}"
48+
echo " $(tar tzf "../${TARBALL}" | grep -c vendor/) vendor entries included"

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+
export GOPROXY = off
11+
export GONOSUMCHECK = *
12+
export GOTOOLCHAIN = local
13+
14+
SOMAJOR = 1
15+
SOVER = $(DEB_VERSION_UPSTREAM)
16+
MULTIARCH_LIBDIR = usr/lib/$(DEB_HOST_MULTIARCH)
17+
18+
%:
19+
dh $@
20+
21+
override_dh_autoreconf:
22+
./build.sh
23+
24+
override_dh_auto_configure:
25+
dh_auto_configure -- --libdir=/usr/lib/$(DEB_HOST_MULTIARCH)
26+
27+
override_dh_auto_build:
28+
$(MAKE) all
29+
30+
override_dh_auto_install:
31+
# Install manually to decouple from the check target
32+
install -d debian/tmp/$(MULTIARCH_LIBDIR)
33+
install -d debian/tmp/usr/include/coraza
34+
install -m 0755 libcoraza.so debian/tmp/$(MULTIARCH_LIBDIR)/
35+
install -m 0644 libcoraza.a debian/tmp/$(MULTIARCH_LIBDIR)/
36+
install -m 0644 coraza/coraza.h debian/tmp/usr/include/coraza/coraza.h
37+
# Set SONAME and create versioned symlink chain
38+
patchelf --set-soname libcoraza.so.$(SOMAJOR) debian/tmp/$(MULTIARCH_LIBDIR)/libcoraza.so
39+
mv debian/tmp/$(MULTIARCH_LIBDIR)/libcoraza.so debian/tmp/$(MULTIARCH_LIBDIR)/libcoraza.so.$(SOVER)
40+
ln -s libcoraza.so.$(SOVER) debian/tmp/$(MULTIARCH_LIBDIR)/libcoraza.so.$(SOMAJOR)
41+
ln -s libcoraza.so.$(SOMAJOR) debian/tmp/$(MULTIARCH_LIBDIR)/libcoraza.so
42+
43+
override_dh_auto_test:
44+
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
45+
# Run only the C integration test; skip go test -race (not portable across archs)
46+
$(MAKE) tests/simple_get
47+
cd tests && ./check_result.sh simple_get
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 2>/dev/null || true
59+
rm -rf .gopath .gocache

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)