Commit graph

2806 commits

Author SHA1 Message Date
Andrew Gregory
1c4e079899 do not try to download an empty db list
Starting the download process, even if there is nothing to actually
download, causes an error when pacman is built without curl and has no
XferCommand defined (like our test suite).

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-19 12:39:37 +10:00
Andrew Gregory
79227dabe0 make alpm download config accessible without curl
Download-related config options are currently limited to builds with
curl.  This causes compilation errors when those options are used
without an appropriate guard which often goes unnoticed because we all
use curl.  Front-ends providing their own download callback may also
want to use these settings.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-19 12:39:10 +10:00
Andrew Gregory
8ed98023b4 sighandler: initialize sigaction fields
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-19 12:38:57 +10:00
Andrew Gregory
a493170420 fully free error list in check_keyring
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-19 12:38:34 +10:00
Andrew Gregory
5151de3011 plug memory leaks in _alpm_key_import
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-19 12:38:02 +10:00
Allan McRae
3f5125e47c doc: move missed sections from alpm_ to libalpm_
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-11 11:10:55 +10:00
Allan McRae
4cdbbcfc34 doc: reference all libalpm sections within libalpm man page
Also, fix minor typo.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-09 09:19:50 +10:00
Allan McRae
c1d23c0ff2 doc: rename libalpm-list man page for consistency
All other libalpm man pages are in the form libalpm_<name>.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-09 09:19:03 +10:00
morganamilo
8fda300e06 doc: change group names to libalpm_*
Also change the group's title to point to the group's man page.

This makes generated man pages be named libalpm_* which is more
consistent with what library man pages are usually called.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-09 00:15:18 +10:00
Emil Velikov
45a648961b libalpm: const annotate struct db_operations
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-09 00:15:14 +10:00
Emil Velikov
1d2dd9a128 libalpm: const annotate struct pkg_operations
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-09 00:15:04 +10:00
Allan McRae
f8614d8c5b get_file_pkg_ops: update comment 2021-01-09 00:14:58 +10:00
Emil Velikov
027d76b9f5 libalpm: introduce get_sync_pkg_ops() helper
Currently default_pkg_ops is accessed in two different ways.

There is get_file_pkg_ops (in be_package.c) creating a local once-off
'tweaked' copy. As well as load_pkg_for_entry (be_sync.c) which modifies
in-place and uses default_pkg_ops.

This seems rather misleading and fragile approach. Introduce a helper
for the second use-case so that default_pkg_ops is handled consistently
and essentially remains unchanged throughout.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-09 00:14:56 +10:00
Emil Velikov
b9ab7790d5 Remove unused SYMHIDDEN macros
The macro hasn't been used since 2007 with commit
7f7da2b5fc. Although it was still copied
over into alpm_list.c an year or so later with commit ca1a1871 ("More
cleanup to alpm_list")

Just remove all instances of it.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-09 00:14:50 +10:00
morganamilo
793e2097a6 libalpm: pass the number of packages being downloaded in totaldlcb
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-09 00:12:32 +10:00
morganamilo
f5b373788f libalpm: don't use curl's deprecated functions
This bumps the minimun curl version from 7.32.0 to 7.55.0.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-09 00:12:19 +10:00
morganamilo
7cc8e0181f libalpm: remove useless if
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-09 00:11:44 +10:00
morganamilo
8e291e6f4b doc: fix typos
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-03 11:24:24 +10:00
Emil Velikov
ccdd1e3fd9 Move hex_representation() to src/common
We'll reuse the function in pacman with a later commit.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-29 12:38:23 +10:00
Emil Velikov
831fc568fc Remove pre libarchive 3.0 code
Pacman has required libarchive 3.0 or later for quite some time mow.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-29 12:37:45 +10:00
morganamilo
e67c306f91 doc: add extra documentation to the man page
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 12:01:58 +10:00
morganamilo
ea975c328d doc: rename alpm_api group to alpm
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 12:01:58 +10:00
morganamilo
1e8816f13d doc: move top level items into groups
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 12:01:58 +10:00
morganamilo
2a16434bfd doc: move alpm_api group to top of file
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 12:01:58 +10:00
morganamilo
4613527738 doc: document options
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 12:01:58 +10:00
morganamilo
7b06b5407b doc: document alpm_list
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 12:01:57 +10:00
morganamilo
50d2171ef0 doc: document misc
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:55:46 +10:00
morganamilo
a321e1f8a5 doc: document transactions
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:55:46 +10:00
morganamilo
3d60a829e1 doc: document files and groups
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:55:45 +10:00
morganamilo
5901ac9cb2 doc: document packages
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:55:45 +10:00
morganamilo
af7a1e834f doc: document logging
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:55:45 +10:00
morganamilo
55efa43f23 doc: document databases
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:55:45 +10:00
morganamilo
e9ac13776e doc: document callbacks
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:55:45 +10:00
morganamilo
bf26b6bbf7 doc: document depends
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:55:44 +10:00
morganamilo
5e9635317b doc: document signatures
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:51:07 +10:00
morganamilo
ab431f6810 doc: document handle
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:51:07 +10:00
morganamilo
49e33aad7c doc: document error
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:51:06 +10:00
morganamilo
48c8869339 doc: add doc header to alpm.h
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:49:33 +10:00
morganamilo
48865e7dac doc: remove stray doxygen comment
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-21 11:33:42 +10:00
Anatol Pomozov
11e09a23be Implement TotalDownload functionality
With the recent 'multibar' interface changes TotalDownload has been disabled.
Now we have a new UI and we need to find another way to display this
information.

When 'TotalDownload' config option is enabled we are going to have an extra
progress bar at the bottom of the screen that shows how much of the entire
download has been completed.

Closes FS#68202

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-09 10:28:10 +10:00
morganamilo
5c24f7dd11 libalpm: set ret in download files
download_files never set ret on failiure, so even when downloading
fails, the transaction goes on to commit and error out.

:: Retrieving packages...
 python-packaging-20.4-4-any.pkg.tar.zst failed to download
error: failed retrieving file 'python-packaging-20.4-4-any.pkg.tar.zst' from mirror.oldsql.cc : The requested URL returned error: 404
warning: failed to retrieve some files
(1/1) checking keys in keyring
(1/1) checking package integrity
error: failed to commit transaction (wrong or NULL argument passed)
Errors occurred, no packages were upgraded.

Also make the ret checking more consistent.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-03 21:31:34 +10:00
morganamilo
73e0d7dedc libalpm: add alpm_option_get_parallel_downloads
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 21:10:16 +10:00
morganamilo
66f9f315cf libalpm: set errno when setting parallel downloads with an invalid number
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 21:08:13 +10:00
morganamilo
75cfce9468 libalpm: clarify alpm_download_event_completed_t status
The comment makes it seem that the result itself is an error code. But
all it does is simply return -1 to indicate an error occured;

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 21:07:48 +10:00
morganamilo
4b8c274f7f libalpm: don't call dlcb when not set
Fixes FS#68728:

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 16:31:27 +10:00
morganamilo
9dc29ebf5f libalpm: set parallel_downloads to 1 when creating the handle
Fixes FS#68729

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 16:19:24 +10:00
Anatol Pomozov
ff7ff3c58d FS#66472: Remove *.sig file if package corrupted
In case if a package corrupted (e.g. signature or hash is invalid)
pacman tries to remove the package file to redownload it anew the next time.
Remove *.sig file as well to make sure no data is left for the invalid
package.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-09-23 17:12:01 +10:00
Eli Schwartz
04b69957c8 remove more autotools files
We forgot to remove m4/ in commit 454ea02438
and now it's tragically reminding me of autotools!

Also take this opportunity to drop some symlinks in lib/libalpm/ for
libcommon source files. In autotools these were built specifically for
libalpm and needed to be available in that directory, but the meson
setup just has libalpm depend on libcommon. So these pseudo source files
aren't needed anymore.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-09-03 12:49:13 +10:00
Anatol Pomozov
f53ac85ff6 Enable sha256/md5 hash verification if detached signatures are used
Pacman has multiple ways to verify package content integrity:
 - gpg signature
 - sha256
 - md5

These verification mechanisms overlap each other. gpg signatures already contain
hash value of the package content. So if a package signature is present then
pacman ignored the other 2 hash values. This worked well with signtures
embedded into pacman database.

Recently pacman got an ability to handle detached signatures (*.sig files
located next to the package files). If pacman verifies detached signature only
then one can replace pkg+sig files with some other content and pacman still
processes it as a valid package. To prevent it we need to verify
database<->package integrity using hash values stored in the database.

This commit fixes FS#67232

The new debug output is:
  checking package integrity...
  debug: found cached pkg: /var/cache/pacman/pkg/ruby-2.7.1-2-x86_64.pkg.tar.zst
  debug: sha256sum: 77baf61c62c5570b3a37cf0c3b16c5d9a97dde6fedd1a3528bf0cc5f96dd5e52
  debug: checking sha256sum for /var/cache/pacman/pkg/ruby-2.7.1-2-x86_64.pkg.tar.zst
  debug: sig data: <from .sig>
  debug: checking signature for /var/cache/pacman/pkg/ruby-2.7.1-2-x86_64.pkg.tar.zst
  debug: 1 signatures returned
  debug: fingerprint: B5971F2C5C10A9A08C60030F786C63F330D7CB92

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-08-10 19:25:59 +10:00
Anatol Pomozov
62246b9355 Fix error during keyring checking
With current master version the 'keyring checking' step produces an error:
  debug: returning error 6 from alpm_pkg_get_sig (../lib/libalpm/package.c: 274) : wrong or NULL argument passed

The package signature is still checked later at the integrity verification step though.

This commit fixes keyring checking and now the debug log looks like this:
  debug: found cached pkg: /var/cache/pacman/pkg/ruby-2.7.1-2-x86_64.pkg.tar.zst
  debug: found detached signature /var/cache/pacman/pkg/ruby-2.7.1-2-x86_64.pkg.tar.zst.sig with size 566
  debug: found signature key: 786C63F330D7CB92
  debug: looking up key 786C63F330D7CB92 locally
  debug: key lookup success, key exists

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-08-10 10:02:02 +10:00