Commit Graph

1575 Commits

Author SHA1 Message Date
Allan McRae 62d5a71fba Remove testdb
Replaced by pacman -Dk / -Dkk

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:44:59 +10:00
Allan McRae e8a3e3d81a Integrate testdb into pacman
The functionality of testdb is now available in pacman. pacman -Dk will
check the local database for consistency, and pacman -Dkk will check the
sync databases.

Note that unlike testdb, you can not specify individual sync databases to
check as sync databases act as a whole and not individually. A single database
can be checked using an alternative pacman.conf file.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:44:58 +10:00
Allan McRae 194dea2de1 Split install reason changing into its own function
Prepare for other functions to be added to the --database option.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:44:58 +10:00
Allan McRae 4c4890dd1c Clarify "assume installed" error message
The error message on failing to add an "assume installed" entry to the backend
was not clear.  Clarify by making "assume-installed" none translatable and
adding a hyphen to match calling flag.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-28 13:06:15 +10:00
Allan McRae d5e93e895b pacsort: fix memory leak
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:32 +10:00
Allan McRae f4796c905c pacman/util.c: fix potential memory leak in indentprint 2014-12-24 11:19:29 +10:00
Allan McRae eac09e1d9f Fix memory leak in ALPM_EVENT_OPTDEP_REMOVAL callback
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae 863cfb5808 Improve db upgrade error message
This message is clearer without (another) error prefix.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:28 +10:00
Allan McRae 54db3745d6 Update translations from transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-19 13:53:35 +10:00
Dave Reisner 16259d728e shut up GCC on -Wmaybe-initialized warnings
Admittedly, these are totally bogus, but a clean build is a happy build.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-18 16:34:03 +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 04bc3a24eb pacsort: parse inputs up front into control struct
This moves most of the parsing work out of the sorting path. The explode
and splitfile functions now call input_new and append input_t structs
to the list of sort candidates instead of raw strings. This lets us
make smarter and easier decisions in the sorting callbacks, which are
now also split into the version and file comparison methods for clarity.

This fixes two bugs:

1) Incorrect ordering with filenames containing epoch in the pkgver
2) Incorrect ordering with package names which are substrings of
each other (e.g. "systemd" and "systemd-sysvcompat").

Performance of the --files mode degrades slightly as a result of this
change, but not unreasonably. Sorting with small inputs (5-10) doubles
in runtime, but larger inputs (4000+) only increase by 20%.

ref: https://bugs.archlinux.org/task/37631

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-11-20 14:40:25 +10:00
Allan McRae 193b2b33f8 Update po files to send to Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-11-18 15:14:51 +10:00
Allan McRae db402d6029 Pull translation updates from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-11-18 15:12:40 +10:00
Allan McRae eda65967ec Do not warn about missing files in NoExtract
When checking a packages files, ignore any missing files in NoExtract

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-11-18 12:50:56 +10:00
Florian Pritz 9594f513a4 Add --assume-installed to pacman --help
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-11-05 11:01:09 +10:00
Andrew Gregory 82208c0239 testdb: ignore ALPM_DB_VERSION
Replaces the test for hidden files which appears to be leftover from
2e431e1cc before sync db checking was moved to a separate function.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-10-19 21:32:46 +10:00
Andrew Gregory 01beca5df7 pacman: add --confirm option
--confirm cancels the effect of a previous --noconfirm.
This makes it easier for scripts to default to --noconfirm
but allow users to override it.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-10-13 12:54:29 +10:00
Florian Pritz 04e8048725 Add --assume-installed option
This allows to ignore specific dependencies.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2014-09-30 22:33:26 +10:00
Andrew Gregory b275e5184e table_display: only check width when non-zero
A width of 0 indicates that either pacman is not attached
to a tty or the user does not want line wrapping.  Either
way pacman should not fall back to the basic display.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-09-30 14:05:13 +10:00
Andrew Gregory dc339faf6a avoid line wrapping if not in a tty or COLUMNS=0
Scripts that parse pacman's output (like pacsearch) generally do not
want wrapped lines.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-09-30 14:04:23 +10:00
Andrew Gregory b52ed49d75 Revert "Remove log_cb, add ALPM_EVENT_LOG instead"
Moving logging to the event callback caused warnings
under clang due to non-literal format strings and
silenced all log messages when --print was used.

This reverts commit cd793c5ab7.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>

Conflicts:
	lib/libalpm/alpm.h
	src/pacman/callback.c
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-09-30 12:56:21 +10:00
Johannes Löthberg 31b9862600 pacman.c: Add -gg, -ii, and -yy to help summary
The sync help summaries was missing the information about:
* -gg: View all groups and members
* -ii: View extended information
* -yy: Force refresh even if DBs are up to date

Fixes FS#41388.

Original-work-by: Earnestly <zibeon@gmail.com>
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-09-23 23:29:03 +10:00
Andrew Gregory 24e0bd215c pacman: set SA_RESTART for signal handler
Calling a signal handler interrupts some functions, most notably read()
and therefore fgets().

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-09-23 21:43:16 +10:00
Andrew Gregory c792262b13 wrap fgets to retry on EINTR
The read() underlying fgets() can be interrupted by a signal handler
causing fgets() to return NULL.  Before we started handling SIGWINCH,
the odds of interrupting a read were low and typically resulted in
termination anyway.  Replace all fgets calls with a wrapper that retries
in EINTR.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-09-23 21:43:16 +10:00
Andrew Gregory d981f93f18 sync.c: fix style violations
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-08-04 14:23:58 +10:00
Andrew Gregory 4ccf49d3e7 pacman.c: simplify stdin parsing
Incorporate memory exhaustion and end-of-stream
checks into the main loop.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-08-04 14:23:58 +10:00
Andrew Gregory 71da296d01 check_pkg_fast: check file type
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-08-03 18:46:32 +10:00
Andrew Gregory c3835c157a check_file_exists: replace lstat with llstat
Paths are constructed directly from package file lists and may contain
trailing slashes, causing lstat to dereference symlinks.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-08-03 18:46:32 +10:00
Andrew Gregory bbeced26f6 llstat: modify path in place
This makes llstat's signature differ from lstat's, but we never actually
use it on a const string and this saves a large number of strdup's.
This also allows stripping multiple trailing slashes and corrects a bug
where calling llstat on "/" would result in calling lstat on an empty
string.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-08-03 18:46:32 +10:00
Andrew Gregory e8de265f80 move _alpm_lstat into util-common
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-08-03 18:46:32 +10:00
Andrew Gregory e0a7682607 use monotonic clock for progress updates
gettimeofday is susceptible to backwards system time adjustments,
skewing or altogether breaking progress output.  For the sake of
platforms that lack clock_gettime support, gettimeofday is retained as
a fallback.

Fixes FS#36983

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-06-29 11:14:42 +10:00
Dave Reisner 357b9a24a9 cache terminal size, add SIGWINCH handler to reset
Refactoring getcols, yet again. We do the following:

1) Introduce a static global in src/pacman/util.c
2) getcols always prefers this cached value, but will derive it from
the COLUMNS environment var, the characteristics of stdout, or a sane
default (in that order).
3) Introduce a SIGWINCH signal handler to reset the cached value,
meaning we only call ioctl when we don't know the value.

On my machine, pacman -Syy goes from ~4300 ioctl calls to 3.
2014-06-29 11:04:17 +10:00
Allan McRae 07647d3d43 Revert refactoring in fa0c1e14
This will cause the code to break as soon as we handle another signal such
as SIGWINCH...

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-06-29 10:59:46 +10:00
Silvan Jegen fa0c1e1419 pacman: Correct signal handler comment and refactor
One of the comments for this function is out of sync with the code.
Since the code exhibits the more sane behavior of treating SIGINT and
SIGHUB the same way (by not exiting pacman when there is a commit in
flight) we adjust the comment.

Given this code flow, the if/else statements can be simplified somewhat
as well.

Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-06-24 15:53:18 +10:00
Olivier Brunel 8dbb80cfe9 events: Make alpm_event_t an union of all event-specific struct
Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-06-24 13:57:18 +10:00
Olivier Brunel f1fadecfb3 Update the question callback
Much like with events, instead of using a bunch of void* arguments for
all questions, we now send one pointer to an alpm_question_t union.
This contains the type of question that was triggered.

With this information, a question-specific struct can be accessed in
order to get additional arguments.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-06-24 13:52:15 +10:00
Hong Shick Pak 7b41952bfc Move break to a new line for consistency
This was the only break that didn't have its own line in the function
parsearg_query.

Signed-off-by: Hong Shick Pak <hong@hspak.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-06-23 22:35:21 +10:00
Allan McRae 4d65332ccd Clarify that -Ql prints a file list
FS#40234

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-05-25 14:38:35 +10:00
Florian Pritz b929e74f2e util: Use off_t instead of int for size values
Old output:
> Total Installed Size:  -1527.44 MiB

Fixed:
> Total Installed Size:  2568.56 MiB

Bug introduced in 7b8f8753b1.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-05-22 15:50:20 +10:00
Andrew Gregory 060d06d2f7 remove.c: downgrade TRANS_DUP_TARGET to warning
Matches the behavior for sync packages.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-05-07 14:14:41 +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
Andrew Gregory b26432dbdb conf.c: remove extra indentation
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-27 15:16:52 +10:00
Andrew Gregory b0dc547fcb check config_new return value
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-27 15:16:52 +10:00
Sören Brinkmann fb8437b588 pacman/upgrade: Fix memory leaks
Make sure allocated memory is freed before returning.

Signed-off-by: Sören Brinkmann <soeren.brinkmann@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-27 15:16:52 +10:00
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