diff options
| author | David Kalnischkies <david@kalnischkies.de> | 2022-04-21 01:45:45 +0200 |
|---|---|---|
| committer | David Kalnischkies <david@kalnischkies.de> | 2022-05-07 10:45:44 +0200 |
| commit | 8d8b45a96ceceb015f7836cf25b99279c2f377b9 (patch) | |
| tree | 93a497556cdfac9332afbeeffdaf9f8a0485e9b2 | |
| parent | ee06eb541e5aa477880ff0fc575be317eccbd929 (diff) | |
Link interactive helpers against system libapt for autopkgtest
Building the library just so we can build the helpers against it is not
only wasteful but as we are supposed to test the system we can use that
as an additional simple smoke test before the real testing starts.
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | debian/tests/run-tests | 6 | ||||
| -rw-r--r-- | po/CMakeLists.txt | 4 | ||||
| -rwxr-xr-x | test/integration/create-test-data | 2 | ||||
| -rw-r--r-- | test/integration/framework | 51 | ||||
| -rwxr-xr-x | test/integration/test-apt-helper-cat-file | 2 | ||||
| -rwxr-xr-x | test/integration/test-no-fds-leaked-to-maintainer-scripts | 6 | ||||
| -rw-r--r-- | test/interactive-helper/CMakeLists.txt | 27 |
8 files changed, 57 insertions, 43 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c6896387..7f3a6a7c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,8 +240,10 @@ configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h) # Add our subdirectories add_subdirectory(vendor) +if (NOT USE_SYSTEM_APTPKG) add_subdirectory(apt-pkg) add_subdirectory(apt-private) +endif() add_subdirectory(cmdline) add_subdirectory(completions) add_subdirectory(doc) diff --git a/debian/tests/run-tests b/debian/tests/run-tests index 461042641..c7ca16b35 100644 --- a/debian/tests/run-tests +++ b/debian/tests/run-tests @@ -15,7 +15,7 @@ else fi if [ ! -e "${BUILD_DIR}/CMakeCache.txt" ]; then - cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" + cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DUSE_SYSTEM_APTPKG=ON -DWITH_DOC=OFF -DUSE_NLS=OFF fi make -C "${BUILD_DIR}/test/interactive-helper" @@ -24,14 +24,14 @@ make -C "${BUILD_DIR}/test/interactive-helper" # the host env does not pollute our environment env -i \ APT_INTEGRATION_TESTS_SOURCE_DIR="${SOURCE_DIR}" \ -APT_INTEGRATION_TESTS_HELPERS_BIN_DIR="${BUILD_DIR}/test/interactive-helper" \ +APT_INTEGRATION_TESTS_BUILD_DIR="${BUILD_DIR}" \ APT_INTEGRATION_TESTS_METHODS_DIR=/usr/lib/apt/methods \ APT_INTEGRATION_TESTS_LIBEXEC_DIR=/usr/lib/apt/ \ APT_INTEGRATION_TESTS_INTERNAL_SOLVER=/usr/lib/apt/solvers/apt \ APT_INTEGRATION_TESTS_DUMP_SOLVER=/usr/lib/apt/solvers/dump \ APT_INTEGRATION_TESTS_INTERNAL_PLANNER=/usr/lib/apt/planners/apt \ -APT_INTEGRATION_TESTS_BUILD_DIR=/usr/bin \ APT_INTEGRATION_TESTS_FTPARCHIVE_BIN_DIR=/usr/bin \ +APT_INTEGRATION_TESTS_CMDLINE_BIN_DIR=/usr/bin \ APT_INTEGRATION_TESTS_LIBRARY_PATH=/dev/null/does/not/exist \ APT_INTEGRATION_TESTS_ARTIFACTS_DIR="${AUTOPKGTEST_ARTIFACTS}" \ "${SOURCE_DIR}/test/integration/run-tests" -q diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index c03d6d03e..73d5ddd80 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -4,12 +4,15 @@ set(languages_excluded he ## disabled by translator request #313283 ) +if (TARGET apt-pkg) apt_add_translation_domain( DOMAIN libapt-pkg${APT_PKG_MAJOR} TARGETS apt-pkg EXCLUDE_LANGUAGES ${languages_excluded} ) +endif() +if (TARGET apt-private) apt_add_translation_domain( DOMAIN apt TARGETS apt apt-cache apt-get apt-config apt-cdrom apt-helper apt-mark @@ -19,6 +22,7 @@ apt_add_translation_domain( SCRIPTS ../dselect/install ../dselect/update EXCLUDE_LANGUAGES ${languages_excluded} ) +endif() apt_add_translation_domain( DOMAIN apt-utils diff --git a/test/integration/create-test-data b/test/integration/create-test-data index eff2ba530..0eca3998c 100755 --- a/test/integration/create-test-data +++ b/test/integration/create-test-data @@ -9,8 +9,6 @@ fi CHECK_ARGS='no' TESTDIR="$(readlink -f "$(dirname "$0")")" . "$TESTDIR/framework" -find_project_binary_dir -BUILDDIRECTORY="${APT_INTEGRATION_TESTS_BUILD_DIR:-"${PROJECT_BINARY_DIR}/cmdline"}" GENERATE="$1" CODENAME="$2" diff --git a/test/integration/framework b/test/integration/framework index c9559a7ba..8bb8c00d6 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -175,7 +175,7 @@ runapt() { shift case "$CMD" in sh|aptitude|*/*|command) ;; - *) CMD="${BUILDDIRECTORY}/$CMD";; + *) CMD="${APTCMDLINEBINDIR}/$CMD";; esac if [ "$CMD" = 'aptitude' ]; then MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}" command "$CMD" "$@" @@ -228,7 +228,7 @@ gdb() { esac shift if [ "${CMD##*/}" = "$CMD" ]; then - CMD="${BUILDDIRECTORY}/${CMD}" + CMD="${APTCMDLINEBINDIR}/${CMD}" fi runapt command gdb --quiet -ex "directory '$SOURCEDIRECTORY'" -ex run "$CMD" --args "$CMD" "$@" } @@ -248,7 +248,7 @@ valgrind() { esac shift if [ "${CMD##*/}" = "$CMD" ]; then - CMD="${BUILDDIRECTORY}/${CMD}" + CMD="${APTCMDLINEBINDIR}/${CMD}" fi runapt command valgrind "$CMD" "$@" } @@ -373,9 +373,6 @@ setupenvironment() { fi mkdir -p 'rootdir/usr/bin' 'rootdir/var/cache' 'rootdir/var/lib' 'rootdir/var/log' 'rootdir/var/crash' 'rootdir/tmp' - # Find the newest build directory (sets PROJECT_BINARY_DIR) - find_project_binary_dir - _setupprojectenvironment # create some files in /tmp and look at user/group to get what this means @@ -383,9 +380,6 @@ setupenvironment() { touch "${TMPWORKINGDIRECTORY}/test-file" TEST_DEFAULT_GROUP=$(stat --format '%G' "${TMPWORKINGDIRECTORY}/test-file") - # prefer our apt binaries over the system apt binaries - export PATH="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin" - if [ -r "${TESTDIRECTORY}/extra-environment" ]; then . "${TESTDIRECTORY}/extra-environment" fi @@ -393,19 +387,20 @@ setupenvironment() { msgdone "info" } _setupprojectenvironment() { - # allow overriding the default BUILDDIR location + # allow overriding the default BUILDDIR locations SOURCEDIRECTORY="${APT_INTEGRATION_TESTS_SOURCE_DIR:-"${TESTDIRECTORY}/../../"}" - BUILDDIRECTORY="${APT_INTEGRATION_TESTS_BUILD_DIR:-"${PROJECT_BINARY_DIR}/cmdline"}" - LIBRARYPATH="${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}/../apt-pkg"}" - METHODSDIR="${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/../methods"}" - APTHELPERBINDIR="${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}" - APTTESTHELPERSBINDIR="${APT_INTEGRATION_TESTS_HELPERS_BIN_DIR:-"${BUILDDIRECTORY}/../test/interactive-helper"}" - APTFTPARCHIVEBINDIR="${APT_INTEGRATION_TESTS_FTPARCHIVE_BIN_DIR:-"${BUILDDIRECTORY}/../ftparchive"}" - APTINTERNALSOLVER="${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/solvers/apt"}" - APTDUMPSOLVER="${APT_INTEGRATION_TESTS_DUMP_SOLVER:-"${BUILDDIRECTORY}/solvers/dump"}" - APTINTERNALPLANNER="${APT_INTEGRATION_TESTS_INTERNAL_PLANNER:-"${BUILDDIRECTORY}/planners/apt"}" + BUILDDIRECTORY="${APT_INTEGRATION_TESTS_BUILD_DIR:-"$(find_project_binary_dir; printf '%s' "$PROJECT_BINARY_DIR")"}" + LIBRARYPATH="${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}/apt-pkg"}" + METHODSDIR="${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}" + APTHELPERBINDIR="${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}/cmdline"}" + APTTESTHELPERSBINDIR="${APT_INTEGRATION_TESTS_HELPERS_BIN_DIR:-"${BUILDDIRECTORY}/test/interactive-helper"}" + APTFTPARCHIVEBINDIR="${APT_INTEGRATION_TESTS_FTPARCHIVE_BIN_DIR:-"${BUILDDIRECTORY}/ftparchive"}" + APTCMDLINEBINDIR="${APT_INTEGRATION_TESTS_CMDLINE_BIN_DIR:-"${BUILDDIRECTORY}/cmdline"}" + APTINTERNALSOLVER="${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${APTCMDLINEBINDIR}/solvers/apt"}" + APTDUMPSOLVER="${APT_INTEGRATION_TESTS_DUMP_SOLVER:-"${APTCMDLINEBINDIR}/solvers/dump"}" + APTINTERNALPLANNER="${APT_INTEGRATION_TESTS_INTERNAL_PLANNER:-"${APTCMDLINEBINDIR}/planners/apt"}" ARTIFACTSDIR="${APT_INTEGRATION_TESTS_ARTIFACTS_DIR:-"${BUILDDIRECTORY}/artifacts"}" - test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first" + test -x "${APTCMDLINEBINDIR}/apt-get" || msgdie 'You need to build tree first' echo "#x-apt-configure-index \"${SOURCEDIRECTORY}/doc/examples/configure-index\";" > aptconfig.conf mkdir aptarchive keys @@ -422,8 +417,7 @@ _setupprojectenvironment() { ln -s "${APTINTERNALPLANNER}" usr/lib/apt/planners/apt echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" >> ../aptconfig.conf echo "Dir::Bin::Planners \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/planners\";" >> ../aptconfig.conf - # use the autoremove from the BUILDDIRECTORY if its there, otherwise - # system + # use the autoremove from the BUILDDIRECTORY if its there, otherwise system if [ -z "${APT_INTEGRATION_TESTS_SOURCE_DIR}" ]; then ln -s "${SOURCEDIRECTORY}/debian/apt.conf.autoremove" etc/apt/apt.conf.d/01autoremove else @@ -452,11 +446,11 @@ _setupprojectenvironment() { echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf echo "Dir::Bin::Methods \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods\";" >> aptconfig.conf # either store apt-key were we can access it, even if we run it as a different user - #cp "${BUILDDIRECTORY}/apt-key" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/" + #cp "${APTCMDLINEBINDIR}/apt-key" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/" #chmod o+rx "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key" #echo "Dir::Bin::apt-key \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key\";" >> aptconfig.conf # destroys coverage reporting though, so we disable changing user for the calling gpgv - echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf + echo "Dir::Bin::apt-key \"${APTCMDLINEBINDIR}/apt-key\";" >> aptconfig.conf if [ "$(id -u)" = '0' ]; then echo 'Binary::gpgv::APT::Sandbox::User "root";' >> aptconfig.conf # same for the solver executables @@ -542,6 +536,9 @@ EOF # most tests just need one signed Release file, not both export APT_DONT_SIGN='Release.gpg' + + # prefer our apt binaries over the system apt binaries + export PATH="${APTCMDLINEBINDIR}:${PATH}:/usr/sbin:/sbin" } getarchitecture() { @@ -1831,12 +1828,12 @@ msgfailoutput() { if [ -s "$COREDUMP" ]; then if [ -z "$COREEXE" ]; then case "$CMD" in - apt) COREEXE="${BUILDDIRECTORY}/${CMD}";; + apt) COREEXE="${APTCMDLINEBINDIR}/${CMD}";; aptftparchive) COREEXE="${APTFTPARCHIVEBINDIR}/apt-ftparchive";; apthelper) COREEXE="${APTHELPERBINDIR}/apt-helper";; aptwebserver) COREEXE="${APTTESTHELPERSBINDIR}/aptwebserver";; - apt*) COREEXE="${BUILDDIRECTORY}/apt-${CMD##*apt}";; - *) COREEXE="${BUILDDIRECTORY}/${CMD}";; + apt*) COREEXE="${APTCMDLINEBINDIR}/apt-${CMD##*apt}";; + *) COREEXE="${APTCMDLINEBINDIR}/${CMD}";; esac fi diff --git a/test/integration/test-apt-helper-cat-file b/test/integration/test-apt-helper-cat-file index a53a6b4a3..064760c9e 100755 --- a/test/integration/test-apt-helper-cat-file +++ b/test/integration/test-apt-helper-cat-file @@ -5,7 +5,7 @@ TESTDIR="$(readlink -f "$(dirname "$0")")" . "$TESTDIR/framework" setupenvironment -TESTTOOL="${BUILDDIRECTORY}/../test/interactive-helper/test_fileutl" +TESTTOOL="${APTTESTHELPERSBINDIR}/test_fileutl" msgtest 'Check if we have build the test tool' "$TESTTOOL" if [ -x "$TESTTOOL" ]; then msgpass diff --git a/test/integration/test-no-fds-leaked-to-maintainer-scripts b/test/integration/test-no-fds-leaked-to-maintainer-scripts index 4606408fc..2b165520e 100755 --- a/test/integration/test-no-fds-leaked-to-maintainer-scripts +++ b/test/integration/test-no-fds-leaked-to-maintainer-scripts @@ -159,11 +159,11 @@ else fi rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log -testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt-get" install -y fdleaks -qq < /dev/null +testsuccess runapt command setsid -w "${APTCMDLINEBINDIR}/apt-get" install -y fdleaks -qq < /dev/null checkinstall rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log -testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt-get" purge -y fdleaks -qq +testsuccess runapt command setsid -w "${APTCMDLINEBINDIR}/apt-get" purge -y fdleaks -qq checkpurge touch rootdir/tmp/read_stdin @@ -174,6 +174,6 @@ checkinstall testequal '2' grep -c '^STDIN: ' rootdir/var/log/apt/term.log rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log -yes '' | testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt-get" purge -y fdleaks -qq +yes '' | testsuccess runapt command setsid -w "${APTCMDLINEBINDIR}/apt-get" purge -y fdleaks -qq checkpurge testequal '3' grep -c '^STDIN: ' rootdir/var/log/apt/term.log diff --git a/test/interactive-helper/CMakeLists.txt b/test/interactive-helper/CMakeLists.txt index fff47300b..8e8764353 100644 --- a/test/interactive-helper/CMakeLists.txt +++ b/test/interactive-helper/CMakeLists.txt @@ -1,18 +1,31 @@ +if(USE_SYSTEM_APTPKG) + find_library(aptpkg NAMES apt-pkg NO_PACKAGE_ROOT_PATH REQUIRED) + set(APTPKG_LIB "${aptpkg}") + # it isn't easy to link against -private, but that is by design + set(APTPRIVATE_LIB "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libapt-private.so.0.0") + set(APTPRIVATE_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}") +else() + set(APTPKG_LIB "apt-pkg") + set(APTPRIVATE_LIB "apt-private") + set(APTPRIVATE_INCLUDE_DIRS "") +endif() + add_executable(mthdcat mthdcat.cc) -target_link_libraries(mthdcat apt-pkg) +target_link_libraries(mthdcat ${APTPKG_LIB}) add_executable(testdeb testdeb.cc) -target_link_libraries(testdeb apt-pkg) +target_link_libraries(testdeb ${APTPKG_LIB}) add_executable(extract-control extract-control.cc) -target_link_libraries(extract-control apt-pkg) +target_link_libraries(extract-control ${APTPKG_LIB}) add_executable(aptwebserver aptwebserver.cc) -target_link_libraries(aptwebserver apt-pkg ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(aptwebserver ${APTPKG_LIB} ${CMAKE_THREAD_LIBS_INIT}) add_executable(aptdropprivs aptdropprivs.cc) -target_link_libraries(aptdropprivs apt-pkg) +target_link_libraries(aptdropprivs ${APTPKG_LIB}) add_executable(test_fileutl test_fileutl.cc) -target_link_libraries(test_fileutl apt-pkg) +target_link_libraries(test_fileutl ${APTPKG_LIB}) add_executable(createdeb-cve-2020-27350 createdeb-cve-2020-27350.cc) add_executable(longest-dependency-chain longest-dependency-chain.cc) -target_link_libraries(longest-dependency-chain apt-pkg apt-private) +target_link_libraries(longest-dependency-chain ${APTPKG_LIB} ${APTPRIVATE_LIB}) +target_include_directories(longest-dependency-chain PRIVATE ${APTPRIVATE_INCLUDE_DIRS}) add_library(noprofile SHARED libnoprofile.c) target_link_libraries(noprofile ${CMAKE_DL_LIBS}) |
