summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2019-11-26dpkg-query: Try to use the description from the available file if not installedGuillem Jover3-0/+36
When we have been requested to load the available file, and that contains a description for a package that is not installed, we should use that instead of printing the confusing string stating that the description is not available. Closes: #43573
2019-11-26libdpkg: Add missing symbols to the version mapGuillem Jover1-0/+7
Several of these are used by the test suite.
2019-10-30libdpkg: Use p instead of name in dpkg_arch_name_is_illegal()Guillem Jover1-1/+1
We assign name to p, which we operate on everywhere in this function except for the first check which we still perform on name. This confuses at least cppcheck, and it's in any case inconsistent. Warned-by: cppcheck Fixes: nullPointerRedundantCheck
2019-10-30libdpkg, dpkg: Use new versiondescribe_c() for non-localizable call sitesGuillem Jover1-1/+1
The output on log files must not be localized. Reported-by: Julien Cristau <jcristau@debian.org>
2019-10-30libdpkg: Add new versiondescribe_c() to force a C localeGuillem Jover3-0/+17
In some contexts we need output in the C locale, such as log files. We add a new versiondescribe_c() that wraps the locale-dependant versiondescribe() function and switches to the C locale and back to the previous one before returning.
2019-10-30libdpkg: Add new C locale switch over supportGuillem Jover3-0/+51
This will make it possible to select either the current locale or a specified one, currently only C is selectable. We use this because the uselocale(3) POSIX API is recent, and the system might not have it available, so we might need to fallback to use setlocale(3) instead, which even though is not thread-safe, it's better than nothing.
2019-10-30libdpkg: Use the totalwritten variable for a consistency checkGuillem Jover1-0/+2
The variable was written to but never used. Warned-by: cppcheck
2019-10-30libdpkg: Use the variable instead of a type as sizeof() argumentGuillem Jover1-2/+2
This is more future proof, and in this particular case it was tripping over cppcheck and emitting a false positive for constArgument. Warned-by: cppcheck
2019-10-30libdpkg: Clarify lock contender error messageGuillem Jover1-3/+16
Print the PID of the lock contender, switch the tense to past as the lock might not be locked anymore by the time we finish, and add a warning explaining that removing the lock file is never the correct solution.
2019-10-12libdpkg: Do not generate a backup file for the available databaseGuillem Jover1-1/+5
This file contains information only valid as long as the downloaded sources are also available. So it is closer to a cache than a database, and as such, there is no need for an uncompressed backup, which can take quite some space. Closes: #343578
2019-03-24libdpkg: Use ERANGE instead of EINVAL for tar_atol8() out-of-range errorGuillem Jover2-5/+5
We should use the correct errno value, otherwise the error string makes little sense, and ends up being very confusing.
2019-03-24libdpkg: Handle non end-of-tape errors from tar_header_decode()Guillem Jover1-0/+2
We need to assign a status value in the non end-of-tape branch, otherwise we are using an uninitialized value, which might be anything, and could end up making the code proceed even if the archive is damaged/broken, etc.
2019-03-24libdpkg: Set tar_entry to zero on tar_entry_destroy()Guillem Jover1-0/+2
When we are destroying a tar_entry we need to zero the struct, otherwise we will end up freeing already freed memory and crashing.
2019-03-24libdpkg: Add a new TAR_FORMAT_UNKNOWN enum valueGuillem Jover1-0/+1
This will make it possible to have a value denoting an unknown format, when we initialize the tar_entry or tar_archive structs.
2019-02-23libdpkg: Fix typosGuillem Jover1-2/+2
2019-02-23libdpkg, dpkg: Print the dpkg database directory on access errorsGuillem Jover4-18/+27
There were several error messages involving the dpkg database, that were ambiguous by referring to it as "dpkg status area", instead of printing the affected pathname. The historical reason for not being more explicit has been to keep the user a bit under the dark, because this has been an internal database storage, and only those in the known would go there to edit it by hand and similar. This is a bit pointless though, because the Internet is full of references to those directories, and other error messages just print them anyway. In addition, for users that want to diagnose what is the problem this is not helpful, and the directory might have been changed at build or run time with one of the options. Closes: #883700
2019-02-23libdpkg: Blank packages that are not-installed with unknown selectionGuillem Jover1-0/+11
Versions before 1.13.10 did not properly clear the Origin and Bugs fields, so there might still be entries with these fields that are not getting garbage collected properly. Make sure to blank these package entries so that they get forgotten on the next database dump. Closes: #922410
2019-02-23libdpkg: Use pkg_set_want() instead of a direct assignmentGuillem Jover1-1/+1
2019-02-23libdpkg: Include <string.h> in pager.cGuillem Jover1-0/+1
Closes: #922212 Reported-by: Y <sevener@cock.li>
2019-02-23libdpkg: Use va_arg copy instead of the original on a vasprintf() callGuillem Jover1-1/+1
We need to do that, as we might try to use args again when constructing the error message into the emergency buffer, which would get garbage instead.
2019-02-23libdpkg: Fix unit test for file_slurp()Guillem Jover1-1/+1
We should compare only the memory being used, and file_slurp() does not guarantee NUL-terminating the varbuf. Closes: #920974 Diagnosed-by: Frank Schaefer <kelledin@gmail.com>
2019-02-23libdpkg: Increase the pkg-hash bins sizeGuillem Jover1-5/+10
We use a number that is close to the amount of packages currently present in a Debian suite, so that installed and available packages do not add tons of collisions. The memory usage is «BINS * sizeof(void *)», so it will be 256 KiB on 32-bit systems and 512 KiB on 64-bit systems. Update the code comment to reflect the above.
2019-02-23libdpkg: Print a more accurate warning for Revision nicknamesGuillem Jover1-3/+1
Now that we do not use a nickname mapping anymore, the field struct contains the actual field name matched, so we can report it correctly instead of listing all possible altrnatives, and then missing some.
2019-02-23libdpkg: Merge nicknames table into fieldinfosGuillem Jover2-30/+7
The current code first does a lookup to see if the fieldname is in the nicknames table, if found fixes up the fieldname to the new alias, and then always does a lookup for the normalized name in fieldinfos table. This penalizes the common case (i.e. non-obsolete fieldnames) substantially. Also moving the nicknames into the fieldinfos table will allow to print correct fieldnames on error as those are not mangled any more, and to provide new wrapper parse functions that print warnings for the obsolete fieldnames.
2019-02-23libdpkg: Optimize error handlingGuillem Jover4-45/+80
Move the error reporting outside the involved functions so that we do not need to call gettext if there is no error, which has a significant performance cost.
2019-02-23libdpkg: Clarify field names in error and warning messagesGuillem Jover3-38/+41
Move all field names to be format arguments so that these do not get accidentally translated. Use fip->name instead of hardcoding the field name. Always refer to the field names as "'%s' field". Use the proper field names instead of descriptions. And capitalize their names.
2019-02-23libdpkg: Move status names from parse errors to argumentsGuillem Jover1-5/+6
Although package states are very unlikely to change their names, it's just better to use a single canonical place to store their values. This also makes sure no translator will accidentally translate these names.
2019-02-23libdpkg: Add new dpkg_has_error() functionGuillem Jover3-0/+11
2019-02-23libdpkg: Add new dpkg_error_move() functionGuillem Jover3-0/+11
2019-02-23libdpkg: New benchmark programs and infrastructureGuillem Jover9-2/+285
These are intended to be used to check performance improvements in the libdpkg implementation.
2019-02-23dpkg: Clarify error on unknown system user/group in statoverride databaseGuillem Jover1-4/+6
Closes: #920880
2019-01-22libdpkg: Add new db-fsys:Files and db-fsys:Last-Modified virtual fieldsGuillem Jover3-2/+60
This will make it possible to access the filesystem entries per package from anything that queries the database, such as «dpkg-query --show».
2019-01-22libdpkg: Detect unsupported tar entry types to give better error messagesGuillem Jover2-0/+32
We know what we do not support, let's detect and give better diagnostics so that users get even less confused.
2019-01-22libdpkg: Add proper tar error handlingGuillem Jover3-51/+81
This makes the tar extractor track and report back parse errors, so that we can give more descriptive messages.
2019-01-22libdpkg: Add new DPKG_ERROR_OBJECT macroGuillem Jover1-0/+2
2019-01-22libdpkg: Add new warning printer setter functionGuillem Jover3-3/+26
This will make it possible for library users to specify alternative warning printers. Prompted-by: Julian Andres Klode <jak@debian.org>
2019-01-22libdpkg: Rename pkg_db symbols to pkg_hashGuillem Jover17-131/+144
These are handling a package hash, and db seems to imply some kind of on-disk storage. Rename the pkgiterator too to pkg_hash_iter to make it consistent.
2019-01-22libdpkg: Cleanup fsys module symbol namesGuillem Jover16-201/+204
2019-01-22libdpkg: Rename ret variable to nextGuillem Jover1-3/+3
2019-01-22libdpkg, dpkg: Rename r variables to fnnGuillem Jover1-4/+4
2019-01-22When allocating use the variable instead of the type in sizeof()Guillem Jover12-24/+24
This makes it easier to guarantee we use the correct size for the involved variable.
2018-10-08libdpkg: Add a pager kill switchGuillem Jover2-0/+16
This way we will be able to forcefully disable it.
2018-10-08libdpkg: Set stdout to be fully buffered when using a pagerGuillem Jover1-0/+5
Force the output to fully buffered, because originally stdout was a tty, so it was set as line buffered. This way we send as much as possible to the pager, which will handle the output by itself.
2018-10-08libdpkg: Ignore SIGPIPE when setting up a pagerGuillem Jover2-1/+14
If the pager quits early, the parent will receive a SIGPIPE as the write end of the pipe will not be available anymore. Instead we ignore SIGPIPE and also EPIPE errors when writing to stdout. Otherwise if we quit the pager early, the program will exit with an error code. Reported-by: Holger Levsen <holger@layer-acht.org> Ref: #909754
2018-10-08libdpkg: When spawning a pager set LESS to “-FRSXMQ” if not already setGuillem Jover1-0/+3
2018-10-08libdpkg: Honor DPKG_PAGERGuillem Jover1-1/+3
This makes it possible to use a dpkg specific pager. Suggested-by: Craig Sanders <cas@taz.net.au> Ref: #909754
2018-10-08libdpkg: Do not spawn a pager if we are going to call «cat»Guillem Jover1-4/+5
There's no point in executing «cat», we are already dumping the contents to stdout.
2018-10-08libdpkg: Call the pager with «$SHELL -c» to respect POSIXGuillem Jover1-4/+1
The PAGER environment variable is specified in POSIX as taking a pager command and any number of arguments to be passed to «sh -c», so we have to preserve that behavior or this breaks badly on systems where PAGER is set that way. This actually gets in the way of improving the pager command presence detection, but we'll fix that later on, by making the scanning of the environment variable smarter or by trying to execute the fallbacks. Closes: #910009
2018-10-08libdpkg: Pass the file contents to the pager instead of the filenameGuillem Jover3-5/+19
Let's just handle opening the file and passing its data to the pager ourselves, as that gives us more control, and then can decide not to run a pager at all, and do not need to mess with arguments which might need to be passed to «sh -c».
2018-10-08libdpkg: Add new fsys-dir moduleGuillem Jover7-0/+169
This module handles setting and getting the filesystem root directory.