Commit Graph

1580 Commits

Author SHA1 Message Date
Sören Brinkmann fcf0cefd1a pacman/upgrade: Refactor memory management
Refactor the upgrade routine to use an array that can be allocated in
one step instead of an alpm_list that is gradually extended in loops.

Signed-off-by: Sören Brinkmann <soeren.brinkmann@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-27 15:16:50 +10:00
Sören Brinkmann 3ebb7b94d9 pacman/upgrade: Check malloc() return value
Check the return value of malloc() before dereferencing the returned pointer.

Signed-off-by: Sören Brinkmann <soeren.brinkmann@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-16 13:43:33 +10:00
Andrew Gregory f3a280bc67 remove check for unused ALPM_ERR_PKG_IGNORED
alpm_add_pkg does not ignore packages.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-04 14:04:29 +10:00
Andrew Gregory 2e9602716c simplify check for leading "local/"
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-04 13:59:46 +10:00
Allan McRae b2488eb356 Fix warnings with strict-overflow in gcc-4.9
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:55 +10:00
Olivier Brunel cfaff6e0c1 Add events on pacnew/pacsave/pacorig file creation
ALPM still adds a warning to the log, but doesn't emit an event about
said warning, instead using a specific event to let the frontend what
happened/how to inform the user.

Note that there are 2 cases for installing a .pacnew file, to not
overwrite user changes and because file is in NoUpgrade. In the later case
the warning was a bit different: it happened before and said "extracting"
instead of "installed." Now both happen after and are phrased the same.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:55 +10:00
Olivier Brunel bd3d1a17c2 Add events _PKGDOWNLOAD_{START, DONE, FAILED}
These will be emmitted when download a package file from a repository,
indicating that the download starts, and whether it was successfull or
not.

Note that when multiple servers are available, no event is emmitted when
switching to another server.

(This doesn't apply to alpm_fetch_pkgurl(), but since it is called by
the frontend, it shouldn't have problems knowing when the download
starts and when it ends.)

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:54 +10:00
Olivier Brunel 01cc55a1f4 Add events ALPM_EVENT_RETRIEVE_{DONE, FAILED}
To go along with RETRIEVE_START, one other event will be emmitted once
the downloads are done: RETRIEVE_DONE if all files were successfully
downloaded, else RETRIEVE_FAILED.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:54 +10:00
Olivier Brunel cd793c5ab7 Remove log_cb, add ALPM_EVENT_LOG instead
When ALPM emits a log message, it still goes through _alpm_log() but
instead of calling a specific log callback, it goes as an event.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:54 +10:00
Olivier Brunel 28dbd5551e Update the event callback
Instead of using two void* arguments for all events, we now send one
pointer to an alpm_event_t struct. This contains the type of event that
was triggered.

With this information, the pointer can then be typecasted to the
event-specific struct in order to get additional arguments.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:54 +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
Andrew Gregory b9601b1e59 alpm: export *_free functions
Front-ends should be able to free memory that alpm hands them.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-02-04 13:48:37 +10:00
Allan McRae 1601532a53 Give groups display text singular and plural forms
Reported on transifex

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-02-04 09:01:38 +10:00
Rafael Ferreira 236f1795e9 Do not remove source code references in PO/POT files
FS#34240.  This is useful for translators and has little cost to us since
we moved to transifex for translations.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-02-02 16:32:55 +10:00
Andrew Gregory aa4d3298fb table_display: free memory on errors
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-30 14:22:27 +10:00
Andrew Gregory 4d68092e2f dump_pkg_full: fix optionalfor memory leak
alpm_pkg_compute_optional returns a generated list that needs to be
free'd.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-30 13:46:58 +10:00
Silvan Jegen 819b4cd54e Move NULL check before dereference
Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-30 13:40:25 +10:00
Silvan Jegen 77da9dc974 Another NULL check removed
Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-30 13:40:25 +10:00
Silvan Jegen cb8eae24c9 Another unneeded NULL check removed
Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-30 13:40:25 +10:00
Silvan Jegen d895cae16c Remove unneeded NULL check
Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-30 13:40:24 +10:00
Andrew Gregory aabb7c3cdd pacman: use exit status 0 for --help and --version
The user requesting usage or version information is not an error.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-30 13:12:00 +10:00
Andrew Gregory 333373f90e enable_colors: always set color strings
Only setting color strings when colors is true allowed subsequent
calls to enable colors but not disable them.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-28 20:52:46 +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
Andrew Gregory e6464f0cb6 pacman.c: free string commandline options
Plugs a memory leak when values were passed twice.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-28 20:10:49 +10:00
Olivier Brunel 4e9d88aa05 Rename ALPM_EVENT_OPTDEP_REQUIRED to _OPTDEP_REMOVAL
Because this event is triggered when an optdepend for another package is
being removed.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-28 20:10:49 +10:00
Olivier Brunel e65a752475 pacman: Fix delayed warnings/errors sent to stdout not stderr
Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-28 20:10:48 +10:00
Andrew Gregory ffe7f6d161 pacman.c: remove unnecessary optarg checks
getopt takes care of making sure that options that require a value have
one.  These checks were only added to silence clang, which no longer
complains about optarg being unchecked, and newer options already use
optarg unchecked.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-28 20:10:48 +10:00
Andrew Gregory 3f34e0936a create_verbose_row: free malloc'd strings
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-10 14:30:05 +10:00
Dan McGee 30740d9d2f Minor struct member reordering for packing concerns
Noticed using clang and `-Wpadded`.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:50 +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
Andrew Gregory 6a656c7429 conf.c: add missing newline to warning
Fixes tests that use pacman's output when built without libcurl.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:49 +10:00
Allan McRae 452ee39de1 Fix build warnings with --disable-nls
The gettext functions return a "char *", so do the same for the defines
in the case where gettext is unavailable.  This prevents a number of
warnings about const being dropped.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:49 +10:00
Allan McRae b847d1d8e7 Color output from pm_vasprintf
This makes sure warning and error messages from _alpm_log are colored.
Fixes FS#35160.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-12-15 20:09:37 +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
Andrew Gregory d78f45ae0c log important events from the backend
This ensures that important events will be logged and consistent
regardless of the frontend.  The need for global context in the event
callback is also removed.  The event is logged before any post_* scripts
run, so this also moves the post_* script output underneath the event in
the log.

Fixes FS#36504

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-15 11:02:27 +10:00
Andrew Gregory af284d5fdb support ALPM_SIG_USE_DEFAULT for file siglevels
This brings file siglevels in line with how db siglevels are handled.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-08 09:28:05 +10:00
Jason St. John 88df07717d Remove spaces between the opening "if" and the opening parenthesis
Signed-off-by: Jason St. John <jstjohn@purdue.edu>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-08 09:28:05 +10:00
Andrew Gregory d5acf7a44a upgrade.c: use iterator variable
remote was being used to loop over itself, making the FREELIST
ineffective.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:03 +10:00
Andrew Gregory 08191b13f2 check for -1 return value from getopt_long
getopt_long returns -1 when it has finished parsing all args.  A return
value of 0 indicates that a flag was set directly by getopt_long and
parsing should continue.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:03 +10:00
Andrew Gregory 1c5b94e6bb callback.c: check for negative xfered size
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:03 +10:00
Florian Pritz 6405ecb259 pacman -Si/-Qi: Autodetect best fitting file size unit
I've tracked this back to e223366 and it looks like this just forces KiB
because back then humanize_size didn't exist, but the size was just
divided by 1024 to keep it somewhat readable. When humanize_size got
introduced in 3c8a448 this was just carried over.

The unit detected for "Download Size" is reused for "Installed Size" to
make it easier to read.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:02 +10:00
Vladimir A. Nazarenko 7e767b7e90 Use getuid instead of geteuid
If someone gives the pacman binary setuid permissions, the geteuid check
allows it to start running but subsequently fail. As we do not support
setting pacman setuid, use getuid to check permissions instead.

FS#37174.

Signed-off-by: Vladimir A. Nazarenko <naszar@ya.ru>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:02 +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
Allan McRae 2d9e7dc2bc Fix detection of joint --native and --foreign usage
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:02 +10:00
Allan McRae 70b2c5f5ef List signiture keyids in -Sii output
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:02 +10:00
Andrew Gregory 807f014d77 include invalid options in error messages
On invalid combinations of flags we were only printing the unhelpfully
vague message "invalid option".

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
Andrew Gregory 2c11e5da1d pacman: die on invalid option combinations
Fixes FS#20950

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
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
Andrew Gregory 64e4f627c1 do not run scriptlets with --dbonly
Running an install script does not fall under "Adds/removes the database
entry only."

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
Andrew Gregory 3b804cb654 imply --print from --print-format
--print-format is totally useless without --print.  Implying --print
will also save us the hassle of checking it when we add transaction
option validation.

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
Andrew Gregory 122e16106f use non-ascii identifiers for optflags
Removes the overlap between optflags for different operations that
allowed non-sensical combinations of flags such as:

  $ pacman -Si --changelog $package
    --changelog is -c, meaning --clean for -S

  $ pacman -Q --sysupgrade
    --sysupgrade is -u, meaning --upgrades for -Q

Also add a few missing braces.

Original-work-by: Dave Reisner <dreisner@archlinux.org>
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
Andrew Gregory 0fc9545546 pacman/util: remove strsplit
strsplit was used in only one place and did the same thing as strtok.

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
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
Dave Reisner c0ee713704 pacman: add front end support for repo usage level
Add a "Usage" key to the repo section of the config which allows for the
tokens "Search", "Install", "Upgrade", "All", which correspond to values
in the alpm_db_usage_t enum. Users can specify "Usage" multiple times
for a given repo, or multiple flags per "Usage" line and they will be
OR'd together. If unspecified, the default is full usage of the repo.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-09-04 09:51:20 +10:00
Sami Kerola 8a72761743 pacman/util.c: use switch when there are fall through statements
An 'if' clause with empty statement is allowed, but unusual construct.
When 'if' is used this way the statement should at least have orphan
semicolon ';'.  For empty statements 'switch' feels like a native way
express what is meant.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>

[Allan] Keep comment
Signed-off-by: Allan McRae <allan@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
Sami Kerola 9020bcee37 common: compare value rather than pointer address
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-09-04 09:51:20 +10:00
Allan McRae ce7456b4cc Store fgetc output as an int.
Bug exposed on ARM when char is unsigned resulting in the comparison
to EOF always failing.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:14:01 +10:00
Andrew Gregory 9085aa4322 check.c: break backup file search loop after match
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:12:56 +10:00
Allan McRae 247b9af02b Do not refer to FlySpray numbers
These references to bug numbers assume we will forever be using that bug
tracker. It is better to properly comment the code instead (which was
done in almost all cases anyway).

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:12:30 +10:00
Andrew Gregory c02b16c4cc ini.c: give recursion limit file scope
The recursion limit is an artificial limitation imposed to prevent
memory exhaustion in a recursive function.  Giving it file-level scope
increases its visibility.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:06:41 +10:00
Andrew Gregory 4d4f46ba2a ini.c: make errors in includes fatal
If an error in the main file would be fatal there is little reason to
ignore the error in an included file.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:06:41 +10:00
Andrew Gregory bf1c8e3a3c ini.c: reuse line buffer
By the time we make the recursive call we have already finished with the
line buffer, making it safe to reuse.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:06:41 +10:00
Andrew Gregory 3d2c8e1fd0 conf.c: extract ini parsing code to separate files
Move _parseconfig to ini.c as _parse_ini and create a convenient wrapper
for the public API.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:06:41 +10:00
Andrew Gregory ab84249a58 conf.c: pass _parse_directive as a callback
This will allow passing arbitrary key/value handlers.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:06:41 +10:00
Andrew Gregory 26da037fd5 conf.c: move section handling out of _parseconfig
_parseconfig now tracks the current section name directly so that the
name stored in the section struct is just a pointer to the one stored by
_parseconfig.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:06:41 +10:00
Andrew Gregory 8287312c29 conf.c: move directive parsing out of _parseconfig
Include directives no longer have to be within a section.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:06:41 +10:00
Andrew Gregory 36f702ba82 conf.c: move repo parsing out of _parseconfig
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:06:41 +10:00
Andrew Gregory 74c8943682 conf.c: add parse_options to section_t
This consolidates all of our state information into a single variable.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:06:41 +10:00
Allan McRae 48861f509a Report missing directory if we can not initialise alpm library
When pacman failed to initialise the alpm library due to the database
directory being missing (either via the root not existing or the database
directory itself not existing), it just printed the non-informative
message "could not find or read directory".  Add the directory
information the the error output.  E.g.:

error: failed to initialize alpm library
(could not find or read directory: /this/does/not/exist/var/lib/pacman/)

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-30 13:02:06 +10:00
Allan McRae e81faa9d6d Warn when directory ownership differs between filesystem and package
We currently only warn if a directory's permissions differ, but using -Qkk
on my system shows that directory permissions tend to change in packages
reasonably frequently without notice.  Provide a warning in such cases
so that it can be altered.  Example output:

(1/1) reinstalling nginx
warning: directory ownership differs on /var/lib/nginx/proxy/
filesystem: 33:0  package: 0:0

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-30 13:01:11 +10:00
Allan McRae 640324f1d4 Only note backup file changes with -Qkk
Backup files are expected to be changed and should not be flagged by -Qkk.
Note changed back-up files in -Qkk but do not count them as altered. Do
not report backup files in -Qqkk.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-30 13:00:58 +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
Ashley Whetter 6e3ea82f9b Corrected return codes for Sg flag
Non-zero is now returned if a group is searched for that doesn't exist.
Fixes FS#36097.

Signed-off-by: Ashley Whetter <awhetter.2011@my.bristol.ac.uk>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-22 13:30:03 +10:00
Allan McRae 58832b0d7c Fix typo
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-22 13:29:44 +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
Allan McRae 29498b6a2a Clarify inter-conflicts message
Use a clear message rather than using a made up word to describe what
we are doing.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-22 13:29:07 +10:00
Allan McRae 96a4d1ca04 Update gitignore files for use with autoreconf
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-22 13:27:23 +10:00
Allan McRae df9d19ba73 Remove autotools files
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-22 13:27:07 +10:00
Dave Reisner eb19d41d5f do not check error from close(2)
On operating systems we support, the behavior is always such that the
kernel will do the right thing as far as invalidating the file
descriptor, regardless of the eventual return value. Therefore,
potentially looping and calling close multiple times is wrong.

At best, we call close again on an invalid FD and throw a spurious EBADF
error. At worst, we might close an FD which doesn't belong to us when a
multi-threaded application opens its own file descriptor between
iterations of the loop.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-05 14:32:23 +10:00
Simon Gomizelj 7b8f8753b1 Consolidate and improve table implementations
Implement both the VerbosePkgList and the summary message with the same
table.

Improve VerbosePkgList by caching attributes and cell's lengths instead
of recaculating them.

Right align every cell that containing a file size in both the
VerbosePkgList and the summary.

Simplify the printf statements and the alignment application.

Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-05 14:32:09 +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
Andrew Gregory 2436351d6e skip unknown repo names for pacman -Sl
Brings pacman -Sl behavior in line with other listing operations.

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
Allan McRae 71328479f3 Merge branch 'maint' 2013-06-18 13:59:18 +10:00
Allan McRae d985a62172 Pull translation updates
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-18 13:17:30 +10:00
Andrew Gregory ab3d8478c2 die if '-' is given with empty stdin
Several operations default to all packages/repos/etc if no targets are
provided.  If a user provides '-' they almost certainly expect there to
be targets on stdin and will be surprised if pacman falls back to the
default because there are none.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-06 13:47:32 +10:00
Allan McRae 9574bfd6c8 Merge branch 'maint' 2013-06-06 13:47:26 +10:00
Allan McRae 450be928da Pull translation updates and regenerate
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-06 13:12:20 +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
Allan McRae a975523fb9 Clean partial downloads from cache
When using "pacman -Sc" to clean the cache, it make sense to also remove
partially downloaded files.

Fixes FS#34317.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-29 14:08:03 +10:00
Allan McRae 0f988beff8 Merge branch 'maint' 2013-05-07 12:59:44 +10:00
Allan McRae 35289bc17e More translation updates
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-07 12:53:23 +10:00
Andrew Gregory 692633264a pacman/util.c: add missing braces
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-07 12:53:23 +10:00
Andrew Gregory 34da9d25e4 pacman/util.c: fix output flushing in questions
Flush stream before taking input in select_question() and only flush
once during question().  Also fix some tabs inside related fprintf
statements.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-07 12:53:23 +10:00
Allan McRae 0aa9628560 Pull translation updates from transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-30 21:18:42 +10:00
Connor Behan b8c8447971 Remove ALPM_QUESTION_LOCAL_NEWER
Remove a question that hasn't been used since the 3.0 days. To prevent
us from having an ugly enum of questions that is missing a bitmask, this
changes the API of the hidden --ask option.

Signed-off-by: Connor Behan <connor.behan@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-24 13:47:19 +10:00
Connor Behan ee3b70c4a9 Unify front and backend responses for --print
When libalpm asks the user a question, there are two possible defaults.
One default for pacman (used when the user presses enter without typing
and for --noconfirm) and the libalpm default. Currently the libalpm
default gets used for the pacman "--print" option. This affects the
printing of ignored packages since the defaults differ for
"ALPM_QUESTION_INSTALL_IGNOREPKG". Adjust the response of this case when
using --print so pacman acts consistently.

Signed-off-by: Connor Behan <connor.behan@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-18 13:26:16 +10:00
Anatol Pomozov 769facca22 Fix spelling errors using 'codespell' tool
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-18 13:20:13 +10:00
Allan McRae 3de8f8f1cc Rework callback message to add translation
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-11 10:53:52 +10:00
Andrew Gregory 95c68d26ef pacman: add -Qkk to usage() help
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-09 11:51:46 +10:00
Simon Gomizelj 0f05bfc340 ctypes.h shouldn't be included twice
Earnestly spotted this on #archlinux.

Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-06 13:01:49 +10:00
Andrew Gregory b5a7734a7e use off_t for table_row_t.size
size went from off_t in _display_targets to int in
add_transaction_sizes and back to off_t in humanize_size
leading to potential overflows.

Fixes FS#34616.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-06 12:55:09 +10:00
Allan McRae e9639ad172 Update translations from transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-01 15:53:12 +10:00
Simon Gomizelj afc77a808d pm_asprintf logs 'failed to allocate' already
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-31 11:08:54 +10:00
Andrew Gregory d5c0f39144 use default foreground color instead of white
Using white made important text invisible on terminals with white
backgrounds.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-30 09:06:12 +10:00
Simon Gomizelj 38f0a7d462 signature_display should also be colourized
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-26 15:55:51 +10:00
Allan McRae 3eee3d67af More translation updating
Pull updates from transifex.  Add new "id" translation.  Regerate po
files with updated filelists...

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-17 13:53:38 +10:00
Allan McRae 47a7ea8c86 Update POTFILES.in for libalpm and pacman
Be complete with files listed. Comment out files where code is used
or heavily based on other projects so will never have translatable
strings.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-17 13:53:38 +10:00
Allan McRae a554e1a460 Fix typo
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-15 13:21:32 +10:00
Allan McRae aa550a85f1 Merge updates from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-15 13:21:32 +10:00
Allan McRae a97f792d3c Remove Indonesian translation
I imported this translation from transifex without realising that there
was no strings translated despite being "acitve" on transifex for quite
some time.  Remove it until translation begins...

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-15 13:21:32 +10:00
Allan McRae b2ea5f6860 update util-common.h copyright year
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-14 11:47:12 +10:00
Allan McRae e42e9ab873 Make "[removal]" translatable
Fixes FS#34241

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-14 11:47:12 +10:00
Dan McGee 62f828014f Use C locale when parsing UseDelta floating point values
We should save the current locale, use the 'C' locale during parsing,
then restore the original locale. Config files should always parse
regardless of the current user's locale setting. Fixes FS#34253.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-14 11:47:11 +10:00
Allan McRae 1e21aa589d Update all translations files to push to Transifex
Run update-po and fix the few errors reported.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 13:32:11 +10:00
Allan McRae 0cb963df03 Remove all leading :: from pacman translations
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 13:32:11 +10:00
Allan McRae c5652361fb Pull updated translations from transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 13:32:10 +10:00
Allan McRae 1366da57fa Add new languages from Transifex
Languages: eo, nl, hr, ko, ja, fa, ar, sl, gl, id

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 13:32:10 +10:00
Andrew Gregory c9b7f9b0d0 testdb: quote output substitutions
Quoting output substitutions makes whitespace errors such as FS#30101
much more obvious:

old:
    missing perl-test-pod  dependency for perl-test-output
new:
    missing 'perl-test-pod ' dependency for 'perl-test-output'

Several of the quoted substitutions should not be capable of containing
whitespace in theory, but this errs on the side of caution as the point
of the tool is to find error conditions.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 09:01:56 +10:00
Andrew Gregory 0ff57350fb testdb: pass empty local pkglist to alpm_checkdeps
Passing the local package list to alpm_checkdeps as both the local
packages and packages to be upgraded did nothing but cause extra
overhead as the packages were all removed from the installed package
list because they were being upgraded.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 09:01:56 +10:00
Simon Gomizelj ce9fd69eba make status/log messages reflect version change
Currently pacman either prints 'adding' or 'upgrading' when installing
a package. This make pacman print and log the other possible actions:
'downgrade' and 'reinstall'

Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 09:01:56 +10:00
Simon Gomizelj 51276f1ac5 remove the duplicate strnlen and strndup
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 09:01:56 +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 7dd1a5a58d colourize -Sl/-Ql
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 326345b378 colourize -Ss/-Qs
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 46c10c5bf3 colourize the output of -Qi/Si
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 ce06e6f9b9 colourize table output
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 5dada13a1a colourize warnings and errors
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 e8130b8f2c colourize colon_printf and question
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 6582f68c9d introduce colstr for colourizing
colstr_t colstr will hold the colourizing agents.

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 c8c7a51374 add a config settings and flag for colours
Colours can be enabled in two ways:

- Add Color to pacman.conf. This enables colours automatically.
- Use --color=WHEN where WHEN is none/auto/always.

WHEN as 'never' disables colours (overrides config file), as 'auto'
enables colours when stdout is a tty, and 'always' enables colours no
matter what.

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 ea42d03ea1 standardize format functions
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 ce5ee8a065 remove format from statistic messages
Remove the format component of the "Total Download Size" and related
messages. The heading will be colourized, the size won't.

However since the length of these messages can vary by language, we need
a pretty printer to format them nicely.

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 b4459f1e04 split "Packages (%zd):" message
Basically all translation messages that need colouring but _also_ happen
to be format strings need to be split up.

This makes it easy to conditionally embed colour codes into the output
at runtime.

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 ef5feb15a7 remove :: prefix from all message
This will substantially simplify the logic to add colours to messages.

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 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
Allan McRae 34749e177d Perform limited conflict checking with --force
Pacman currently bails when trying to extract a file over a directory
when using --force.  Instead of ignoring all conflict, perform the
check and skip any file-file conflicts. Conflicts between directories
and files are still flagged and cause the transation to abort.

As a bonus, we now know about files changing packages when using
--force, so we can skip removing them fixing upgrade046.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24 13:11:54 +10:00
Allan McRae 3fa2830829 Add format attributes to all required functions
Fixes all clang warnings with -Wformat-literal.

Also, fix genuine formating issue discovered once adding these attributes
and add a cast to prevent a gcc warning.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-13 11:50:33 +10:00
Martin Panter 390b08f18b Exit with failure status if download or installation is not confirmed
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:37 +10:00
Allan McRae 9aead554bc pacman: print version information in debug output
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:37 +10:00
Allan McRae 31b9b264c1 Check keys are in keyring before package validation
Keys used to create signatures are checked for presence in the keyring
before package validation is performed.

Signed-off-by: Allan McRae <allan@archlinux.org>

Conflicts:
	lib/libalpm/alpm.h

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:37 +10:00
Andrew Gregory 1631255357 use strtok_r to parse multi-value config options
This prevents multiple spaces between values from being
parsed as empty values.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-07 10:48:11 +10:00
Allan McRae 7956441350 Better error message with "-" is specified without stdin
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-07 10:48:11 +10:00
Allan McRae 33b3b6d9b8 Add configuration option for Upgrade operation SigLevel
Add LocalFileSigLevel and RemoteFileSigLevel to control the signature
checking for "pacman -U <file>" and "pacman -U <url>" operations
respectively. The starting value for both these options is SigLevel,
if it is specified in the [options] section, or the built-in system
default. The specified values override and/or supplement this initial
value. Note there is no distinction between setting "Required" and
"PackageRequired" as there are no database options for Upgrade
operations.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-07 10:48:11 +10:00
Dan McGee 3aece8f0ee Restore libarchive 2.8.x compatibility
We still call some of these 'deprecated' methods elsewhere, so this
shouldn't present a problem. When we decide 2.x support is to be dropped,
we should update all of the code to not call deprecated methods.

Allan: Adjusted with respect to previous patches adding libarchive
compatibilty layer.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-29 13:37:32 +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 66a9b53141 add caller prefix to alpm_logaction
prefix defaults to "UNKOWN" if null or an empty string is provided.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-28 23:38:46 +10:00
Dave Reisner a64a713fc2 pacsort: add -f, --files option for sorting filenames
Teach pacsort to understand package filenames and optionally strip away
some of the context. alpm_pkg_vercmp() intentionally only understands
pure versions, so strings such as '18.0-2-x86_64' and '18.0.1-1-x86_64'
will be compared wrongly.

Partially addresses FS#33455.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-28 23:38:46 +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
Gerardo Exequiel Pozzi 86eefc1a3a Fix space between control structure and open parens
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04 21:49:38 +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
Gerardo Exequiel Pozzi e13a3bf599 Fix missing spaces in operators
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
Gerardo Exequiel Pozzi 46e9afdd74 fix comment 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
Allan McRae 27d9c25ee2 Split common utility functions for libalpm and pacman
There is duplicated code in the util.c files in the libalpm and pacman
source code. Split this into a separate file so that it can be shared
via a symlink. This prevents code divergence between the two code bases.

Also, move mbasename and mdirname from pacman/util.c into util-common.c
in preparation for the following patch that uses them to add an extension
to pacsave files.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04 21:49:37 +10:00
Allan McRae d5a6ce8ca1 Remove checks for geteuid
The geteuid function is defined in POSIX and we will not support any
operating systems without it.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-03 12:03:10 +10:00
Allan McRae 5aaf5bcf83 Remove Cygwin support
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-03 12:03:10 +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
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 5186f702d3 Remove leading "./" from filenames in mtree file
A properly formatted mtree file may stick a leading "./" in front
of file names in the root directory.  Strip this if present.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 13:45:12 +10:00
Allan McRae 7d27b2b0f4 Check file types match before comparing properties
Bail early in file validation checks if the file type given in the
mtree file does not match that in the filesystem.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 13:45:12 +10:00
Allan McRae ddd2b9e6f6 Check "install" and "changelog" files for changes
The "install" and "changelog" entries for a package  in the local
database are now checked for changes with -Qkk.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 13:45:12 +10:00
Allan McRae 01e093d0ae Perform full checking of files with -Qkk
The follow fields are checked:
  Directory: uid, gid, mode
  File: uid, gid, mode, size, time
  Symbolic Link: uid, gid, mode, link, time

A skeleton is added for checking a files md5sum and sha256sum when
reading this information is supported by libarchive.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 13:45:12 +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 cfd9f1cc69 Separate checking a files existence into a function
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
Allan McRae f5d904d97f Do not warn about missing database if being downloaded
When a configured repo database is not already downloaded, a warning
message such as "warning: database file for 'testing' does not exist"
is printed.  Disable this warning when the database is scheduled to
be downloaded in the transaction.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Simon Gomizelj 95f566d98a Print package name before changelog entry with -Qc
Fixes FS#32362

Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +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
Andrew Gregory 964640fbfc Plug various minor memory leaks
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
Allan McRae 8e736e1c9a Display install status of optdependencies
When a packages (new) optdepends are printed in install (update),
add a note of their current installation status.  Packages currently
installed are labelled with [installed] and packages to be installed
in this transaction are labelled [pending].

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae d0e5cd2c7f Add "Optional for" to package information output
Much like packages that require a give package are displayed in the
"Required by" field of its information output, alos display packages
that optionally require the package.

Inspired-by: Benedikt Morbach <benedikt.morbach@googlemail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae 63a2874fe4 Display optdep install status in package query output
Indicate which optional dependencies are installed when viewing
local package information (-Qi).

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae eb9e74ecc7 Notify of removed package required as optdepend
When a package is being removed, provide a notification (via a callback)
if any local package requires it as an optdepend.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +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
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
Dave Reisner 40d6894910 buildsys: eschew use of DEFS, prefer AM_CPPFLAGS
This is redundant, and any usage of -D should belong to CPPFLAGS.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
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
Allan McRae 8f5ee72974 Avoid interger overflow when calculating remaining line length
When the len and cidx were changed to size_t in a8a1b093, it was
possible to have an integer overflow when a line ended right at the
edge of the terminal width.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-09-18 08:38:45 -05:00
Allan McRae 7262f4bed4 Fix typo in documentation
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-09-18 08:38:15 -05: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 0fe562011c Move important information up in -Si output
Currently, the package description is printed at the end of the -Si output.
This is probably one of the more important pieces of information so should
be nearer the top. Also move the package architecture up.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-07 21:10:16 -05:00
Florian Pritz 8853a6f282 coding style fixes
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-07 20:32:30 -05:00
Jan Alexander Steffens (heftig) 49dbebcc36 Allow cleaning only some cachedirs
When cleaning the cache, ask for each cachedir separately.

Allan: add some white space in output

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-02 09:34:45 -05:00
Dan McGee f619bc61f5 Clean up exclusion list in sync cache cleanup
Make an array out of our various glob skip patterns and loop through
them looking for items to skip. Additionally, when doing a full clean,
delete all objects rather than respect this skip list.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01 09:14:40 -05:00
Dan McGee cc6fb2e8a7 Skip deltas and partial downloads in package cleanup
This affects -Sc only, not -Scc.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01 09:14:32 -05:00