Commit Graph

61 Commits

Author SHA1 Message Date
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
Andrew Gregory edbe6c2bdc move strtrim to util-common
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-20 17:36:27 +10:00
Will Miles bb94729c09 util: Use util-common for strndup in pacsort and pactree
This small refactor reduces the number of replications of the local
imeplementation of strndup.

Signed-off-by: Will Miles <wmiles@sgl.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +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
Micah Saint Germain a4b23417f9 Fix pointer declarations to be globally consistent
Refactored inconsistent pointer declarations to better improve consistency
throughout the pacman codebase which will, in turn, increase readability to
the user.

Expected format of a pointer declaration:
`typename *varname`

Signed-off-by: Micah Saint Germain <micah@lexme.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-18 16:32:55 +10:00
Dave Reisner 5293d57840 strtrim: reset pointer after trimming leading whitespace
Breakage introduced in 92216c5864 when we changed the signature
of strtrim to return something more useful.

Fixes FS#39976.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-04-21 20:25:45 +10:00
Pierre Neidhardt 0deeb9991c pactree: removed 'provision' from linear output
Linear output is especially useful when piped to other commands, e.g.

  $ pactree -lu pacman | pacman -Qqkk -

The above command would previously show errors on packages with provisions.

Signed-off-by: Pierre Neidhardt <ambrevar@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-02-04 14:21:07 +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
Dave Reisner 61e806b96a pactree: set full usage on DBs when registering
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-09-04 09:51:20 +10:00
Jason St. John a86015f73f Improve --help switch output for pacman utils
Unify the formatting of the --help switch for pacman utils, if it exists.
All of the pacman utils will now output help text using the following
format:

  util-name (pacman) v<pacman version>

  one line description of util's purpose

  Usage: util-name [options]

    -b, --bar      whatever --bar does
    -f, --foo      whatever --foo does
    -h, --help     display this help message

The --help switch does not exist for a couple of the utils, so the
help/usage text for those will be displayed when the util is run
with no arguments.

Reported-by: Karol Błażewicz <karol.blazewicz at gmail.com>
Signed-off-by: Jason St. John <jstjohn@purdue.edu>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-09-04 09:51:20 +10:00
Jason St. John 4ad6939980 Fix whitespace in pacsort.c and pactree.c
Replace spaces with tabs.
Remove extra spaces.

Signed-off-by: Jason St. John <jstjohn@purdue.edu>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-30 13:00:20 +10:00
Zulker Nayeen Nahiyan 66f3b93331 clarified descriptions for pactree -r (--help)
Signed-off-by: Zulker Nayeen Nahiyan <nahiyan02@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-22 13:29:25 +10:00
Gerardo Exequiel Pozzi b5709b8171 Fix open braces style
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04 21:49:37 +10:00
Dan McGee 038b1815d0 util/pactree: correctly free the deps list in walk_deps()
If we are reversed, then we were correctly freeing both the list and the
contained data. However, we were leaking a list in the case of a
non-reversed traversal.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-03 12:03:10 +10:00
Andrew Gregory a459156a4e pactree: unindent first limb
Removing the leader for the toplevel package shifted the name left
but not it's limb.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27 15:16:15 +10:00
Dave Reisner d9e8197e60 pactree: unify output between utf8 and ascii
Ensure that both output formats have equal spacing, and therefore an
equivalent layout. This change also removes the styling from the
toplevel package being searched for.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27 15:16:15 +10:00
Dave Reisner 8054a254cb pactree: fix style violations
Stick to c89 and avoid mixed code and declarations, and always brace
block statements, even if they're only 1 line.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27 15:16:15 +10:00
Dave Reisner 1c0c292728 pactree: autodetect and use unicode line drawing characters
Add a compile time check for langinfo.h so that we can possibly use
unicode line drawing characters if the current locale is supportive of
them. This can be explicitly disabled at runtime with the use of a new
switch: -a, --ascii.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27 15:16:15 +10:00
Andrew Gregory e1fdcfb145 pactree: style last branch node differently
Also removes the less helpful provides-specific branch tip.

  Old:                        New:
  |--pkg                      |--pkg
     +--dep1 provides dep5       |--dep1 provides dep5
     |  |--dep2                  |  `--dep2
     |--dep3                     `--dep3
        |--dep4                     `--dep4

[dreisner@archlinux.org: switch original suggestion of \-- to `--]

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27 15:16:15 +10:00
Andrew Gregory c4c5b8ba1d pactree: fix --sync getopt value
The long --sync options has apparently never worked.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27 15:16:15 +10:00
Andrew Gregory 3fb934b59a pactree: show tree vertical "limbs"
Showing vertical limbs makes the tree easier to follow.

Old:            New:
|--pkg          |--pkg
   |--dep1         |--dep1
      |--dep2      |  |--dep2
   |--dep3         |--dep3
      |--dep4         |--dep4

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
[Allan: fix shadow warning]
Signed-off-by: Allan McRae <allan@archlinux.org>

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01 09:12:45 -05:00
Andrew Gregory a6bd14285d pactree: consolidate both walk_deps functions
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
[Allan: fix shadow warning]
Signed-off-by: Allan McRae <allan@archlinux.org>

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01 09:12:29 -05:00
Dan McGee c7321a7b80 Merge branch 'maint'
Conflicts:
	lib/libalpm/sync.c
	src/util/pactree.c
2012-02-13 10:14:06 -06:00
Allan McRae 294f0fdf4d pactree: allow comments after repo section header
Duplicate the fix in config file parsing from d95c0494.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-11 14:58:28 -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 e28f321a48 pactree: cleanup register_syncs
- take advantage of the new strtrim return value
- tighten scope on line pointer

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-12-23 14:37:03 -06:00
Dave Reisner bec0b0c823 pactree: update with new strtrim function
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-12-23 14:37:03 -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
Jonathan Conder a3f9399295 create a typedef for enum _alpm_errno_t
This is consistent with the other enums and structs, and should be
slightly more readable.

Signed-off-by: Jonathan Conder <jonno.conder@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-14 08:54:03 -06: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
Lukas Fleischer 8f414cd040 pactree: Make error message smarter in register_syncs()
Our error message used to be very unclear when the configuration file
could not be found:

    $ ./pactree -lsr gtk
    error: failed to register sync DBs

Instead, display an accurate message and include the file name:

    $ ./pactree -lsr gtk
    error: config file /usr/local/etc/pacman.conf could not be read

Also, move the error message inside register_syncs() to allow for
differentiating between different errors that might require a handler in
the future.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-10 19:09:18 -05:00
Lukas Fleischer fb401f569e pactree: Add "--config" option
This allows for specifying an alternate configuration file path, similar
to pacman's "--config" option.

Given that there is currently no other way to tell pactree to read from
another configuration file (except for patching or symlinking), this
seems totally sensible - even if there are plans to refactor and/or
replace the standalone configuration file parser.

We do not define a short option for the sake of consistency with
pacman's set of command line options.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-10 19:09:12 -05:00
Dave Reisner 83ee9708b1 src/util: provide strndup definitions where needed
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 16:58:21 -05:00
Dave Reisner c12fa4ab19 pactree: include missing ctype.h header
needed for isspace() -- avoids warnings on OSX.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 16:57:09 -05:00
Dan McGee c5982a3eb5 strtrim: don't move empty string
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-25 17:14:19 -05:00
Dave Reisner 1d37c19e04 mark option structs as const
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-08 16:50:03 -05:00
Dan McGee 7af0ab1cde signing: move to new signing verification and return scheme
This gives us more granularity than the former Never/Optional/Always
trifecta. The frontend still uses these values temporarily but that will
be changed in a future patch.

* Use 'siglevel' consistenly in method names, 'level' as variable name
* The level becomes an enum bitmask value for flexibility
* Signature check methods now return a array of status codes rather than
  a simple integer success/failure value. This allows callers to
  determine whether things such as an unknown signature are valid.
* Specific signature error codes mostly disappear in favor of the above
  returned status code; pm_errno is now set only to PKG_INVALID_SIG or
  DB_INVALID_SIG as appropriate.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:13:20 -05:00
Allan McRae ddad400900 Rename pmerrno_t to alpm_errno_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae 9540dfc4d9 Rename pmdepend_t to alpm_depend_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae 8a04bc25a1 Rename pmpkg_t to alpm_pkg_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:26:39 +10:00
Allan McRae 64c1cf7921 Rename pmhandle_t to alpm_handle_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 14:04:00 +10:00
Dan McGee f01c6f814a Fix several -Wshadow warnings
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-27 10:10:08 -05:00
Dave Reisner 3725998cbc pactree: add -s option to walk sync DBs
Add a whole lot of bloat to parse pacman.conf and only a few lines to
use the list of sync DBs instead of the local DB.

Dan: I fully plan on this being temporary and us finding a better way in
the future to parse pacman.conf from multiple binaries. Adding a
standalone config parser is probably not the right way of going about
things, but for now it is by far the easiest.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 14:18:07 -05:00
Dave Reisner e06586ceb4 pactree: carry a list of databases for dep resolution
Declare an alpm_list which, for now, only holds our local database.
walk_deps and walk_reverse_deps are refactored to account for this, and
a helper function is added to wrap alpm_db_get_pkg for traversing a
list.

This is groundwork for letting pactree walk the sync DBs.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 13:37:09 -05:00
Dan McGee 7f6c1a76c6 Make pmdepend_t and pmdepmissing_t public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:57:33 -05:00
Dan McGee e2aa952689 Move pm_errno onto the handle
This involves some serious changes and a very messy diff, unfortunately.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:38:38 -05:00
Dan McGee 17a6ac5675 Require handle argument to all alpm_option_(get|set)_*() methods
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-09 14:24:45 -05:00
Dan McGee 19755b648c Update utilities for new initialize/release methods
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-07 11:37:05 -05:00
Dan McGee c4fccfe3e6 pactree: make -Wwrite-strings friendly
Use a few structs to hold configuration values we change given certain
options so we can be const-correct with string assignment across the
board. Behavior should be completely unchanged.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-04 15:49:47 -05:00