build: detect system libpam in prepare-local-deps
All checks were successful
Source release / source-package (push) Successful in 1m52s

prepare-local-deps.sh only stages PAM headers and expects final linking
against the host libpam.  Some distributions/containers do not provide the
unversioned /usr/lib/libpam.so development symlink, but do provide the runtime
soname such as /lib/x86_64-linux-gnu/libpam.so.0.

Detect the host libpam path when printing the CMake hints so the generated
command can be used directly in those environments.
This commit is contained in:
ChatGPT
2026-06-13 00:00:00 +00:00
committed by Mario Fetka
parent 2ade7e72e8
commit ef946b4282

View File

@@ -24,6 +24,18 @@ find_one() {
printf '%s\n' "$1"
}
find_system_lib() {
soname=$1
for dir in /lib /usr/lib /lib/* /usr/lib/* /usr/local/lib; do
if [ -e "$dir/$soname" ]; then
printf '%s\n' "$dir/$soname"
return 0
fi
done
command -v ldconfig >/dev/null 2>&1 || return 1
ldconfig -p 2>/dev/null | awk -v n="$soname" '$1 == n { print $NF; exit }'
}
require_root() {
if [ ! -f .gitmodules ] || [ ! -f CMakeLists.txt ]; then
echo "error: run this script from the mars-nwe root" >&2
@@ -110,6 +122,14 @@ extract_headers() {
}
print_cmake_hints() {
pam_lib=$(find_system_lib libpam.so 2>/dev/null || true)
if [ -z "$pam_lib" ]; then
pam_lib=$(find_system_lib libpam.so.0 2>/dev/null || true)
fi
if [ -z "$pam_lib" ]; then
pam_lib=/usr/lib/libpam.so
fi
cat <<HINTS
Prepared local dependency prefix: $PREFIX
@@ -121,9 +141,9 @@ Use the local GDBM build and extracted PAM/ncurses headers like this:
-DGDBM_INCLUDE_DIR=$PWD/$PREFIX/include \\
-DGDBM_LIBRARY=$PWD/$PREFIX/lib/libgdbm.so \\
-DPAM_INCLUDE_DIR=$PWD/$PREFIX/include \\
-DPAM_LIBRARY=/usr/lib/libpam.so
-DPAM_LIBRARY=$pam_lib
Adjust PAM_LIBRARY to the real system libpam path on the build host. PAM and
PAM_LIBRARY above was auto-detected for this host. PAM and
ncurses are not vendored libraries here: only their headers are staged for
compile checks, and final linking is against the system libraries.
HINTS