summaryrefslogtreecommitdiffstats
path: root/src/pacman/util.h
AgeCommit message (Collapse)AuthorFilesLines
2010-09-27Add wrapper around asprintf callsAllan McRae1-0/+1
Not checking the return value of asprintf calls reuslts in a warning when using -D_FORTIRFY_SOURCE=2. This adds a simple wrapper around asprintf calls which checks the return value. Currently the check does nothing more than outputing a message to stderr on failure, but that is at least an improvement over silent failures. Signed-off-by: Allan McRae <allan@archlinux.org>
2010-07-27Use the plural features of gettextDan McGee1-0/+2
Gettext has this whole 'Plural-Form' thing that until now we haven't taken advantage of. Given that not all languages have the same plural form rules as English, take advantage of it by defining a new _n() macro which will normally define to ngettext(), and adjust a few messages as an example of how to use. There are surely other places where we do singular/plural logic without me having noticed, so further patches are welcome to fix those up too. Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-15Bump copyright dates to 2010Dan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-15Add new --print operation for all operationsXavier Chantry1-0/+1
And a new --print-format option to configure the output. This implements FS#14208 Example usage : pacman -Sp --print-format "%r/%n-%v : %l [%s]" kdelibs extra/kdelibs-4.3.2-4 : ftp://mir2.archlinuxfr.org/archlinux/extra/os/i686/kdelibs-4.3.2-4-i686.pkg.tar.gz [0,00] Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-10-11Remove makepath function from frontendLaszlo Papp1-1/+0
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-09Remove transaction typeXavier Chantry1-2/+1
This basically started with this change : /* Transaction */ struct __pmtrans_t { - pmtranstype_t type; pmtransflag_t flags; pmtransstate_t state; - alpm_list_t *packages; /* list of (pmpkg_t *) */ + alpm_list_t *add; /* list of (pmpkg_t *) */ + alpm_list_t *remove; /* list of (pmpkg_t *) */ And then I have to modify all the code accordingly.
2009-07-01Update copyright headers and messagesDan McGee1-1/+2
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-02We don't need root with -SpNagy Gabor1-1/+1
FS#8905 is fixed. The front-end passes PM_TRANS_FLAG_NOLOCK to the back-end, so it doesn't lock the database. That's why we don't need root anymore. I reworked (and renamed) needs_transaction() accordingly. I also added missing -Sc check there (for example, -Sci didn't print non-root error, but pacman wanted to lock the database). Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-10-13Merge branch 'maint'Dan McGee1-3/+3
2008-10-13Reduce number of calls to getcols()Dan McGee1-3/+3
Every call to getcols() results in two ioctl() calls, which we really didn't need as changing the number of columns in mid-print would be pretty crazy. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-08-26pacman : smarter optdepends handling.Xavier Chantry1-0/+1
During an upgrade, only the new optdepends will be displayed, to only keep the useful information and not clutter pacman output too much. The whole optdepends list is always available with -Si / -Qi. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-08-23split yesno() into yesno() and noyes() functions.Xavier Chantry1-1/+2
The yesno function had a preset argument for specifying the default answer : yes or no. However, in all our calls to yesno, only one used the default "no" answer. Having to specify preset==1 for all the other cases was rather cumbersome. To make this easier, this commit adds a noyes function, with the following behavior : yesno() : default answer is yes noyes() : default answer is no Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-08-23pacman: print optdepends on install and upgrade.Xavier Chantry1-0/+1
This implements FS#10630. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-08-23Add new list_display_linebreak functionNagy Gabor1-0/+1
list_display puts several members on the same line, which is not appropriate for optdepends: Optdepends: foo: feature1 bar: feature2 baz: feature3 The new list_display_linebreak function puts every member on its own line, which is much better with optdepends: Optdepends: foo: feature1 bar: feature2 baz: feature3 Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Xav: implement this new behavior as a new function rather than as a parameter of list_display] Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-07-25src/pacman : rework the display_targets function.Xavier Chantry1-1/+2
We had a lot of duplicated code here. The code handling the showsize option needed to be there three times : 1) for install part of -S 2) for remove part of -S (conflict removal) 3) for -R This patch introduce a new display_targets(pkglist, install) function which can handle the 3 cases above. We pass install == 1 for case 1), and install == 0 for case 2) and 3). Now we can finally get the benefit of an old patch which handled the ShowSize option consistently in the 3 cases above, without an awful lot of duplicated code : http://www.archlinux.org/pipermail/pacman-dev/2008-January/011029.html Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-26Refactor the trans init and release code.Chantry Xavier1-0/+2
The calls to alpm_trans_init and alpm_trans_release (+ error checking) were duplicated between remove.c, sync.c and upgrade.c This patch introduces trans_init and trans_release functions in util.c to have this code just once. So instead of having to do the same change 3 times for fixing FS#10273, I just had to do it once (so I did it too :)) Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-25Improve yesno function.Chantry Xavier1-1/+1
Add a preset paramater to yesno function saying which answer should be the default. Ref: http://www.archlinux.org/pipermail/pacman-dev/2007-June/008470.html This allows us to answer no by default to some questions, like the -Scc one mentioned in the above thread, and implemented by this patch. Another advantage is that we don't have to repeat the [Y/n] in every questions. It's only put once in yesno function. This highly reduces the chances that YES and NO strings are translated, but not some questions, which lead to obvious confusions. Finally, the noconfirm variable only needs to be used in that yesno function. So all other usages of it were removed. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-02-06pacman/util.c: add mdirname functionDan McGee1-0/+1
This function mirrors mbasename and will be used by the 'owns' machinery. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-11Update GNU GPL boilerplate and copyright datesDan McGee1-3/+1
Update the GPL boilerplate to direct people to the GNU website for a copy of the license, as well as bump all of Judd's copyrights to 2007. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-04Delay output during progress barChantry Xavier1-0/+1
This fixes the output issue related to the progress bar by delaying the output. We can decide later (post-release) if we like this method or we want to switch to something else. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> [Dan: just some minor cleanups] Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-01Unify dump_pkg_full in pacman [-Si, -Qip, -Qi and -Qii]Nagy Gabor1-0/+1
dump_pkg_sync is now a trivial wrapper for dump_pkg_full Some smaller changes: * string_display function added to util.c [prints None in case of empty string] * Filename field added to -Qip * rename License to Licenses * 'Compressed Size' used instead of 'Download Size' for -Qip Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Dan: fix whitespace errors, spacing issues, const modifiers] Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-25Move mbasename from pacman.c to util.cChantry Xavier1-0/+1
This function can be useful in other places. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-14Make it easier to ignore multiple packages.Nathan Jones1-0/+1
This makes --ignore and --ignoregroup able to accept multiple packages/groups by separating each with a comma. For instance: pacman -Su --ignore kernel26,udev,glibc This was requested in the comments of FS#8054. Signed-off-by: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-24Add strndup implemention for environments that are missing itDan McGee1-0/+4
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-23Ensure all localization stuff is correctly guardedDan McGee1-5/+5
Anything dealing with libintl and localization should be correctly guarded inside an ENABLE_NLS block on both the pacman and libalpm sides. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-20Add download size to target list.Nathan Jones1-1/+1
This displays the download size, taking into account delta files and cached files. This closes FS#4182. Signed-off-by: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-09Update usage of gcc __attribute__ flagsDan McGee1-3/+3
Change the default visibility of libalpm functions to internal instead of hidden- this allows for slightly better optimization because it tells GCC that the function can never be called outside of the current module (see http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html). Also added some attributes to the pacman print functions so that they check the format strings being passed to them. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-28Break out transaction test to a separate functionAaron Griffin1-0/+1
Added needs_transaction, putting out "hey do we need root?" tests in one place. Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-06-12pacman util.h: Add missing stdarg.h includeDan McGee1-0/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-09Add a series of pm_printf functions to pacman frontendDan McGee1-0/+3
Add pm_printf, pm_fprintf, and pm_vfprintf to the pacman frontend for use by debug printing and other output messages from pacman. These will be incorporated into the log callback functions in the next iteration of changes. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-05Const correctness!Dan McGee1-2/+2
Add some 'const' keywords all over the code to make it a bit more strict on what you can and can't do with data. This is especially important when we return pointers to the pacman frontend- ideally this would always be untouchable data. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-05Add a parseconfig to the pacman frontend that compilesDan McGee1-1/+1
Warning: this compiles but may not work as intended quite yet. :) Signed-off-by: Dan McGee <dan@archlinux.org>
2007-05-31Move DB and cache dirs away from there dependence on ROOTDIRDan McGee1-2/+2
This change allows us to use all autoconf specified paths, most notably $(localstatedir). It is quite a change and touches a lot of files, as all references to the DB and cache were done with the ROOTDIR as a prefix. * add --lock command-line option to pacman to specify the location of the lockfile (this can now be specified at configure time by setting the $localstatedir path). * Rip quite a few settings out of configure.ac as they are now picked by setting the paths during configure or make. * Fix bug with /tmp fallback for sync downloads not working correctly (related to root location, now the system tmp dir is used). * Simplified the parameters to some libalpm functions, and added get/set for the new lockfile option. * Renamed several of the DEFS to names without the PM_ prefix. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-27Clean up gettext on the libalpm sideDan McGee1-0/+4
Remove inclusion of libintl.h from all files, because we can do it once in util.c where the _() macro is defined. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-27Remove output.c and output.hDan McGee1-4/+5
One function was left in this set of files after the earlier cleansing, so I moved yesno to util.c. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-27Start of the newline fixes after switching over the outputDan McGee1-1/+0
* A few quick newline fixes, mostly related to sync operations. * Moved get_update_timediff to callback.c as it is not used outside of that file. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-26Pacman side code consolidation- unify callback functions to one fileDan McGee1-1/+0
Some more major code reorginization here. The download progress callback function has been renamed and moved to callback.c, which is the former trans.c with the download and log callbacks added. In addition, this allows util.c to be cleaned up as fill_progress can now be static in callback.c. We've also cut two more source files out. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-26More pacman side cleanupDan McGee1-19/+0
* Cleaned up more of the header #includes, and got rid of a lot of stuff that was due to trying to make it compile on BSD/Darwin/CYGWIN. We can add it later but lets keep it simple for now and do it in seperate files if possible later. * Removed a lot of #define MACROS. Some were not even used, and others were only used a few times. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-25Remove more unnecessary stuffDan McGee1-1/+3
* Remove libintl.h from most files, as we only need to include it once in util.h where _() is defined. * Remove other unnecessary header inclusions. * Remove a macro that was only used once and replaced it with actual code. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-03-13* Resizing terminal while progress bars were displayed caused some weirdDan McGee1-2/+2
issues, this should fix it. Progress bars now go from displaying, to showing percent only, to not displaying at all. Changed unsigned -> signed to prevent wraparound errors in integer comparison.
2007-03-06* Added missing header include guards in md5.h and sha1.h.Dan McGee1-1/+0
* Some header cleanup on the pacman side of things - we had alpm.h instead alpm_list.h in a few headers. * removed an extra slash in path-building snprintf in server.c.
2007-02-04Implemented a crappy version of -Qu (query upgrades). This simply outputs theAaron Griffin1-1/+1
packages to be upgraded in a -Su operation. Much of the code is duplicated from sync.c. TODO: move the implementation to upgrades.c, and reimplement the sync_sysupgrade function in terms of this: trans->packages = alpm_get_upgrades();
2007-02-04* unified the progress bars (fill_progress function)Aaron Griffin1-0/+6
* fixed progress output (needs an fflush to move cursor properly) * broke display_targets function out, to display a list of syncpkgs in preparation for a -Qu option * added get_update_time function to deal with progress functions that shouldn't update too fast due to output redraw speeds
2007-02-01* Tried to clean up newline display a bit in the frontend.Dan McGee1-1/+0
* Removed useless buildstring function from util.h; replaced all calls of it with list_display. * Made list_display output 2 spaces instead of 1 between each item.
2007-01-19Preliminary checkin for alpm_list conversionAaron Griffin1-2/+8
* renamed pmlist_t -> alpm_list_t * made alpm_list_t a public type (alpm_list.h header) * removed additional storage for registered DBs in pacman source * some code cleanup * removed duplicate (pm)list_display functions from pacman source * misc code cleanup
2007-01-18Dan McGee <dpmcgee@gmail.com>Aaron Griffin1-3/+3
* Removed some unnecessary headers and library links * Made things static if possible * Cleaned up makefiles a bit * Fixed some old comments in the code * Fixed some errors the static code checker splint pointed out * Backwards arguments in a memset call in _alpm_db_read (could have been worse) * Other various small fixes Other: * Default to 80 columns when getcols cannot determine display width * Removal of ._install as a valid install file in packages
2006-11-20* repo-add script - to add entries to a db file directly from package data ↵Aaron Griffin1-2/+2
(no PKGBUILD) * libalpm api changes - move from a _getinfo(p, WHAT_WE_WANT) scheme to a typesafe _get_what_we_want(p) scheme [not 100% complete yet] * some const correctness changes * removal of PM_* types in alpm.h in favor of the pm*_t types used throughout libalpm
2006-10-15Merged frugalware changes. Added a few other minor things too, but there's alotAaron Griffin1-1/+1
to list. The diff should show you 8)
2006-05-15first stage of i18n stuff from VMiklosJudd Vinet1-0/+2
2006-03-13- removed pacman.hAurelien Foret1-1/+4
- removed unuseful extern declarations - set pacman.c internal functions as static