summaryrefslogtreecommitdiffstats
path: root/src/pacman/query.c
AgeCommit message (Collapse)AuthorFilesLines
2017-01-04Update copyright yearsAllan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30Turn off colours once finished using themAllan McRae1-2/+3
The colour of the package version could leak onto the next line in both -Qo and -Fo. Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05Add colour to the output of the "-{F, Q}o" operations.Xavion1-2/+3
Matching output for -s operations, the repository is coloured 'magenta', the package name is 'bold', and the version is outputted in 'green'. Signed-off-by: Xavion <Xavion (dot) 0 (at) Gmail (dot) com> Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05Handle provides with -QAllan McRae1-0/+3
It is useful to be able to use "pacman -Qi" on any dependency, even if that dependency is a provide. For example, on Arch Linux systems, "sh" is provided by the "bash" package, and many packages depend on "sh". Querying the package that provides the "sh" dependency currently requires first searching for "sh". This patch allows the use of "pacman -Qi" on a provide. Fixes FS#20650. Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05pacman_query: move error messages into relevant if statementsAllan McRae1-16/+16
This ensures any additions to these test do not have to rely on the correct error condition being set by libalpm. Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04Update copyright years for 2016Allan McRae1-1/+1
make update-copyright OLD=2015 NEW=2016 Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01Update copyright notices for 2015Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-28Remove ts and sw from vim modeline when noet is setFlorian Pritz1-1/+1
Forcing vim users to view files with a tabstop of 2 seems really unnecessary when noet is set. I find it much easier to read code with ts=4 and I dislike having to override the modeline by hand. Command run: find . -type f -exec sed -i '/vim.* noet/s# ts=2 sw=2##' {} + Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06Update copyright years for 2014Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-15Fix whitespace and other formatting issuesJason St. John1-1/+1
This commit: -- replaces space-based indents with tabs per the coding standards -- removes extraneous whitespace (e.g. extra spaces between function args) -- adds missing braces for a one-line if statement Signed-off-by: Jason St. John <jstjohn@purdue.edu>
2013-10-31Indicate ignored packages in -Qu outputAllan McRae1-0/+4
Add "[ignored]" in the "pacman -Qu" output after packages that have their upgrades ignored. Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-14rename PKG_LOCALITY_LOCAL -> PKG_LOCALITY_NATIVEAndrew Gregory1-2/+2
PKG_LOCALITY_LOCAL was confusing because the enum is used with -Q, so all packages are "local". Also reversed the config->op_q_locality assignment so that the locality matches the option used. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-14Display old and new version in pacman -Qu outputFlorian Pritz1-1/+8
This changes the output from "foo 1.0" to "foo 1.0 -> 1.1" which makes cronjobs that mail the -Qu output way more helpful. Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-26query_fileowner: resolve trailing . or .. in pathsAndrew Gregory1-1/+1
The full path needs to resolved any time it ends with "." or "..", not just when those are the entire path. This allows strange-but-valid paths such as: "/home/." to be queried. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-26query_fileowner: remove useless path variableAndrew Gregory1-27/+3
We no longer need it for resolving package files and using it to resolve root is unnecessary as alpm does that for us. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-26query_group: allow package filtersAndrew Gregory1-41/+47
Relocated query_group() to allow calling filter(). Fixes FS#19716 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-26Make --unrequired filter packages that are optdep as wellOlivier Brunel1-3/+8
Specify it twice to only filter direct dependencies. Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03query_fileowner: remove symlink supportAndrew Gregory1-73/+64
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07colourize -QSimon Gomizelj1-1/+3
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07refactor common code in query_search/sync_searchSimon Gomizelj1-55/+1
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-29Consolidate --foreign/--native filteringSimon Gomizelj1-10/+6
Also fix a small bug where pacman won't check if the sync dbs are first downloaded when invoked with --native (it should). Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04Allow querying directory ownershipAndrew Gregory1-19/+41
The restriction of not checking the ownership of a directory is unnecessary given that all the package filelists contain this information. Remove this restriction, with the expectation that you might get multiple packages returned for a given directory. Additionally attempt to minimise the number of files getting through to the slow realpath call. Original-work-by: Dan McGee <dan@archlinux.org> Original-work-by: Allan McRae <allan@archlinux.org> Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04query_fileowner: don't append '/' if path is "/"Andrew Gregory1-2/+4
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-03Update copyright year for 2013Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14Basic running of pacman -Qkk to check mtree filesAllan McRae1-1/+5
If a package has an mtree file, using pacman -Qkk will read that file and use it to perform more in depth package checking. Currently this only checks for file presence. Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14Move check function into its own fileAllan McRae1-55/+1
There is going to be a lot of overlap in the code for the quick and full checks that can be abstracted into their own functions. Also many other file checking functions will be needed for the full check. Put all these in a separate source file. Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14query.c: simplify is_foreignAndrew Gregory1-10/+3
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27pacman: add -n/--native filter to -QSimon Gomizelj1-0/+4
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27Fix thinko in configure.ac CFLAGS empty checkingDan McGee1-1/+1
Since commit d2669b47, CFLAGS specified on the command line haven't been respected at all, resulting in no optimization being applied to builds. This exposed one warning flag issue in some new code, which is also fixed here. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2012-09-18query_fileowner, mdirname: add error checksAndrew Gregory1-14/+14
Also consolidates cleanup for query_fileowner. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2012-09-18query_fileowner: remove assumption that root is "/"Andrew Gregory1-25/+6
Returning "/" from mdirname removes it as a special case which allows us to test it like any other directory. This corrects a false positive when querying a file in / and root is not set to /. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2012-09-18query_fileowner: remove trailing '/' from targetsAndrew Gregory1-1/+8
Trailing '/' in paths causes lstat to dereference symlinks to directories which causes it to break even though the symlink is a valid target. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2012-09-18query_fileowner: resolve root earlyAndrew Gregory1-9/+25
Resolving root early prevents later calls to realpath from having to do the work of actually resolving any symlinks in root. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-18query_fileowner: remove resolve_path functionAndrew Gregory1-20/+3
resolve_path is a equivalent to calling realpath(path, NULL) except that the returned string is guaranteed to be PATH_MAX long. We never append to the returned string, so this is unnecessary. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2012-09-18query_fileowner: break/continue pkgfile loopAndrew Gregory1-0/+4
Break out of pkgfile loop on match or continue if the pkgfile path is too long. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2012-06-26Allow leading "local/" in query operationsAllan McRae1-1/+8
I find that when copying the output of "pacman -Qs foo" into a "pacman -Qi" operation to get more information on the packages, I consistently copy the "local/" prefix. It is a minor usability improvement to strip this if present. Dan: Pluck out LOCAL_PREFIX and magic numbers. Signed-off-by: Allan McRae <allan@archlinux.org>
2012-06-26query: avoid false ownership matches for files in rootDave Reisner1-2/+4
Check for an exact match when querying ownership of files in the root. Previously, our test was too simple and would match the the basename of package files against the query parameter, e.g. $ pacman -Qo config /config is owned by cower-git 20120614-1 Adds a new test to verify this behavior, query007.py. Fixes FS#30388. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-16Reduce calls to getcolsDan McGee1-3/+5
This dramatically improves upon a much older attempt in 2008 in commit ce3d70aa99ab86. We don't need to call it once per line we print unless there is a reasonable expectation of being able to resize the terminal mid-operation; this is really only the case during our callback progress bars. Some before and after numbers of ioctl() calls, gleaned from strace of the following operations (no targets to any of them to maximize the amount of output): pacman -Qii : 37768 -> 2616 (93.1% decrease) pacman -Qs : 2616 -> 4 (99.8%) pacman -Sii : 133036 -> 10926 (91.8%) pacman -Ss : 10926 -> 14 (99.9%) Obviously the search results are astounding; we only call getcols() once in the case of -Qs, and once per repo in the case of -Ss. For -Qii and -Sii we are still calling it once per package, but this is much better than once per line of info output. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-20Update copyright yearsAllan McRae1-1/+1
Add 2012 to the copyright range for all libalpm and pacman source files. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-06ALPM API adjustments for sanity and consistencyDan McGee1-7/+7
This makes several small adjustments to our exposed method names, and in one case, parameters. The justification here is to make methods less odd in their naming convention. If a method takes an alpm_db_t argument, the method should be named 'alpm_db_*', but perhaps more importantly, if it doesn't take a database as the first parameter, it should not. Summary of changes: alpm_db_register_sync -> alpm_register_syncdb alpm_db_unregister_all -> alpm_unregister_all_syncdbs alpm_option_get_localdb -> aplpm_get_localdb alpm_option_get_syncdbs -> aplpm_get_syncdbs alpm_db_readgroup -> alpm_db_get_group alpm_db_set_pkgreason -> alpm_pkg_set_reason All methods keep the same argument list except for alpm_pkg_set_reason; there we drop the 'handle' argument as it can be retrieved from the passed in package object. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-22include config.h via MakefilesDave Reisner1-2/+0
Ensures that config.h is always ordered correctly (first) in the includes. Also means that new source files get this for free without having to remember to add it. We opt for -imacros over -include as its more portable, and the added constraint by -imacros doesn't bother us for config.h. This also touches the HACKING file to remove the explicit mention of config.h as part of the includes. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-22Merge branch 'maint'Dan McGee1-14/+14
Conflicts: src/pacman/package.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21Remove pm_fprintf() in favor of pm_printf()Dan McGee1-14/+14
Now that pm_printf() always prints to stderr, we don't need this second function that was always used with stderr as the first argument. Thus, this patch removes the function and makes the following sed replacement: sed -i -e 's#pm_fprintf(stderr, #pm_printf(#g' src/pacman/*.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-14Use puts() instead of no-op printf() where applicableDan McGee1-5/+5
This replaces several printf calls of the following styles: printf("%s", ...); printf("some fixed string"); printf("x"); We can use either fputs() or putchar() here to do the same thing without incurring the overhead of the printf format parser. The biggest gain here comes when we are calling the print function in a loop repeatedly; notably when printing local package files. $ /usr/bin/time ./pacman-before -Ql | md5sum 0.25user 0.04system 0:00.30elapsed 98%CPU $ /usr/bin/time ./pacman-after -Ql | md5sum 0.17user 0.06system 0:00.25elapsed 94%CPU $ /usr/bin/time ./pacman-before -Qlq | md5sum 0.20user 0.05system 0:00.26elapsed 98%CPU $ /usr/bin/time ./pacman-after -Qlq | md5sum 0.15user 0.05system 0:00.23elapsed 93%CPU So '-Ql' shows a 17% improvement while '-Qlq' shows a 13% improvement on 382456 total files. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12Remove alpm_list_getdata wrapper functionDan McGee1-13/+13
This one is pretty darn useless. Just derefence the ->data attribute since the type is public anyway and save yourself the function call. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-08query check: use provided filelist count instead of keeping trackDan McGee1-6/+6
We don't need to keep track of how many files are in a package now that said value is provided to us. It also makes more sense to use size_t here for types rather than the (hopefully never too short) int. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-06sync: add missing newline in warning messageDave Reisner1-1/+1
Dan: fix the other missing one too. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-03Add -p/--print tip for -Q operations on filepathDan McGee1-0/+6
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-29Allow access to package origin dataDan McGee1-2/+2
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-29Better error handling out of package load methodDan McGee1-2/+12
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>