summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
Commit message (Collapse)AuthorAgeFilesLines
* Allow parsing an empty Provides linemainDavid Kalnischkies2024-04-261-1/+1
| | | | | | | | | | | | | If dpkg-gencontrol was involved in the creation of a package we will not usually encounter empty or otherwise useless fields, but apparently not everyone is using it. It isn't recommended to have these empty lines, but it isn't too hard to ignore for Provides as we did for dependencies already and apt-ftparchive can be convinced to produce empty files (if you feed it such a package) as well, so lets be nice and provide users with a more accepting parser. Closes: #1069874
* Change the default log level from debug to noticeJulian Andres Klode2024-04-191-1/+1
| | | | | | | | | | We never used the debug level before, so we can do that. This allows us to have the new audit level. We did call DumpErrors() with DEBUG in two debug code paths, so don't touch those. debug
* Allow no spaces for the last dependency in ParseDepends, tooDavid Kalnischkies2024-04-171-1/+1
| | | | | | | | | | | | | | | | | | | | All other entries in a dependency line get substantial leeway about the amount of spaces surrounding the entry itself and its individual parts, but the very last entry was required to have a version constraint be at least 4 chars long (excluding opening bracket and spaces following it), so if the version is short and a single-char relation used a space had to make up for it. This is a bit unfair in comparison to the other entries who do not have such unreasonable demands, so we reduce our demand to 3 chars or longer, which is satisfied by "=1)". If it is a good idea to hate spaces that much remains unanswered by this commit, but in practice most tools (re)writing the files we parse will include spaces, so its only in files (or on the satisfy command line) directly edited by users that we can encounter such a situation, which is a relatively new development given this line came unchanged from the introduction of this method in 1998. LP: #2061834
* Revert "debrecords: Do not reparse if given same location"Julian Andres Klode2024-03-222-14/+3
| | | | This reverts commit 9bb953fddae0246a4dcedddb769d75d3521e1f2f.
* debrecords: Do not reparse if given same locationJulian Andres Klode2024-03-222-3/+14
| | | | | | | The TagFile parser will have already parsed further and can't go back so it needs to reopen the file if compressed. Closes: #1067440
* Parse unsupported != relation in dependenciesDavid Kalnischkies2024-03-071-1/+11
| | | | | | | | | | | | | | | | | libapt has a NotEquals relation for version constraints in dependencies, which is used internally e.g. in the MultiArch implementation, but this relation is not supported by Debian policy and as such can not be used in packages. Our parser here is extremely accepting, even unknown relations are parsed as Equals relation – but the version that must match will be a rather strange one… For our own testcases and e.g. on the command line with 'satisfy' it can make sense to have != available… and what strange things apt does parsing unsupported relations is not really much of a concern. Real packages will not have such relations anyhow as we are (mostly) just a consumer, not a producer of packages and index files.
* Delete SHADOWED metaIndex if we don't actually use snapshotsJulian Andres Klode2024-02-201-0/+7
| | | | | | | | This adds a bit more code but avoids any surprises later on by having both the shadowed and non-shadowed meta index in the list. Gbp-Dch: ignore
* Automatically enable snapshots where supportedJulian Andres Klode2024-02-201-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | Convert sources.list Snapshot option from opt-in to automatic. If we can find a snapshot server, Snapshot: yes is assumed if a snapshot is specified. On the implementation side, we record automatic snapshot enablement by adding a '?' suffix to the snapshot timestamp, if any is specified, this avoids introducing bugs into the code where we could end up with an empty snapshot. This has an annoying internal implementation caveat: Since we call GetDebReleaseIndexBy() with the SHADOWED option emplaced, if we do not find a server, we need to remove the SHADOWED option again, but we already have inserted a shadowed release index into the list. This will simply insert the release index a second time without the SHADOWED option which in preliminary testing works fine, but it would arguably be more correct to also remove the release index again if we have created it. FIXME: This only has one test case: A source with supported snapshot server is auto-discovered. We should also add a test case where we cannot detect a server and then don't fail in automatic mode.
* Modernize standard library includesJulian Andres Klode2024-02-2011-28/+27
| | | | | | This was automated with sed and git-clang-format, and then I had to fix up the top of policy.cc by hand as git-clang-format accidentally indented it by two spaces.
* Stop calculating Description-md5 if missingJulian Andres Klode2023-10-041-19/+1
| | | | | | | | This avoids the rabbit hole of md5 on FIPS systems, and repositories have moved to including the value as well. Also stop validating the field, this can be an arbitrary string as far as we are concerned.
* Compare SHA256 to check if versions are really the sameJulian Andres Klode2023-08-021-0/+10
| | | | | | | | | | | | | If we know both SHA256, and they're different, the packages are. This approach stores the SHA256 only at runtime, avoiding the overhead of storing it on-disk, because when we update repositories we update all of them anyhow. Note that pkgCacheGenerator is hidden, so we can just modify its ABI, hooray. Closes: #931175 LP: #2029268
* Fix snapshot crashesJulian Andres Klode2023-07-121-1/+3
| | | | | We did not handle multiple components properly, add a contrib component to the test case.
* update: Add notice about missing Signed-By in deb822 sourcesJulian Andres Klode2023-06-271-0/+3
| | | | | | | We want to gently steer users towards having Signed-By for each source such that we can retire a shared keyring across sources which improves resilience against configuration issues and incompetent malicious actors.
* Rework the domain iteration in the host fallbackJulian Andres Klode2023-05-241-3/+18
| | | | | | Separate the determination of the next level domain into its own function and split out the "we found a result" into its own break for improved readability.
* Ensure that Snapshots: no doesn't get overriden by host-name configJulian Andres Klode2023-05-241-7/+3
|
* Seed snapshot servers for well-known hostsJulian Andres Klode2023-05-241-9/+31
| | | | | This will attempt to fallback to a per-server setting if we could not determine a value from the release file.
* Initial support for snapshot servers, apt --snapshot optionJulian Andres Klode2023-05-022-4/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provide snapshot support for offical Debian and Ubuntu archives. There are two ways to enable snapshots for sources: 1. Add Snapshot: yes to your sources file ([snapshot=yes]). This will allow you to specify a snapshot to use when updating or installing using the --snapshot,-S option. 2. Add Snapshot: ID to your sources files to request a specific snapshot for this source. Snapshots are discovered using Label and Origin fields in the Release file of the main source, hence you need to have updated the source at least once before you can use snapshots. The Release file may also declare a snapshots server to use, similar to Changelogs, it can contain a Snapshots field with the values: 1. `Snapshots: https://example.com/@SNAPSHOTID@` where `@SNAPSHOTID@` is a placeholder that is replaced with the requested snapshot id 2. `Snapshots: no` to disable snapshot support for this source. Requesting snapshots for this source will result in a failure to load the source. The implementation adds a SHADOWED option to deb source entries, and marks the main entry as SHADOWED when a snapshot has been requested, which will cause it to be updated, but not included in the generated cache. The concern here was that we need to keep generating the shadowed entries because the cleanup in `apt update` deletes any files not queued for download, so we gotta keep downloading the main source. This design is not entirely optimal, but avoids the pitfalls of having to reimplement list cleanup. Gaps: - Ubuntu Pro repositories and PPAs are not yet supported.
* Allow apt to run if no dpkg/status file existsDavid Kalnischkies2022-09-021-0/+7
| | | | | | | | | | | | | | | Not having a dpkg/status file used to be a hard error which from a boostrap perspective is suspect as in the beginning, there is no status so you would need to touch it into existence. We make a difference between factual non-existence and inaccessibility to catch mistakes in which the file is not readable for some reason, the testcase test-bug-254770-segfault-if-cache-not-buildable is an example of this. Note that apt has already figured out at this point that this is a Debian-like system which should have a dpkg/status file. This change does not effect the auto-detection and is not supposed to.
* Report failures back from debSystem::AddStatusFilesDavid Kalnischkies2022-09-021-2/+14
| | | | | | | | | | | | | | | | Failing to properly create the status file class should be reported back to the caller so it can proceed accordingly instead of proceeding into more failures. This gives us: E: flAbsPath on /var/lib/dpkg/status failed - realpath (2: No such file or directory) E: The package lists or status file could not be parsed or opened. instead of: E: flAbsPath on /var/lib/dpkg/status failed - realpath (2: No such file or directory) E: Could not open file - open (2: No such file or directory) E: Problem opening E: The package lists or status file could not be parsed or opened. and valgrind reporting actions on uninitialised values.
* Parse Checksum fields via pkgTagSection::Key, tooDavid Kalnischkies2022-04-012-18/+10
| | | | | | | We abstract hashes a fair bit to be able to add new ones eventually, which lead us to building the field names on the fly. We can do better through by keeping a central place for these names, too, which even helps in reducing code as we don't need the MD5 → Files dance anymore.
* Use pkgTagSection::Key in more places in src:aptDavid Kalnischkies2022-04-013-28/+29
| | | | | | | | | | The speed critical paths were converted earlier, but the remaining could benefit a tiny bit from this as well especially as we have the facility now available and can therefore brush up the code in various places in the process as well. Also takes the time to add the hidden Exists method advertised in the headers, but previously not implemented.
* Avoid .c_str() on strings feed into pkgTagSection::FindSDavid Kalnischkies2022-04-011-1/+1
| | | | | | FindS has a APT::StringView based API nowadays, so we can avoid these explicit calls also allowing us to avoid the std::string in input or output entirely or at least move it a few branches down.
* Drop support for long obsoleted Suggests alias: OptionalDavid Kalnischkies2022-04-011-4/+1
| | | | | dpkg-dev stopped recognizing it in 2007 (1.14.7) while building packages. The rename itself happened in 1995 (0.93.72).
* Introduce and use isalpha_ascii() in debversion rather than isalpha()Julian Andres Klode2022-01-061-1/+1
| | | | | Avoid misclassifying additional alphabetical characters from certain locales as alpha and then sort them by ASCII...
* Don't print every inline PGP key in Signed-ByVictor Westerhuis2021-11-051-1/+0
| | | | It looks like a debug line was left in accidentally.
* Merge branch 'fakechroot' into 'main'Julian Andres Klode2021-10-191-2/+12
|\ | | | | | | | | apt-pkg/deb/dpkgpm.cc: make DPkg::Chroot-Directory work under fakechroot See merge request apt-team/apt!189
| * apt-pkg/deb/dpkgpm.cc: make DPkg::Chroot-Directory work under fakechrootJohannes Schauer Marin Rodrigues2021-09-191-2/+12
| |
* | Only allow full Signed-By keys where filenames are allowedJulian Andres Klode2021-10-181-3/+5
| | | | | | | | | | | | Rename the argument to Introducer and generalize it to anything that introduces new keys into the trusted vector, like file names and full keys.
* | Add support for embedding PGP keys into Signed-By in deb822 sourcesJulian Andres Klode2021-10-181-0/+17
| | | | | | | | | | | | 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.
* | Streamline access to barbarian architecture functionalityDavid Kalnischkies2021-09-041-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | APT is not the place this information should be stored at, but it is a good place to experiment and see what will be (not) needed in the future for a proper implementation higher up the stack. This is why "BarbarianArchitectures" is chosen instead of a more neutral and/or sensible "VeryForeign" and isn't readily exported in the API to other clients for this PoC as a to be drawn up standard will likely require potentially incompatible changes. Having a then outdated and slightly different implementation block a "good" name would be bad. The functionality itself mostly exists (ignoring bugs) since the introduction of MultiArch as we always had the risk of encountering packages of architectures not known to dpkg (forced onto the system, potentially before MultiArch) we had to deal with somehow and other edge cases. All this commit really does is allowing what could previously only be achieved with editing sources.list and some conf options via a single config option: -o APT::BarbarianArchitectures=foo,bar
* | Barbarian M-A:allowed don't satisfy :any deps of other archsDavid Kalnischkies2021-09-041-4/+13
|/ | | | | | | | | | | | | | | | | | | | | What does a M-A:allowed package from non-native/non-foreign architecture provide? If we look at M-A:foreign, such a package satisfies dependencies within its own architecture, but not in other architectures, so the same should apply to :any dependencies on M-A:allowed packages, but we have a problem: While unqualified package names are architecture-specific, the virtual package name qualified with :any is not (see 3addaba1ff). We could of course make it architecture-specific now, but that would introduce many virtual packages for this relatively minor usecase and would reintroduce a need for special display handling. So, we pull a trick here: Barbarian M-A:allowed packages do not provide the architecture-independent :any package anymore, but only a specific one and every :any dependency from a barbarian package is rewritten to an or-group of the specific and the independent :any package. References: 3addaba1ff
* Merge branch 'fix/dpkgchroot' into 'main'Julian Andres Klode2021-07-053-30/+26
|\ | | | | | | | | Restore dpkg::chroot-directory functionality See merge request apt-team/apt!178
| * Restore dpkg::chroot-directory functionalityDavid Kalnischkies2021-06-103-30/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we call dpkg inside a chroot we have to ensure that the temporary directory we construct to call dpkg --recursive is inside the chroot and that we strip the path to the chroot from the directory name we pass to dpkg. Note that the added test succeeds before and (hopefully) after as we can't really chroot here or fiddle with the needed settings as we are already setting up apt to work with a quasi-chroot. The test perhaps helps in ensuring we don't break it too much in the future though. (Broken five years (and one day) ago this seems to have an immense user base at the moment, but it might in the future via mmdebstrap) References: f495992428a396e0f98886c9a761a804aa161c68 Reported-By: Johannes Schauer Marin Rodrigues on IRC Tested-By: Johannes Schauer Marin Rodrigues
* | Store size from volatile sources for already installed versionsDavid Kalnischkies2021-06-101-1/+6
|/ | | | | | | | Volatile sources are parsed after the status file, so if we have a version already installed the size information is not stored, so that a reinstall of said version is refused claiming a broken repository. References: 1412cf51403286e9c040f9f86fd4d8306e62aff2
* No URL decode and quoting support for Files in SourcesDavid Kalnischkies2021-06-041-16/+14
| | | | | | | | The code exists since ever, but no other client supports this and the specification like debian-policy isn't asking for this either. What it does do is breaking than all others continue working through: If the filename includes in fact URI encoded bits (hopefully no quotes) which is rather unlikely, but none the less possible.
* Allow superfluous commas in build-dependency linesDavid Kalnischkies2021-04-251-3/+8
| | | | | | | | This code can interact with handwritten files who can have unneeded commas for writing easy. As dpkg allows it, we should do as well. Reported-By: Arnaud Ferraris <arnaud.ferraris@gmail.com> References: https://lists.debian.org/debian-devel/2021/03/msg00101.html
* Streamline or-group closing after other arch-specific packageDavid Kalnischkies2021-04-251-7/+3
| | | | | | | | The comment and code are a bit too roundabout about what they actually try to do, so lets just set that straight as this is really just about a very specific case and doesn't deserve a general resetting. Gbp-Dch: Ignore
* Do not pass --force-remove-protected with --auto-deconfigureJulian Andres Klode2021-04-211-3/+0
| | | | dpkg 1.20.8 no longer requires this.
* Merge the three RAII vectors managing args lifetimeDavid Kalnischkies2021-03-091-90/+108
| | | | | | | | Having three different vectors littered over the method to manage various parts of the lifetime of the argument vector we are creating is a bit dangerous as it means a simple code change could result in a desync of these three, so by moving the functionality of them all into a wrapper class should prevent us from making such mistakes.
* Handle multi-arch pkgnames for dpkg call via RAIIDavid Kalnischkies2021-03-091-11/+5
|
* Use RAII to clean up tmp dir for dpkg recursive installDavid Kalnischkies2021-03-091-10/+7
| | | | One less thing to remember to do in all branches.
* Replace multi-statement macro with lambdaDavid Kalnischkies2021-03-091-42/+32
| | | | | | It is easy to make mistakes while dealing with such macros regardless of how much you guard them, so just using a lambda removes a lot of concerns here basically for free.
* Do not require force-loopbreak on Protected packagesJulian Andres Klode2021-02-231-0/+3
| | | | | | | | | 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
* Guess compressor only if no AR nember with exact name existsDavid Kalnischkies2021-02-021-25/+34
| | | | | | | | | | | Explicitly opening a tar member is a bit harder than it needs to be as you have to remove the compressor extension so that it can be guessed here gain potentially choosing the wrong member. Doesn't really matter for deb packages of course as the member count is pretty low and strongly defined, but testing is easier this way. It also finally fixes an incorrectly formatted error message.
* Merge branch 'pu/include-all-translations' into 'master'Julian Andres Klode2021-01-271-1/+1
|\ | | | | | | | | Include all translations when building the cache See merge request apt-team/apt!156
| * Include all translations when building the cacheJulian Andres Klode2021-01-271-1/+1
| | | | | | | | | | | | | | | | | | We do download all translations we ever downloaded, but we don't add all of those to the cache, meaning that if we run update with LANG=C, it might still download your de_DE translation, but it won't insert it into the cache, causing your de_DE user to not get translated messages. LP: #1907850
* | dpkg: fix passing readonly /dev/null fd as stdout/stderrYoufu Zhang2021-01-221-1/+1
|/ | | | | | | | | | | The read-only /dev/null was duplicated to stdout and stderr, causing writes to those descriptors to fail: [pid 260] openat(AT_FDCWD, "/dev/null", O_RDONLY) = 7 [pid 260] dup2(7, 0) = 0 [pid 260] close(5) = 0 [pid 260] dup2(6, 1) = 1 [pid 260] dup2(7, 2) = 2 [pid 260] write(2, "Chrooting into ", 15) = -1 EBADF (Bad file descriptor) [pid 260] chroot("/chroot/") = 0
* Add support for Phased-Update-PercentageJulian Andres Klode2021-01-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for Phased-Update-Percentage by pinning upgrades that are not to be installed down to 1. The output of policy has been changed to add the level of phasing, and documentation has been improved to document how phased updates work. The patch detects if it is running in a chroot, and if so, always includes phased updates, restoring classic apt behavior to avoid behavioral changes on buildd chroots. Various options are added to control this all: * APT::Get::{Always,Never}-Include-Phased-Updates and their legacy update-manager equivalents to always or never include phased updates * APT::Machine-ID can be set to a UUID string to have all machines in a fleet phase the same * Dir::Etc::Machine-ID is weird in that it's default is sort of like ../machine-id, but not really, as ../machine-id would look up $PWD/../machine-id and not relative to Dir::Etc; but it allows you to override the path to machine-id (as opposed to the value) * Dir::Bin::ischroot is the path to the ischroot(1) binary which is used to detect whether we are running in a chroot.
* Determine autoremovable kernels at run-timeJulian Andres Klode2021-01-041-1/+7
| | | | | | | | | | | | | | | | | | | | | | | Our kernel autoremoval helper script protects the currently booted kernel, but it only runs whenever we install or remove a kernel, causing it to protect the kernel that was booted at that point in time, which is not necessarily the same kernel as the one that is running right now. Reimplement the logic in C++ such that we can calculate it at run-time: Provide a function to produce a regular expression that matches all kernels that need protecting, and by changing the default root set function in the DepCache to make use of that expression. Note that the code groups the kernels by versions as before, and then marks all kernel packages with the same version. This optimized version inserts a virtual package $kernel into the cache when building it to avoid having to iterate over all packages in the cache to find the installed ones, significantly improving performance at a minor cost when building the cache. LP: #1615381
* Keep URIs encoded in the acquire systemDavid Kalnischkies2020-12-182-4/+11
| | | | | | | | | | | | | | | | | | | We do not deal a lot with URIs which need encoding, but then we do it is a pain that we store it decoded in the acquire system as it means we have to decode and reencode URIs eventually which is potentially giving us slightly different URIs. We see that in our own testing framework while setting up redirects as the config options are effectively double-encoded and decoded to pass them around successfully as otherwise %2f and / in an URI are treated the same. This commit adds the infrastructure for methods to opt into getting URIs send in encoded form (and returning them to us in encoded form, too) so that we eventually do not have to touch the URIs which is how it should be. This means though that we have to deal with methods who do not support this yet (aka: all at the moment) for which we decode and encode while communicating with them.