Commit Graph

1472 Commits

Author SHA1 Message Date
Travis Burtrum abb057844e Add per-repo PinnedPubKey option
This sets curl's CURLOPT_PINNEDPUBLICKEY option in the built-in
downloader, or replaces %p in XferCommand.  This pins public
keys to ensure your TLS connection is not man-in-the-middled
without relying on CAs etc.  Probably most useful currently
for very small or single groups of servers.

It would obviously be best as a per-mirror option, but such
a thing currently does not exist.

Signed-off-by: Travis Burtrum <travis.archlinux@burtrum.org>
2016-10-31 02:12:31 -04:00
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
Ivy Foster 0d2ba870c9 Do not #define _RESERVED_IDENTIFIERS
Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 18:04:57 +10:00
Ivy Foster 58140dba74 Normalize alpm download callback's frontend cb arguments
When curl calls alpm's dlcb, alpm calls the frontend's cb with the
following (dlsize, totalsize) arguments:

0, -1: initialize
0, 0: no change since last call
x {x>0, x<y}, y {y>0}: data downloaded, total size known
x {x>0}, x: download finished

If total size is not known, do not call frontend cb (no change to
original behavior); alpm's callback shouldn't be called if there is a
download error.

See agregory's original spec here:
https://wiki.archlinux.org/index.php/User:Apg#download_callback

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +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 0f0b192d8a Remove obsolete TODO
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Allan McRae 7a9d8b7001 Turn off colours once finished using them
The colour of the package version could leak onto the next line in both
-Qo and -Fo.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
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 0088a7ab1c Add colour to the output of the "-{F, Q}o" operations.
Matching output for -s operations, the repository is coloured 'magenta', the
package name is 'bold', and the version is outputted in 'green'.

Signed-off-by: Xavion <Xavion (dot) 0 (at) Gmail (dot) com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
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
Allan McRae 7d1ea0b814 Handle provides with -Q
It is useful to be able to use "pacman -Qi" on any dependency, even if that
dependency is a provide.  For example, on Arch Linux systems, "sh" is provided
by the "bash" package, and many packages depend on "sh". Querying the
package that provides the "sh" dependency currently requires first searching
for "sh".

This patch allows the use of "pacman -Qi" on a provide.

Fixes FS#20650.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Allan McRae 502e0d1db0 pacman_query: move error messages into relevant if statements
This ensures any additions to these test do not have to rely on the correct
error condition being set by libalpm.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Allan McRae ee960048b2 Remove notification of system upgrade when only printing URLs
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Allan McRae 3ed57be450 Print replacements when using -Sup
When printing a list of URLs of packages to be updated, pacman was ignoring any
replacements that would be made in the update process.

Fixes FS#35812

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Allan McRae 2ee1706a72 Do not add root prefix twice when checking database files
When checking .INSTALL and .CHANGELOG files in the mtree file, we need to find
the path they are stored in the local database. This was appending the root
prefix twice as alpm_option_get_dbpath already returns the absolute path to
the database.

While fixing that issue I added checks that the paths for the database files
were not longer than PATH_MAX.

Fixes FS#48563.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-03-28 17:16:27 +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 9375715ae4 Regenerate translations for 5.0.1 2016-02-23 13:09:39 +10:00
Allan McRae e2ca25623b Manually fix space before ellipses in translations
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 13:05:02 +10:00
Stefan Tatschner cd4a3d03a0 Fix inconsistent status messages
This patch fixes an inconsistency in the status messages.

    :: Proceed with installation? [Y/n]
    :: Retrieving packages ...         <--- Space before "...".
     blas-3.6.0-4-x86_64
     cblas-3.6.0-4-x86_64
     lapack-3.6.0-4-x86_64
    (3/3) checking keys in keyring
    (3/3) checking package integrity
    (3/3) loading package files
    (3/3) checking for file conflicts
    (3/3) checking available disk space
    :: Processing package changes...  <--- No space before "..."
    (1/3) upgrading blas
    (2/3) upgrading cblas
    (3/3) upgrading lapack

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:56:52 +10:00
Allan McRae 5c136d85db Pull translation updates from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:56:40 +10:00
Andrew Gregory c1bb41a037 dump_pkg_info: fix wide character title alignment
The padding added to the end of the title was based on the return value
of mbstowcs which is the number of characters.  This caused alignment
issues for languages with characters that span multiple columns.
Instead, base the padding on the number of columns needed by the
translated string as returned by wcswidth.

Fixes #47980

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:52 +10:00
Allan McRae e910d45ac0 Update translations
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-30 10:13:55 +10:00
Allan McRae 4291500c82 Remove spacing when outputting package sizes
This spacing appears to have been added to align sizes.  It sometimes worked...

$ pacman -Si glibc | grep Size
Download Size   :   8.03 MiB
Installed Size  :  35.08 MiB

And it sometimes failed...

$ pacman -Si pacman | grep Size
Download Size   : 662.82 KiB
Installed Size  : 4045.00 KiB

Remove the spaces for a consistent output.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-25 15:30:56 +10:00
Allan McRae ad65462a05 Pull translations updates from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-17 13:39:02 +10:00
Allan McRae 4742f5929d Update copyright years for 2016
make update-copyright OLD=2015 NEW=2016

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Allan McRae 686fae6d74 Give error message when --files will do nothing
Point people towards the help when using "pacman -F" or "pacman -F foo".

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:15:04 +10:00
Allan McRae d721bae443 alpm-hooks: add Description field
The "Description" field allows a hook to provide a some text for frontends
to use in describing what the hook is doing.  For example:

Description = updating info page directory

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:15:02 +10:00
Allan McRae 760bea5432 Show progress processing hooks
Introduces the ALPM_EVENT_HOOK_RUN_{START,DONE} events that are triggered
at the start and end of running an individual hook.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:12:23 +10:00
Allan McRae 8d3bd4ec13 Add ALPM_EVENT_TRANSACTION_{START,DONE} events
This provides a way to detect when the processing of package changes starts,
allowing pacman to delineate hook output and package installation/removal
output.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 15:12:32 +10:00
Olivier Brunel 132ec4c3b9 Add events ALPM_EVENT_HOOK_{START,DONE}
Add events to let frontends know when hooks are being processed (and when it's
done), as that might be useful to update the UI.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
2015-12-15 15:09:28 +10:00
Allan McRae f98541400b Pull translations from Transifex and prepare for next release
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-09 16:11:58 +10:00
Andrew Gregory a8e2578feb remove soft interrupt handler before cleanup
The soft interrupt handler dereferences config, causing a segfault if
it is called during cleanup.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:10:43 +10:00
Andrew Gregory b8a7277061 extract soft interrupt handlers
Delays handler setup until after config is set to a valid
value to avoid a segmentation fault.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:10:23 +10:00
Andrew Gregory 8089081ef9 extract SIGSEGV handler
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:10:06 +10:00
Andrew Gregory c74495a3b2 extract SIGWINCH handler
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:09:53 +10:00
Andrew Gregory 4d2317dafb move signal handlers to sighandler.[ch]
Signals are special because they run asynchronously, making them
non-trivial to handle correctly.  Move the handlers a separate file to
offset them from the normal code and make them easier to separate into
individual functions without further cluttering pacman.c

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:09:39 +10:00
Andrew Gregory 220a3ce2b8 avoid unsafe functions in signal handler
signal(7) lists a set of functions that can safely be called from within
a signal handler.  Even fileno and strlen are not guaranteed to be safe.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:08:43 +10:00
Andrew Gregory 8d11aa3cdf remove SIG_IGN check when setting signal handler
Our signal handler provides a way to gracefully interrupt a transaction
and should always be set.

The check appears to have originally been copied directly from the glibc
manual.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:08:05 +10:00
Andrew Gregory 85508b478e do not catch SIGTERM
On SIGTERM pacman was exiting immediately, even in the middle of
a transaction.  In this case we should leave the lock file in place as
an indication that the database may not be in a consistent state.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:07:24 +10:00
Andrew Gregory 7fb8a299c2 pacman: exit without memory cleanup on signals
Memory allocation/deallocation functions are not safe to call from
signal handlers.  Just remove the lock file if there is one and exit
immediately.

Fixes: FS#46375, FS#45995, FS#47011

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:57:49 +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
Andrew Gregory 8fa02036c3 files_search: reset found for each target
Otherwise any invalid targets following a successful match will not get
an error message.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 15:06:21 +10:00
Andrew Gregory 726712aa08 files_search: free compiled regex
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 15:06:08 +10:00
Andrew Gregory 978b197120 files: do not unnecessarily strdup targets
Targets are never modified so we can just use the original copy.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 15:05:52 +10:00
Andrew Gregory 0d877ec429 files.c: add vim modeline
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 14:51:49 +10:00
Andrew Gregory 08b0b6de96 add detail to broken dependency errors
The difference between a sync target having an unmet dependency and
breaking a dependency for an installed package is a common source of
confusion.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 14:50:57 +10:00
Andrew Gregory 556c56d4d5 add --quiet to -Fh
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 14:50:57 +10:00