Commit Graph

182 Commits

Author SHA1 Message Date
Allan McRae 7a9d8b7001 Turn off colours once finished using them
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-08-30 18:10:40 +10:00
Xavion 0088a7ab1c Add colour to the output of the "-{F, Q}o" operations.
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-05 13:52:23 +10:00
Allan McRae 7d1ea0b814 Handle provides with -Q
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-05 13:52:23 +10:00
Allan McRae 502e0d1db0 pacman_query: move error messages into relevant if statements
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-05-05 13:52:23 +10:00
Allan McRae 4742f5929d Update copyright years for 2016
make update-copyright OLD=2015 NEW=2016

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Allan McRae 2e48101999 Update copyright notices for 2015
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:19:04 +10:00
Florian Pritz cd2370754a Remove ts and sw from vim modeline when noet is set
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-28 20:19:25 +10:00
Allan McRae 3bb3b1555a Update copyright years for 2014
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:50 +10:00
Jason St. John 230bd5c2fd Fix whitespace and other formatting issues
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-11-15 11:02:27 +10:00
Allan McRae 2194eddf30 Indicate ignored packages in -Qu output
Add "[ignored]" in the "pacman -Qu" output after packages that have their
upgrades ignored.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:02 +10:00
Andrew Gregory 55ca38b4cd rename PKG_LOCALITY_LOCAL -> PKG_LOCALITY_NATIVE
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-14 13:01:15 +10:00
Florian Pritz d43f54e5c4 Display old and new version in pacman -Qu output
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-10-14 12:59:48 +10:00
Andrew Gregory 96ac9c5299 query_fileowner: resolve trailing . or .. in paths
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-26 15:32:16 +10:00
Andrew Gregory b36b87656e query_fileowner: remove useless path variable
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-26 15:32:16 +10:00
Andrew Gregory de7ccedbe7 query_group: allow package filters
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-26 15:32:16 +10:00
Olivier Brunel 00513823dc Make --unrequired filter packages that are optdep as well
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-26 15:32:15 +10:00
Andrew Gregory 47762ab687 query_fileowner: remove symlink support
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03 13:33:47 +10:00
Simon Gomizelj 32f3b4304c colourize -Q
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07 15:55:04 +10:00
Simon Gomizelj 098cfe516d refactor common code in query_search/sync_search
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07 15:55:03 +10:00
Simon Gomizelj cb43bd8dfb Consolidate --foreign/--native filtering
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-29 13:36:58 +10:00
Andrew Gregory 9c160cf3f3 Allow querying directory ownership
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-04 21:49:38 +10:00
Andrew Gregory 7a83cd003a query_fileowner: don't append '/' if path is "/"
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04 21:49:38 +10:00
Allan McRae 1dd3405813 Update copyright year for 2013
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-03 12:03:09 +10:00
Allan McRae 327c272bb4 Basic running of pacman -Qkk to check mtree files
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-14 13:45:12 +10:00
Allan McRae 18ddf90ff4 Move check function into its own file
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-14 13:45:12 +10:00
Andrew Gregory 53d610e0a5 query.c: simplify is_foreign
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Simon Gomizelj fc35b16fd4 pacman: add -n/--native filter to -Q
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27 15:16:15 +10:00
Dan McGee 1d0ab50c05 Fix thinko in configure.ac CFLAGS empty checking
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-11-27 15:16:15 +10:00
Andrew Gregory ea35ce5d2e query_fileowner, mdirname: add error checks
Also consolidates cleanup for query_fileowner.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2012-09-18 08:28:34 -05:00
Andrew Gregory de7a5cf346 query_fileowner: remove assumption that root is "/"
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-18 08:27:59 -05:00
Andrew Gregory 03f2e2360a query_fileowner: remove trailing '/' from targets
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-18 08:27:23 -05:00
Andrew Gregory 140c76d328 query_fileowner: resolve root early
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-18 08:24:02 -05:00
Andrew Gregory 9648887481 query_fileowner: remove resolve_path function
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-18 08:21:42 -05:00
Andrew Gregory bad00696f3 query_fileowner: break/continue pkgfile loop
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-09-18 08:19:11 -05:00
Allan McRae 0c62b36c19 Allow leading "local/" in query operations
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-25 23:43:36 -05:00
Dave Reisner da0dcc29cf query: avoid false ownership matches for files in root
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-06-25 23:05:59 -05:00
Dan McGee 8da489eac5 Reduce calls to getcols
This dramatically improves upon a much older attempt in 2008 in commit
ce3d70aa99. 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-03-16 17:57:04 -05:00
Allan McRae 326c6a8eed Update copyright years
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-20 16:54:34 -06:00
Dan McGee b488f229d2 ALPM API adjustments for sanity and consistency
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>
2012-02-06 05:49:52 -06:00
Dave Reisner d6ccd44390 include config.h via Makefiles
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-12-21 18:13:17 -06:00
Dan McGee 90ddcbe71d Merge branch 'maint'
Conflicts:
	src/pacman/package.c

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21 19:29:47 -05:00
Dan McGee 9e9ecf2183 Remove pm_fprintf() in favor of pm_printf()
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-21 10:45:18 -05:00
Dan McGee 8605284e0d Use puts() instead of no-op printf() where applicable
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-13 20:59:16 -05:00
Dan McGee 6be492d2f7 Remove alpm_list_getdata wrapper function
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-10-12 14:22:49 -05:00
Dan McGee b961ebe16f query check: use provided filelist count instead of keeping track
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-07 20:51:35 -05:00
Dave Reisner 7054e37126 sync: add missing newline in warning message
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-06 08:43:23 -05:00
Dan McGee 7c956d5d4b Add -p/--print tip for -Q operations on filepath
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02 21:45:33 -05:00
Dan McGee 040083b97f Allow access to package origin data
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-28 23:41:17 -05:00
Dan McGee 2cfcc874b9 Better error handling out of package load method
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-28 19:52:41 -05:00
Dan McGee c9cc2332cf pacman/query.c: avoid variable redeclaration
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-11 20:17:21 -05:00