From 3e24f431d9527816820e103df7db9f39062b551d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 5 Apr 2024 14:02:39 +0000 Subject: Do not ignore if a cmake execute_process fails Ignoring errors might lead to failures later on anyhow, but especially with triehash it could also lead to broken builds or other crazy stuff, so lets better be save than sorry. --- CMake/vendor_substitute.cmake | 3 ++- CMakeLists.txt | 9 ++++++--- apt-pkg/CMakeLists.txt | 12 ++++++++---- vendor/CMakeLists.txt | 3 ++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CMake/vendor_substitute.cmake b/CMake/vendor_substitute.cmake index 71449c9e8..277cb3ac9 100644 --- a/CMake/vendor_substitute.cmake +++ b/CMake/vendor_substitute.cmake @@ -2,7 +2,8 @@ file(READ ${IN} input) foreach(variable ${VARS}) execute_process(COMMAND ${PROJECT_SOURCE_DIR}/vendor/getinfo --vendor ${CURRENT_VENDOR} ${variable} - OUTPUT_VARIABLE value OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE value OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) string(REPLACE "&${variable};" "${value}" input "${input}") endforeach() file(WRITE ${OUT} "${input}") diff --git a/CMakeLists.txt b/CMakeLists.txt index 00ba2e499..11b614af5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,17 +211,20 @@ string(REGEX MATCH "^[0-9.]+" PROJECT_VERSION ${PACKAGE_VERSION}) if (NOT DEFINED DPKG_DATADIR) execute_process(COMMAND ${PERL_EXECUTABLE} -MDpkg -e "print $Dpkg::DATADIR;" - OUTPUT_VARIABLE DPKG_DATADIR_CMD OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE DPKG_DATADIR_CMD OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) message(STATUS "Found dpkg data dir: ${DPKG_DATADIR_CMD}") set(DPKG_DATADIR "${DPKG_DATADIR_CMD}" CACHE PATH "dpkg data directory") endif() if (NOT DEFINED COMMON_ARCH) execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH - OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) endif() if (NOT DEFINED ROOT_GROUP) execute_process(COMMAND id -gn root - OUTPUT_VARIABLE ROOT_GROUP OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE ROOT_GROUP OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) message(STATUS "Found root group: ${ROOT_GROUP}") endif() set(ROOT_GROUP "${ROOT_GROUP}" CACHE STRING "Group of root (e.g.: wheel or root)") diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt index d13aed96c..63052faad 100644 --- a/apt-pkg/CMakeLists.txt +++ b/apt-pkg/CMakeLists.txt @@ -3,7 +3,8 @@ include_directories(${PROJECT_BINARY_DIR}/include/apt-pkg) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/apt-pkg/) execute_process(COMMAND grep -v "^#" "${CMAKE_CURRENT_SOURCE_DIR}/tagfile-keys.list" - OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.clean.list") + OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.clean.list" + COMMAND_ERROR_IS_FATAL ANY) execute_process(COMMAND ${TRIEHASH_EXECUTABLE} --ignore-case --header ${PROJECT_BINARY_DIR}/include/apt-pkg/tagfile-keys.h @@ -13,7 +14,8 @@ execute_process(COMMAND ${TRIEHASH_EXECUTABLE} --function-name pkgTagHash --include "" --include "" - "${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.clean.list") + "${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.clean.list" + COMMAND_ERROR_IS_FATAL ANY) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "tagfile-keys.list") set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.cc" PROPERTIES COMPILE_DEFINITIONS APT_COMPILING_APT) @@ -22,11 +24,13 @@ set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.cc" PROPER execute_process(COMMAND awk -v ORS=. "/^\#define APT_PKG_M/ {print \$3}" COMMAND sed "s/\\.\$//" INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h - OUTPUT_VARIABLE MAJOR OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE MAJOR OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) execute_process(COMMAND grep "^#define APT_PKG_RELEASE" COMMAND cut -d " " -f 3 INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h - OUTPUT_VARIABLE MINOR OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE MINOR OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})") set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index f6d88690a..615d282da 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -1,7 +1,8 @@ # Determine the current vendor, export to CURRENT_VENDOR if (NOT DEFINED CURRENT_VENDOR) execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/getinfo current - OUTPUT_VARIABLE CURRENT_VENDOR_OUT OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE CURRENT_VENDOR_OUT OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) set(CURRENT_VENDOR "${CURRENT_VENDOR_OUT}" CACHE STRING "Select the system vendor") message(STATUS "Detected vendor: ${CURRENT_VENDOR_OUT}") -- cgit v1.2.3-70-g09d2 From 7d93bcabc3f2c47c093faae7b36b7709f287cce2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 3 Apr 2024 12:36:40 +0000 Subject: Avoid figuring which kept pkgs are phased if we don't display it Not all commands show kept back packages, so even if it hardly matters, lets not crunch numbers needlessly if we don't need the info which also reduces the lifetime of the involved variables hopefully also reducing the mental requirements for a reader. --- apt-private/private-install.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 9a2ed0b2a..8d1bc74f0 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -214,16 +214,6 @@ bool InstallPackages(CacheFile &Cache, APT::PackageVector &HeldBackPackages, boo return false; } - APT::PackageVector PhasingPackages; - APT::PackageVector NotPhasingHeldBackPackages; - for (auto const &Pkg : HeldBackPackages) - { - if (Cache->PhasingApplied(Pkg)) - PhasingPackages.push_back(Pkg); - else - NotPhasingHeldBackPackages.push_back(Pkg); - } - // Show all the various warning indicators if (_config->FindI("APT::Output-Version") < 30) ShowDel(c1out,Cache); @@ -234,6 +224,16 @@ bool InstallPackages(CacheFile &Cache, APT::PackageVector &HeldBackPackages, boo ShowWeakDependencies(Cache); if (ShwKept == true) { + APT::PackageVector PhasingPackages; + APT::PackageVector NotPhasingHeldBackPackages; + for (auto const &Pkg : HeldBackPackages) + { + if (Cache->PhasingApplied(Pkg)) + PhasingPackages.push_back(Pkg); + else + NotPhasingHeldBackPackages.push_back(Pkg); + } + ShowPhasing(c1out, Cache, PhasingPackages); ShowKept(c1out, Cache, NotPhasingHeldBackPackages); if (not PhasingPackages.empty() && not NotPhasingHeldBackPackages.empty()) -- cgit v1.2.3-70-g09d2 From e099ee946000797f4c03b8c5075ce7ebba193337 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 3 Apr 2024 19:12:01 +0000 Subject: Match version constraints before saving garbage packages We remove new garbage packages from the solution if we can as installing a new package which is at the same time considered garbage looks silly, but it could also be a new dependency of another garbage package, so we have a second round trying to save such packages. In this round we weren't considering versioned constraints on dependency relations through so even an unsatisfied old recommends could save which it shouldn't. --- apt-private/private-install.cc | 20 ++++++++++++++------ test/integration/test-bug-604222-new-and-autoremove | 21 +++++++++++++++++---- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 8d1bc74f0..4f71f18c4 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -620,12 +621,14 @@ bool DoAutomaticRemove(CacheFile &Cache) for (APT::PackageSet::iterator Pkg = tooMuch.begin(); Pkg != tooMuch.end(); ++Pkg) { - APT::PackageSet too; - too.insert(*Pkg); - for (pkgCache::PrvIterator Prv = Cache[Pkg].CandidateVerIter(Cache).ProvidesList(); - Prv.end() == false; ++Prv) - too.insert(Prv.ParentPkg()); - for (APT::PackageSet::const_iterator P = too.begin(); P != too.end(); ++P) + auto const PkgCand = Cache[Pkg].CandidateVerIter(Cache); + if (unlikely(PkgCand.end())) + continue; + std::vector> too; + too.emplace_back(*Pkg, PkgCand.VerStr()); + for (pkgCache::PrvIterator Prv = PkgCand.ProvidesList(); not Prv.end(); ++Prv) + too.emplace_back(Prv.ParentPkg(), Prv.ProvideVersion()); + for (auto const &[P, PVerStr] : too) { for (pkgCache::DepIterator R = P.RevDependsList(); R.end() == false; ++R) @@ -650,6 +653,11 @@ bool DoAutomaticRemove(CacheFile &Cache) } else // ignore dependency from a non-candidate version continue; + if (R->Version != 0) + { + if (not Cache->VS().CheckDep(PVerStr, R->CompareOp, R.TargetVer())) + continue; + } if (Debug == true) std::clog << "Save " << APT::PrettyPkg(Cache, Pkg) << " as another installed package depends on it: " << APT::PrettyPkg(Cache, RP) << std::endl; Cache->MarkInstall(Pkg, false, 0, false); diff --git a/test/integration/test-bug-604222-new-and-autoremove b/test/integration/test-bug-604222-new-and-autoremove index 47da810c6..adb2c26d3 100755 --- a/test/integration/test-bug-604222-new-and-autoremove +++ b/test/integration/test-bug-604222-new-and-autoremove @@ -17,8 +17,21 @@ insertpackage 'stable' 'libkf5kipi-bin' 'i386' '4:16.08.0-1' insertpackage 'stable' 'libkf5kipi-data' 'i386' '4:16.08.0-1' 'Breaks: libkipi-data' insertpackage 'stable' 'libkipi-data' 'i386' '4:15.08.0-1' '' 'important' +insertpackage 'stable' 'libgphoto2-l10n' 'all' '2' +insertpackage 'installed,stable' 'photoapp1' 'all' '1' 'Recommends: libgphoto2-l10n (= 1)' +insertinstalledpackage 'photoapp2' 'all' '1' +insertpackage 'stable' 'photoapp2' 'all' '2' 'Conflicts: photoapp1 +Recommends: libgphoto2-l10n (= 2)' + setupaptarchive +testsuccessequal 'Reading package lists... +Building dependency tree... +Calculating upgrade... +The following packages have been kept back: + photoapp2 +0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.' apt upgrade -s + insertinstalledpackage 'libvtk5.4' 'i386' '5.4.2-7' testsuccess aptmark markauto 'libvtk5.4' testmarkedauto 'libvtk5.4' @@ -36,7 +49,7 @@ The following package was automatically installed and is no longer required: Use '$AUTOREMOVE' to remove it. The following NEW packages will be installed: libavcodec52 -0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded. +0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded. Inst libavcodec52 (4:0.5.2-6 stable [i386]) Conf libavcodec52 (4:0.5.2-6 stable [i386])" aptget install libavcodec52 -s @@ -47,7 +60,7 @@ Reading state information... Use '$AUTOREMOVE' to remove it. The following NEW packages will be installed: libavcodec52 -0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded. +0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded. Inst libavcodec52 (4:0.5.2-6 stable [i386]) Conf libavcodec52 (4:0.5.2-6 stable [i386])" aptget install libavcodec52 -s -o APT::Get::HideAutoRemove=small @@ -61,7 +74,7 @@ The following additional packages will be installed: libavcodec52 libopenal-dev The following NEW packages will be installed: dummy-archive libavcodec52 libopenal-dev -0 upgraded, 3 newly installed, 0 to remove and 1 not upgraded. +0 upgraded, 3 newly installed, 0 to remove and 2 not upgraded. Need to get 0 B/126 B of archives. After this operation, 129 kB of additional disk space will be used. E: Trivial Only specified but this is not a trivial operation." aptget install dummy-archive --trivial-only @@ -74,7 +87,7 @@ The following additional packages will be installed: libavcodec52 libopenal-dev The following NEW packages will be installed: dummy-archive libavcodec52 libopenal-dev -0 upgraded, 3 newly installed, 0 to remove and 1 not upgraded. +0 upgraded, 3 newly installed, 0 to remove and 2 not upgraded. Need to get 0 B/126 B of archives. After this operation, 129 kB of additional disk space will be used. E: Trivial Only specified but this is not a trivial operation." aptget install dummy-archive --trivial-only -o APT::Get::HideAutoRemove=small -- cgit v1.2.3-70-g09d2 From d030a1041b243c45dcd41e34d3c2b21cf1a533ba Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 14 Mar 2024 20:59:10 +0000 Subject: Do not upgrade rev-deps ear-marked for removal We schedule reverse dependencies for an upgrade, but we shouldn't do it if we have ear-marked this package for removal later on. Usually the solver will end up doing the right thing like it already did in the included testcase in the end, but given that before it reaches the right end it explored a bad path which can lead to more installs and removals influencing later decisions or are just too hard for the resolver to undo later on, we can just not explore this path to begin with. References: e077370ffcb3669a50a600e80356c2002e6b176d --- apt-pkg/depcache.cc | 7 ++- .../integration/test-not-upgrading-removed-depends | 50 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100755 test/integration/test-not-upgrading-removed-depends diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 76a5c09ba..72cbf8dcc 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1463,7 +1463,7 @@ static bool MarkInstall_RemoveConflictsIfNotUpgradeable(pkgDepCache &Cache, bool return not failedToRemoveSomething; } /*}}}*/ -static bool MarkInstall_CollectReverseDepends(pkgDepCache &Cache, bool const DebugAutoInstall, pkgCache::VerIterator const &PV, unsigned long Depth, APT::PackageVector &toUpgrade) /*{{{*/ +static bool MarkInstall_CollectReverseDepends(pkgDepCache &Cache, bool const DebugAutoInstall, pkgCache::VerIterator const &PV, unsigned long Depth, APT::PackageVector &toUpgrade, APT::PackageVector const &delayedRemove) /*{{{*/ { auto CurrentVer = PV.ParentPkg().CurrentVer(); if (CurrentVer.end()) @@ -1474,6 +1474,9 @@ static bool MarkInstall_CollectReverseDepends(pkgDepCache &Cache, bool const Deb // Skip non-installed versions and packages already marked for upgrade if (ParentPkg.CurrentVer() != D.ParentVer() || Cache[ParentPkg].Install()) continue; + // Skip rev-depends we already tagged for removal + if (Cache[ParentPkg].Delete() || std::find(delayedRemove.begin(), delayedRemove.end(), ParentPkg) != delayedRemove.end()) + continue; // We only handle important positive dependencies, RemoveConflictsIfNotUpgradeable handles negative if (not Cache.IsImportantDep(D) || D.IsNegative()) continue; @@ -1722,7 +1725,7 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg, bool AutoInst, return false; hasFailed = true; } - if (not MarkInstall_CollectReverseDepends(*this, DebugAutoInstall, PV, Depth, toUpgrade)) + if (not MarkInstall_CollectReverseDepends(*this, DebugAutoInstall, PV, Depth, toUpgrade, delayedRemove)) { if (failEarly) return false; diff --git a/test/integration/test-not-upgrading-removed-depends b/test/integration/test-not-upgrading-removed-depends new file mode 100755 index 000000000..54b20422c --- /dev/null +++ b/test/integration/test-not-upgrading-removed-depends @@ -0,0 +1,50 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" +setupenvironment +configarchitecture 'amd64' + +insertpackage 'unstable' 'untouchable-for-solving' 'all' '1' 'Conflicts: main' +insertpackage 'installed' 'bad' 'all' '1' 'Depends: main (= 1)' +insertpackage 'unstable' 'bad' 'all' '2' 'Depends: main (= 2), untouchable-for-solving' + +insertpackage 'installed' 'main' 'all' '1' +insertpackage 'unstable' 'main' 'all' '2' 'Breaks: bad' + +insertpackage 'unstable' 'else' 'all' '1' +insertpackage 'unstable' 'meta' 'all' '1' 'Depends: main (= 2) | else' + +setupaptarchive + +testsuccessequal 'Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + bad +The following packages will be upgraded: + main +1 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv bad [1] +Inst main [1] (2 unstable [all]) +Conf main (2 unstable [all])' apt install -s main +testsuccess apt install -s main -o Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::Marker=1 -o Debug::pkgDepCache::AutoInstall=1 +testfailure grep 'untouchable-for-solving' rootdir/tmp/testsuccess.output +testsuccessequal 'Reading package lists... +Building dependency tree... +The following additional packages will be installed: + main +The following packages will be REMOVED: + bad +The following NEW packages will be installed: + meta +The following packages will be upgraded: + main +1 upgraded, 1 newly installed, 1 to remove and 0 not upgraded. +Remv bad [1] +Inst main [1] (2 unstable [all]) +Inst meta (1 unstable [all]) +Conf main (2 unstable [all]) +Conf meta (1 unstable [all])' apt install -s meta +testsuccess apt install -s meta -o Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::Marker=1 -o Debug::pkgDepCache::AutoInstall=1 +testfailure grep 'untouchable-for-solving' rootdir/tmp/testsuccess.output -- cgit v1.2.3-70-g09d2 From 9c06578c37ff77b70b9d978d48528df13e13530f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 23 Apr 2024 16:13:46 +0000 Subject: Drop sudo-related envvars in testing framework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our autoremoval-advertisment is modified by SUDO_USER as if the current apt call was made with sudo it seems a good idea to show the ad with sudo as well. That is annoying for our tests through as normally the tests are run locally or by autopkgtest without sudo, but in Gitlab CI we use it (to run our tests as user… as we are already root) and so individual tests had to deal with this. That is annoying and really not needed as we can have our autoremove test check that this ad gets displayed the right way and ignore it the rest of the time. --- test/integration/framework | 1 + test/integration/test-apt-get-autoremove | 26 +++++++++++++--------- .../integration/test-bug-604222-new-and-autoremove | 13 ++++------- test/integration/test-bug-611729-mark-as-manual | 8 +------ .../test-bug-613420-new-garbage-dependency | 8 ++----- test/integration/test-disappearing-packages | 13 +---------- .../test-external-dependency-solver-protocol | 6 +---- test/integration/test-kernel-helper-autoremove | 10 +++------ 8 files changed, 29 insertions(+), 56 deletions(-) diff --git a/test/integration/framework b/test/integration/framework index 147de9808..de280cb8d 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -324,6 +324,7 @@ setupenvironment() { unset DEB_CHECK_COMMAND DEB_SIGN_KEYID DEB_BUILD_OPTIONS DEB_BUILD_PROFILES unset DH_VERBOSE DH_QUIET DH_COMPAT DH_NO_ACT DH_OPTIONS DH_EXTRA_ADDONS unset GREP_OPTIONS POSIXLY_CORRECT + unset SUDO_USER SUDO_UID SUDO_GID SUDO_COMMAND unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy export GCOV_ERROR_FILE=/dev/null diff --git a/test/integration/test-apt-get-autoremove b/test/integration/test-apt-get-autoremove index 66257f442..9454df5c8 100755 --- a/test/integration/test-apt-get-autoremove +++ b/test/integration/test-apt-get-autoremove @@ -27,10 +27,6 @@ testdpkginstalled 'po-debconf' 'unrelated' echo 'unrelated purge' | dpkg --set-selections testdpkgstatus 'pi' '1' 'unrelated' -AUTOREMOVE='apt autoremove' -if [ -n "$SUDO_USER" ]; then - AUTOREMOVE="sudo $AUTOREMOVE" -fi echo 'APT::NeverAutoRemove { "^debc.*nf$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove testsuccessequal 'Reading package lists... Building dependency tree... @@ -39,20 +35,28 @@ The following packages will be REMOVED: po-debconf 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. Remv po-debconf [1.0.16]' aptget autoremove -s -testequal "Reading package lists... +for sudouser in '_apt' ''; do + if [ -n "$sudouser" ]; then + export SUDO_USER="$sudouser" + AUTOREMOVE='sudo apt autoremove' + else + unset SUDO_USER + AUTOREMOVE='apt autoremove' + fi + testequal "Reading package lists... Building dependency tree... Reading state information... The following package was automatically installed and is no longer required: po-debconf Use '$AUTOREMOVE' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -testequal "Reading package lists... + testequal "Reading package lists... Building dependency tree... Reading state information... 1 package was automatically installed and is no longer required. Use '$AUTOREMOVE' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small -testequal "Reading package lists... + testequal "Reading package lists... Building dependency tree... Reading state information... Calculating upgrade... @@ -60,6 +64,8 @@ The following package was automatically installed and is no longer required: po-debconf Use '$AUTOREMOVE' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget upgrade -s +done + testsuccessequal 'Reading package lists... Building dependency tree... Reading state information... @@ -111,7 +117,7 @@ Reading state information... Calculating upgrade... The following package was automatically installed and is no longer required: po-debconf -Use '$AUTOREMOVE' to remove it. +Use 'apt autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget upgrade -s rm -f rootdir/etc/apt/apt.conf.d/autoremoval @@ -163,13 +169,13 @@ Building dependency tree... Reading state information... The following packages were automatically installed and are no longer required: debhelper po-debconf -Use '$AUTOREMOVE' to remove them. +Use 'apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s testequal "Reading package lists... Building dependency tree... Reading state information... 2 packages were automatically installed and are no longer required. -Use '$AUTOREMOVE' to remove them. +Use 'apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small testsuccess aptmark hold debhelper diff --git a/test/integration/test-bug-604222-new-and-autoremove b/test/integration/test-bug-604222-new-and-autoremove index adb2c26d3..78a288214 100755 --- a/test/integration/test-bug-604222-new-and-autoremove +++ b/test/integration/test-bug-604222-new-and-autoremove @@ -36,17 +36,12 @@ insertinstalledpackage 'libvtk5.4' 'i386' '5.4.2-7' testsuccess aptmark markauto 'libvtk5.4' testmarkedauto 'libvtk5.4' -AUTOREMOVE='apt autoremove' -if [ -n "$SUDO_USER" ]; then - AUTOREMOVE="sudo $AUTOREMOVE" -fi - testsuccessequal "Reading package lists... Building dependency tree... Reading state information... The following package was automatically installed and is no longer required: libvtk5.4 -Use '$AUTOREMOVE' to remove it. +Use 'apt autoremove' to remove it. The following NEW packages will be installed: libavcodec52 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded. @@ -57,7 +52,7 @@ testsuccessequal "Reading package lists... Building dependency tree... Reading state information... 1 package was automatically installed and is no longer required. -Use '$AUTOREMOVE' to remove it. +Use 'apt autoremove' to remove it. The following NEW packages will be installed: libavcodec52 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded. @@ -69,7 +64,7 @@ Building dependency tree... Reading state information... The following package was automatically installed and is no longer required: libvtk5.4 -Use '$AUTOREMOVE' to remove it. +Use 'apt autoremove' to remove it. The following additional packages will be installed: libavcodec52 libopenal-dev The following NEW packages will be installed: @@ -82,7 +77,7 @@ testequal "Reading package lists... Building dependency tree... Reading state information... 1 package was automatically installed and is no longer required. -Use '$AUTOREMOVE' to remove it. +Use 'apt autoremove' to remove it. The following additional packages will be installed: libavcodec52 libopenal-dev The following NEW packages will be installed: diff --git a/test/integration/test-bug-611729-mark-as-manual b/test/integration/test-bug-611729-mark-as-manual index 63f8245a7..bd9af32b6 100755 --- a/test/integration/test-bug-611729-mark-as-manual +++ b/test/integration/test-bug-611729-mark-as-manual @@ -56,14 +56,8 @@ testdpkginstalled b c testmarkedauto 'b' sed -i rootdir/var/log/apt/history.log -e '/^Commandline: / d' -e '/^Start-Date: / d' -e '/^End-Date: / d' -if [ -n "$SUDO_USER" ] && [ "$(id -u "$SUDO_USER")" -gt 0 ]; then - testfileequal 'rootdir/var/log/apt/history.log' " -Requested-By: $SUDO_USER ($(id -u "$SUDO_USER")) -Reinstall: b:i386 (1.0)" -else - testfileequal 'rootdir/var/log/apt/history.log' ' +testfileequal 'rootdir/var/log/apt/history.log' ' Reinstall: b:i386 (1.0)' -fi testsuccessequal 'Reading package lists... Building dependency tree... diff --git a/test/integration/test-bug-613420-new-garbage-dependency b/test/integration/test-bug-613420-new-garbage-dependency index 46c3d94c9..75a653c7e 100755 --- a/test/integration/test-bug-613420-new-garbage-dependency +++ b/test/integration/test-bug-613420-new-garbage-dependency @@ -16,17 +16,13 @@ setupaptarchive touch rootdir/var/lib/apt/extended_states testsuccess aptmark markauto openoffice.org-officebean testmarkedauto openoffice.org-officebean -AUTOREMOVE='apt autoremove' -if [ -n "$SUDO_USER" ]; then - AUTOREMOVE="sudo $AUTOREMOVE" -fi testfailureequal "Reading package lists... Building dependency tree... Reading state information... The following packages were automatically installed and are no longer required: libreoffice-officebean openoffice.org-officebean -Use '$AUTOREMOVE' to remove them. +Use 'apt autoremove' to remove them. The following additional packages will be installed: libreoffice-core libreoffice-officebean openoffice.org-officebean The following packages will be REMOVED: @@ -43,7 +39,7 @@ testequal "Reading package lists... Building dependency tree... Reading state information... 2 packages were automatically installed and are no longer required. -Use '$AUTOREMOVE' to remove them. +Use 'apt autoremove' to remove them. The following additional packages will be installed: libreoffice-core libreoffice-officebean openoffice.org-officebean The following packages will be REMOVED: diff --git a/test/integration/test-disappearing-packages b/test/integration/test-disappearing-packages index f3fed04f3..f93e10e74 100755 --- a/test/integration/test-disappearing-packages +++ b/test/integration/test-disappearing-packages @@ -60,23 +60,12 @@ all files have been overwritten by other packages: Note: This is done automatically and on purpose by dpkg.' tail -n 4 disappear.output sed -i rootdir/var/log/apt/history.log -e '/^Commandline: / d' -e '/^Start-Date: / d' -e '/^End-Date: / d' -e "s#:$(getarchitecture 'native') #:native #" -if [ -n "$SUDO_USER" ] && [ "$(id -u "$SUDO_USER")" -gt 0 ]; then - testfileequal 'rootdir/var/log/apt/history.log' " -Requested-By: $SUDO_USER ($(id -u "$SUDO_USER")) -Install: old-pkg:native (1) - -Requested-By: $SUDO_USER ($(id -u "$SUDO_USER")) -Install: new-pkg:native (2, automatic) -Upgrade: old-pkg:native (1, 2) -Disappeared: old-pkg (1)" -else - testfileequal 'rootdir/var/log/apt/history.log' ' +testfileequal 'rootdir/var/log/apt/history.log' ' Install: old-pkg:native (1) Install: new-pkg:native (2, automatic) Upgrade: old-pkg:native (1, 2) Disappeared: old-pkg (1)' -fi testmarkedauto # new-pkg should have get the manual flag from old-pkg diff --git a/test/integration/test-external-dependency-solver-protocol b/test/integration/test-external-dependency-solver-protocol index 485a77068..ca6a5ae8b 100755 --- a/test/integration/test-external-dependency-solver-protocol +++ b/test/integration/test-external-dependency-solver-protocol @@ -113,17 +113,13 @@ Remv somestuff [1] Remv cool [1] Remv stuff [1]' aptget autoremove --solver apt somestuff -s -AUTOREMOVE='apt autoremove' -if [ -n "$SUDO_USER" ]; then - AUTOREMOVE="sudo $AUTOREMOVE" -fi testsuccessequal "Reading package lists... Building dependency tree... Reading state information... Execute external solver... The following package was automatically installed and is no longer required: stuff -Use '$AUTOREMOVE' to remove it. +Use 'apt autoremove' to remove it. The following packages will be REMOVED: cool* somestuff* 0 upgraded, 0 newly installed, 2 to remove and 1 not upgraded. diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index 208bd1425..20a09685a 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -45,10 +45,6 @@ testprotected() { testfailure --nomsg grep -e '^\^linux-image-amd64\$$' -e '^\^linux-image-686-pae\$$' -e ':i386' protected.list } -AUTOREMOVE='apt autoremove' -if [ -n "$SUDO_USER" ]; then - AUTOREMOVE="sudo $AUTOREMOVE" -fi testsuccessequal "Reading package lists... Building dependency tree... Reading state information... @@ -60,7 +56,7 @@ The following packages were automatically installed and are no longer required: ${CURRENTKERNEL}+variant (5-1) ${CURRENTKERNEL}-686-pae:i386 (5-1) ${CURRENTKERNEL}-dbg (5-1) -Use '$AUTOREMOVE' to remove them. +Use 'apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV -o APT::Protect-Kernels=0 testsuccessequal "Reading package lists... Building dependency tree... @@ -74,13 +70,13 @@ The following packages were automatically installed and are no longer required: ${CURRENTKERNEL}-686-pae:i386 (5-1) ${CURRENTKERNEL}-dbg (5-1) ${CURRENTKERNEL}-rt (5-1) -Use '$AUTOREMOVE' to remove them. +Use 'apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV --ignore-hold -o APT::Protect-Kernels=0 testequal "Reading package lists... Building dependency tree... Reading state information... 7 packages were automatically installed and are no longer required. -Use '$AUTOREMOVE' to remove them. +Use 'apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small -o APT::Protect-Kernels=0 testequal "Reading package lists... Building dependency tree... -- cgit v1.2.3-70-g09d2 From 7a1063e81b855ac7ff9ee54f115843c3af6dd1bf Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 4 Apr 2024 13:36:24 +0000 Subject: Add test for dealing with unsat Suggests promoted to Recommends Our code does the right thing currently, so lets add a test to ensure this keeps being the case in the future. --- .../test-suggests-promoted-to-recommends | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 test/integration/test-suggests-promoted-to-recommends diff --git a/test/integration/test-suggests-promoted-to-recommends b/test/integration/test-suggests-promoted-to-recommends new file mode 100755 index 000000000..57497f7d9 --- /dev/null +++ b/test/integration/test-suggests-promoted-to-recommends @@ -0,0 +1,65 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" +setupenvironment +configarchitecture 'amd64' + +insertinstalledpackage 'oldrec' 'all' '1' +insertinstalledpackage 'oldsug' 'all' '1' +insertinstalledpackage 'instreg' 'all' '1' +insertinstalledpackage 'instsug' 'all' '1' + +insertpackage 'unstable' 'unsatrec' 'all' '2' +insertpackage 'unstable' 'unsatsug' 'all' '2' +insertpackage 'unstable' 'newrec' 'all' '2' +insertpackage 'unstable' 'newsug' 'all' '2' +insertpackage 'unstable' 'promote' 'all' '2' + +insertinstalledpackage 'foo' 'all' '1' 'Recommends: oldrec, instrec, unsatrec +Suggests: oldsug, instsug, unsatsug, promote' +insertpackage 'unstable' 'foo' 'all' '2' 'Recommends: instrec, unsatrec, promote, newrec +Suggests: instsug, unsatsug, newsug' + +setupaptarchive + +testsuccess aptmark auto oldrec instrec oldsug instsug + +testsuccessequal "Reading package lists... +Building dependency tree... +Reading state information... +Calculating upgrade... +The following packages were automatically installed and are no longer required: + oldrec oldsug +Use 'apt autoremove' to remove them. +The following NEW packages will be installed: + newrec promote +The following packages will be upgraded: + foo +1 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst foo [1] (2 unstable [all]) +Inst newrec (2 unstable [all]) +Inst promote (2 unstable [all]) +Conf foo (2 unstable [all]) +Conf newrec (2 unstable [all]) +Conf promote (2 unstable [all])" apt full-upgrade -s + +testsuccessequal "Reading package lists... +Building dependency tree... +Reading state information... +Calculating upgrade... +The following packages were automatically installed and are no longer required: + oldrec oldsug +Use 'apt autoremove' to remove them. +The following NEW packages will be installed: + newrec newsug +The following packages will be upgraded: + foo +1 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst foo [1] (2 unstable [all]) +Inst newrec (2 unstable [all]) +Inst newsug (2 unstable [all]) +Conf foo (2 unstable [all]) +Conf newrec (2 unstable [all]) +Conf newsug (2 unstable [all])" apt full-upgrade -s --install-suggests -- cgit v1.2.3-70-g09d2