Commit Graph

313 Commits

Author SHA1 Message Date
Ivy Foster fa06951d90 Represent bitfields as ints, not enums
Many bitfield variables are declared to be enums, because they are
generated using bitwise operations on enums such. However, their
actual values aren't necessary members of their parent enum, so
declaring them 'int' is more accurate.

Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-22 20:50:55 +10:00
Tobias Stoeckmann af83a58574 Handle all POSIX compliant systems in mbscasecmp.
The width of wchar_t is allowed to be of the same width as long,
according to standards. The return type of mbscasecmp is int though.

On amd64 with a 32 bit int, this means that mbscasecmp can return
zero (indicating that strings are equal) even though the input
strings differ.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Allan McRae 7bebe4deff Report local file URL for -Sp operations if package is in cache
When using "pacman -Sp" operation to get URLs of packages to download, it is
useful to know which packages are already in the file cache and do not need
downloaded.  Print packages in the cache with a file:// prefix.

e.g
$ pacman -Sp glibc
file:///var/cache/pacman/glibc-2.23-1-x86_64.pkg.tar.xz

Also use package locations in case statements rather than opersations. This
allows the ALPM_PKG_SYNCDB to fall thorough to just printing the package name
for weird serverless repo setups.

Fixes FS#15868

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-18 15:45:55 +10:00
Xavion 7e7c64f513 Add colour to group selection dialog
Colour the group name in 'blue' and the repository names in 'magenta'.

Signed-off-by: Xavion <Xavion (dot) 0 (at) Gmail (dot) com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Andrew Gregory 02731189f1 use multi-byte character matching for user input
Fixes FS#47992

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:52:25 +10:00
Allan McRae af5d69d59d Failed database downloads cause transaction to stop
Previously, we errored only if all databases failed to download. If any
database downloads fail, we are unable to determine whether an update is
still considered safe. So now if any database download fails, the transaction
is aborted (after attempting all database downloads).

Fixes FS#47599.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae 3da06c3519 Use versions specified in optdepends
Checking install status and if a package is optionally required on removal
now considers the version of the optdepend.

Fixes FS#44957.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae 76a7d2293c Consider provides when labelling optdepends status as pending install
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae 4742f5929d Update copyright years for 2016
make update-copyright OLD=2015 NEW=2016

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Rikard Falkeborn 9e22e75fa1 Use correct format specifiers
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-11 13:47:08 +10:00
Pierre Neidhardt 456ebe8f8e Use ARRAYSIZE macro for non-string array size computation
Signed-off-by: Pierre Neidhardt <ambrevar@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-27 13:53:18 +10:00
Andrew Gregory edbe6c2bdc move strtrim to util-common
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-20 17:36:27 +10:00
Rikard Falkeborn 2d0e2bf255 pacman/util.c: Fix memory leak if realloc fails
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-08-08 10:36:21 +10:00
Allan McRae 5782b8356c Prototype pacman files database operations
Add the -F/--files operations, -s/--sync support and nd provide dummy
functions for -s/--search, -l/-list and -o/--owns.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:30 +10:00
Allan McRae e49abc9860 pacman: move database syncing to util.c
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:30 +10:00
Andrew Gregory 2e5e496eb0 Fix overflow warnings
Fix new warnings generated by gcc-5 about potential overflows.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-12 16:23:18 +10:00
Lukas Fleischer a187fa4562 Match providers when showing optdep install status
Use alpm_find_satisfier() instead of alpm_db_get_pkg() when retrieving
the install status of a package to make sure we spot providers as well.

Fixes FS#36412

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-06-20 17:32:57 +10:00
Johannes Löthberg 53d9633449 util.c: table_display: Fix incorrect docstring
Commit 7b8f8753 removed the title parameter but forgot to remove it
from the docstring.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-06-20 17:32:57 +10:00
Allan McRae 2e48101999 Update copyright notices for 2015
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:19:04 +10:00
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 f4796c905c pacman/util.c: fix potential memory leak in indentprint 2014-12-24 11:19:29 +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 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
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
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
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
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
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
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
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 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
Allan McRae 3bb3b1555a Update copyright years for 2014
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:50 +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
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 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
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
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
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 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
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
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
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
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 e42e9ab873 Make "[removal]" translatable
Fixes FS#34241

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-14 11:47:12 +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 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