From e6cefc7683de4f29be7ebcab004ea0ab80ce49bc Mon Sep 17 00:00:00 2001 From: Vagrant Cascadian Date: Sun, 17 Apr 2022 23:12:47 +0000 Subject: Pass -DCMAKE_BUILD_RPATH_USE_ORIGIN=ON via dh_auto_configure override CMake by default sets the RPATH property on executables that link to shared libraries in the same project with an absolute path, which triggers BuildId differences. References: https://tests.reproducible-builds.org/debian/issues/unstable/cmake_rpath_contains_build_path_issue.html https://gitlab.kitware.com/cmake/cmake/-/issues/18413 Closes: #1009796 [@donkult: reworded commit message slightly and have flag passed first] --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 8a110f7a1..202f1b86d 100755 --- a/debian/rules +++ b/debian/rules @@ -47,4 +47,4 @@ override_dh_installsystemd: override_dh_auto_configure-arch: flags=-DWITH_DOC=OFF override_dh_auto_configure-indep: flags=-DWITH_DOC=ON override_dh_auto_configure-arch override_dh_auto_configure-indep: - dh_auto_configure -- $(flags) $(configure_test_flags) + dh_auto_configure -- -DCMAKE_BUILD_RPATH_USE_ORIGIN=ON $(flags) $(configure_test_flags) -- cgit v1.2.3-70-g09d2 From 725fef5ebf45d03fea75866e9795717bf576d26a Mon Sep 17 00:00:00 2001 From: Vagrant Cascadian Date: Sun, 17 Apr 2022 22:11:12 +0000 Subject: Add support for "nodoc" build profile References: https://wiki.debian.org/BuildProfileSpec#Registered_profile_names Closes: #1009797 [@donkult: reworded commit message slightly & changed variable name] --- debian/control | 4 +++- debian/rules | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/debian/control b/debian/control index 2f1d0515e..7f10eec3e 100644 --- a/debian/control +++ b/debian/control @@ -31,7 +31,7 @@ Build-Depends: cmake (>= 3.4), triehash, xsltproc, zlib1g-dev -Build-Depends-Indep: doxygen, graphviz, w3m +Build-Depends-Indep: doxygen , graphviz , w3m Vcs-Git: https://salsa.debian.org/apt-team/apt.git Vcs-Browser: https://salsa.debian.org/apt-team/apt @@ -101,6 +101,7 @@ Priority: optional Depends: ${misc:Depends} Section: doc Multi-Arch: foreign +Build-Profiles: Description: documentation for APT This package contains the user guide and offline guide for various APT tools which are provided in a html and a text-only version. @@ -125,6 +126,7 @@ Priority: optional Depends: ${misc:Depends} Section: doc Multi-Arch: foreign +Build-Profiles: Description: documentation for APT development This package contains documentation for development of the APT Debian package manipulation program and its libraries. diff --git a/debian/rules b/debian/rules index 202f1b86d..502840080 100755 --- a/debian/rules +++ b/debian/rules @@ -17,6 +17,12 @@ else configure_test_flags = endif +ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),) + profile_doc_flags=-DWITH_DOC=ON +else + profile_doc_flags=-DWITH_DOC=OFF +endif + %: dh $@ --buildsystem=cmake+ninja @@ -44,7 +50,7 @@ override_dh_installsystemd: dh_installsystemd -papt --no-restart-on-upgrade --no-restart-after-upgrade --no-start apt-daily.service apt-daily-upgrade.service dh_installsystemd --remaining-packages -override_dh_auto_configure-arch: flags=-DWITH_DOC=OFF -override_dh_auto_configure-indep: flags=-DWITH_DOC=ON +override_dh_auto_configure-arch: configure_doc_flags=-DWITH_DOC=OFF +override_dh_auto_configure-indep: configure_doc_flags=$(profile_doc_flags) override_dh_auto_configure-arch override_dh_auto_configure-indep: - dh_auto_configure -- -DCMAKE_BUILD_RPATH_USE_ORIGIN=ON $(flags) $(configure_test_flags) + dh_auto_configure -- -DCMAKE_BUILD_RPATH_USE_ORIGIN=ON $(configure_doc_flags) $(configure_test_flags) -- cgit v1.2.3-70-g09d2 From cd92098caa64b7fd30cdc6b5d56bf7e9e17a449e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 19 Apr 2022 13:06:44 +0200 Subject: Avoid building all docs in nodoc build profile Differentiating between different types of documentation we build helps in better expressing what needs to be done for our arch:any and arch:all packages currently as well. --- CMakeLists.txt | 9 ++++++++- debian/apt-utils.examples | 1 + debian/apt-utils.install | 7 ------- debian/apt-utils.manpages | 6 ++++++ debian/apt.examples | 1 + debian/apt.install | 27 --------------------------- debian/apt.manpages | 26 ++++++++++++++++++++++++++ debian/control | 8 ++++---- debian/rules | 16 ++++++++-------- doc/CMakeLists.txt | 13 +++++++++++-- vendor/CMakeLists.txt | 2 ++ 11 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 debian/apt-utils.examples create mode 100644 debian/apt-utils.manpages create mode 100644 debian/apt.examples create mode 100644 debian/apt.manpages diff --git a/CMakeLists.txt b/CMakeLists.txt index 86e5060d1..5c6896387 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,12 @@ include_directories(${PROJECT_BINARY_DIR}/include) enable_testing() -option(WITH_DOC "Build documentation." ON) +option(WITH_DOC "Build all documentation." ON) +include(CMakeDependentOption) +cmake_dependent_option(WITH_DOC_MANPAGES "Force building manpages." OFF "NOT WITH_DOC" OFF) +cmake_dependent_option(WITH_DOC_GUIDES "Force building guides." OFF "NOT WITH_DOC" OFF) +cmake_dependent_option(WITH_DOC_DOXYGEN "Force building doxygen documentation." OFF "NOT WITH_DOC" OFF) +cmake_dependent_option(WITH_DOC_EXAMPLES "Force building example configurations." OFF "NOT WITH_DOC" OFF) option(WITH_TESTS "Build tests" ON) option(USE_NLS "Localisation support." ON) @@ -247,7 +252,9 @@ add_subdirectory(test) if (USE_NLS) add_subdirectory(po) +endif() +if(TARGET update-po AND TARGET update-po4a) # Link update-po4a into the update-po target add_dependencies(update-po update-po4a) endif() diff --git a/debian/apt-utils.examples b/debian/apt-utils.examples new file mode 100644 index 000000000..b66de3cdd --- /dev/null +++ b/debian/apt-utils.examples @@ -0,0 +1 @@ +usr/share/doc/apt-utils/examples/* diff --git a/debian/apt-utils.install b/debian/apt-utils.install index a27f1e1e4..9b304e535 100644 --- a/debian/apt-utils.install +++ b/debian/apt-utils.install @@ -3,11 +3,4 @@ usr/bin/apt-ftparchive usr/bin/apt-sortpkgs usr/lib/apt/planners/ usr/lib/apt/solvers/ -usr/share/doc/apt-utils usr/share/locale/*/*/apt-utils.mo -usr/share/man/*/*/apt-extracttemplates.* -usr/share/man/*/*/apt-ftparchive.* -usr/share/man/*/*/apt-sortpkgs.* -usr/share/man/*/apt-extracttemplates.* -usr/share/man/*/apt-ftparchive.* -usr/share/man/*/apt-sortpkgs.* diff --git a/debian/apt-utils.manpages b/debian/apt-utils.manpages new file mode 100644 index 000000000..c61b908ea --- /dev/null +++ b/debian/apt-utils.manpages @@ -0,0 +1,6 @@ +usr/share/man/*/*/apt-extracttemplates.* +usr/share/man/*/*/apt-ftparchive.* +usr/share/man/*/*/apt-sortpkgs.* +usr/share/man/*/apt-extracttemplates.* +usr/share/man/*/apt-ftparchive.* +usr/share/man/*/apt-sortpkgs.* diff --git a/debian/apt.examples b/debian/apt.examples new file mode 100644 index 000000000..3e15bddda --- /dev/null +++ b/debian/apt.examples @@ -0,0 +1 @@ +usr/share/doc/apt/examples/* diff --git a/debian/apt.install b/debian/apt.install index 3658bf5e6..e3a911a9f 100644 --- a/debian/apt.install +++ b/debian/apt.install @@ -16,32 +16,5 @@ usr/lib/apt/planners/dump usr/lib/apt/solvers/dump usr/lib/dpkg/methods/apt/ usr/share/bash-completion/completions/ -usr/share/doc/apt usr/share/locale/*/*/apt.mo -usr/share/man/*/*/apt-cache.* -usr/share/man/*/*/apt-cdrom.* -usr/share/man/*/*/apt-config.* -usr/share/man/*/*/apt-get.* -usr/share/man/*/*/apt-key.* -usr/share/man/*/*/apt-mark.* -usr/share/man/*/*/apt-secure.* -usr/share/man/*/*/apt-patterns.* -usr/share/man/*/*/apt.* -usr/share/man/*/*/apt_preferences.* -usr/share/man/*/*/apt_auth.* -usr/share/man/*/*/apt-transport-*.* -usr/share/man/*/*/sources.list.* -usr/share/man/*/apt-cache.* -usr/share/man/*/apt-cdrom.* -usr/share/man/*/apt-config.* -usr/share/man/*/apt-get.* -usr/share/man/*/apt-key.* -usr/share/man/*/apt-mark.* -usr/share/man/*/apt-secure.* -usr/share/man/*/apt-patterns.* -usr/share/man/*/apt.* -usr/share/man/*/apt_preferences.* -usr/share/man/*/apt_auth.* -usr/share/man/*/apt-transport-*.* -usr/share/man/*/sources.list.* var/ diff --git a/debian/apt.manpages b/debian/apt.manpages new file mode 100644 index 000000000..80dbabd44 --- /dev/null +++ b/debian/apt.manpages @@ -0,0 +1,26 @@ +usr/share/man/*/*/apt-cache.* +usr/share/man/*/*/apt-cdrom.* +usr/share/man/*/*/apt-config.* +usr/share/man/*/*/apt-get.* +usr/share/man/*/*/apt-key.* +usr/share/man/*/*/apt-mark.* +usr/share/man/*/*/apt-secure.* +usr/share/man/*/*/apt-patterns.* +usr/share/man/*/*/apt.* +usr/share/man/*/*/apt_preferences.* +usr/share/man/*/*/apt_auth.* +usr/share/man/*/*/apt-transport-*.* +usr/share/man/*/*/sources.list.* +usr/share/man/*/apt-cache.* +usr/share/man/*/apt-cdrom.* +usr/share/man/*/apt-config.* +usr/share/man/*/apt-get.* +usr/share/man/*/apt-key.* +usr/share/man/*/apt-mark.* +usr/share/man/*/apt-secure.* +usr/share/man/*/apt-patterns.* +usr/share/man/*/apt.* +usr/share/man/*/apt_preferences.* +usr/share/man/*/apt_auth.* +usr/share/man/*/apt-transport-*.* +usr/share/man/*/sources.list.* diff --git a/debian/control b/debian/control index 7f10eec3e..44650bfb9 100644 --- a/debian/control +++ b/debian/control @@ -9,8 +9,8 @@ Rules-Requires-Root: no Standards-Version: 4.1.1 Build-Depends: cmake (>= 3.4), debhelper-compat (= 12), - docbook-xml, - docbook-xsl, + docbook-xml , + docbook-xsl , dpkg-dev (>= 1.20.8), gettext (>= 0.12), googletest | libgtest-dev , @@ -27,9 +27,9 @@ Build-Depends: cmake (>= 3.4), libzstd-dev (>= 1.0), ninja-build, pkg-config, - po4a (>= 0.34-2), + po4a (>= 0.34-2) , triehash, - xsltproc, + xsltproc , zlib1g-dev Build-Depends-Indep: doxygen , graphviz , w3m Vcs-Git: https://salsa.debian.org/apt-team/apt.git diff --git a/debian/rules b/debian/rules index 502840080..9ab42f24c 100755 --- a/debian/rules +++ b/debian/rules @@ -17,12 +17,6 @@ else configure_test_flags = endif -ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),) - profile_doc_flags=-DWITH_DOC=ON -else - profile_doc_flags=-DWITH_DOC=OFF -endif - %: dh $@ --buildsystem=cmake+ninja @@ -50,7 +44,13 @@ override_dh_installsystemd: dh_installsystemd -papt --no-restart-on-upgrade --no-restart-after-upgrade --no-start apt-daily.service apt-daily-upgrade.service dh_installsystemd --remaining-packages -override_dh_auto_configure-arch: configure_doc_flags=-DWITH_DOC=OFF -override_dh_auto_configure-indep: configure_doc_flags=$(profile_doc_flags) +ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),) +override_dh_auto_configure-arch: configure_doc_flags="-DWITH_DOC=OFF -DWITH_DOC_MANPAGES=ON" +override_dh_auto_configure-indep: configure_doc_flags="-DWITH_DOC=ON" +else +override_dh_auto_configure-arch: configure_doc_flags="-DWITH_DOC=OFF" +override_dh_auto_configure-indep: configure_doc_flags="-DWITH_DOC=OFF" +endif + override_dh_auto_configure-arch override_dh_auto_configure-indep: dh_auto_configure -- -DCMAKE_BUILD_RPATH_USE_ORIGIN=ON $(configure_doc_flags) $(configure_test_flags) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 3060949e5..72a1fed88 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,4 +1,6 @@ +if (WITH_DOC OR WITH_DOC_MANPAGES OR WITH_DOC_GUIDES) include(Documentation) +endif() set(LINGUAS de @@ -21,7 +23,7 @@ set(ENTITIES ../vendor/${CURRENT_VENDOR}/apt-vendor.ent ) -if(WITH_DOC) +if(WITH_DOC OR WITH_DOC_GUIDES) add_docbook(apt-doc HTML TEXT ALL DOCUMENTS guide.dbk @@ -43,7 +45,9 @@ add_docbook(libapt-pkg-doc HTML TEXT ALL TRANSLATED_ENTITIES ${TRANSLATED_ENTITIES} DEPENDS ${ENTITIES} ) +endif() +if(WITH_DOC OR WITH_DOC_DOXYGEN) find_package(Doxygen REQUIRED) file(GLOB_RECURSE apt_pkg "../apt-pkg/*.h" "../apt-pkg/*.cc") @@ -65,9 +69,9 @@ install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/doxygen/html PATTERN "*.map" EXCLUDE PATTERN "*.md5" EXCLUDE ) - endif() +if(WITH_DOC OR WITH_DOC_MANPAGES) add_docbook(apt-man MANPAGE ALL DOCUMENTS apt.8.xml @@ -93,7 +97,12 @@ add_docbook(apt-man MANPAGE ALL TRANSLATED_ENTITIES ${TRANSLATED_ENTITIES} LINGUAS ${LINGUAS} ) +endif() +if(WITH_DOC OR WITH_DOC_MANPAGES OR WITH_DOC_GUIDES) add_update_po4a(update-po4a po/${PROJECT_NAME}-doc.pot "po/header.pot.txt") +endif() +if(WITH_DOC OR WITH_DOC_EXAMPLES) add_subdirectory(examples) +endif() diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 8246c725a..f6d88690a 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -10,6 +10,7 @@ else() endif() # Handle sources.list example +if (WITH_DOC OR WITH_DOC_EXAMPLES) add_vendor_file(OUTPUT sources.list INPUT "${CURRENT_VENDOR}/sources.list.in" MODE 644 @@ -21,6 +22,7 @@ add_vendor_file(OUTPUT sources.list current-codename) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sources.list DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples) +endif() # Handle apt.conf snippets file(GLOB conffiles ${CURRENT_VENDOR}/apt.conf-*) -- cgit v1.2.3-70-g09d2 From c5b22c3dabd0cc8d0ce87576cded2594c2cd7ca1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 20 Apr 2022 13:18:20 +0200 Subject: Add pkg.apt.nodoxygen build profile The documentation generated by doxygen is currently not reproducible, but as fixing this seems hard we can at least provide a way to check more automatically if the rest of src:apt is reproducible or not. --- debian/control | 2 +- debian/rules | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/debian/control b/debian/control index 44650bfb9..7a91e0f05 100644 --- a/debian/control +++ b/debian/control @@ -31,7 +31,7 @@ Build-Depends: cmake (>= 3.4), triehash, xsltproc , zlib1g-dev -Build-Depends-Indep: doxygen , graphviz , w3m +Build-Depends-Indep: doxygen , graphviz , w3m Vcs-Git: https://salsa.debian.org/apt-team/apt.git Vcs-Browser: https://salsa.debian.org/apt-team/apt diff --git a/debian/rules b/debian/rules index 9ab42f24c..e7cbdc732 100755 --- a/debian/rules +++ b/debian/rules @@ -44,12 +44,17 @@ override_dh_installsystemd: dh_installsystemd -papt --no-restart-on-upgrade --no-restart-after-upgrade --no-start apt-daily.service apt-daily-upgrade.service dh_installsystemd --remaining-packages -ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),) -override_dh_auto_configure-arch: configure_doc_flags="-DWITH_DOC=OFF -DWITH_DOC_MANPAGES=ON" -override_dh_auto_configure-indep: configure_doc_flags="-DWITH_DOC=ON" +ifneq ($(filter pkg.apt.nodoxygen,$(DEB_BUILD_PROFILES)),) +override_dh_auto_configure-arch: configure_doc_flags=-DWITH_DOC=OFF -DWITH_DOC_MANPAGES=ON +override_dh_auto_configure-indep: configure_doc_flags=-DWITH_DOC=OFF -DWITH_DOC_GUIDES=ON -DWITH_DOC_EXAMPLES=ON else -override_dh_auto_configure-arch: configure_doc_flags="-DWITH_DOC=OFF" -override_dh_auto_configure-indep: configure_doc_flags="-DWITH_DOC=OFF" +ifneq ($(filter nodoc,$(DEB_BUILD_PROFILES)),) +override_dh_auto_configure-arch: configure_doc_flags=-DWITH_DOC=OFF +override_dh_auto_configure-indep: configure_doc_flags=-DWITH_DOC=OFF +else +override_dh_auto_configure-arch: configure_doc_flags=-DWITH_DOC=OFF -DWITH_DOC_MANPAGES=ON +override_dh_auto_configure-indep: configure_doc_flags=-DWITH_DOC=ON +endif endif override_dh_auto_configure-arch override_dh_auto_configure-indep: -- cgit v1.2.3-70-g09d2 From 065c17440bd030341d7729c626dc732eff48ff7e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 20 Apr 2022 18:09:21 +0200 Subject: Use build-dep & satisfy for our CI dependency resolution As the name suggests the command was introduced for the travis CI which used to be based on a fixed old(er) ubuntu release. The service is no more (at least not like it was) and nowadays the command runs in unstable or equivalent environments, so can depend a bit more on apt features we have implemented years ago instead of duck tapping. --- prepare-release | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/prepare-release b/prepare-release index 5eef65276..7e417912c 100755 --- a/prepare-release +++ b/prepare-release @@ -25,29 +25,6 @@ librarysymbolsfromfile() { done | sort -u } -test_deb_control() { - echo "Package: apt-test-depends" - echo "Version: 1.0" - echo "Architecture: all" - printf "Depends:" - ( - for i in Build-Depends Build-Depends-Indep Build-Depends-Arch; do - grep-dctrl -ns $i -S apt ./debian/control && echo , - done - grep-dctrl -ns Depends -F Tests run-tests ./debian/tests/control - ) | tr '\n' ' '\ - | sed -r -e 's#<[^,<>()@]*>##g' \ - -e 's#@[^,<>()@]*@##g' \ - -e 's#\[linux-any\]*##g' \ - -e 's#\[[^][]*\]*##g' \ - -e 's#dpkg-dev \([^)]*\)#dpkg-dev#g' \ - -e 's#debhelper \([^)]*\)#debhelper#g' \ - -e 's#g\+\+ \([^)]*\)#g++#g' \ - -e 's#@##g' \ - -e 's#,(\s+,)+#, #g' \ - -e 's#\s+# #g' -} - if [ "$1" = 'pre-export' ]; then libraryversioncheck() { local LIBRARY="$1" @@ -185,11 +162,11 @@ elif [ "$1" = 'buildlog' ]; then shift done elif [ "$1" = 'travis-ci' ]; then - apt-get install -qy --no-install-recommends dctrl-tools equivs gdebi-core moreutils - - test_deb_control > test-control - equivs-build test-control - gdebi -n apt-test-depends_1.0_all.deb + apt-get build-dep -qy . + apt-get install -qy --no-install-recommends dctrl-tools + for t in $(grep '^Tests: ' debian/tests/control | cut -d':' -f 2- | tr ',' '\n'); do + apt-get satisfy -qy --no-install-recommends "base-files,$(grep-dctrl -ns Depends -F Tests $t ./debian/tests/control | sed -e 's#@[^,<>()@]*@\s*,\s*##g' -e 's#@\s*,\s*##g')" + done elif [ "$1" = 'coverage' ]; then DIR="${2:-./coverage}" git clean -dfX # remove ignored build artifacts for a clean start @@ -387,7 +364,7 @@ Both will format the diff properly. \t$0 coverage [output-dir] »travis-ci« is a shortcut to install all build- as well as test-dependencies -used by .travis.yml. +used in .gitlab-ci.yml and other CI infrastructure. »coverage« does a clean build with the right flags for coverage reporting, runs all tests and generates a html report in the end. -- cgit v1.2.3-70-g09d2 From a48a432223e9feb3e70b6d7dee09d035f594eeed Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 20 Apr 2022 18:42:12 +0200 Subject: Mark pkg-config-test autopkgtest as superficial Reorganising the control file allows this simple test to run first and be marked as superficial which makes no practical difference, but is more correct. --- debian/tests/control | 13 +++++++------ debian/tests/pkg-config-test | 31 ++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/debian/tests/control b/debian/tests/control index 446f0afcc..e273b737f 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -1,10 +1,11 @@ -Tests: run-tests, pkg-config-test +Tests: pkg-config-test +Restrictions: superficial +Depends: libapt-pkg-dev, pkg-config + +Tests: run-tests Restrictions: allow-stderr Depends: @, @builddeps@, dpkg (>= 1.20.8), fakeroot, wget, stunnel4, lsof, db-util, - gnupg (>= 2) | gnupg2, - gnupg1 | gnupg (<< 2), - gpgv (>= 2) | gpgv2, - gpgv1 | gpgv (<< 2), + gnupg (>= 2) | gnupg2, gnupg1 | gnupg (<< 2), + gpgv (>= 2) | gpgv2, gpgv1 | gpgv (<< 2), libfile-fcntllock-perl, python3-apt, aptitude, - pkg-config, valgrind, gdb-minimal | gdb diff --git a/debian/tests/pkg-config-test b/debian/tests/pkg-config-test index 1e4ec141e..e074b1603 100644 --- a/debian/tests/pkg-config-test +++ b/debian/tests/pkg-config-test @@ -1,23 +1,32 @@ #!/bin/sh - set -e -WORKDIR=$(mktemp -d) -trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM -cd $WORKDIR -cat < pkgconfigtest.c +if [ -z "$AUTOPKGTEST_TMP" ]; then + WORKDIR='' + cleanup() { + if [ -n "$WORKDIR" ]; then cd /; rm -rf -- "$WORKDIR"; fi + WORKDIR='' + } + trap 'cleanup' 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM + WORKDIR="$(mktemp -d)" + cd "$WORKDIR" +else + cd "$AUTOPKGTEST_TMP" +fi + +cat >pkgconfigtest.cc < -#include +#include int main() { - printf("Apt Version: %s \n", pkgVersion); + printf("APT Version: %s\n", pkgVersion); return 0; } EOF -g++ -o pkgconfigtest pkgconfigtest.c `pkg-config --cflags --libs apt-pkg` -echo "build: OK" -[ -x pkgconfigtest ] +g++ -Wall -Wextra -o pkgconfigtest pkgconfigtest.cc `pkg-config --cflags --libs apt-pkg` +echo 'build: OK' +test -x pkgconfigtest ./pkgconfigtest -echo "run: OK" +echo 'run: OK' -- cgit v1.2.3-70-g09d2 From ee06eb541e5aa477880ff0fc575be317eccbd929 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 20 Apr 2022 18:51:47 +0200 Subject: Avoid building inside the source dir in autopkgtest autopkgtest says: Tests may not modify the source tree (and may not have write access to it). We don't really modify the source of course, but we created our build/ directory in the tree, which seems to work just fine (for now), but lets be nice. --- .gitlab-ci.yml | 1 + debian/tests/run-tests | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93a577ad2..700f29b0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,4 +37,5 @@ test as user: - sudo -u travis env -C build cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja .. - sudo -u travis --preserve-env=CCACHE_DIR,CCACHE_BASEDIR ninja -C build - sudo -u travis CTEST_OUTPUT_ON_FAILURE=1 ninja -C build test + - chmod -R o-w $PWD - sudo -u travis unbuffer ./test/integration/run-tests -q -j 4 diff --git a/debian/tests/run-tests b/debian/tests/run-tests index ff3359fae..461042641 100644 --- a/debian/tests/run-tests +++ b/debian/tests/run-tests @@ -1,19 +1,30 @@ #!/bin/sh - set -e -if [ ! -e build/CMakeCache.txt ]; then - mkdir build || true - ( cd build && cmake .. ) +SOURCE_DIR="$(pwd)" +if [ -z "$AUTOPKGTEST_TMP" ]; then + BUILD_DIR='' + cleanup() { + if [ -n "$BUILD_DIR" ]; then cd /; rm -rf -- "$BUILD_DIR"; fi + BUILD_DIR='' + } + trap 'cleanup' 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM + BUILD_DIR="$(mktemp -d)" +else + BUILD_DIR="$AUTOPKGTEST_TMP" +fi + +if [ ! -e "${BUILD_DIR}/CMakeCache.txt" ]; then + cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" fi -make -C build/test/interactive-helper +make -C "${BUILD_DIR}/test/interactive-helper" # run tests against the installed apt, use "env -i" to ensure # the host env does not pollute our environment env -i \ -APT_INTEGRATION_TESTS_SOURCE_DIR=$(pwd) \ -APT_INTEGRATION_TESTS_HELPERS_BIN_DIR=$(pwd)/build/test/interactive-helper \ +APT_INTEGRATION_TESTS_SOURCE_DIR="${SOURCE_DIR}" \ +APT_INTEGRATION_TESTS_HELPERS_BIN_DIR="${BUILD_DIR}/test/interactive-helper" \ 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 \ @@ -23,4 +34,4 @@ APT_INTEGRATION_TESTS_BUILD_DIR=/usr/bin \ APT_INTEGRATION_TESTS_FTPARCHIVE_BIN_DIR=/usr/bin \ APT_INTEGRATION_TESTS_LIBRARY_PATH=/dev/null/does/not/exist \ APT_INTEGRATION_TESTS_ARTIFACTS_DIR="${AUTOPKGTEST_ARTIFACTS}" \ -./test/integration/run-tests -q +"${SOURCE_DIR}/test/integration/run-tests" -q -- cgit v1.2.3-70-g09d2 From 8d8b45a96ceceb015f7836cf25b99279c2f377b9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 21 Apr 2022 01:45:45 +0200 Subject: 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. --- CMakeLists.txt | 2 + debian/tests/run-tests | 6 +-- po/CMakeLists.txt | 4 ++ test/integration/create-test-data | 2 - test/integration/framework | 51 ++++++++++------------ test/integration/test-apt-helper-cat-file | 2 +- .../test-no-fds-leaked-to-maintainer-scripts | 6 +-- 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}) -- cgit v1.2.3-70-g09d2 From 8fd65748589bb1e0b671d4a291521bfba1664c5c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 21 Apr 2022 03:01:22 +0200 Subject: Remove unused public zlib include from libapt fileutl.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our public interface doesn't use zlib for quite a while now so lets drop the last remnants as hopefully nobody depends on us bringing it in… Unlike our own private lib for transitive provision of unistd.h. References: 680b916ce7203a40ebd0a3882b9a71ca77278a67 --- apt-pkg/contrib/fileutl.h | 3 --- apt-private/private-cmndline.cc | 1 + apt-private/private-json-hooks.cc | 1 + debian/control | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index dd16aa754..f4eefd7c2 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -28,9 +28,6 @@ #include #include -#include - - /* Define this for python-apt */ #define APT_HAS_GZIP 1 diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index e9af3a8c2..f607c4ccc 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/apt-private/private-json-hooks.cc b/apt-private/private-json-hooks.cc index 957140525..a17204dda 100644 --- a/apt-private/private-json-hooks.cc +++ b/apt-private/private-json-hooks.cc @@ -22,6 +22,7 @@ #include #include #include +#include /** * @brief Simple JSON writer diff --git a/debian/control b/debian/control index 7a91e0f05..58c6be15e 100644 --- a/debian/control +++ b/debian/control @@ -112,7 +112,6 @@ Multi-Arch: same Priority: optional Pre-Depends: ${misc:Pre-Depends} Depends: libapt-pkg (= ${binary:Version}), - zlib1g-dev, ${misc:Depends} Section: libdevel Description: development files for APT's libapt-pkg and libapt-inst -- cgit v1.2.3-70-g09d2 From ccc6abd872fdbb443e0378addfd85e420b05a59a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 21 Apr 2022 12:28:12 +0200 Subject: Run ./prepare-release post-build checks in Gitlab CI The checks mostly deal with verifying the syntax of the documentation files and the po4a translations which have no tests otherwise. --- .gitlab-ci.yml | 2 ++ prepare-release | 29 ++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 700f29b0a..d1711d51b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,6 +19,8 @@ test as root: - sudo -u travis mkdir -p build .ccache - sudo -u travis env -C build cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja .. - sudo -u travis --preserve-env=CCACHE_DIR,CCACHE_BASEDIR ninja -C build + - apt-get install --no-install-recommends -qq libxml2-utils + - ./prepare-release post-build --report-failure - CTEST_OUTPUT_ON_FAILURE=1 ninja -C build test - unbuffer ./test/integration/run-tests -q -j 4 diff --git a/prepare-release b/prepare-release index 7e417912c..39e2250bc 100755 --- a/prepare-release +++ b/prepare-release @@ -7,10 +7,10 @@ if [ -n "${GBP_BUILD_DIR}" ]; then cd "$GBP_BUILD_DIR" fi -VERSION=$(dpkg-parsechangelog | sed -n -e '/^Version:/s/^Version: //p') -DISTRIBUTION=$(dpkg-parsechangelog | sed -n -e '/^Distribution:/s/^Distribution: //p') +VERSION=$(dpkg-parsechangelog -S 'Version') +DISTRIBUTION=$(dpkg-parsechangelog -S 'Distribution') -LIBAPTPKGVERSION="$(awk -v ORS='.' '/^\#define APT_PKG_M/ {print $3}' apt-pkg/contrib/macros.h | sed 's/\.$//')" +LIBAPTPKGVERSION="$(awk -v ORS='.' '/^#define APT_PKG_M/ {print $3}' apt-pkg/contrib/macros.h | sed 's/\.$//')" librarysymbolsfromfile() { local MISSING="$(grep '^+#MISSING' "$1")" @@ -81,7 +81,7 @@ elif [ "$1" = 'pre-build' ]; then echo "You probably want to run »./prepare-release pre-export« to fix this." exit 1 fi - NEWSDISTRIBUTION=$(dpkg-parsechangelog -l debian/NEWS | sed -n -e '/^Distribution:/s/^Distribution: //p') + NEWSDISTRIBUTION=$(dpkg-parsechangelog -l debian/NEWS -S 'Distribution') if [ "$NEWSDISTRIBUTION" = 'UNRELEASED' ]; then echo "changelog (${VERSION}) has a distribution (${DISTRIBUTION}) set, while the NEWS file hasn't!" echo "You probably want to edit »debian/NEWS« to fix this." @@ -89,7 +89,12 @@ elif [ "$1" = 'pre-build' ]; then fi fi elif [ "$1" = 'post-build' ]; then - if [ "$DISTRIBUTION" != "UNRELEASED" ]; then + FAILED=false + REPORT_FAILURE=false + + if [ "$2" = '--report-failure' ]; then + REPORT_FAILURE=true + elif [ "$DISTRIBUTION" != "UNRELEASED" ]; then echo >&2 "REMEMBER: Tag this release with »git tag -s ${VERSION}« if you are satisfied" else echo >&2 'REMEMBER: Change to a valid distribution before release' @@ -103,6 +108,7 @@ elif [ "$1" = 'post-build' ]; then if ! sed -n '1,/^$/p' "$FILE" | cmp "$HEADERBLUEPRINT" - >/dev/null 2>&1; then echo >&2 "WARNING: Manpage $FILE has not the usual header! (see diff below)" sed -n '1,/^$/p' "$FILE" | diff -u "$HEADERBLUEPRINT" - || true + FAILED=true fi done sed -n '1,/^$/p' doc/guide.dbk > "$HEADERBLUEPRINT" @@ -110,30 +116,35 @@ elif [ "$1" = 'post-build' ]; then if ! sed -n '1,/^$/p' "$FILE" | cmp "$HEADERBLUEPRINT" - >/dev/null 2>&1; then echo >&2 "WARNING: Documentation $FILE has not the usual header (see diff below)!" sed -n '1,/^$/p' "$FILE" | diff -u "$HEADERBLUEPRINT" - || true + FAILED=true fi done rm "$HEADERBLUEPRINT" # check the manpages with each vendor for vendor-specific errors… find vendor -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 2 | while read DISTRO; do - ln -sf ../vendor/${DISTRO}/apt-vendor.ent doc - if ! xmllint --nonet --valid --noout $(find doc/ -maxdepth 1 -name '*.xml'); then + if ! xmllint --path vendor/${DISTRO} --nonet --valid --noout $(find doc/ -maxdepth 1 -name '*.xml'); then echo >&2 "WARNING: original docbook manpages have errors with vendor ${DISTRO}!" + FAILED=true fi done # lets assume we will always have a german manpage translation if [ -e */doc/de/ -o -e doc/de ]; then # … but check the translations only with one vendor for translation-specific errors - if ! xmllint --path /vendor/$(./vendor/getinfo current)/ \ + if ! xmllint --path vendor/$(./vendor/getinfo current)/ \ --path doc/ \ --nonet --valid --noout $(find doc/ */doc/ -mindepth 2 -maxdepth 2 -name '*.xml'); then echo >&2 "WARNING: translated docbook manpages have errors!" + FAILED=true fi else echo >&2 "ERROR: translated manpages need to be build before they can be checked!" + FAILED=true fi - rm -f doc/apt-vendor.ent + if $REPORT_FAILURE && $FAILED; then + exit 1 + fi elif [ "$1" = 'library' ]; then librarysymbols() { local libname=$(echo "${1}" | cut -c 4-) -- cgit v1.2.3-70-g09d2 From cacf80aea3f1511aa1d8436fd4fd49d916390d10 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 21 Apr 2022 12:47:47 +0200 Subject: Do not build documentation twice in CI The documentation will not realistically vary between architectures so building it twice is just wasting time and resources. --- .gitlab-ci.yml | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d1711d51b..487437847 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,24 +3,29 @@ variables: DEBIAN_FRONTEND: noninteractive CCACHE_DIR: $CI_PROJECT_DIR/.ccache CCACHE_BASEDIR: $CI_PROJECT_DIR + APT_CMAKE_BUILD_OPTIONS: '' + DEB_BUILD_PROFILES: '' cache: paths: - .ccache - -test as root: - stage: test - script: +before_script: - adduser --home /home/travis travis --quiet --disabled-login --gecos "" --uid 1000 - rm -f /etc/dpkg/dpkg.cfg.d/excludes - apt-get update - - apt-get install -qq build-essential expect sudo ccache + - apt-get install --no-install-recommends -qq build-essential expect sudo ccache moreutils + - chmod 755 /root - chmod -R o+rwX $PWD - ./prepare-release travis-ci - sudo -u travis mkdir -p build .ccache - - sudo -u travis env -C build cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja .. + - sudo -u travis env -C build cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ${APT_CMAKE_BUILD_OPTIONS} -G Ninja .. - sudo -u travis --preserve-env=CCACHE_DIR,CCACHE_BASEDIR ninja -C build - - apt-get install --no-install-recommends -qq libxml2-utils - - ./prepare-release post-build --report-failure + +test as root: + stage: test + variables: + APT_CMAKE_BUILD_OPTIONS: '-DWITH_DOC=OFF -DUSE_NLS=OFF' + DEB_BUILD_PROFILES: 'nodoc' + script: - CTEST_OUTPUT_ON_FAILURE=1 ninja -C build test - unbuffer ./test/integration/run-tests -q -j 4 @@ -28,16 +33,8 @@ test as user: image: i386/debian:unstable stage: test script: - - adduser --home /home/travis travis --quiet --disabled-login --gecos "" --uid 1000 - - rm -f /etc/dpkg/dpkg.cfg.d/excludes - - apt-get update - - apt-get install -qq build-essential expect sudo ccache - - chmod 755 /root - - chmod -R o+rwX $PWD - - ./prepare-release travis-ci - - sudo -u travis mkdir -p build .ccache - - sudo -u travis env -C build cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja .. - - sudo -u travis --preserve-env=CCACHE_DIR,CCACHE_BASEDIR ninja -C build + - apt-get install --no-install-recommends -qq libxml2-utils + - ./prepare-release post-build --report-failure - sudo -u travis CTEST_OUTPUT_ON_FAILURE=1 ninja -C build test - chmod -R o-w $PWD - sudo -u travis unbuffer ./test/integration/run-tests -q -j 4 -- cgit v1.2.3-70-g09d2 From e5aa5c04ecbd3cdab611794cebf9eb3aa8cbddd4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 21 Apr 2022 12:51:20 +0200 Subject: Ignore stty failures in testcases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We use 'stty sane' to combat against stepped output and co caused by (especially) failed tests, but it does so many things that it occasionally fails to reset some bits in the parallel interaction we have with it which fails the tests without a real problem in apt… Ideally we would be better at stitching the output together, but for the time being lets ignore these failures instead to stabilize the tests. --- test/integration/run-tests | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/run-tests b/test/integration/run-tests index f5a39f244..c1cc780f0 100755 --- a/test/integration/run-tests +++ b/test/integration/run-tests @@ -80,9 +80,9 @@ if [ -n "$TESTTORUN" ]; then fi } >"$OUTPUT" 2>&1 # without we end up getting stepped output 'randomly' - stty sane + stty sane || true cat >&2 "$OUTPUT" - stty sane + stty sane || true if [ "$FAIL" = 'yes' ]; then exit 1 else -- cgit v1.2.3-70-g09d2 From 320245536a7ad21606286d9dcf54acf3bdf096c6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 22 Apr 2022 17:05:36 +0200 Subject: Include our config.h in all C++ files to avoid ODR violations Some of our headers use APT_COMPILING_APT trickery to avoid exposing too broadly details we don't want external clients to know and make use of. The flip-side is that this can lead to different compilation units seeing different definitions if they aren't all using the same config. --- apt-pkg/contrib/proxy.cc | 2 ++ apt-pkg/metaindex.cc | 2 ++ apt-pkg/statechanges.cc | 2 ++ apt-private/private-json-hooks.cc | 1 + ftparchive/sources.cc | 2 ++ prepare-release | 5 +++++ test/interactive-helper/createdeb-cve-2020-27350.cc | 2 ++ test/interactive-helper/test_fileutl.cc | 2 ++ test/libapt/extracttar_test.cc | 2 ++ test/libapt/file-helpers.cc | 2 ++ test/libapt/gtest_runner.cc | 4 +++- 11 files changed, 25 insertions(+), 1 deletion(-) diff --git a/apt-pkg/contrib/proxy.cc b/apt-pkg/contrib/proxy.cc index 6dc3b0686..a99f44f49 100644 --- a/apt-pkg/contrib/proxy.cc +++ b/apt-pkg/contrib/proxy.cc @@ -7,6 +7,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/metaindex.cc b/apt-pkg/metaindex.cc index fc03f3db0..97996b3f1 100644 --- a/apt-pkg/metaindex.cc +++ b/apt-pkg/metaindex.cc @@ -1,4 +1,6 @@ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/statechanges.cc b/apt-pkg/statechanges.cc index 45468e462..bbcde71d3 100644 --- a/apt-pkg/statechanges.cc +++ b/apt-pkg/statechanges.cc @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/apt-private/private-json-hooks.cc b/apt-private/private-json-hooks.cc index a17204dda..ddf1c89d6 100644 --- a/apt-private/private-json-hooks.cc +++ b/apt-private/private-json-hooks.cc @@ -5,6 +5,7 @@ * * SPDX-License-Identifier: GPL-2.0+ */ +#include #include #include diff --git a/ftparchive/sources.cc b/ftparchive/sources.cc index ee6efda05..a59224395 100644 --- a/ftparchive/sources.cc +++ b/ftparchive/sources.cc @@ -1,3 +1,5 @@ +#include + #include #include diff --git a/prepare-release b/prepare-release index 39e2250bc..988ccabad 100755 --- a/prepare-release +++ b/prepare-release @@ -142,6 +142,11 @@ elif [ "$1" = 'post-build' ]; then FAILED=true fi + if [ "$(find -name '*.cc' ! -name 'tagfile-keys.cc' -exec grep --files-without-match '^#include $' '{}' \+ | wc -l)" != '0' ]; then + echo >&2 'WARNING: C++ files not including our config.h can cause ODR violations!' + find -name '*.cc' ! -name 'tagfile-keys.cc' -exec grep --files-without-match '^#include $' '{}' \+ >&2 + FAILED=true + fi if $REPORT_FAILURE && $FAILED; then exit 1 fi diff --git a/test/interactive-helper/createdeb-cve-2020-27350.cc b/test/interactive-helper/createdeb-cve-2020-27350.cc index 7fc9b0e55..57c53ae91 100644 --- a/test/interactive-helper/createdeb-cve-2020-27350.cc +++ b/test/interactive-helper/createdeb-cve-2020-27350.cc @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/test/interactive-helper/test_fileutl.cc b/test/interactive-helper/test_fileutl.cc index 6c29b748f..5569af1bf 100644 --- a/test/interactive-helper/test_fileutl.cc +++ b/test/interactive-helper/test_fileutl.cc @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/test/libapt/extracttar_test.cc b/test/libapt/extracttar_test.cc index ae74341e6..c945a0c68 100644 --- a/test/libapt/extracttar_test.cc +++ b/test/libapt/extracttar_test.cc @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/test/libapt/file-helpers.cc b/test/libapt/file-helpers.cc index 85fc6838e..bb7052b2a 100644 --- a/test/libapt/file-helpers.cc +++ b/test/libapt/file-helpers.cc @@ -1,3 +1,5 @@ +#include + #include #include diff --git a/test/libapt/gtest_runner.cc b/test/libapt/gtest_runner.cc index 5620aa0bd..09fc55d92 100644 --- a/test/libapt/gtest_runner.cc +++ b/test/libapt/gtest_runner.cc @@ -1,10 +1,12 @@ -#include +#include #include #include #include #include +#include + int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); if (pkgInitSystem(*_config, _system) == false) -- cgit v1.2.3-70-g09d2 From 018cf7c225837b65e2b146788f786685629a5b12 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 22 Apr 2022 17:49:06 +0200 Subject: Ship our README.md in apt package The rest of our documentation files is in apt-docs, but this one is general and small enough to be in the default install so users have an easier time finding information like how to reach us and some debug advice. --- debian/apt.docs | 1 + 1 file changed, 1 insertion(+) create mode 100644 debian/apt.docs diff --git a/debian/apt.docs b/debian/apt.docs new file mode 100644 index 000000000..b43bf86b5 --- /dev/null +++ b/debian/apt.docs @@ -0,0 +1 @@ +README.md -- cgit v1.2.3-70-g09d2