summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2018-10-08libdpkg: Add new fsys-dir moduleGuillem Jover7-0/+169
This module handles setting and getting the filesystem root directory.
2018-09-26libdpkg: Check that the public headers can be compiled with C++Guillem Jover3-0/+86
2018-09-18perl: Replace all calls to Cwd::cwd with Cwd::getcwdJosh Triplett2-2/+2
The former calls /bin/pwd, while the latter uses the getcwd() syscall directly. Signed-off-by: Guillem Jover <guillem@debian.org>
2018-09-18libdpkg: Fix filesystem digest parsingGuillem Jover1-1/+1
Allocate the digest into the non-freeing memory pool, as we have stopped doing that for the entire loaded file with the switch to the file_slurp() function. Otherwise when we release the varbuf the fsys nodes will be pointing to garbage. Fixes: commit 1166bbb5f099580a0c1c26d0e29b1ae3fe11ad0f Reported-by: Sven Joachim <svenjoac@gmx.de> Bisected-by: Sven Joachim <svenjoac@gmx.de>
2018-08-30libdpkg: Add new unit tests for namevalue, fsys-hash and pkg-hash modulesGuillem Jover5-0/+340
2018-08-30libdpkg, dpkg: Use new pager spawning supportGuillem Jover1-16/+3
Use it instead of open-coding it, or piping it via a shell invocation, which required metacharacter escaping.
2018-08-30libdpkg: Add pager spawning and reaping supportGuillem Jover3-0/+72
This will make using a pager way easier, and make it possible to remove some redundant and unsafe system() usage.
2018-08-30libdpkg: Require both stdin and stdout to be a tty to use a pagerGuillem Jover1-1/+1
A pager requires both input being connected to a tty, and we want to use it when the output goes to the tty, so require both.
2018-08-30libdpkg: Split pager specific code into its own moduleGuillem Jover11-61/+177
We also namespace the pager function with the module name.
2018-08-30libdpkg: Fix internerr format stringGuillem Jover1-1/+1
Do not print filename which is going to be NULL. Fixes: commit 9f7e58acdf28043bce2dfaf24ba27bb878418658
2018-08-30libdpkg: Dump database package records in alphabetical orderGuillem Jover1-4/+13
When dumping all stanzas from the package database, do it in alphabetical order, so that we get reproducible output, both on disk and for the upcoming output to stdout.
2018-08-30libdpkg: Factor out package stanza printing into its own functionGuillem Jover3-6/+17
We will then be able to use it to print the package database into stdout, for example.
2018-08-30libdpkg: Add new m_dup() functionGuillem Jover3-0/+15
2018-08-30libdpkg: Add new pkg_infodb_reset_dir()Guillem Jover2-5/+14
This makes it possible to update the infodb directory when we have changed the underlying directory with dpkg_db_set_dir().
2018-08-30libdpkg: Add support for new test_get_srcdir() and test_get_builddir()Guillem Jover2-1/+18
2018-08-30libdpkg: Switch db-fsys to use the new file_slurp() functionGuillem Jover2-67/+26
This reduces code duplication.
2018-08-30libdpkg: Add new file_slurp() functionGuillem Jover5-0/+147
2018-08-30libdpkg: Add new varbuf_new() and varbuf_free() functionsGuillem Jover4-1/+44
2018-08-30libdpkg: Change dpkg_error to track errno valuesGuillem Jover3-8/+19
This will make it possible for the caller to check what errno caused an error to be emitted, if any.
2018-08-30Switch from strchr() + strlen() to strchrnul()Guillem Jover1-5/+2
2018-08-30libcompat: Add new strchrnul() compat functionGuillem Jover3-0/+48
2018-08-30libdpkg: Split push_cleanup() into push_cleanup_fallback()Guillem Jover12-16/+45
We separate the function in one that takes one callback, and another that takes two. This simplifies most of the call sites which only need one callback.
2018-08-30libdpkg: Reset nfiles in files_db_reset()Guillem Jover1-0/+2
2018-08-30libdpkg: Switch to a new tiny struct to track file ondisk identityGuillem Jover2-3/+11
We only need the device and inode numbers for a given file to be able to compare them for identity. Avoid storing the entire struct stat which is rather fat.
2018-08-30libdpkg: Factor out package files handling into its own moduleGuillem Jover4-66/+144
We need these functions from the list and mtree implementations. Move them out so that they can be shared. In addition this is pure in-core handling so it makes sense to split out from the db-fsys modules.
2018-08-30libdpkg: Use a pointer to pointer to track previous entry in pkg_files_blank()Guillem Jover1-6/+4
We reduce the nesting level, and avoid a conditional inside the loop.
2018-08-30libdpkg: Rename pkg-db module to pkg-hashGuillem Jover2-2/+2
It contains the package hash table implementation. The on-disk database is handled elsewhere, and using db here instead of hash makes it fairly confusing.
2018-08-30libdpkg: Move db-fsys code from src to lib/dpkgGuillem Jover7-0/+1078
This will prepare the ground for external programs to start using libdpkg to access the dpkg fsys database via a proper API, instead of messing with the on-disk layout in so many improper ways.
2018-08-30libdpkg: Move files list information from dpkg clientdata to pkginfoGuillem Jover2-0/+16
This will make it possible to move the fsys database parsing and dumping code out from dpkg into libdpkg. This is general package information, even if some clients might not be interested in its contents, such as frontends that just manage metadata and drive dpkg itself.
2018-08-30libdpkg: Rename struct pkginfo files member to archivesGuillem Jover6-36/+42
Rename matching types and macros, so that the purpose of the symbols is clear, and to open the way for moving the fsys files list from the dpkg clientdata.
2018-08-30libdpkg: Document in pkg_db_get_pkg() which pkgbin members can be initializedGuillem Jover1-0/+4
The only member that can be safely initialized in a new pkginfo's pkgbin is the arch member, because that's used as part of the lookup. Anything else might get overwritten with the data from the new object, for example during deb822 parsing.
2018-08-30libdpkg: Change pkg_name() and pkgbin_name() back to get non-const structsGuillem Jover6-7/+77
This partially reverts commit cd96cca4b2cf83f46d6e289418ed06e3c2ef7066. It is not safe to assume that the pkgname_arcqual member has been populated before. The caller might have used a local variable filled manually. So we should always check whether it is NULL and fill it ourselves, before returning it. In addition now that we have the const function variants we can turn these back into non-const so that we can do the archqualified package name generation, and cache it for later use.
2018-08-30libdpkg, dselect: Use new pkg_name_const() and pkgbin_name_const()Guillem Jover1-12/+12
This will make it possible to switch the pkg_name() and pkgbin_name() back to take non-const structs, and then fill the pkgname_archqual cache on demand.
2018-08-30libdpkg: Add new pkg_name() and pkgbin_name() const variantsGuillem Jover3-0/+60
Because C does not have a C++ equivalent for the mutable keyword, we cannot mark the pkgname_archqual member as such. Instead we will add a new couple of const functions that will fallback to return a non-freeing string to be used mostly in error handling code paths in case there is no cached member, as otherwise we'd be "leaking" those strings (just generating new instances that will be released as part of the pool) every time we call these functions.
2018-08-30libdpkg: Factor out cached arch-qualified package name generationGuillem Jover3-8/+22
Move this into a proper function so that we can call it from multiple places. In addition we always return a non-freeing allocated string, in case the architecture is empty or none.
2018-08-30libdpkg: Fix pkgbin_name_needs_arch() to ignore empty and missing archesGuillem Jover1-2/+5
There's no point in arch-qualifying a package name if we got no architecture to qualify it with.
2018-08-30libdpkg: Add missing db-ctrl symbols to the libdpkg.map fileGuillem Jover1-0/+7
2018-08-30libdpkg: Fix dpkg_arch_find() Doxygen commentGuillem Jover1-4/+5
2018-08-30libdpkg: Fix header file titleGuillem Jover10-10/+10
2018-08-30Fix some typosGuillem Jover2-2/+2
Thanks-to: Niels Thykier <niels@thykier.net> (for typo in dpkg(1))
2018-08-01libdpkg: Do not compare an unsigned int with <=Guillem Jover1-1/+1
Warned-by: cppcheck
2018-08-01libdpkg: Improve unit test to use assigned variableGuillem Jover1-1/+3
Add a couple of checks to make the test more robust, and to use an assigned variable. Warned-by: cppcheck
2018-08-01libdpkg: Turn variable into unsigned to match format stringGuillem Jover1-1/+1
Warned-by: cppcheck
2018-08-01libdpkg: Use memccpy() instead of strncpy()Guillem Jover1-2/+4
We were using strncpy() here as originally intended, to copy a string into a struct member without copying the NUL-terminator. But now gcc warns about the intended truncation, which might catch some people unexpectedly. Switch to use memccpy() which has similar semantics, but is more explicit. Warned-by: gcc-8
2018-07-24Use Synopsis instead of Summary for the short DescriptionGuillem Jover4-12/+13
This unifies the term with the rest of the codebase, and makes it more descriptive.
2018-07-24Track package status dirtinnessGuillem Jover3-5/+14
Now that the status changes are abstracted via a setter, which makes sure only new changes are recorded, we can also record whether those changes happened, so that we avoid unnecessarily logging unchanged states. Closes: #365921
2018-05-05libdpkg: Use MD5_CTX instead of struct MD5ContextGuillem Jover1-1/+1
The former is more portable as it's defined in more system md5.h implementations, such as Solaris, while the latter is not. Analysis-support-by: Bruno Ramos from IRC
2018-05-04libdpkg: Move control database code into db-ctrl modulesGuillem Jover5-0/+577
This continues the work to generalize and make these interfaces available to other users beside dpkg itself.
2018-05-04libdpkg: Introduce frontend lockingJulian Andres Klode2-0/+22
Currently, in order to run dpkg, frontends have to release the database lock before invoking dpkg and re-acquire it afterwards, leaving a short time where the database is unlocked and a different dpkg process or frontend could lock it. Frontend locking addresses the problem by creating a "lock-frontend" file that is acquired by the frontend and not released for dpkg invocations. Thus, multiple frontends cannot race for the database lock. This change extends the frontend lock to dpkg itself, acquiring it whenever the variable DPKG_FRONTEND_LOCKED is not set, so that a user manually running dpkg or a frontend not supporting this protocol cannot interfere with a currently running frontend. [guillem@debian.org: - Add documentation. - Rename frontend lock file. - Fix error strings. ] Signed-off-by: Guillem Jover <guillem@debian.org>
2018-05-03libdpkg: Use a single struct filenamenode definitionGuillem Jover2-31/+4
The struct filenamenode hash implementation is lightweight, and once split from the bulk of the on-disk database handling there's no point in reimplementing it, and then redefining the same struct in multiple places, which is rather confusing for the reader, and even for static analyzers. Closes: #746766