summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2011-08-29pacsort: use boolean, not binary OR operationDave Reisner
Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28Allow access to package origin dataDan McGee
Add new alpm_pkg_get_origin() method, use it in the front end now that the enum constants are publicly available. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28Removed multiple definitions of pkgfrom_tDiogo Sousa
libalpm now exports type alpm_pkgfrom_t in alpm.h, which may be used by frontends. Pacman now uses alpm_pkgfrom_t instead of replicating that type (pkg_from as was in src/pacman/package.h) Updated API change in README. Signed-off-by: Diogo Sousa <diogogsousa@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28Better error handling out of package load methodDan McGee
There are many other ways to fail a package load other than "file not found". We should also use the correct error code in this case. Clean it up a bit in the various callers. 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-28pacman.c: Remove redundant strdup() in parsearg_global()Lukas Fleischer
config_set_arch() already calls strdup(). Remove strdup() from the config_set_arch() invocation to avoid a memory leak. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28Make sync error message smarter on unfound targetsDan McGee
We had two issues here. One is a file with an absolute path passed to -S results in a cryptic error message due to the database name being '\0'. The second is not realizing you should be doing -U instead of -S. Fix both of these to transform this: $ sudo pacman -S /tmp/binutils-2.21.1-2-i686.pkg.tar.xz error: database not found: to this: $ sudo pacman -S /tmp/binutils-2.21.1-2-i686.pkg.tar.xz error: target not found: /tmp/binutils-2.21.1-2-i686.pkg.tar.xz warning: '/tmp/binutils-2.21.1-2-i686.pkg.tar.xz' is a file, did you mean -U/--upgrade instead of -S/--sync? 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-25Slight refresh of the download progress callbackDan McGee
This cleans up some of the mess we have here. * switch to long units for the download size * omit the .0 decimal part from the download rate * omit the almost always zero HH: from estimated time if eta_h == 0 * Display --:-- if eta_h > 99; formatting was screwed up before The net result of this is we usually have 1 more character to use for filename display. Before: extra 500.9K 1242.4K/s 00:00:00 [######################] 100% community-testing 947.0B 28.2M/s 00:00:00 [######################] 100% multilib 26.5K 405.1K/s 00:00:00 [######################] 100% community 450.6K 1238.3K/s 00:00:00 [######################] 100% After: extra 500.9 KiB 1118K/s 00:00 [######################] 100% community-testing 947.0 B 23M/s 00:00 [######################] 100% multilib 26.5 KiB 255K/s 00:00 [######################] 100% community 450.6 KiB 1211K/s 00:00 [######################] 100% 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-25Add new 'lt' and 'zh_TW' translations from transifexDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-25Update existing translations from TransifexDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-23Retrieve default SigLevel value from backend after initial settingDan McGee
This ensures we grab and use the library default once we have processed the global SigLevel setting, but before processing the repo-specific settings. This means the following two configs will now evaluate the same, as the backend currently defaults to 'Optional': Config 1: [options] # nothing here [repo] SigLevel = TrustAll Config 2: [options] SigLevel = Optional [repo] SigLevel = TrustAll 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 callback messages to stderrAllan McRae
Fixes FS#25099. Signed-off-by: Allan McRae <allan@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-22pacsort: correct list freeingPang Yan Han
Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-22pacsort: ensure list is freed if size is 0Dan McGee
Found using: `valgrind ./src/util/.libs/lt-pacsort /dev/null` Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-22pacsort: correct pointer type in list_newPang Yan Han
Pointer sizes are the same but this makes intention clearer. Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Update message catalogsDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Update translations from TransifexDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Parse conflicts/provides/replaces at database load timeDan McGee
We did this with depends way back in commit c244cfecf654d3 in 2007. We can do it with these fields as well. Of note is the inclusion of provides even though only '=' is supported- we'll parse other things, but no guarantees are given as to behavior, which is more or less similar to before since we only looked for the equals sign. Also of note is the non-inclusion of optdepends; this will likely be resolved down the road. The biggest benefactors of this change will be the resolving code that formerly had to parse and reparse several of these fields; it only happens once now at load time. This does lead to the disadvantage that we will now always be parsing this information up front even if we never need it in the split form, but as these are uncommon fields and our parser is quite efficient it shouldn't be a big concern. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Show 'None' in Signatures -Qip/-Si output if none foundDan McGee
This is to be as consistent as possible across both types of display. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Load and allow access to sha256sumDan McGee
This adds a field in the package struct for this checksum type as well as allowing access via the API to it. The frontend is now able to display any read value. Note that this does not implement any use or verification of the value internally. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15pacman/package: show presence of signature in in -SiDave Reisner
adds a new API method: alpm_pkg_get_base64_sig [Dan: don't use a new header string in frontend] Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11pacman/query.c: avoid variable redeclarationDan McGee
We were using i as the loop variable in both the inner and outer loop. Use j in the inner loop instead for clarity. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11Enable recursive/needed sync on SyncFirstDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11pacman: remove --dbonly shortoptDave Reisner
This is somewhat of a dangerous option with limited use cases. Don't advertise it as an easily accessibly option. Signed-off-by: Dave Reisner <dreisner@archlinux.org> 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-11Allow --needed and --recursive on -U operationsDan McGee
Trivial to implement as the same backend machinery is used anyway. Document it and add it to the accepted options. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11Add -S --recursive operationDan McGee
This closely matches what we had before for -R --recursive. Basically, when specifying a target (e.g., pacman), we can now recursively pull all dependencies, regardless of version specifiers and whether they are already satisfied in the local database. This could be used to update pacman on a system with an old glibc, for example, as both pacman and glibc would get pulled into the transaction. This is most useful with --needed to prevent needless reinstalls as described in the man page changes. The end goal of this change is to wire it into SyncFirst and have it be the default mode of operation there, but that belongs in a separate changeset. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-09Merge branch 'maint'Dan McGee
Conflicts: src/pacman/callback.c
2011-08-09Update string catalogs after string tweaksDan McGee
This also pulls in some early translations we had entered in Transifex in the last day so those would not be lost. The diffstat is huge and not very telling as usual, as all sorts of fuzzyness switches happened this time around for some reason. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08Add reason to corrupted package callbackDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08Attempt to fix up some of the brokenness around failed package loadsDan McGee
This is a bit of a mess, due to the fact that we have a progress meter running. It is also ironic that we are in the midst of a method named "commit" when we haven't done a damn thing yet, and can still fail hard if either a checksum or signature is invalid or unrecognized. Adapt the former test_md5sum method to be invoked for any of the various failure types, which at least gives the user some indication of what packages are failing. A second patch will be needed to actually show worthwhile error codes, but this is going to involve modifying the actual data passed with the callback. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08Fix divide by zero when downloading zero length filesDan McGee
If someone did a 'touch bogusrepo.db', we had the potential to throw a SIGFPE or divide by zero, given that the total file size was 0 and getting passed up to the pacman callback. Fix this so we get weird but sane output and don't blow up when downloading: :: Synchronizing package databases... core 35.7K 306.7K/s 00:00:00 [###################] 100% bogusrepo 0.0K 0.0K/s 00:00:00 [###################] 100% Exception as seen in gdb: Program received signal SIGFPE, Arithmetic exception. 0x000000000040cc73 in cb_dl_progress (filename=0x619dfc "bogusrepo.db", file_xfered=0, file_total=0) at callback.c:584 584 file_percent = (file_xfered * 100) / file_total; Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08Update all translation filesDan McGee
This moves us toward staring translations for the 4.0.0 release, although this should not be interpreted as a string freeze by any means. 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-08-08mark option structs as constDave Reisner
These are never modified and even getopt_long's prototype shows this modifier on the parameter. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08src/util/Makefile.am: alphabetize targetsDave Reisner
Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08pacsort: add new utilityDave Reisner
pacsort is a command line sorting utility that implements libalpm's alpm_pkg_vercmp algorithm. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08Check return value of rename() callsDan McGee
We did a good job checking this in add.c, but not necessarily anywhere else. Fix this up by adding checks into dload.c, remove.c, and conf.c in the frontend. Also add loggers where appropriate and make the message syntax more consistent. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-02Implement parsing of the new SigLevel directiveDan McGee
Add code to conf.c that parses the new SigLevel directive. An overwhelming number of options are presented, but most users will still be fine with the Never/Optional/Required trio. More advanced users can combine these or any of the other options on a 'SigLevel = ' line, which is parsed in a left-to-right fashion and flags turned on and off accordingly. For example, all three of these will net the same config: SigLevel = Required PackageOptional SigLevel = Optional DatabaseRequired SigLevel = DatabaseRequired PackageOptional Additionally, database-specific lines assume you wish to start with any global default that has been set. For example, if any of the above lines were in the [options] section, something such as: SigLevel = PackageRequired PackageAllowMarginal Would continue to enforce required database signatures. Inspiration-by: Kerrick Staley <mail@kerrickstaley.com> Signed-off-by: Dan McGee <dan@archlinux.org>
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-28Tidy up testdb to match coding stylesDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-27Remove duplicate code shared between sync and upgradeDan McGee
Pacman did a great job of having almost (but not quite) duplicate code paths through the sync and upgrade code. We can use the same logic in both upgrade in sync once the targets are resolved, so extract a function and delete a bunch of code. 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-21Convert package filelists to an array instead of linked listDan McGee
This accomplishes quite a few things with one rather invasive change. 1. Iteration is much more performant, due to a reduction in pointer chasing and linear item access. 2. Data structures are smaller- we no longer have the overhead of the linked list as the file struts are now laid out consecutively in memory. 3. Memory allocation has been massively reworked. Before, we would allocate three different pieces of memory per file item- the list struct, the file struct, and the copied filename. What this resulted in was massive fragmentation of memory when loading filelists since the memory allocator had to leave holes all over the place. The new situation here now removes the need for any list item allocation; allocates the file structs in contiguous memory (and reallocs as necessary), leaving only the strings as individually allocated. Tests using valgrind (massif) show some pretty significant memory reductions on the worst case `pacman -Ql > /dev/null` (366387 files on my machine): Before: Peak heap: 54,416,024 B Useful heap: 36,840,692 B Extra heap: 17,575,332 B After: Peak heap: 38,004,352 B Useful heap: 28,101,347 B Extra heap: 9,903,005 B Several small helper methods have been introduced, including a list to array conversion helper as well as a filelist merge sort that works directly on arrays. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-18pacman/callback: show .sig suffix on sig downloadDave Reisner
Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>