Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions debian/install-openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ main() {
exit 0
fi

if [ -n "output_dir" ]; then
output_dir=$(realpath $output_dir)
fi

work_dir=$(mktemp -d)
printf "Working directory: $work_dir\n"
pushd $work_dir 2>&1 > /dev/null
Expand All @@ -183,13 +187,13 @@ main() {
openssl_install
fi

if [ -n "$output_dir" ] && [ "$output_dir" != ".." ]; then
if [ -n "$output_dir" ]; then
if [ ! -d "$output_dir" ]; then
printf "Creating output directory: $output_dir\n"
mkdir -p "$output_dir"
fi
cp ../openssl*.deb $output_dir
cp ../libssl*.deb $output_dir
cp ../openssl*.deb $output_dir || true
cp ../libssl*.deb $output_dir || true
else
printf "No output directory specified, packages stored in $work_dir\n"
fi
Expand Down
8 changes: 6 additions & 2 deletions debian/install-wolfprov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ main() {
exit 1
fi

if [ -n "output_dir" ]; then
output_dir=$(realpath $output_dir)
fi

work_dir=$(mktemp -d)
printf "Working directory: $work_dir\n"
pushd $work_dir 2>&1 > /dev/null
Expand All @@ -199,12 +203,12 @@ main() {
wolfprov_install
fi

if [ -n "$output_dir" ] && [ "$output_dir" != ".." ]; then
if [ -n "$output_dir" ]; then
if [ ! -d "$output_dir" ]; then
printf "Creating output directory: $output_dir\n"
mkdir -p "$output_dir"
fi
cp ../*.* $output_dir
cp ../*.* $output_dir || true
else
printf "No output directory specified, packages stored in $work_dir\n"
fi
Expand Down
47 changes: 41 additions & 6 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,35 @@ endif

# Debug build flag
WOLFPROV_DEBUG?=0
DEBUG_FLAG=
ifeq ($(WOLFPROV_DEBUG),1)
VARIANT := $(VARIANT)-debug
VARIANT_DESC := $(VARIANT_DESC) with debug logs
VERSION := $(VERSION)-debug
DEBUG_FLAG := --enable-debug
endif

ifeq ($(DEB_CFLAGS_APPEND),)
export PKG_CONFIG_LIBDIR # value comes from outer environment
export PKG_CONFIG_DIR :=
export PKG_CONFIG_PATH :=
endif

override_dh_auto_configure:
./autogen.sh
ifneq ($(WOLFPROV_DEBUG),0)
./configure --enable-debug
else
./configure
endif
@if [ -n "$(DEB_CFLAGS_APPEND)" ]; then \
printf "DEB_CFLAGS_APPEND: %s\n" $(DEB_CFLAGS_APPEND); \
printf "DEB_CPPFLAGS_APPEND: %s\n" $(DEB_CPPFLAGS_APPEND); \
printf "DEB_CXXFLAGS_APPEND: %s\n" $(DEB_CXXFLAGS_APPEND); \
printf "DEB_LDFLAGS_APPEND: %s\n" $(DEB_LDFLAGS_APPEND); \
@echo "PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR)" \
# ensure only our .pc dirs are searched: \
PKG_CONFIG_DIR= PKG_CONFIG_PATH= \
PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" \
dh_auto_configure -- $(DEBUG_FLAG); \
else \
./configure $(DEBUG_FLAG); \
fi

override_dh_auto_build:
$(MAKE)
Expand Down Expand Up @@ -82,4 +98,23 @@ override_dh_auto_clean:
rm -rf test/standalone/tests/.libs

override_dh_auto_test:
$(MAKE) test
@if [ -n "$(DEB_LDFLAGS_APPEND)" ]; then \
# If DEB_LDFLAGS_APPEND is set, it usually means the \
# build system is using a custom library path, rather \
# than the system path. So let's set up LD_LIBRARY_PATH \
# to use it when running `make test`. \
echo "Setting up LD_LIBRARY_PATH from DEB_LDFLAGS_APPEND"; \
LD_LIBRARY_PATH="$$(echo $(DEB_LDFLAGS_APPEND) | \
grep -oE -- '-L[^ ]+' | sed 's/^-L//' | awk '!seen[$$0]++' | paste -sd: -)" \
$(MAKE) test; \
else \
$(MAKE) test; \
fi

override_dh_shlibdeps:
@if [ -n "$(DEB_LDFLAGS_APPEND)" ]; then \
# Skip shlibdeps for now since we're using a custom library path \
: \
else \
dh_shlibdeps; \
fi
42 changes: 37 additions & 5 deletions scripts/build-wolfprovider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ fi
if [ -n "$build_debian" ]; then
set -e

DEB_OUTPUT_DIR=$(realpath '..')

echo "Building Debian package..."
WOLFSSL_OPTS=
WOLFPROV_OPTS=
Expand All @@ -161,12 +163,42 @@ if [ -n "$build_debian" ]; then
WOLFSSL_OPTS+=" --fips"
WOLFPROV_OPTS+=" --fips"
fi
if [ "$WOLFPROV_REPLACE_DEFAULT" = "1" ]; then
OPENSSL_OPTS+=" --replace-default"
fi

# wolfSSL and OpenSSL are independent and must be built first
debian/install-wolfssl.sh $WOLFSSL_OPTS --no-install -r $DEB_OUTPUT_DIR
debian/install-openssl.sh $OPENSSL_OPTS --no-install $DEB_OUTPUT_DIR

# wolfProvider depends on wolfSSL and OpenSSL headers and libraries.
# We don't want to install them locally, so we unpack them to
# temp dirs and reference those in the build.

# Unpack the wolfssl packages to a temporary directory
wolfssl_dev_dir=$(mktemp -d)
dpkg -x $DEB_OUTPUT_DIR/libwolfssl_*.deb $wolfssl_dev_dir
dpkg -x $DEB_OUTPUT_DIR/libwolfssl-dev_*.deb $wolfssl_dev_dir
# Unpack the libssl-dev package to a temporary directory
openssl_dev_dir=$(mktemp -d)
dpkg -x $DEB_OUTPUT_DIR/openssl_*.deb $openssl_dev_dir
dpkg -x $DEB_OUTPUT_DIR/libssl-dev_*.deb $openssl_dev_dir

export DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH)

printf "wolfssl_dev_dir: %s\n" $wolfssl_dev_dir
printf "wolfssl_dev_dir libs: %s\n" $(ls $wolfssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH)
printf "openssl_dev_dir: %s\n" $openssl_dev_dir
printf "openssl_dev_dir libs: %s\n" $(ls $openssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH)

export DEB_CFLAGS_APPEND="-I$wolfssl_dev_dir/usr/include -I$openssl_dev_dir/usr/include"
export DEB_CPPFLAGS_APPEND="-I$wolfssl_dev_dir/usr/include -I$openssl_dev_dir/usr/include"
export DEB_CXXFLAGS_APPEND="-I$wolfssl_dev_dir/usr/include -I$openssl_dev_dir/usr/include"
export DEB_LDFLAGS_APPEND="-L$wolfssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH -L$openssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH"
export PKG_CONFIG_LIBDIR=$wolfssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH/pkgconfig:$openssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH/pkgconfig
debian/install-wolfprov.sh $WOLFPROV_OPTS --no-install $DEB_OUTPUT_DIR

# Must install wolfSSL locally since it is needed to build wolfProvider
debian/install-wolfssl.sh $WOLFSSL_OPTS -r ..
# Always build replace-default mode for openssl. Use the standard one from apt.
debian/install-openssl.sh $OPENSSL_OPTS --replace-default ..
debian/install-wolfprov.sh $WOLFPROV_OPTS --no-install
printf "Debian packages built in: %s\n" $DEB_OUTPUT_DIR

exit 0
fi
Expand Down
Loading