Skip to content

Commit 92d504f

Browse files
authored
Merge pull request #9161 from LinuxJedi/enhance-debian
Make Debian packaging more Debian-like
2 parents ce5878f + 0a4ce40 commit 92d504f

8 files changed

Lines changed: 112 additions & 71 deletions

File tree

.github/workflows/packaging.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
- name: Confirm packages built
4646
run: |
4747
DEB_COUNT=$(find -name 'libwolfssl*.deb' | wc -l)
48-
if [ "$DEB_COUNT" != "2" ]; then
49-
echo Did not find exactly two deb packages!!!
48+
if [ "$DEB_COUNT" != "3" ]; then
49+
echo Did not find exactly three deb packages!!!
5050
exit 1
5151
fi
5252
# disabled 20240919 -- broken target.

Docker/packaging/debian/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ FROM debian:latest
22

33
RUN apt-get -y update
44
RUN apt-get -y upgrade
5-
RUN apt-get install -y build-essential autoconf gawk debhelper lintian
6-
5+
RUN apt-get install -y build-essential autoconf gawk debhelper lintian dpkg-dev

configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ AC_ARG_VAR(EXTRA_LDFLAGS, [Extra LDFLAGS to add to end of autoconf-computed arg
4646
WOLFSSL_CONFIG_ARGS=$ac_configure_args
4747
AC_SUBST([WOLFSSL_CONFIG_ARGS])
4848

49+
# Store configure options and CFLAGS for debian rules generation
50+
CONFIGURE_OPTIONS="$ac_configure_args"
51+
CONFIGURE_CFLAGS="$CFLAGS"
52+
AC_SUBST([CONFIGURE_OPTIONS])
53+
AC_SUBST([CONFIGURE_CFLAGS])
54+
4955
# shared library versioning
5056
# The three numbers in the libwolfssl.so.*.*.* file name. Unfortunately
5157

@@ -10940,6 +10946,7 @@ AC_CONFIG_FILES([Makefile
1094010946
wolfcrypt/test/test_paths.h
1094110947
])
1094210948
AC_CONFIG_FILES([scripts/unit.test],[chmod +x scripts/unit.test])
10949+
AC_CONFIG_FILES([debian/rules],[chmod +x debian/rules])
1094310950
1094410951
AX_CREATE_GENERIC_CONFIG
1094510952
AX_AM_JOBSERVER([yes])

debian/include.am

Lines changed: 15 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,25 @@
11
# vim:ft=automake
22

3-
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
4-
3+
# Debian packaging using dpkg-buildpackage
54
deb:
6-
# Setup meta folders
7-
mkdir -p debian/libwolfssl/DEBIAN debian/libwolfssl-dev/DEBIAN
8-
# "Install" wolfSSL
9-
make install exec_prefix=$(CURDIR)/debian/libwolfssl/usr \
10-
prefix=$(CURDIR)/debian/libwolfssl-dev/usr
11-
# deb shared lib stuff
12-
fakeroot dh_makeshlibs
13-
dh_shlibdeps
14-
dh_installdeb
15-
# Generate the lib and src descriptions
16-
fakeroot dh_gencontrol
17-
# Make adjustments to the package structure and to satisfy lintian checks
18-
# Correct doc dir name
19-
@rm -rf debian/libwolfssl-dev/usr/share/doc/libwolfssl-dev
20-
@mv debian/libwolfssl-dev/usr/share/doc/wolfssl \
21-
debian/libwolfssl-dev/usr/share/doc/libwolfssl-dev
22-
# Clear lib folder
23-
@rm -rf debian/libwolfssl-dev/usr/lib
24-
@mkdir -p debian/libwolfssl-dev/usr/lib
25-
# Move the top level .so into the dev pkg
26-
@mv debian/libwolfssl/usr/lib/libwolfssl.so debian/libwolfssl-dev/usr/lib
27-
# Create correct pkg doc dir
28-
@rm -rf debian/libwolfssl/usr/share/doc/libwolfssl
29-
@mkdir -p debian/libwolfssl/usr/share/doc/libwolfssl
30-
# Place changelog
31-
@gzip -n -9 -c debian/changelog | \
32-
tee debian/libwolfssl/usr/share/doc/libwolfssl/changelog.gz > \
33-
debian/libwolfssl-dev/usr/share/doc/libwolfssl-dev/changelog.gz
34-
# Place copyright
35-
@cp debian/copyright debian/libwolfssl/usr/share/doc/libwolfssl
36-
@cp debian/copyright debian/libwolfssl-dev/usr/share/doc/libwolfssl-dev
37-
# Remove .la file https://wiki.debian.org/ReleaseGoals/LAFileRemoval
38-
@rm debian/libwolfssl/usr/lib/libwolfssl.la
39-
# Strip unwanted symbols
40-
# https://www.debian.org/doc/debian-policy/ch-files.html#binaries
41-
@strip --strip-unneeded debian/libwolfssl/usr/lib/libwolfssl.so.*.*.*
42-
# Place pkgconfig so that it is available for cross-compilation
43-
# https://lintian.debian.org/tags/pkg-config-unavailable-for-cross-compilation
44-
@rm -rf debian/libwolfssl/usr/lib/$(DEB_HOST_MULTIARCH)
45-
@mkdir -p debian/libwolfssl/usr/lib/$(DEB_HOST_MULTIARCH)
46-
@mv debian/libwolfssl/usr/lib/pkgconfig \
47-
debian/libwolfssl/usr/lib/$(DEB_HOST_MULTIARCH)
48-
# Set the expected access rules
49-
@chmod 644 debian/libwolfssl/usr/lib/libwolfssl.so.*.*.*
50-
@chmod 644 debian/libwolfssl/usr/share/doc/libwolfssl/changelog.gz \
51-
debian/libwolfssl/usr/share/doc/libwolfssl/copyright \
52-
debian/libwolfssl-dev/usr/share/doc/libwolfssl-dev/changelog.gz \
53-
debian/libwolfssl-dev/usr/share/doc/libwolfssl-dev/copyright
54-
# Do this as the last step to mark all directories with the correct access bits
55-
@find debian/libwolfssl*/usr -type d | xargs chmod 755
56-
# Generate debs
57-
dpkg-deb --root-owner-group -b debian/libwolfssl .
58-
dpkg-deb --root-owner-group -b debian/libwolfssl-dev .
59-
# Check that everything is correct with lintian
60-
# - we don't provide a manual page for wolfssl-config
61-
# - we don't care about matching the soname for our debs
62-
lintian *.deb --fail-on error,warning --tag-display-limit 0 \
63-
--suppress-tags no-manual-page,package-name-doesnt-match-sonames
64-
# Clean up the working dirs
65-
make deb-clean
5+
dpkg-buildpackage -us -uc
6+
7+
deb-source:
8+
dpkg-buildpackage -S -us -uc
9+
10+
deb-binary:
11+
dpkg-buildpackage -B -us -uc
6612

6713
deb-docker:
6814
docker build -t "debian-builder:Dockerfile" Docker/packaging/debian
6915
docker run --rm -v $(CURDIR):/opt/wolfssl debian-builder:Dockerfile \
70-
bash -c 'cd /opt/wolfssl && ./config.status --recheck && make deb && \
71-
make clean deb-clean &> /dev/null'
72-
# To allow the user to keep using the configuration on the host
73-
@./config.status --recheck &> /dev/null
16+
bash -c 'cd /opt/wolfssl && ./autogen.sh && ./configure $(WOLFSSL_CONFIG_ARGS) && make deb && find .. -maxdepth 1 -type f -exec cp {} . \;'
7417

7518
deb-clean:
19+
dh_clean --exclude=debian/control --exclude=debian/changelog \
20+
--exclude=debian/rules || true
7621
rm -rf debian/libwolfssl debian/libwolfssl-dev debian/files \
77-
debian/*.substvars debian/.debhelper
22+
debian/*.substvars debian/.debhelper debian/tmp
23+
rm -f debian/debhelper-build-stamp
24+
25+
.PHONY: deb deb-source deb-binary deb-docker deb-clean

debian/libwolfssl-dev.install

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
usr/include/
2+
usr/lib/*/libwolfssl.so
3+
usr/lib/*/libwolfssl.a
4+
usr/lib/*/pkgconfig/wolfssl.pc
5+
usr/bin/wolfssl-config
6+
usr/share/doc/wolfssl/

debian/libwolfssl.install

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

debian/rules.in

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/make -f
2+
3+
# Store the configure options and CFLAGS used during ./configure
4+
# This file is generated from rules.in by the configure script
5+
CONFIGURE_OPTIONS = @CONFIGURE_OPTIONS@
6+
CONFIGURE_CFLAGS = @CONFIGURE_CFLAGS@
7+
ENABLED_FIPS = @ENABLED_FIPS@
8+
9+
# Use debhelper with automatic sequence
10+
%:
11+
dh $@
12+
13+
# Override configure to use the stored options
14+
override_dh_auto_configure:
15+
./configure \
16+
--build=$(DEB_BUILD_GNU_TYPE) \
17+
--host=$(DEB_HOST_GNU_TYPE) \
18+
--prefix=/usr \
19+
--mandir=\$${prefix}/share/man \
20+
--infodir=\$${prefix}/share/info \
21+
--sysconfdir=/etc \
22+
--localstatedir=/var \
23+
--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
24+
--libexecdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
25+
--disable-maintainer-mode \
26+
--disable-dependency-tracking \
27+
--enable-shared \
28+
--enable-static \
29+
$(CONFIGURE_OPTIONS) \
30+
CFLAGS="$(CONFIGURE_CFLAGS)"
31+
32+
# Override test to skip them (optional, remove if you want to run tests)
33+
#override_dh_auto_test:
34+
# Skip tests during package build
35+
36+
# Handle FIPS builds which require special hash generation
37+
override_dh_auto_build:
38+
ifeq ($(ENABLED_FIPS),yes)
39+
# FIPS build requires two-stage process with hash generation
40+
$(MAKE)
41+
./fips-hash.sh
42+
$(MAKE)
43+
else
44+
# Standard build
45+
dh_auto_build
46+
endif
47+
48+
# Handle multiarch library placement and remove .la files
49+
override_dh_auto_install:
50+
dh_auto_install
51+
# Remove .la files (not needed in modern Debian packages)
52+
find debian/tmp -name '*.la' -delete
53+
# Move libraries to multiarch directory if needed
54+
if [ -d debian/tmp/usr/lib ]; then \
55+
mkdir -p debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH); \
56+
if [ -f debian/tmp/usr/lib/libwolfssl.so.* ]; then \
57+
mv debian/tmp/usr/lib/libwolfssl.so.* debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/; \
58+
fi; \
59+
if [ -f debian/tmp/usr/lib/libwolfssl.so ]; then \
60+
mv debian/tmp/usr/lib/libwolfssl.so debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/; \
61+
fi; \
62+
if [ -f debian/tmp/usr/lib/libwolfssl.a ]; then \
63+
mv debian/tmp/usr/lib/libwolfssl.a debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/; \
64+
fi; \
65+
if [ -d debian/tmp/usr/lib/pkgconfig ]; then \
66+
mv debian/tmp/usr/lib/pkgconfig debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/; \
67+
fi; \
68+
fi
69+
70+
# Set proper permissions and strip symbols
71+
override_dh_strip:
72+
dh_strip --dbgsym-migration='libwolfssl-dbg (<< 5.0.0-1~)'
73+
74+
# Auto-clean override - prevent make distclean from removing debian files
75+
override_dh_auto_clean:
76+
# Run make clean instead of make distclean to preserve debian files
77+
if [ -f Makefile ]; then \
78+
$(MAKE) clean; \
79+
fi

debian/source/format

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

0 commit comments

Comments
 (0)