summaryrefslogtreecommitdiff
path: root/src/pacman/util.c
AgeCommit message (Collapse)Author
2011-09-28Always show download size if -w/--downloadonly was providedDan McGee
The prompt can be rather confusing otherwise when all files have already been downloaded, but there is not a single total size listed. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Table format creation code cleanupDan McGee
Better scoping of variables for the most part, and ensure we are using string_length() and not strlen() as appropriate. Also refactor the longest cell code to call string_length() a lot less; by simply using an array of max sizes we don't have to recompute values nearly as much. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Use unsigned types for indent width and column countDan McGee
For getcols(), the functions we call return a value of type 'unsigned short', so it makes sense for us to do the same. string_length() is meant to behave like strlen(), so it should return type size_t. This exposes other functions such as indentprint() which should also be using signed return types. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Show download sizes when using -S/--syncDan McGee
We now label the old 'Size' column as 'Net Change' to reflect the reality of what we are looking at. Sync operations now get an additional 'Download Size' column. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Keep track of explicitly added and removed packagesDan McGee
This allows us to sort the output list by showing all pulled dependencies first, followed by the explicitly specified targets. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Combine add and removal package list displayDan McGee
There was no real reason for these to be done separately. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22Add status and check for key being disabledDan McGee
Because we aren't using gpgv and a dedicated keyring that is known to be all safe, we should honor this flag being set on a given key in the keyring to know to not honor it. This prevents a key from being reimported that a user does not want to be used- instead of deleting, one should mark it as disabled. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22Fix signature printing in package infoDan McGee
pm_asprintf() does not return a length as asprintf() does. Fail. Make sure it is not -1 as that is the only failure condition. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20pacman: use dynamic string allocation where it makes senseDan McGee
None of these are hot-code paths, and at least the target reading has little need for an arbitrary length limitation (however crazy it might be to have longer arguments). Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-14Don't duplicate header stringsDan McGee
There is no need to print them into buffers; we can use the values returned by gettext() directly without issue. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02Move all callbacks up to the handle levelDan McGee
This was just disgusting before, unnecessary to limit these to only usage in a transaction. Still a lot of more room for cleanup but we'll start by attaching them to the handle rather than the transaction we may or may not even want to use these callbacks. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-29Improve advice for sync ops when db.lck is presentPang Yan Han
When the database is locked, sync operations involving transactions, such as pacman -Syy, show the following: :: Synchronizing package databases... error: failed to update core (unable to lock database) error: failed to update extra (unable to lock database) error: failed to update community (unable to lock database) error: failed to update multilib (unable to lock database) error: failed to synchronize any databases Whereas pacman -U <pkg> shows: error: failed to init transaction (unable to lock database) if you're sure a package manager is not already running, you can remove /var/lib/pacman/db.lck Which is much more meaningful, since the presence of db.lck may indicate an erroneous lockfile instead of an ongoing transaction. Improve the error messages for sync operations by advising the user to remove db.lck if he is sure that no package manager is running. Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28Refactor signature result return formatDan McGee
I was trying to take a shortcut and not introduce a wrapper struct for the signature results, so packed it all into alpm_sigresult_t in the first iteration. However, this is painful when one wants to add new fields or only return information regarding a single signature. Refactor the type into a few components which are exposed to the end user, and will allow a lot more future flexibility. This also exposes more information regarding the key to the frontend than was previously available. The "private" void *data pointer is used by the library to store the actual key object returned by gpgme; it is typed this way so the frontend has no expectations of what is there, and so we don't have any hard gpgme requirement in our public API. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-25strtrim: don't move empty stringDan McGee
There were many cases where the string coming in was a blank line, e.g. "\n\0", length 1. The trim routine starts by trimming leading spaces, thus trimming everything. We would then proceed to do a memmove of the NULL byte, which is completely worthless as we can just assign it instead. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-25Remove short/long label distinctionDan McGee
We only used short labels in one place, and the short label is always the first character of the long label anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-25Add a few more sizes to humanize_sizes()Dan McGee
Because why the hell not? Exbibyte, zebibyte, and yobibyte are going in, even though nothing bigger than the 2^60 exbibyte can be represented using an off_t variable anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-22pacman/util: use string_length to calculate line lengthDave Reisner
This is measuring strings that are potentially localized, so we need a multibyte aware function to count characters instead of bytes. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-22Print debug timestamps to same stream as rest of outputDan McGee
We used fprintf() elsewhere in this function, but we didn't use it on the debug timestamp printing. Use fprintf() instead of printf() to fix this. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11Update trust level strings in -Qi displayDan McGee
It makes more sense to use the same tense and construction on all of these. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08Merge branch 'maint'Dan McGee
Conflicts: lib/libalpm/dload.c lib/libalpm/po/fi.po lib/libalpm/po/libalpm.pot po/de.po po/fi.po src/pacman/po/pacman.pot src/pacman/util.c
2011-07-28Revamp signing checksDan McGee
This ensures we are actually making correct use of the information gpgme is returning to us. Marginal being allowed was obvious before, but Unknown should deal with trust level, and not the presence or lack thereof of a public key to validate the signature with. Return status and validity information in two separate values so check methods and the frontend can use them independently. For now, we treat expired keys as valid, while expired signatures are invalid. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-25Fix group selection entry for large inputsDan McGee
Hardcoding anything always ends up burning you, and the arbitrary length of 64 here did just that. Add the ability to reallocate the readline buffer for longer inputs if necessary, and add other error checking as approprate. This also plugs one small memory leak of the group processing code selection array. Addresses FS#24253. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05Remove most usages of strncmp()Dan McGee
The supposed safety blanket of this function is better handled by explicit length checking and usages of strlen() on known NULL-terminated strings rather than hoping things fit in a buffer. We also have no need to fully fill a PATH_MAX length variable with NULLs every time as long as a single terminating byte is there. Remove usages of it by using strcpy() or memcpy() as appropriate, after doing length checks via strlen(). Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05Remove alpm_list_firstAllan McRae
The only thing this accessor did was remove the const qualifier given our entire list implementation requires passing around the head anyway. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05Allow invalid sync DBs to be returned by the libraryDan McGee
They are placeholders, but important for things like trying to re-sync a database missing a signature. By using the alpm_db_validity() method at the right time, a client can take the appropriate action with these invalid databases as necessary. In pacman's case, we disallow just about anything that involves looking at a sync database outside of an '-Sy' operation (although we do check the validity immediately after). A few operations are still permitted- '-Q' ops that don't touch sync databases as well as '-R'. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05Allow frontend access to signature verification informationDan McGee
Show output in -Qip for each package signature, which includes the UID string from the key ("Joe User <joe@example.com>") and the validity of said key. Example output: Signatures : Valid signature from "Dan McGee <dpmcgee@gmail.com>" Unknown signature from "<Key Unknown>" Invalid signature from "Dan McGee <dpmcgee@gmail.com>" Also add a backend alpm_sigresult_cleanup() function since memory allocation took place on this object, and we need some way of freeing it. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-02Prefix _alpm_errno_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02Prefix alpm_transflag_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02Prefix alpm_loglevel_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmerrno_t to alpm_errno_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmtransflag_t to alpm_transflag_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmloglevel_t to alpm_loglevel_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmpkg_t to alpm_pkg_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmdb_t to alpm_db_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-27Fix several -Wshadow warningsDan McGee
Only one of these looked like a real red flag, in find_requiredby(), but it doesn't hurt to fix several of them up anyway. Unfortunately, we can't turn this on universally due to things like the sync(), remove(), etc. builtins which we often use as variable names. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24Move database 'version' check to registration timeDan McGee
This is another step toward doing both local database validation (ensuring we don't have depends files) and sync database validation (via signatures if present) when the database is registered. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-20pacman/util.c: support terminals with unknown widthDave Reisner
Add detection for stdout being attached to a tty device. When this check fails, return a default width of 0, which callers interpret to mean "don't wrap". Conversely, when our term ioctl suceeds but returns 0, we interpret this to mean a tty with an unknown width (e.g., a serial console), in which case we default to a sane value of 80. Signed-off-by: Dave Reisner <d@falconindy.com>
2011-06-15Merge branch 'maint'Dan McGee
2011-06-15Ensure humanize_size works for negative valuesJakob Gruber
Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-15Use pm_fprintpf in table_create_formatJakob Gruber
Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-15list_display: fix incorrect assignmentDan McGee
Commit 895a88886525d erroneously left this around. Noticed-by: Jakob Gruber <jakob.gruber@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Merge branch 'maint'Dan McGee
Conflicts: doc/makepkg.conf.5.txt
2011-06-14Remove alpm_db_get_url()Dan McGee
This method is old, it doesn't adequately check for a NULL server list, and can easily be done using better API method we provide these days. All former users of this method can get similar results by calling alpm_db_get_servers() and using the data from the returned server list. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13Move pm_errno onto the handleDan McGee
This involves some serious changes and a very messy diff, unfortunately. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13Fix all current return(x) usagesDan McGee
A few of these snuck in as of late, some from the table display patches that were using the previous format before we changed it after the 3.5.X major release. Noticed-by: Kerrick Staley <mail@kerrickstaley.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13Fix list_display on non-ttys and other output fixesDan McGee
commit c1f742d7750a14 broke what was one of the tenants of out output- if piping pacman output somewhere else, we shouldn't ever try to line-wrap and indent print our output. This makes it easier for tools to use output from pacman -Ss, -Qs, -Qi, etc. list_display() unfortunately was given a default value of 80 rather than 0, so fix this. Next, make some additional changes that ensure we don't insert an unnecessary blank line if for some crazy reason the indent level (such as on -Qi output) is greater than the number of columns. Accomplish this by printing the first item unconditionally as we do in list_display_linebreak(). Finally, teach indentprint to not wrap if the number of columns is less than the indent level, this prevents some forms of ridiculous output such as the following: Install Date : Wed 08 Jun 2011 04:39:19 AM CDT Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle argument to all alpm_trans_*() methodsDan McGee
Begin enforcing the need to pass a handle. This allows us to remove one more extern handle declaration from the backend. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle argument to all alpm_option_(get|set)_*() methodsDan McGee
This requires a lot of line changes, but not many functional changes as more often than not our handle variable is already available in some fashion. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-02Merge branch 'maint'Dan McGee
Conflicts: src/pacman/callback.c
2011-06-02Show net upgrade size on -U/-S operationsDan McGee
If it is different than the raw installed size metric we already show, compute the net upgrade size. For some sync operations, this can even be negative if newer packages are smaller than the ones they replace locally. Implements FS#12566. Example: Targets (1): telepathy-glib-0.14.7-1 Total Download Size: 1.07 MiB Total Installed Size: 15.72 MiB Net Upgrade Size: -0.29 MiB Signed-off-by: Dan McGee <dan@archlinux.org>