100 Commits
Author SHA1 Message Date
Julian Andres Klode dccfe14ffb Release 2.5.3 2022-09-28 17:34:34 +02:00
Julian Andres Klode 5f5a8deedf full-upgrade: Mark phased upgrades for keep before anything else
By marking them at the end, we might make other decisions that
depend on the new phased updates, confusing the solver. Run the
marking at the start too.

The EDSP test file from Jeremy was modified to include Machine-ID
and Phased-Update-Percentage fields and then filtered to mostly
exclude packages irrelevant to the test case by running

    grep-dctrl   \( -FRequest "EDSP 0.5" -o -FInstalled yes \
                    -oFPhased-Update-Percentage 10  \)  \
                -a --not -FArchitecture i386

LP: #1990586
2022-09-28 16:32:44 +02:00
Julian Andres Klode f93a5aa2da Check state of dependency, not dependee in dependency keep back
When iterating over I's dependencies (which are called Pkg), we
accidentally checked if I was Protected() instead of Pkg when deciding
whether Pkg can be kept back.

LP: #1990684
2022-09-28 16:32:44 +02:00
Julian Andres Klode 28e44a3cd8 edsp: Add support for phased updates (test in LP#1990586)
Add Machine-ID to the first stanza, and copy Phased-Update-Percentage
to package stanzas.

This will be tested at a later state by the EDSP test case for
bug 1990586.
2022-09-28 16:32:34 +02:00
Julian Andres Klode 2d87af57ea Release 2.5.2 2022-07-24 18:00:08 +02:00
Julian Andres Klode c28fc7366c Add NEWS entry 2022-07-24 16:29:59 +02:00
Julian Andres Klode 518746f7e0 Add flag to disable upgrade by source and test case 2022-07-24 15:44:13 +02:00
Julian Andres Klode c4bab3c935 Avoid recursion by looping of other binaries twice
First mark them for upgrade without autoInst, so we don't call
their "mark other binaries loop"; then call them again with it.

Without this change, each binary package would upgrade the next
one in the list, recursively.
2022-07-24 15:27:18 +02:00
Julian Andres Klode 119a8d0ed1 Upgrade all binaries in a source package
Schedule all other binaries in the source package for upgrade if
the candidate version belongs to the same source version as the
package we are upgrading.

This will significantly reduce the risk of partial upgrades and
should make life a lot easier.
2022-07-24 15:27:18 +02:00
Julian Andres Klode 07fe16bcc6 Add test cases 2022-07-11 18:06:59 +02:00
Julian Andres Klode e481022470 Let the auto installer loose for non-broken packages too
Because the auto installer now also marks other binaries in the
package for upgrade, we do need to run it or we don't mark those
for upgrade.
2022-07-11 16:37:35 +02:00
Julian Andres Klode e077370ffc Mark broken reverse depends for upgrade
Currently the solver handles cases where a Breaks b (<< 1) and
if we install that a, upgrades b. However, where b Depends a (= 1),
b was removed again.

This addresses the problem by iterating over installed reverse
dependencies of upgrades and upgrading them so that both cases
work roughly similarly.

LP: #1974196
2022-07-11 16:37:33 +02:00
Julian Andres Klode 0163492684 Release 2.5.1 2022-06-30 13:28:23 +02:00
Julian Andres Klode 8416bcb58c test-phased-updates-upgrade: Tests with arguments
Pass some package names to upgrade to see that that works

Gbp-Dch: ignore
2022-06-30 13:21:19 +02:00
Julian Andres Klode 20739359fa policy: Do not override negative pins with 1 due to phasing
If a package is already pinned to a negative value, we should not
override this with a positive 1. This causes packages to be installable
that were pinned to -1, which is not intended.

For this, implement phasing as a ceiling of 1 for the pin instead
of a fixed 1 value. An alternative would have been to fix it to
NEVER_PIN, but that would mean entirely NEW packages would not be
installable while phasing which is not the intention either.

LP: #1978125
2022-06-28 14:54:42 +02:00
Julian Andres Klode db131677be (Temporarily) Rewrite phased updates using a keep-back approach
This is a lot closer to the original implementation in update-manager,
but still has a couple of differences that might cause bugs:

- When checking whether a version is a security update, we only
  check versions in between and not any later version. This happens
  mostly because we do not know the suite, so we just check if there
  is any version between the installed version and our target that
  is a security update

- We only keep already installed packages, as we run before the
  resolver. update-manager first runs the resolver, and then marks
  for keep all packages that were upgraded or newly installed that
  are phasing (afaict).

This approach has a significant caveat that if you have version 1
installed from a release pocket, version 2 is in security, and version
3 is phasing in updates, that it installs version 3 rather than 2
from security as the policy based implementation does.

It also means that apt install does not respect phasing and would
always install version 3 in such a scenario.

LP: #1979244
2022-06-28 14:25:18 +02:00
Julian Andres Klode 5a042d8c8e Release 2.5.0 2022-05-17 18:50:49 +02:00
Julian Andres Klode f15178f139 tests: Add g++ dependency to pkg-config test 2022-05-17 18:50:09 +02:00
Julian Andres Klode c6dbd6be7b Do not accept arguments for apt-cache dotty, xvcg
These commands do not actually interpret the same
arguments as depends, or any own ones for that matter.

Gbp-Dch: full
2022-05-06 18:16:35 +02:00
Julian Andres Klode 72782263dc Release 2.4.5 2022-04-08 12:23:25 +02:00
Julian Andres Klode 863421c52a Fix segfault in CacheSetHelperAPTGet::tryVirtualPackage()
We forgot to check whether Archive() and Codename() exist in
the first place, sigh. Maybe we should return empty strings
instead of nullptr.

Reported-By: Johannes 'josch' Schauer Marin Rodrigues on IRC
2022-04-07 18:25:43 +02:00
Julian Andres Klode 824651ded0 Only protect two kernels, not last installed one
The kernel autoremoval algorithm was written to accomodate
for Ubuntu's boot partition sizing, which was written to
accomodate 3 kernels - 2 installed ones + a new one being
unpacked.

It seems that when the algorithm was designed, it was overlooked
that it actually kept 3 kernels.

LP: #1968154
2022-04-07 13:19:52 +02:00
Julian Andres Klode 098a5843dc Release 2.3.13 2021-11-24 16:24:51 +01:00
Julian Andres Klode 312e7d7310 Release 2.3.12
This release is dedicated to Linus Tech Tips.
2021-11-17 18:31:12 +01:00
Julian Andres Klode 1d1a92241e Release 2.3.12 2021-11-17 18:29:58 +01:00
Julian Andres Klode 891efe3b20 Do not remove Essential/Protected due to dependencies
Suggesting the removal of Essential and Protected packages as a
solution leads to situations where YouTubers end up removing their
desktop.

Let's not remove such packages ourselves.
2021-11-17 17:32:18 +01:00
Julian Andres Klode 21cc694f55 Require argument to remove essential packages, do not prompt
Let's make this one step harder.
2021-11-17 17:21:03 +01:00
Julian Andres Klode f4c4f05766 Release 2.3.11 2021-10-21 12:21:53 +02:00
Julian Andres Klode 307912e8d7 Invalidate cached architecture list when building cache
Fix a regression in python-apt where switching the architectures
in the config between cache invocations regressed.

Regression-Of: 8ff4e226af
Gbp-Dch: full
2021-10-19 18:25:51 +02:00
Julian Andres Klode 400a689556 Respect NO_COLOR environment variable
When color has not been turned on explictly in the configuration
file or options, only turn it on if NO_COLOR is not set.
2021-10-19 15:38:22 +02:00
Julian Andres Klode 4a73fd686a Release 2.3.10 2021-10-18 16:36:14 +02:00
Julian Andres Klode dcbae50530 Only allow full Signed-By keys where filenames are allowed
Rename the argument to Introducer and generalize it to anything
that introduces new keys into the trusted vector, like file names
and full keys.
2021-10-18 16:12:54 +02:00
Julian Andres Klode 3f07f5345e Add support for embedding PGP keys into Signed-By in deb822 sources
Extend the Signed-By field to handle embedded public key blocks,
this allows shipping self-contained .sources files, making it
substantially easier to provide third party repositories.
2021-10-18 16:12:54 +02:00
Julian Andres Klode c8e5008794 acquire-item: Quote Signed-By before sending it
This currently has no effect, as there are no quotable characters
inside it, but it will allow us to send embedded keys through to
the method.
2021-10-18 15:49:10 +02:00
Julian Andres Klode 883a12310a Release 2.3.9 2021-09-07 17:27:09 +02:00
Julian Andres Klode e664bdcfb2 Improve error handling of cycling delayed queues
When an item has been delayed and the queue is cycled to start
it, we did not properly report an error from the cycling, and
we would then fail in the assert(), causing all errors to be
lost.

Propagate the error instead and make the assert a warning.
2021-09-06 16:51:27 +02:00
Julian Andres Klode 7dbf6b0506 Release 2.3.8 2021-08-14 23:52:09 +02:00
Julian Andres Klode 2f510c5632 Bump to C++17
Comparison operators need to be const-invocable now, but
otherwise no change seems necessary.
2021-08-09 22:24:43 +02:00
Julian Andres Klode 6442107478 Release 2.3.7 2021-07-29 17:00:26 +02:00
Julian Andres Klode 3ca5e18b1f tests (retry-downloads): Avoid delay in second test
This delay of 4+2+1=7 seconds in unnecessary.
2021-07-29 11:50:16 +02:00
Julian Andres Klode 70ee96670b Enhance test to check time spent
This is subject to clock skew, unfortunately, as we cannot read
monotonic time in shell.

We check for >=5s out of the 7s it should take to reduce the
risk of skew a bit.
2021-07-29 11:49:59 +02:00
Julian Andres Klode 4001af8920 Add support for a maximum delay and testing of delay
This is very basic support on the testing side, we just test
the debug output but not how long it actually took. Would be
nice to check time really.
2021-07-28 13:08:35 +02:00
Julian Andres Klode 51ee79e385 Properly convert PulseInterval to timeval
Fix the typo, and use the helper function to convert it, so we
do not end up with 5 seconds encoded as 0s and 5*10^6 microseconds.
2021-07-28 13:08:35 +02:00
Julian Andres Klode 48a7ece8d0 Convert to monotonic clock
This yields more accurate delays and avoids issues with clock
skew.
2021-07-28 13:08:35 +02:00
Julian Andres Klode 7e88def054 acquire: Automatically reduce select() timeout as needed
If there is an item with fetchAfter at the top of a queue,
reduce sleep() timeout so we can detect it and start it,
by calling Cycle() on the queue in the next iteration.

For some reasons we have to call select() with a 0s timeout
if we just marked an item as ready. Oh well.

Previous versions of this patch only called global Bump() after a timeout
from select(); this was unfortunately incorrect - it meant that we
never bumped a queue that did not start yet while other queues were
running, potentially significantly delaying retries.
2021-07-28 13:08:32 +02:00
Julian Andres Klode 121ccd0e0c Implement exponential delay between retries
Add a new Item field called FetchAfter, which determines the earliest
time the item should be fetched at. Adjust insertion into queue to
take it into account alongside priority, and only fill pipelines
with items that are ready.
2021-07-28 13:04:10 +02:00
Julian Andres Klode 363e3a4c91 pkgAcqIndex::CommonFailed: Set StatIdle before calling Init()
Enqueuing by calling Init(), and then resetting the status to
idle means that the item can get enqueued twice if we call
Cycle() from inside pkgAcquire::Run().

Reset the status to StatIdle before calling Init()
2021-07-13 16:16:55 +02:00
Julian Andres Klode fe4201380b Set haveContent to FALSE on Content-Length: 0
Set haveContent to HaveContent::FALSE when Content-Length is 0,
and change remaining code to only set it to TRUE if it has not
been set so far.

Closes: #990281
2021-07-01 15:47:48 +02:00
Julian Andres Klode f9e2e91499 basehttp: Turn HaveContent into a TriState
We need to be able to set HaveContent to false if the Content-Length
is 0, and not have that overriden just because a later header is
Content-Type.
2021-07-01 15:35:21 +02:00
Julian Andres Klode 690f6191a4 Check sources.list could be parsed before adding volatile files
We just used the pointer returned which might be nullptr, properly
call BuildSourceList() and check the result first.

Closes: #990518
2021-07-01 11:34:04 +02:00
Julian Andres Klode 06da685fc1 Release 2.3.6 2021-06-09 13:42:02 +02:00
Julian Andres Klode aeae140b11 Release 2.3.5 2021-05-17 11:43:54 +02:00
Julian Andres Klode 81eb944c76 policy: Apply phasing to uninstalled packages too
If a package is not installed yet, we do need to apply
phasing as we otherwise get into weird situations when
installing packages:

In the launchpad bug below, ubuntu-release-upgrader-core
was installed, and hence the phasing for the upgrade to it
was applied. However, ubuntu-release-upgrader-gtk was about
to be installed - and hence the phasing did not apply, causing
a version mismatch, because ubuntu-release-upgrader-gtk from
-updates was used, but -core from release pocket. Sigh.

An alternative approach to dealing with this issue could be to
apply phasing to all packages within the same source package,
which would work in most cases. However, there might be unforeseen
side effects and it is of course possible to have = depends between
source packages, such as -signed packages on the unsigned ones for
bootloaders.

This problem does not occur in the update-manager implementation
of phased updates as update-manager only deals with upgrading packages,
but does not install new packages and thus does not see that issue. APT
however, has to apply phasing more broadly, as you can and often do
install additional packages during upgrade, or upgrade packages during
install commands, as both accept package list arguments and have the
same code in the backend.

LP: #1925745
2021-05-17 10:25:28 +02:00
Julian Andres Klode 1be9dc6371 Release 2.3.4 2021-05-12 18:06:32 +02:00
Julian Andres Klode 2129ffecc0 Turn TLS handshake issues into transient errors
This makes them retriable, and brings them more into line with
TCP, where handshake is also a transient error.

LP: #1928100
2021-05-12 13:06:11 +02:00
Julian Andres Klode 6fe716703b Merge branch 'master' of https://github.com/kraj/apt
See https://github.com/Debian/apt/pull/129
2021-05-05 12:14:11 +02:00
Julian Andres Klode 51b5ed3273 Release 2.3.3 2021-04-29 10:45:32 +02:00
Julian Andres Klode b60cda7992 Temporarily Revert "2.3-only: Warn that the 0.1 protocol is deprecated"
This reverts commit 6412747863.
2021-04-29 10:42:59 +02:00
Julian Andres Klode 408f4e0d32 Release 2.3.2 2021-04-23 18:26:34 +02:00
Julian Andres Klode 502fc4c325 doc: Single-line JSON encoding is still mandatory
Gbp-Dch: ignore
2021-04-23 17:43:56 +02:00
Julian Andres Klode a7f2152f0c Support deconfiguring Essential packages
dpkg 1.20.8 also made --force-remove-essential optional for
deconfiguring essential packages, so let's do this.

Also extend the test case to make sure we actuall pass
auto-deconfigure and do not make any --remove calls, or
pass --force-remove to dpkg.
2021-04-23 17:13:55 +02:00
Julian Andres Klode 329f0cc365 test/json: Make the test hook more reliable
Ugh, this was super flaky under -j 16 and -j 4, each behaving
in slightly different ways. This seems to be stable now. No
real bug though, all behaviors were OK.
2021-04-23 15:20:45 +02:00
Julian Andres Klode 94cf539796 Avoid infinite loop on EOF on media change prompt
The code missed a break, so it was looping infinitely because
the while loop condition only checked for '\n' and '\r', but not
end of file.
2021-04-23 15:04:32 +02:00
Julian Andres Klode 6412747863 2.3-only: Warn that the 0.1 protocol is deprecated 2021-04-23 12:26:46 +02:00
Julian Andres Klode 80dd144759 json: Hook protocol 0.2 (added upgrade,downgrade,reinstall modes)
Hook protocol 0.2 makes the new fields we added mandatory, and
replaces `install` mode with `upgrade`, `downgrade`, `reinstall`
where appropriate.

Hook negotiation is hacky, but it's the best we can do for now.
Users are advised to upgrade to 0.2
2021-04-23 12:26:46 +02:00
Julian Andres Klode dc11a4422d json: Add package-list and statistics install hooks
This enables hooks to output additional information.
2021-04-23 12:26:46 +02:00
Julian Andres Klode de86a4b076 upgrade: Add JSON hook support (AptCli::Hooks::Upgrade) 2021-04-23 12:26:46 +02:00
Julian Andres Klode 4b5215e8e2 json: Add origins fields to version
Provide access to the origins of a package, such that tools
can display information about them; for example, you can write
a hook counting security upgrades.
2021-04-23 12:26:46 +02:00
Julian Andres Klode 949f382126 test: Set -e in our test hook
Gbp-Dch: ignore
2021-04-23 12:25:40 +02:00
Julian Andres Klode 0ed07360cd json: Flush standard file descriptors before calling hooks
This ensures messages are displayed in the correct order.
2021-04-23 12:25:40 +02:00
Julian Andres Klode b5211b9b21 json: Encode NULL strings as null
This is the only nullable thing we have here.
2021-04-23 12:25:40 +02:00
Julian Andres Klode 09e3c0c855 json: Actually pop states
The JSON encoder only looked at the top state, but did not
pop it, so if we nested objects, we got stuck in whatever
the last state we pushed aside was, so in our example, we
wrongly get a comma inserted _after_ key "b":

{"a":[{}],
 "b":,[{}]
}
2021-04-23 12:25:40 +02:00
Julian Andres Klode 57b727af4e json: Escape strings using \u escape sequences, add test
This allows us to correctly encode strings containing quotation
marks, escape characters and control characters.

The test case is a bit nasty because it embeds private-cachefile.cc
for linkage reasons.
2021-04-23 12:25:40 +02:00
Julian Andres Klode 6cb80d1eb2 Do not pass --force-remove-protected with --auto-deconfigure
dpkg 1.20.8 no longer requires this.
2021-04-21 11:49:50 +02:00
Julian Andres Klode 30f47dc8d6 Require dpkg >= 1.20.8
We use a Breaks for the binary package instead of adding
a versioned depends, as Breaks will cause apt solver to upgrade dpkg,
while depends would make apt try to remove apt as first choice.
2021-04-21 11:49:50 +02:00
Julian Andres Klode 10631550f1 Automatically retry failed downloads 3 times
Enable the Acquire::Retries option by default, set to 3.
This will help with slightly unreliable networking; future
work is needed for adding backoff and SRV/IP rotation.

LP: #1876035
Gbp-Dch: full
2021-04-15 19:36:47 +02:00
Julian Andres Klode 9d95c64be8 Remove inversed comment for AllowUnsizedPackages
It defaults to false, like the other options there do.
2021-04-13 17:52:07 +02:00
Julian Andres Klode 8f84d45b7b Release 2.3.1 2021-04-13 17:26:59 +02:00
Julian Andres Klode e59d47fbde debian/gbp.conf: HEAD branch is main now 2021-04-13 17:23:03 +02:00
Julian Andres Klode 1412cf5140 Error on packages without a Size field (option Acquire::AllowUnsizedPackages)
Repositories without Size information for packages are not
proper and need fixing. This ensures people see an error in
CI, and get notifications and hence the ability to fix it.

It can be turned off by setting Acquire::AllowUnsizedPackages
to true.
2021-04-13 16:00:41 +02:00
Julian Andres Klode 27a4fb3a9a Fix downloads of unsized files that are largest in pipeline
The maximum request size is accidentally set to any sized file,
so if an unsized file is present, and it turns out to be larger
than the maximum size we set, we'd error out when checking if
its size is smaller than the maximum request size.

LP: #1921626
2021-04-13 16:00:41 +02:00
Julian Andres Klode 8613225f31 Check for and discard expected warning from MaybeAddAuth
MaybeAddAuth() here tells us that it refused to use the credentials
for an http source; but that caused the test suite to fail at a later
stage because we checked if there were any errors/warning. Strangely,
this is only triggered with LTO enabled.

Actually check that the warning is being set and then reject it.
2021-03-31 15:29:09 +02:00
Julian Andres Klode ade9d3c41d Release 2.3.0 2021-03-08 11:51:58 +01:00
Julian Andres Klode 3a7aecd232 Revert "Branch of as 2.2.y for bullseye"
This reverts commit d96c9a0280.
It is not correct for master.
2021-03-01 22:30:05 +01:00
Julian Andres Klode 757304ce49 Merge tag '2.2.1'
apt Debian release 2.2.1
2021-03-01 22:29:12 +01:00
Julian Andres Klode 16b905aabc Release 2.2.1 2021-03-01 22:28:15 +01:00
Julian Andres Klode 0d51cf1428 regression fix: do require force-loopbreak for Conflicts
Conflicts do require removing the package temporarily, so they really
should not be used.

We need to improve that eventually such that we can deconfigure packages
when we have to remove their dependencies due to conflicts.
2021-03-01 21:43:54 +01:00
Julian Andres Klode 8eccb902aa RunScripts: Do not reset SIGQUIT and SIGINT to SIG_DFL
This caused python-apt to unset the Python signal handler when running
update or install commands, breaking KeyboardInterrupt amongst possibly
other things.

We do not set those signal handlers in this functions, and the calling
functions restore signal handlers to previous ones.

LP: #1898026
2021-03-01 21:26:24 +01:00
Julian Andres Klode ad59f1d7f1 Remove .travis.yml, we are using GitLab CI these days 2021-02-24 10:55:09 +01:00
Julian Andres Klode fb6f4070cd configuration: Add missing #include <array>
As user "DaOfficialRolex" on GitHub pointed out:

This is needed to allow for APT on iOS to compile correctly. If not included the two following errors happen while compiling APT.

~/apt/apt-pkg/contrib/configuration.cc:900:44: error: constexpr variable cannot have non-literal type 'const std::array<APT::StringView, 3>'
         constexpr std::array<APT::StringView, 3> magicComments { "clear"_sv, "include"_sv, "x-apt-configure-index"_sv };
                                                  ^
~/apt/apt-pkg/contrib/configuration.cc:900:44: error: implicit instantiation of undefined template 'std::__1::array<APT::StringView, 3>'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__tuple:219:64: note: template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
                                                               ^
2021-02-24 10:47:51 +01:00
Julian Andres Klode d96c9a0280 Branch of as 2.2.y for bullseye 2021-02-23 21:58:45 +01:00
Julian Andres Klode f8ff3afcd4 Do not require force-loopbreak on Protected packages
dpkg will be changed in 1.20.8 to not require --force-remove for
deconfiguration anymore, but we want to decouple our changes from the
dpkg ones, so let's always pass --force-remove-protected when installing
packages such that we can deconfigure protected packages.

Closes: #983014
2021-02-23 19:10:29 +01:00
Julian Andres Klode db391379e1 Release 2.2.0 2021-02-18 20:36:16 +01:00
Julian Andres Klode 0691aea355 symbols: Remove spurios package line, add kernel autoremoval helper 2021-02-18 15:36:51 +01:00
Julian Andres Klode 5bfc150688 kernels: Avoid std::regex for escaping '.' and '+'
std::regex pulls in about 50 weak symbols which is complete and
utter madness, especially because we version all our symbols, so no
other library could ever reuse them.

Avoid using the regular expression here all together, loop using
string::find_first_of() and insert backslashes with strng::insert().
2021-02-12 17:13:57 +01:00
Julian Andres Klode 3b19861642 Do not make DefaultRootSetFunc2 public symbol 2021-02-12 12:53:57 +01:00
Julian Andres Klode 9fabce10ee Release 2.1.20 2021-02-10 00:05:19 +01:00
Julian Andres Klode ea114447ee Adjust loops to use size_t instead of int
Gbp-Dch: ignore
2021-02-09 23:49:31 +01:00
Julian Andres Klode 6284c8221d Fix test suite regression from StrToNum fixes
We ignored the failure from strtoul() that those test cases had values
out of range, hence they passed before, but now failed on 32-bit
platforms because we use strtoull() and do the limit check ourselves.

Move the tarball generator for test-github-111-invalid-armember to the
createdeb helper, and fix the helper to set all the numbers for like uid
and stuff to 0 instead of the maximum value the fields support (all 7s).

Regression-Of: e0743a85c5
2021-02-09 23:33:47 +01:00
Julian Andres Klode e6bdafad65 CI: Run test as user on i386 2021-02-09 23:33:47 +01:00