Skip to content

Commit 5567f17

Browse files
committed
Build debs without install in build-wolfprovider.sh
1 parent dec159a commit 5567f17

File tree

4 files changed

+75
-15
lines changed

4 files changed

+75
-15
lines changed

debian/install-openssl.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ main() {
171171
exit 0
172172
fi
173173

174+
if [ -n "output_dir" ]; then
175+
output_dir=$(realpath $output_dir)
176+
fi
177+
174178
work_dir=$(mktemp -d)
175179
printf "Working directory: $work_dir\n"
176180
pushd $work_dir 2>&1 > /dev/null
@@ -183,13 +187,13 @@ main() {
183187
openssl_install
184188
fi
185189

186-
if [ -n "$output_dir" ] && [ "$output_dir" != ".." ]; then
190+
if [ -n "$output_dir" ]; then
187191
if [ ! -d "$output_dir" ]; then
188192
printf "Creating output directory: $output_dir\n"
189193
mkdir -p "$output_dir"
190194
fi
191-
cp ../openssl*.deb $output_dir
192-
cp ../libssl*.deb $output_dir
195+
cp ../openssl*.deb $output_dir || true
196+
cp ../libssl*.deb $output_dir || true
193197
else
194198
printf "No output directory specified, packages stored in $work_dir\n"
195199
fi

debian/install-wolfprov.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ main() {
188188
exit 1
189189
fi
190190

191+
if [ -n "output_dir" ]; then
192+
output_dir=$(realpath $output_dir)
193+
fi
194+
191195
work_dir=$(mktemp -d)
192196
printf "Working directory: $work_dir\n"
193197
pushd $work_dir 2>&1 > /dev/null
@@ -199,12 +203,12 @@ main() {
199203
wolfprov_install
200204
fi
201205

202-
if [ -n "$output_dir" ] && [ "$output_dir" != ".." ]; then
206+
if [ -n "$output_dir" ]; then
203207
if [ ! -d "$output_dir" ]; then
204208
printf "Creating output directory: $output_dir\n"
205209
mkdir -p "$output_dir"
206210
fi
207-
cp ../*.* $output_dir
211+
cp ../*.* $output_dir || true
208212
else
209213
printf "No output directory specified, packages stored in $work_dir\n"
210214
fi

debian/rules

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,22 @@ ifeq ($(WOLFPROV_DEBUG),1)
3838
VERSION := $(VERSION)-debug
3939
endif
4040

41+
ifeq ($(DEB_CFLAGS_APPEND),)
42+
export PKG_CONFIG_LIBDIR # value comes from outer environment
43+
export PKG_CONFIG_DIR :=
44+
export PKG_CONFIG_PATH :=
45+
endif
46+
4147
override_dh_auto_configure:
48+
printf "DEB_CFLAGS_APPEND: %s\n" $(DEB_CFLAGS_APPEND)
49+
printf "DEB_CPPFLAGS_APPEND: %s\n" $(DEB_CPPFLAGS_APPEND)
50+
printf "DEB_CXXFLAGS_APPEND: %s\n" $(DEB_CXXFLAGS_APPEND)
51+
printf "DEB_LDFLAGS_APPEND: %s\n" $(DEB_LDFLAGS_APPEND)
4252
./autogen.sh
43-
ifneq ($(WOLFPROV_DEBUG),0)
44-
./configure --enable-debug
45-
else
46-
./configure
47-
endif
53+
@echo "PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR)" # ensure only our .pc dirs are searched:
54+
PKG_CONFIG_DIR= PKG_CONFIG_PATH= \
55+
PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" \
56+
dh_auto_configure -- $(if $(WOLFPROV_DEBUG),--enable-debug,)
4857

4958
override_dh_auto_build:
5059
$(MAKE)
@@ -82,4 +91,23 @@ override_dh_auto_clean:
8291
rm -rf test/standalone/tests/.libs
8392

8493
override_dh_auto_test:
85-
$(MAKE) test
94+
@if [ -n "$(DEB_LDFLAGS_APPEND)" ]; then \
95+
# If DEB_LDFLAGS_APPEND is set, it usually means the \
96+
# build system is using a custom library path, rather \
97+
# than the system path. So let's set up LD_LIBRARY_PATH \
98+
# to use it when running `make test`. \
99+
echo "Setting up LD_LIBRARY_PATH from DEB_LDFLAGS_APPEND"; \
100+
LD_LIBRARY_PATH="$$(echo $(DEB_LDFLAGS_APPEND) | \
101+
grep -oE -- '-L[^ ]+' | sed 's/^-L//' | awk '!seen[$$0]++' | paste -sd: -)" \
102+
$(MAKE) test; \
103+
else \
104+
$(MAKE) test; \
105+
fi
106+
107+
override_dh_shlibdeps:
108+
@if [ -n "$(DEB_LDFLAGS_APPEND)" ]; then \
109+
# Skip shlibdeps for now since we're using a custom library path \
110+
: \
111+
else \
112+
dh_shlibdeps; \
113+
fi

scripts/build-wolfprovider.sh

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,36 @@ if [ -n "$build_debian" ]; then
161161
WOLFSSL_OPTS+=" --fips"
162162
WOLFPROV_OPTS+=" --fips"
163163
fi
164+
if [ "$WOLFPROV_REPLACE_DEFAULT" = "1" ]; then
165+
OPENSSL_OPTS+=" --replace-default"
166+
fi
164167

165168
# Must install wolfSSL locally since it is needed to build wolfProvider
166-
debian/install-wolfssl.sh $WOLFSSL_OPTS -r ..
167-
# Always build replace-default mode for openssl. Use the standard one from apt.
168-
debian/install-openssl.sh $OPENSSL_OPTS --replace-default ..
169-
debian/install-wolfprov.sh $WOLFPROV_OPTS --no-install
169+
debian/install-wolfssl.sh $WOLFSSL_OPTS --no-install ..
170+
debian/install-openssl.sh $OPENSSL_OPTS --no-install ..
171+
172+
# Unpack the wolfssl packages to a temporary directory
173+
wolfssl_dev_dir=$(mktemp -d)
174+
dpkg -x ../libwolfssl_*.deb $wolfssl_dev_dir
175+
dpkg -x ../libwolfssl-dev_*.deb $wolfssl_dev_dir
176+
# Unpack the libssl-dev package to a temporary directory
177+
openssl_dev_dir=$(mktemp -d)
178+
dpkg -x ../openssl_*.deb $openssl_dev_dir
179+
dpkg -x ../libssl-dev_*.deb $openssl_dev_dir
180+
181+
export DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH)
182+
183+
printf "wolfssl_dev_dir: %s\n" $wolfssl_dev_dir
184+
printf "wolfssl_dev_dir libs: %s\n" $(ls $wolfssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH)
185+
printf "openssl_dev_dir: %s\n" $openssl_dev_dir
186+
printf "openssl_dev_dir libs: %s\n" $(ls $openssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH)
187+
188+
export DEB_CFLAGS_APPEND="-I$wolfssl_dev_dir/usr/include -I$openssl_dev_dir/usr/include"
189+
export DEB_CPPFLAGS_APPEND="-I$wolfssl_dev_dir/usr/include -I$openssl_dev_dir/usr/include"
190+
export DEB_CXXFLAGS_APPEND="-I$wolfssl_dev_dir/usr/include -I$openssl_dev_dir/usr/include"
191+
export DEB_LDFLAGS_APPEND="-L$wolfssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH -L$openssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH"
192+
export PKG_CONFIG_LIBDIR=$wolfssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH/pkgconfig:$openssl_dev_dir/usr/lib/$DEB_HOST_MULTIARCH/pkgconfig
193+
debian/install-wolfprov.sh $WOLFPROV_OPTS --no-install ..
170194

171195
exit 0
172196
fi

0 commit comments

Comments
 (0)