From 039979e460892457d1be33e354b42d516a2fc48f Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Tue, 13 Apr 2021 18:58:22 +0200 Subject: [PATCH] Install BIND with "make DESTDIR= install" BIND installation should be done by setting $DESTDIR during "make install", not by setting --prefix via ./configure to the destination directory. However, on 9.11 --prefix still needs to be set to eliminate the compatibility mode with older BIND9 releases (see the comment in configure.ac, lines 379-396), which does not place sysconfdir and localstatedir to $DESTDIR/$prefix but directly to $DESTDIR. When --prefix is set they end up in $DESTDIR/$prefix, which is the BIND 9.16+ default). $ ./configure && make && make install DESTDIR=/tmp/bind9 $ ls /tmp/bind9/{,usr/local} /tmp/bind9/: etc usr var /tmp/bind9/usr/local: bin include lib sbin share $ ./configure --prefix=/usr/local && make && make install DESTDIR=/tmp/bind9 $ ls /tmp/bind9/{,usr/local} /tmp/bind9/: usr /tmp/bind9/usr/local: bin etc include lib sbin share var Make sure that installation with DESTDIR= works by checking that named binary and it's respective man page were installed and that well-known BIND9 directories - and only them - are present in DESTDIR. Also rename install path variable from BIND_INSTALL_PATH to INSTALL_PATH to avoid namespace clash in stress tests which use BIND_INSTALL_PATH variable to configure path to BIND9 binaries. (cherry picked from commit 823bf3e79ba8f287b63d2e6ec5006d091c8c54e8) --- .gitlab-ci.yml | 12 ++++++------ util/check-make-install.in | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 21d19954db..f8ede4e6e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ variables: TARBALL_COMPRESSOR: gzip TARBALL_EXTENSION: gz - BIND_INSTALL_PATH: "${CI_PROJECT_DIR}/.local" + INSTALL_PATH: "${CI_PROJECT_DIR}/.local" # Default platforms to run "stress" tests on BIND_STRESS_TEST_OS: linux @@ -237,7 +237,7 @@ stages: --with-cmocka \ --with-libxml2 \ --with-libjson \ - --prefix="${BIND_INSTALL_PATH}" \ + --prefix=/usr/local \ --without-make-clean \ $EXTRA_CONFIGURE \ || (test -s config.log && cat config.log; exit 1) @@ -253,8 +253,8 @@ stages: - test -n "${SKIP_MAKE_DEPEND}" || make -j${BUILD_PARALLEL_JOBS:-1} depend 2>&1 | tee make-depend.log - test -n "${SKIP_MAKE_DEPEND}" || ( ! grep -F "error:" make-depend.log ) - make -j${BUILD_PARALLEL_JOBS:-1} -k all V=1 - - test -z "${RUN_MAKE_INSTALL}" || make install - - test -z "${RUN_MAKE_INSTALL}" || sh util/check-make-install + - test -z "${RUN_MAKE_INSTALL}" || make DESTDIR="${INSTALL_PATH}" install + - test -z "${RUN_MAKE_INSTALL}" || DESTDIR="${INSTALL_PATH}" sh util/check-make-install - if [[ "${CFLAGS}" == *"-fsanitize=address"* ]]; then ( ! grep -F AddressSanitizer config.log ); fi needs: - job: autoreconf @@ -1484,10 +1484,10 @@ respdiff: - *setup_interfaces - *setup_softhsm - make -j${BUILD_PARALLEL_JOBS:-1} -k all V=1 - - make install + - make DESTDIR="${INSTALL_PATH}" install - git clone --depth 1 https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.isc.org/isc-private/bind-qa.git - cd bind-qa/bind9/stress - - DIG="${BIND_INSTALL_PATH}/bin/dig" WORKSPACE="${CI_PROJECT_DIR}" bash stress.sh + - LD_LIBRARY_PATH="${INSTALL_PATH}/usr/local/lib" BIND_INSTALL_PATH="${INSTALL_PATH}/usr/local" WORKSPACE="${CI_PROJECT_DIR}" bash stress.sh needs: - job: autoreconf artifacts: true diff --git a/util/check-make-install.in b/util/check-make-install.in index 53899fefde..024f7f2a08 100644 --- a/util/check-make-install.in +++ b/util/check-make-install.in @@ -10,8 +10,10 @@ # information regarding copyright ownership. abs_top_srcdir=@abs_top_srcdir@ +abs_builddir=@abs_builddir@ prefix=@prefix@ includedir=@includedir@ +install_dir="${DESTDIR}@prefix@" headers_to_install() { find "${abs_top_srcdir}/lib" -name "*.h" -or -name "*.h.in" | @@ -32,4 +34,28 @@ for header in $(headers_to_install); do fi done +named_binary_path="${install_dir}/sbin/named" +if [ ! -x "${named_binary_path}" ]; then + echo "ERROR: ${named_binary_path} does not exist or is not executable" + status=1 +fi + +named_man_page_path="${install_dir}/share/man/man8/named.8" +if [ ! -f "${named_man_page_path}" ]; then + echo "ERROR: ${named_man_page_path} does not exist" + status=1 +fi + +if [ -n "${DESTDIR}" ]; then + for expected_subdir in bin etc include lib sbin share var; do + echo "${install_dir}/${expected_subdir}" >> "${abs_builddir}/expected_dirs" + done + find "${install_dir}" -maxdepth 1 -mindepth 1 -type d | sort > "${abs_builddir}/existing_dirs" + if ! diff -u "${abs_builddir}/expected_dirs" "${abs_builddir}/existing_dirs"; then + echo "ERROR: Contents of DESTDIR do not match expectations" + status=1 + fi + rm -f "${abs_builddir}/expected_dirs" "${abs_builddir}/existing_dirs" +fi + exit $status