summaryrefslogtreecommitdiff
path: root/ftparchive
Commit message (Collapse)AuthorAgeFilesLines
* apt: funcs called with a string literal consisting of a single characterHerman Semenoff2026-04-081-1/+1
| | | | | | | | Benchmark: - https://stackoverflow.com/questions/62058906/why-my-performance-benchmark-gives-me-wrong-results References: - https://clang.llvm.org/extra/clang-tidy/checks/performance/prefer-single-char-overloads.html
* Bump CMAKE_CXX_STANDARD to 23 and fix codeJulian Andres Klode2025-05-251-1/+1
| | | | | | | | ftparchive/contents.h failed with operator< defined only, so define operator<=> instead. The operator and FileCopyType constructor both had a warning about not throwing and adding a noexcept, so add one
* apt-ftparchive: Do not output locale dependent dsc file sizeDavid Kalnischkies2025-02-211-1/+1
| | | | | | | | | | | | | | Removal of std::to_string avoids the temporary std::string, but it leads to locale-dependent output that parsers (including ours) are not prepared to encounter especially as number formatting can be highly ambiguous due to different rules surrounding '.' and ','. In the distant future (c++20) this could be replaced with a variant of std::format, which incidentally is also what std::to_string becomes an alias for in an even more distant future (c++26). Regression-of: 729a5c8f4fb8c841497d26170e1a47c41617ecd9 Reported-By: Stefan Lippers-Hollmann and Kel Modderman on IRC
* Run unifdef -DAPT_PKG_ABI=700 againJulian Andres Klode2025-02-151-4/+0
| | | | | main picked up a couple new ifdefs since the branch started; so clean them up again.
* string{=> _view} flNotDir(string{=> _view}). Configuration::{Cnd,}Set(Value: ↵наб2025-02-141-3/+3
| | | | string{=> _view})
* Drop usage of macro APT_OVERRIDE for simple overrideDavid Kalnischkies2025-01-052-5/+5
| | | | | | | | | We were rather inconsistent in using it and as our public headers contain deduction guides (a c++17 feature) it seems silly to try to hide a c++11 feature in a macro, so lets stop this charade and drop the macro and while we are changing all these lines lets apply [[nodiscard]] (another c++17 feature) and other suggestions from clang-tidy and formatting for a little more consistency.
* ftparchive: writer: Remove line length limit on file listsJulian Andres Klode2024-11-201-20/+13
| | | | LP: #2087848
* ftparchive: cachedb: Remove 600-byte key limitJulian Andres Klode2024-11-201-3/+4
| | | | | | | | | | Instead of snprintf() into a fixed-size buffer, construct an std::string using assign() and append(). A previous version used strprintf() which would have been hilariously inefficient. LP: #2087848
* ftparchive: override: Remove fixed-size line buffersJulian Andres Klode2024-11-181-4/+8
| | | | LP: #2087848
* Merge branch 'noref' into 'main'Julian Andres Klode2024-11-144-7/+7
|\ | | | | | | | | std::string_view const & -> std::string_view See merge request apt-team/apt!397
| * std::string_view const & -> std::string_viewнаб2024-11-144-7/+7
| | | | | | | | Fixes: 2c03eed649068c8838d971ceeb1a09603dcc8e9c
* | Merge branch 'append' into 'main'Julian Andres Klode2024-11-141-1/+1
|\ \ | | | | | | | | | | | | (+=)+= -> append().append() See merge request apt-team/apt!398
| * | (+=)+= -> append().append()наб2024-11-141-1/+1
| |/
* / pkgTagSection::Tag constructors: std::string const& -> std::string_view ↵наб2024-11-141-0/+4
|/ | | | (always copied) [#if APT_PKG_ABI > 600]
* ftparchive/: prepare for APT::StringView -> std::string_viewнаб2024-11-144-118/+122
|
* Turn char[APT_BUFFER_SIZE] buffers into std::array<char, APT_BUFFER_SIZE>наб2024-11-113-16/+15
|
* Bump read()/write() loop buffers from 4k to APT_BUFFER_SIZE (64k). Bump ↵наб2024-11-071-1/+1
| | | | FileFdPrivate's read()/discard buffer from 1k to APT_BUFFER_SIZE (64k)
* ftparchive: contents: Avoid exponential complexity and overflowsJulian Andres Klode2024-10-072-228/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Wstored directory entries as a binary tree, but we did not balance it, leading to exponential complexity on insertion and potentially exponential levels of stack recursion in DoPrint(), causing overflows. Simply use an std::set storing pairs of (path, package) instead, this is very simple, and handles aspects such as ordering or the same package appearing multiple times correctly. Iteration becomes a bit tricky: After seeing (file1, pkg1) when we see (file1, pkg2) we need to append pkg2 to the current line; once we see (file2, anything), we need write out the line and start a new one. For memory optimization, we use a new class StringInBlock to handle the block-managed C strings generated by Mystrdup() in a type-safe manner. This ensures proper lifetime of objects and no accidental conversions to std::string. This saves a significant amount of space (a pair of std::string is 64-byte large; a pair of pointers is 16 byte large, a 48 byte saving per entry); reproducing the Contents file of Ubuntu 24.10, using straight-forward std::string resulted in GB of memory usage, whereas the C-style string only uses 1.35 GB. As a side effect of the patch we also remove arbitrary 1024-byte buffer sizes. There also is a change in output: The package names are now sorted alphabetically, instead of being in visit order. LP: #2083697
* ftparchive: Mystrdup: Add safety check and bump buffer sizeJulian Andres Klode2024-10-071-1/+3
| | | | | | | | | Add a safety check to ensure that the block were are allocating actually fits the string we want to write. If it doesn't, abort the program. While we are here, bump the buffer size from 40 KiB to 4 MiB, because why bother with smaller buffers.
* Modernize standard library includesJulian Andres Klode2024-02-2010-26/+26
| | | | | | 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.
* Drop unneeded usage of deprecated std::binary_functionDavid Kalnischkies2023-01-291-3/+3
| | | | | | | | The code isn't using any of the member types this template provides, so we can just drop it from the code without any practical effect. Reported-By: gcc -Wdeprecated-declarations Gbp-Dch: Ignore
* typecast time_t and suseconds_t from std::chronoKhem Raj2022-09-161-1/+1
| | | | | | | | This fixes build on some architectures like mips progress.cc:125:31: error: non-constant-expression cannot be narrowed from type 'std::chrono::duration<long long>::rep' (aka 'long long') to '__time_t' (aka 'long') in initializer list [-Wc++11-narrowing] struct timeval NowTime = { Now_sec.count(), Now_usec.count() }; Signed-off-by: Khem Raj <raj.khem@gmail.com>
* Include our config.h in all C++ files to avoid ODR violationsDavid Kalnischkies2022-05-071-0/+2
| | | | | | | Some of our headers use APT_COMPILING_APT trickery to avoid exposing too broadly details we don't want external clients to know and make use of. The flip-side is that this can lead to different compilation units seeing different definitions if they aren't all using the same config.
* Parse Checksum fields via pkgTagSection::Key, tooDavid Kalnischkies2022-04-011-5/+5
| | | | | | | 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-011-45/+39
| | | | | | | | | | 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.
* Drop support for long obsoleted Suggests alias: OptionalDavid Kalnischkies2022-04-011-14/+0
| | | | | dpkg-dev stopped recognizing it in 2007 (1.14.7) while building packages. The rename itself happened in 1995 (0.93.72).
* Rename CMake find_package helpers to avoid developer warningsDavid Kalnischkies2020-11-051-3/+3
| | | | | | | | | | | | | | | | CMake Warning (dev) at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message): | The package name passed to `find_package_handle_standard_args` (Berkeley) | does not match the name of the calling package (BerkeleyDB). This can lead | to problems in calling code that expects `find_package` result variables | (e.g., `_FOUND`) to follow a certain pattern. | Call Stack (most recent call first): | CMake/FindBerkeleyDB.cmake:57 (find_package_handle_standard_args) | CMakeLists.txt:83 (find_package) | This warning is for project developers. Use -Wno-dev to suppress it. And indeed, we checked for BERKLEY_DB_FOUND which was not defined so our HAVE_BDB was not set – just that it is never used, so it wasn't noticed.
* Fix remaining usec vs sec time-delta calculation typosDavid Kalnischkies2020-02-061-23/+13
| | | | | | | | | | | | | | | | | | | While moving to a more stable clock in 79b61ae I typoed the microsecond calculation part and copied it all over the place… Julian fixed the first two instances in 089e6271 and Trent reported the apt-ftparchive instances leaving one instance in progress (invisible for user though). A bit ironic that in an attempt to stop "confusing (and amusing) users" I managed to hide a typo for close to two years doing just that… Sadly we can't really test this as while "apt-ftparchive generate /dev/null" is a great interactive test, it is hard to teach our test framework that the output is "reasonably below an hour" (usually 0s, but on busy test systems it is perhaps longer…). Thanks: Trent W. Buck for initial patch Closes: #950776 References: 79b61ae7673eb6213493e2cb202f0d70c390932d, 089e627153781ae7c320a5a0724c6c70d684b689
* Remove includes of (md5|sha1|sha2).h headersJulian Andres Klode2020-01-142-6/+0
| | | | Remove it everywhere, except where it is still needed.
* Convert users of {MD5,SHA1,SHA256,SHA512}Summation to use HashesJulian Andres Klode2020-01-142-7/+6
| | | | | | | This makes use of the a function GetHashString() that returns the specific hash string. We also need to implement another overload of Add() for signed chars with sizes, so the existing users do not require reinterpret_cast everywhere.
* Apply various suggestions by cppcheckDavid Kalnischkies2019-07-083-8/+5
| | | | Reported-By: cppcheck
* Adjust code for missing includes/using std::stringJulian Andres Klode2019-06-121-0/+1
|
* Merge libapt-inst into libapt-pkgJulian Andres Klode2019-05-061-1/+1
|
* Fix typos reported by codespell & spellintianDavid Kalnischkies2018-08-292-2/+2
| | | | | | | | No user-visible change as it effects mostly code comments and not a single error message, manpage or similar. Reported-By: codespell & spellintian Gbp-Dch: Ignore
* Use a steady clock source for progress reportingDavid Kalnischkies2018-05-281-32/+38
| | | | | | Clock changes while apt is running can result in strange reports confusing (and amusing) users. Sadly, to keep the ABI for now the code is a bit more ugly than it would need to be.
* Remove obsolete RCS keywordsGuillem Jover2018-05-0712-12/+0
| | | | Prompted-by: Jakub Wilk <jwilk@debian.org>
* Fix various typos reported by spellcheckersDavid Kalnischkies2018-05-051-1/+1
| | | | | Reported-By: codespell & spellintian Gbp-Dch: Ignore
* avoid some useless casts reported by -Wuseless-castDavid Kalnischkies2017-12-131-4/+1
| | | | | | | | | The casts are useless, but the reports show some where we can actually improve the code by replacing them with better alternatives like converting whatever int type into a string instead of casting to a specific one which might in the future be too small. Reported-By: gcc -Wuseless-cast
* ftparchive: Do not pass through disabled hashes in SourcesJulian Andres Klode2017-09-091-0/+8
| | | | | | | | | | | | | | | | When writing a Sources files hashes that were already present in the .dsc were always copied through (or modified), even if disabled. Remove them instead when they are disabled, otherwise we end up with hashes for tarballs and stuff but not for dsc files (as the dsc obviously does not hash itself). Also adjust the tests: test-compressed-indexes relied on Files being present in showsrc, and test-apt-update-weak-hashes expected the tarball to be downloaded when an archive only has MD5 and we are requiring SHA256 because that used to work because the tarball was always included. Closes: #872963
* ftparchive: sort discovered filenames before writing indexesDavid Kalnischkies2017-08-042-23/+39
| | | | | | | | | | | | | | | | | | | If 'apt-ftparchive packages /path/to/files/' (or sources) is used the files to include in the generated index (on stdout) were included in the order in which they were discovered, which isn't a very stable order which could lead to indexes changing without actually changing content causing needless changes in the repository changing hashsums, pdiffs, rsyncs, downloads, …. This does not effect apt-ftparchive calls which already have an order defined via a filelist (like generate) which will still print in the order given by the filelist. Note that a similar effect can be achieved by post-processing index files with apt-sortpkgs. Closes: 869557 Thanks: Chris Lamb for initial patch & Stefan Lippers-Hollmann for testing
* Reformat and sort all includes with clang-formatJulian Andres Klode2017-07-1213-56/+53
| | | | | | | | | | | | | This makes it easier to see which headers includes what. The changes were done by running git grep -l '#\s*include' \ | grep -E '.(cc|h)$' \ | xargs sed -i -E 's/(^\s*)#(\s*)include/\1#\2 include/' To modify all include lines by adding a space, and then running ./git-clang-format.sh.
* fix various typos reported by codespell & spellintianDavid Kalnischkies2017-07-081-1/+1
| | | | | Reported-By: codespell & spellintian Gbp-Dch: Ignore
* Refactor to avoid loop/dangling gcc warningsDavid Kalnischkies2017-06-261-8/+4
| | | | Gbp-Dch: Ignore
* Refactor finding compressor by name to avoid code dupDavid Kalnischkies2017-06-261-46/+33
| | | | Git-Dch: Ignore
* apt-ftparchive: Support '.ddeb' dbgsym packagesUnit 1932017-04-241-1/+1
|
* fix various typos reported by spellintianDavid Kalnischkies2017-01-192-3/+3
| | | | | | | | Most of them in (old) code comments. The two instances of user visible string changes the po files of the manpages are fixed up as well. Gbp-Dch: Ignore Reported-By: spellintian
* CMake: Document that the globs are expanded during CMakeJulian Andres Klode2017-01-171-1/+3
| | | | | | | This will avoid people from thinking that they have to do nothing when they change the set of files. Gbp-Dch: ignore
* apt-ftparchive: Support NotAutomatic and ButAutomaticUpgrades fieldsJames Clarke2016-11-111-11/+25
| | | | | | | This also changes Acquire-By-Hash to be "yes" rather than "true", so it is consistent with dak's output. Closes: #272557
* CMake: Handle Berkeley DB on FreeBSDJulian Andres Klode2016-08-261-0/+1
| | | | | | | | | | | | | The BSD systems still ship their own db.h with a historical BSD implementation, which is preferred by CMake, as it searches its default path first. We thus have to disable the DEFAULT_PATH for the search, unfortunately. We also need to pass the correct include directory to the target. Furthermore, on FreeBSD the library is called db-<VERSION>, so let's add db-5 to the list of allowed names. Gbp-Dch: ignore
* support compression and by-hash for .diff/Index filesDavid Kalnischkies2016-08-171-0/+1
| | | | | | | | | | | In af81ab9030229b4ce6cbe28f0f0831d4896fda01 by-hash got implemented as a special compression type for our usual index files like Packages. Missing in this scheme was the special .diff/Index index file containing the info about individual patches for this index file. Deriving from the index file class directly we inherent the compression handling infrastructure and in this way also by-hash nearly for free. Closes: #824926