summaryrefslogtreecommitdiff
path: root/apt-pkg
Commit message (Collapse)AuthorAgeFilesLines
* solver3: Avoid std::vector for statically sized arraysJulian Andres Klode2025-02-072-26/+70
| | | | | | | | | | The bounds checking on the vector accesses is killing performance, so switch from vector to a basic array, given that we don't actually need _any_ functionality from vector... Of course while we are at it, let us define a safe wrapper around it so we cannot accidentally index arrays for package IDs with version IDs and whatnot.
* solver3: Add const where helpfulJulian Andres Klode2025-02-072-10/+24
| | | | | operator[] is a bit annoying here, but oh well, what can we do?
* solver3: Point to stored clauses, do not copy themJulian Andres Klode2025-02-072-38/+41
| | | | | | This makes Work trivially destructible, and in turn solved, allowing their queues to be destructed without running destructors, and avoiding the copy should have a nice performance improvement.
* solver3: Use a package clause for optional rootsJulian Andres Klode2025-02-072-6/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of iterating over the version here and picking it, just enqueue the package as well, which should allow us to select the version at a later time. This also causes a funny inverse problem now, though, as was evidenced in one of the test cases: To summarize, if our optional roots are all single items, they will be considered soft-unit, causing them to be processed in order. However it can be that an optional root has a specific version selected because another version was rejected. Consider X Conflicts A (= 1) A, B have 2 versions: '2' available, '1' installed B (= n) Depends A (= n) Run `apt install X`. The expected result is for A and B to be upgraded to version 2. With only a package root, if B appears in the cache before A however, we will get: Install X Reject A (= 1) Install B Install B (= 1) # keep it installed Reject A (= 2) => A is being removed as both versions are rejected Hence we do also need to re-introduce the additional version clause, now we get: Install X Reject A (= 1) Install A (= 2) # it got "promoted" to a 'stronger' soft-unit Install B Fail B (= 1) # keep it installed Install B (= 2) Introduce a root state to hold all the clauses that don't have another owner. moo
* solver3: Refactor Dump() to toString()Julian Andres Klode2025-02-072-54/+27
| | | | | This vastly simplifies the code at the expense of performance, lol.
* solver3: Support comparing packages and versionsJulian Andres Klode2025-02-071-8/+15
| | | | | | | | | | | When comparing packages, we compare the best version for the package. To determine the best version, the rules for comparisons are applied normally. This allows us to mix packages and versions in a clause as the solutions for a dependency, which means we'll be able to defer the selection of a particular version of a package to a later time.
* solver3: Replace PropagateInstall() with Discover()Julian Andres Klode2025-02-072-93/+83
| | | | | | | | | | | | | | | Just propagate the stored clauses after we have discovered them; this is quite straightforward. We now more reliably discover common dependencies at the package level, adjust the test case accordingly. The next step is to make discovery recursive, or iterative, to build an entire recursive tree from all roots, and then we can reject reverse dependencies based on it. A bunch of refactorings are needed in the process. We remove the useless Hint enumeration and insert a flags struct into the State, such that we can record whether a package/version has been discovered, to avoid spending double time on discovery.
* solver3: Extract TranslateOrGroup() out of EnqueueOrGroup()Julian Andres Klode2025-02-072-40/+42
| | | | | | | This is not *purely* a refactoring, we accidentally used the version of the dependency when enqueuing conflicts rather than the reason, so the conflict string in the test case is different; the logging had the same issue.
* solver3: Extract Clause out of WorkJulian Andres Klode2025-02-072-66/+86
| | | | | Extract clause into a separate struct and embed a copy of it in our Work class.
* solver3: Simplify WhyStr()Julian Andres Klode2025-02-071-16/+5
| | | | Reuse the generic variable rendering
* solver3: Cache all configuration callsJulian Andres Klode2025-02-072-9/+10
|
* solver3: Cache calls to policyJulian Andres Klode2025-02-072-6/+22
| | | | It's a bit silly otherwise.
* solver3: Propagate single choice clauses as factsJulian Andres Klode2025-02-072-10/+12
| | | | | | | | | | | | This removes a bunch of complexity, and generalizes the propagation behavior, such that we don't need to do if (w.solutions.size() == 1 && not w.optional) Enqueue() else AddWork(w); in our callers.
* solver3: Annotate all bool functions with [[nodiscard]]Julian Andres Klode2025-02-071-12/+12
| | | | | It is very important that we check the return value of all these functions, otherwise the logic is wrong.
* solver3: Early exit when propagating satisfied clausesJulian Andres Klode2025-02-071-4/+5
|
* solver3: Partially generalize work items from Version to VarJulian Andres Klode2025-02-072-31/+46
| | | | | | | | Store all possible solutions and choices as Var. Currently any Var in here must be a Version because CompareProviders3 cannot compare versions against packages yet, but in the future (TM), this will allow storing packages directly in clauses, which allows defering version selection to a later point.
* solver3: Simplify work orderingJulian Andres Klode2025-02-071-14/+4
| | | | | | | | | | Moving the optional != b.optional comparison ahead of the group one allows us to get a better behavior; and now we avoid the nested if. Also remove the special cases that ordered based on the reason of the work item, these have been superseded by groups a while ago.
* solver3: Drop unused upgrade flagJulian Andres Klode2025-02-072-5/+3
| | | | This was leftover from before the groups were added.
* dpkg: Pass --admindir if a different one is specifiedJulian Andres Klode2025-02-071-0/+7
| | | | | | | Otherwise if we set e.g. Dir, we end up with the foreign architectures from the host which is wrong. Fixes: 8e6a86aa3bc6d5a9013bb42fccea9bbce3fd97e2
* Measure BootSize as integerJulian Andres Klode2025-02-032-3/+3
| | | | I don't know why I used a double here this is awkward.
* Correctly calculate kernel size in /bootJulian Andres Klode2025-02-031-32/+25
| | | | | | | | | | | | Change the code to get the size from the existing vmlinuz, rather than using the package size, which only worked in Ubuntu, and possibly not on all kernel packages either. Refactor the code a bit to avoid the nested if as well, and use off_t to measure and sum the sizes before switching to floating point. Closes: #1085184
* Include Extra in the size counted for Version structDavid Kalnischkies2025-01-301-1/+1
| | | | | | It is a tiny struct, so the difference in 'stats' is minor even with all the versions but it is more correct and also helps in case the Extra struct is changed to predictably trigger a binary cache invalidation.
* Record all available sources for descriptionsDavid Kalnischkies2025-01-301-53/+55
| | | | | | | | | | | | Avoiding duplications is one thing, but it could also be handy to know all sources for a description so that you can e.g. avoid opening another file or similar such if its also present in one you already have open. Given how the structures were set up this was probably intended all along and either worked at some point or was abandoned for the duplicates that we started culling heavily with the introduction of MultiArch as at that point they blew up the cache and needed to be dealt with.
* Do not create descriptions structs for each architectureDavid Kalnischkies2025-01-301-6/+9
| | | | | | | | The architectures are supposed to share the descriptions as they are (very usually) the same, but the code was happily creating structs for every architecture of a package which is especially pointless as for e.g. Debian those will be the short description likely superseded in output and all uses by the 'en' "translation".
* Drop unused version stanza size info from binary cacheDavid Kalnischkies2025-01-302-5/+11
| | | | | | | | | | | | | | Same reason as with the description size before, but this one had actually one extremely dated user in src:apt left with dumpavail, which is changed to an implementation that is (in comparison) a bit slower, but should be good enough for a command that is ideally not used anymore (even if codesearch suggests otherwise). After all, what makes this a bit slower is not that we don't know the size, but that this one does additional work preparing for accessing the fields which we don't do. In exchange pkgTagFile has a better implementation for "Jitter" than the old code that we would "just" need to copy here if speed were really an issue.
* Drop unused description size info from binary cacheDavid Kalnischkies2025-01-302-5/+11
| | | | | | | | | | | Nothing in src:apt uses this information and that isn't all to surprising as it is usually not that interesting to know how big a specific stanza of a description is as the max size is available and you are usually working with more than one description. So this information just takes up space in our binary cache… 64 bits per structure which can quickly add up to whole MBs depending on how many (and which) sources you have enabled.
* Do not overflow ver/desc<->file relation countersDavid Kalnischkies2025-01-301-0/+5
| | | | | | | | | | | | | | | | The counters aren't used for anything really except for the 'stats' command that is off in its display and calculation due to 16bit not being enough for counting all the relations we have. Semi-broken more than a decade ago as I accidentally aligned it with the other file relation counters which count far less frequent ones through, so 'unsigned long' should have been changed to the id type rather than the smaller fileid type. Of course, this commit only prepares the fix as this would be an ABI break, so with the current ABI we are still overflowing. Regression-of: 4ad8619bb1f0bf777d17c568bb7a6cf7f30aac34
* solver3: Credit MiniSATJulian Andres Klode2025-01-301-0/+11
| | | | Gbp-Dch: ignore
* solver3: Use a propagation queueJulian Andres Klode2025-01-302-8/+29
| | | | | | | | | | | | | | | | | | | Instead of directly propagating in a recursive fashion, queue propagations in a queue and work on them in a loop per the miniSAT paper. We call Propagate() only at the end of the FromDepCache() function and then in the Solve loop. Delaying the initial propagation means that we get a stronger reasoning: Assume you have x->a->b->c, y->c and you install x,y: - Previously we traversed: x, y, x->a, a->b, b->c, (y->c) - but now we traverse: x, y, x->a, y->c, a->b, (b->c) Notably c now has the implication y->c instead of x->a->b->c. Inside the solver we need to call Propagate in a loop: Propagating facts can fail and we then backtrack. If backtracking is succesful, we have gained a new fact to propagate.
* solver3: Replace Install() with Enqueue(), and PropagateInstall()Julian Andres Klode2025-01-302-44/+36
| | | | | | Do not enqueue common dependencies if a version is selected already, this avoids test suites changing now in behavior as the ordering is different.
* solver3: Remove NewUnsatRecommends groupJulian Andres Klode2025-01-302-3/+0
| | | | | | This is more or less unused; but it particularly has the bad problem of forcing new unsat recommends to be solved *before* dependencies. Which is awkward.
* solver3: Soft unit propagation for optional itemsJulian Andres Klode2025-01-301-2/+7
| | | | | If both items are optional, unit items should be processed first.
* apt: Introduce the modernize-sources commandJulian Andres Klode2025-01-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | This handles rewriting .list entries to .sources ones; the only options handled are - signed-by => Signed-By - trusted => Trusted The options to specify architectures, check-valid-until, etc. are not supported as they are not exposed in the code. We probably should refactor the parser at some point so we can actually read the parsed entry rather than the abstract objects we create from it. This can be improved further: - Keyrings from /etc/apt/trusted.gpg.d should be moved to /etc/apt/keyrings. - automatic detection by trying to verify using each keyring in trusted.gpg.d until we find the right one and then using that for Signed-By rather than leave some sources empty.
* metaindex: Support loading without filenameJulian Andres Klode2025-01-282-0/+14
|
* sqv, gpgv: Do not fail if Dir::Etc::Trusted is set and trusted.gpg.d is missingJulian Andres Klode2025-01-221-2/+10
| | | | | | | | | | This should remain a warning case for now. So push the errors to a stack and see if we can find any file. Explictly warn again if Dir::Etc::trusted is set, as it is like _super_ deprecated. Reported-By: Cyril Brulebois <kibi@debian.org> in Bug#1032131
* Unset Dir::Etc::trustedJulian Andres Klode2025-01-211-1/+0
| | | | | | | | | | | The trusted.gpg file has been deprecated since February 2022 and can no longer be managed easily without apt-key, so we should not be falling back to it by default. We do not remove the actual code to fall back to it, such that code that passes Dir::Etc::trusted explicitly continues to work for the time being (with the warnings in update), as the overhead is now rather trivial.
* Remove superseded warning about trusted.gpg fallbackJulian Andres Klode2025-01-211-2/+2
| | | | | | | | | | This warning has been superseded by the missing sources.list notice (which will also become a warning shortly) Adjust the sqv exit to avoid introducing a new spurious "No good signature" that we did not reach before. moo
* Write Pre-Depends with a dash again in EDSPDavid Kalnischkies2025-01-171-1/+1
| | | | | | | | | | | | | | For some reason ~ that I don't know and can't come up with on the spot ~ we output the Pre-Depends field as PreDepends in the translated user-visible output and I accidentally copied that over to the untranslated variant that replaced the embedded copy (with a dash) in the EDSP generator. Code-copies and implementation details littered all over the place are apparently sometimes a good bug-free thing, too… Regression-of: 6828ae2c2f9268c8187f0fa91b3c464ed84a8476 Closes: #1093254
* proxy: Avoids triggering bounds check in std::string_viewJulian Andres Klode2025-01-141-1/+1
| | | | | Check for empty string_view instead of first byte being '\0'; this otherwise breaks when compiling with higher ABI version.
* Merge branch 'check-missing-dpkg-bin' into 'main'Julian Andres Klode2025-01-142-3/+11
|\ | | | | | | | | apt-pkg/deb/debsystem.cc: Fall back to "dpkg" when Dir::Bin::dpkg is not found See merge request apt-team/apt!419
| * apt-pkg/deb/debsystem.cc: Fall back to "dpkg" when Dir::Bin::dpkg is not foundBalint Reczey2024-12-302-3/+11
| | | | | | | | | | | | The custom dpkg binary may be removed by apt and that breaks the end of the operation. This can be observed when using eatmydata as dpkg and removing the symlink to eatmydata when removing the apt-eatmydata package.
* | Remove leftovers from ftp and rsh/ssh methods removalDavid Kalnischkies2025-01-051-1/+1
| | | | | | | | References: fd3684cdbc165ceaa635ed19fcbd231f509b0179
* | Remove leftovers of the apt-key removalDavid Kalnischkies2025-01-052-3/+1
| | | | | | | | References: a00fbbdb28cc31e78882301c2efe7218583ab4cb
* | Drop unused short form APT_IGNORE_DEPRECATEDDavid Kalnischkies2025-01-051-6/+1
| | | | | | | | | | | | Even the long form isn't used much (or currently not at all), but given that the short form is not really working even if it would be used… lets drop it and use the long form if we have to.
* | Drop usage of APT_MUSTCHECKDavid Kalnischkies2025-01-055-14/+14
| | | | | | | | | | nodiscard is a C++17 feature and already used (not just due to my recent changes) in our codebase, so lets drop the last remaining holdouts.
* | Drop usage of APT_UNUSEDDavid Kalnischkies2025-01-052-3/+3
| |
* | Drop APT_DEPRECATED usageDavid Kalnischkies2025-01-055-15/+16
| | | | | | | | | | | | | | | | C++14 includes the standard attribute, so we can use that instead. Note that we drop the deprecation of {Pkg,Dep}Iterator::operator<< as this is ignored (a friends declaration must be a definition to have attributes) very noisily by GCC >= 12 and the methods can be somewhat useful in debugging if you are to lazy to get APT::Pretty{Pkg,Dep}.
* | Drop APT_NORETURN usageDavid Kalnischkies2025-01-054-9/+12
| | | | | | | | | | [[noreturn]] is a C++11 feature and so we can just use it unconditionally.
* | Drop unused FLAG macro and friendsDavid Kalnischkies2025-01-051-6/+4
| | | | | | | | | | They are rather generic names for macros and have no usage in our codebase at all, so lets remove them for good now.
* | Drop the remaining usage of APT_ARRAY_SIZEDavid Kalnischkies2025-01-052-5/+2
| | | | | | | | | | | | That macro is not that useful as it might perhaps once was. Lets prepare dropping it now in favour of more standard ways of working with arrays now.