Compare commits

..

151 Commits

Author SHA1 Message Date
Colin Woodbury
a4240a55e4 Restore usage line for -Fh
Unlike the other main commands, -F was missing its top-level usage line in its
help output.

Signed-off-by: Colin Woodbury <colin@fosskers.ca>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-03 21:37:30 +10:00
Allan McRae
20f2ae56eb Modify "pacman -h" output for files operations
pacman -F can take both a file(s) or a package(s) as arguments.  Passing a
file is more common, so adjust to show that in the help.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-12-03 21:34:01 +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
Ivy Foster
08f4ae709c Add fossil scm support to makepkg
Signed-off-by: Ivy Foster <escondida@iff.ink>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 21:58:40 +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
db4092e33d Move cursor to the end of the screen at the SIGINT
It requires exposing 'move cursor to the end' function in a pacman
header file. We use it as a chance to make naming of the cursor management
functions more consistent.

Note that there is still possibility of a race condition in the cursor
update logic. 'update cursor index variable' and 'send ASCII control
symbols to console' is not an atomic operation. So if an SIGINT is
received between these two action then cursor position is going to be
screwed.

Fixes FS#67973

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 16:10:26 +10:00
Anatol Pomozov
2859a6eefc Go to the end of screen if 'printonly' mode enabled
At the end of download operation our code makes sure the cursor is moved
to the end of the drawing area. But 'printonly' mode has its own if() branch
that skips this cursor alignment. Add cursor_goto_end() to the 'printonly'
codepath to make sure it does not clobber previous output.

Fixes FS#68355

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 15:47:47 +10:00
Michael Straube
94ac3330dd libmakepkg: compress: fix tar extension
With commit 74aacf4495 creating uncompressed .tar
packages fails.

  -> Compressing package...
/usr/share/makepkg/util/compress.sh: line 70: COMPRESS.TAR[@]: invalid variable name
bsdtar: Write error

Empty the '$ext' variable for the '.tar' extension in get_compress_command() to
fix this. We would fallback to cat for 'tar' anyways.

Signed-off-by: Michael Straube <michael.straubej@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 15:45:29 +10:00
Michael Straube
4d8f58d3b9 makepkg: emptydirs: fix typo
Fix typo in a comment in tidy_emptydirs().

Signed-off-by: Michael Straube <michael.straubej@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-10-21 11:19:01 +10:00
Eli Schwartz
c99a3cc867 makepkg: properly localize some internal function variables
We leaked fullver and pkgarch all over the place, and only conditionally
unset the other variables. Marking them local is a more proactive
solution.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-10-21 11:18:32 +10:00
Eli Schwartz
f76bd2c6c1 makepkg: fix signing of source packages
In commit c6b04c0465 the signing stage was
moved out of fakeroot, and thus into the main control flow instead of
create_{,src}package

While the function for signing binary packages has logic to build
and gpg-sign multiple filenames, the source package never got this
special treatment. This would be fine, except it uses the standard
variables to set define the filename... like ${fullver}, which is
usually set beforehand, but in this case is not. We don't define fullver
globally as it's an internal implementation detail, except by sheer
coincidence if PKGVERFUNC is false due to improperly guarded code.

Result: source packages didn't end up signed. Instead, we raised a logic
error:

==> WARNING: Failed to sign package file somepackage-.src.tar.gz.

==> ERROR: An unknown error has occurred. Exiting...

Instead, let's just build the version inline, since we only use it once.

Reported-by: GaKu999 <g4ku999@gmail.com>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-10-21 11:17:14 +10:00
Eli Schwartz
406a37206f makepkg: libprovides: don't provide both versioned and unversioned sonames
If multiple files match the pattern libfoo.so*, we want to check each of
them and see if they are shared libraries, and if so, if they have
versions attached.

But some packages can have both shared libraries and random files which
match the filename pattern. This is true at least for files in
/usr/share/gdb/auto-load/, which must match the filename they are paired
with, followed by "-gdb.py" (or some other gdb scripting ext), but
definitely don't contain a shared library. In this case, we don't want
to double-report the library in the generated provides.

It's also possible (probably) for a package to provide a versioned as
well as an unversioned shared library, but in such cases a single
provides entry is sufficient to cover both cases (and the libdepends
for the depending package would contain an unversioned dependency).

Solve this by keeping track of whether we have added a versioned soname
provides already, and then only adding a maximum of one unversioned
provides *iff* there isn't a versioned one yet.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-09-23 17:12:01 +10:00
Chih-Hsuan Yen
4533c6a8e0 util.c: table_print_line: properly align texts involving CJK
For printf in C, width is counted as bytes rather than Unicode width. [1]

> If the precision is specified, no more than that many bytes are written.

[1] Section 7.21.6, N2176, final draft for ISO/IEC 9899:2017 (C18)

Thanks Andrew Gregory for suggesting a simpler approach.

Fixes FS#59229

Signed-off-by: Chih-Hsuan Yen <yan12125@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-09-23 17:12:01 +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
Ronan Pigott
d85d9c8c60 Add pacman-conf zsh completions
Signed-off-by: Ronan Pigott <rpigott@berkeley.edu>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-09-03 12:55:34 +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
Allan McRae
f235cea733 makepkg.conf: Reword "Defaults"
FS#61661 notes that we have a comment "Defaults" value for BUILDENV and OPTIONS
but that does not necessarily correspond to what the example makepkg.conf sets.

Change the comment to "Makepkg defaults" to indicate this is what makepkg will
do unless told otherwise.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-09-03 12:44:24 +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
Eli Schwartz
2403fc9732 repo-add: use more libmakepkg to handle common compression routines
Currently the list of supported formats for an archive, is maintained in
two places. And repo-add does not actually get updated. :(

In the process, remove some of the logical duplication when calling
bsdtar/compress_as.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-08-10 09:57:37 +10:00
Eli Schwartz
74aacf4495 libmakepkg: extend compress.sh to also permit checking validity
get_compression_command() can now be used to do upfront checks for
whether a given extension is known to do something successfully. This is
useful when writing tools in which an unknown compression type is a
fatal error.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-08-10 09:57:32 +10:00
Morten Linderud
2a352dc059 doc/makepkg.8: Added punctuations.
Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-07-14 23:44:16 +10:00
Anatol Pomozov
14c0e53eed Check that destfile_name exists before using it
In some cases (when trust_remote_name is used for a URL without a filename and
no Content-Disposition is provided by the server) destfile_name will be
NULL. In this case payload data will be stored in tempfile_name and no
destfile_name is set.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-07-14 23:43:10 +10:00
Anatol Pomozov
1fd95939db Do not free payload fields in the middle of this structure use
At the end of payload use it calls _alpm_dload_payload_reset()
that will free() these and other fields anyway.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-07-14 23:41:45 +10:00
Anatol Pomozov
a8bdc2e10a Build signature remote name based on the main payload name
The main payload final name might be affected by url redirects or
Content-Disposition HTTP header value.

We want to make sure that accompanion *.sig filename always matches the
package filename. So ignore finalname/Content-Disposition for the *.sig file.

It also helps to fix a corner case when the download URL does not contain
a filename and server provides Content-Disposition for the main payload
but not for the signature payload.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-07-14 23:39:37 +10:00
Anatol Pomozov
b01bcc7d3d Fallback to detached signatures during keyring check
Pacman has a 'key in keyring' verification step that makes sure the signatures
have a valid keyid. Currently pacman parses embedded package signatures only.

Add a fallback to detached signatures. If embedded signature is missing then it
tries to read corresponding *.sig file and get keyid from there.

Verification:
  debug: found cached pkg: /var/cache/pacman/pkg/glib-networking-2.64.3-1-x86_64.pkg.tar.zst
  debug: found detached signature /var/cache/pacman/pkg/glib-networking-2.64.3-1-x86_64.pkg.tar.zst.sig with size 310
  debug: found signature key: A5E9288C4FA415FA
  debug: looking up key A5E9288C4FA415FA 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-07-07 21:38:13 +10:00
Anatol Pomozov
f3dfba73d2 FS#33992: force download *.sig file if it does not exist in the cache
In case if *.pkg exists but *.sig file does not we still have to pass
the pkg to multi_download API.

To avoid redownloading *.pkg file we use CURLOPT_TIMECONDITION curl option.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-07-07 21:38:00 +10:00
Anatol Pomozov
78d6dcec6c Add a utility function to check whether a file exists in the cache
It is similar to _alpm_filecache_find() but does not return a
dynamically allocated memory to user. Thus the user does not need to
free this resource.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-07-07 21:36:56 +10:00
Anatol Pomozov
34ba8d984d Do not use counter for error tracking
Current code uses an incrementing counter to check whether a function
returned error:

  errors += some_function();
  if(errors) { goto finish }

Replace with a more standard variable
  errors = some_function();
  if(errors) { goto finish }

Rename 'errors' variable to a more typical 'ret'.

Avoid reporting both ALPM_EVENT_PKG_RETRIEVE_FAILED and
ALPM_EVENT_PKG_RETRIEVE_DONE in the error path.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-07-07 21:35:39 +10:00
Anatol Pomozov
f078c2d3bc Move signature payload creation to download engine
Until now callee of ALPM download functionality has been in charge of
payload creation both for the main file (e.g. *.pkg) and for the accompanied
*.sig file. One advantage of such solution is that all payloads are
independent and can be fetched in parallel thus exploiting the maximum
level of download parallelism.

To build *.sig file url we've been using a simple string concatenation:
$requested_url + ".sig". Unfortunately there are cases when it does not
work. For example an archlinux.org "Download From Mirror" link looks like
this https://www.archlinux.org/packages/core/x86_64/bash/download/ and
it gets redirected to some mirror. But if we append ".sig" to the end of
the link url and try to download it then archlinux.org returns 404 error.

To overcome this issue we need to follow redirects for the main payload
first, find the final url and only then append '.sig' suffix.
This implies 2 things:
 - the signature payload initialization need to be moved to dload.c
 as it is the place where we have access to the resolved url
 - *.sig is downloaded serially with the main payload and this reduces
 level of parallelism

Move *.sig payload creation to dload.c. Once the main payload is fetched
successfully we check if the callee asked to download the accompanied
signature. If yes - create a new payload and add it to mcurl.

*.sig payload does not use server list of the main payload and thus does
not support mirror failover. *.sig file comes from the same server as
the main payload.

Refactor event loop in curl_multi_download_internal() a bit. Instead of
relying on curl_multi_check_finished_download() to return number of new
payloads we simply rerun the loop iteration one more time to check if
there are any active downloads left.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-07-07 21:35:35 +10:00
Denton Liu
6b9c1b4d54 srcinfo.sh: remove trailing newline
When a .SRCINFO file is generated via `makepkg --printsrcinfo`, each
section is concluded with an empty line. This means that at the end of
the file, an empty line remains. This is considered a trailing
whitespace error. In fact, `git diff --check` will warn about this,
saying "new blank line at EOF."

Instead of closing each section off with an empty line, use the empty
line to separate sections, omitting the empty line at the end of the
file.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-26 16:00:26 +10:00
Anatol Pomozov
84723cab5d Cleanup the old sequential download code
All users of _alpm_download() have been refactored to the new API.
It is time to remove the old _alpm_download() functionality now.

This change also removes obsolete SIGPIPE signal handler functionality
(this is a leftover from libfetch days).

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
2020-06-26 15:59:16 +10:00
Anatol Pomozov
16d98d6577 Convert '-U pkg1 pkg2' codepath to parallel download
Installing remote packages using its URL is an interesting case for ALPM
API. Unlike package sync ('pacman -S pkg1 pkg2') '-U' does not deal with
server mirror list. Thus _alpm_multi_download() should be able to
handle file download for payloads that either have 'fileurl' field
or pair of fields ('servers' and 'filepath') set.

Signature for alpm_fetch_pkgurl() has changed and it accepts an
output list that is populated with filepaths to fetched packages.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
2020-06-26 15:59:08 +10:00
Eli Schwartz
59e751f72d doc/pacman.8: fix typo
Fixes FS#67000

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-19 15:38:24 +10:00
Allan McRae
7ba8e5f376 pacman-key: change signing key to RSA4096
RSA2048 may have been fine when this was written many moons ago, but time
this has a bump.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-15 19:17:41 +10:00
Eli Schwartz
02ae97b0da makepkg/repo-add: do not accept public-only keys for signing
If it's not listed by --list-secret-key we don't care if it has been
imported into your keyring, it's unusable. And you might not have a
private key at all in the no-keyid-specified case.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-11 10:57:59 +10:00
Eli Schwartz
899d39b635 makepkg/repo-add: handle GPGKEY with spaces
We pass this to gpg -u and this gpg option can accept a number of
different formats, not just the historical hexadecimal fingerprint we
assumed. We should not barf hard if a format is used which happens to
contain spaces.

This also fixes a validation bug. When we initially check if the desired
key is available, we don't quote spaces, so gpg goes ahead and treats
each space-separated string as a *different key* to search for,
returning partial matches, and returning success if at least one key is
found. But gpg --detach-sign -u will certainly not accept multiple keys!

Fixes FS#66949

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-11 10:56:30 +10:00
Eli Schwartz
bf458cced7 libmakepkg: fix regression in sending plain() output to stderr
In commit 882e707e40 we changed message
output to go to stdout by default, unless it was an error. The plain()
function doesn't *look* like an error function, but in practice it was
-- it's used to continue multiline messages, and all in-tree uses were
for warning/error.

This is a problem both because we're sending output to the wrong place,
and because in some cases, we were performing error logging from a
function which would otherwise return a value to be captured in a
variable using command substution.

Fix this and straighten out the API by providing two functions: one for
continuing msg output, and one which wraps this by sending output to
stderr, for continuing error output.

Change all callers to use the second function.
2020-06-11 10:54:54 +10:00
Eli Schwartz
381e113755 makepkg: correctly handle missing download clients
This was broken in commit 882e707e40,
which changed 'plain()' messages to go to stdout, which was then
captured as the download client in question: cmdline=("Aborting...").

The result was a very confusing error message e.g.

/usr/share/makepkg/source/file.sh: line 72: $'\E[1m': command not found

or with makepkg --nocolor:

/usr/share/makepkg/source/file.sh: line 72: Aborting...: command not found

The problem here is that we checked to see if an asynchronous subshell,
in our case <(...), failed, by checking if its captured stdout is
non-empty. Which is terrible, and also a limitation of old bash. But
bash 4.4 can use wait $! to retrieve the return value of an asynchronous
subshell. Now we target that as our minimum, we can sanely handle errors
in such functions.

Losing error messages on stdout by capturing them in a variable instead
of printing them, continues to be a problem, but this will be fixed
systematically in a later commit.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-11 10:53:24 +10:00
Eli Schwartz
817f9fb715 makepkg: guard against undefined git pinned sources
If something like source=(..."#commit=") is used, e.g. due to failed
variable expansion, we try to check out an empty refspec as nothing at
all, and end up just running "git checkout". This happens because we
fail at variable expansion too -- so let's quote our variables properly
and make sure git sees this as an empty refspec, so it can error out.

Also make sure it is interpreted as a ref instead of a path.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-11 10:50:52 +10:00
Eli Schwartz
3bd88821bb build: add libintl dependency to meson and the .pc file
In order to use gettext on systems where it is not part of libc, the
correct linker flags are needed in libalpm.pc (for static compilation).
This has never been the case.

The new meson build system currently only checks for ngettext in libc,
but does not fall back to searching for the existence of -lintl; add it
to the libalpm dependencies.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-11 10:47:14 +10:00
Filipe Laíns
e348ba3881 ci: cache packages
Results in ~40s saved in each job.

Signed-off-by: Filipe Laíns <lains@archlinux.org>
2020-06-11 10:30:15 +10:00
Allan McRae
40bbaead44 Revert "makepkg: drop duplicate reporting of missing dependencies"
This removed all information on dependency failures if the --syncdeps
flag was not used.  A better approach is needed.

This reverts commit 4246a4cc4f.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-11 10:27:54 +10:00
Allan McRae
5f6ef895b1 libalpm/signing.c: Fix calculation of packet size in parse_subpacket
Given RFC 4880 provides the code to do this calculation, I am not sure
how I managed to stuff that up!  This bug was only exposed when a
signature made with "include-key-block" was added to the Arch repos,
which provided a subpacket with the required size to hit this issue.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-01 10:59:08 +10:00
Dave Reisner
23b50d60e3 Avoid depending on side effects in assert(...) expressions
When building with -DNDEBUG, assert statements are compiled out to
no-ops. Thus, we can't depend on assignments or other computations
occurring inside the assert().

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-01 10:59:08 +10:00
Eli Schwartz
3674144a74 libmakepkg/strip: don't re-add the same debug source multiple times
It's either a waste of work, or triggers edge cases in some packages
(like coreutils-8.31) where the source file is readonly and cp gets a
permission denied error trying to overwrite it with an identical copy of
itself.

Also while we are at it, make the variable names be something readable,
because I could barely tell what this was doing while editing it.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-06-01 10:59:08 +10:00
Allan McRae
454ea02438 Remove autotools support
This removes support for autotools in favour of meson.
2020-06-01 10:59:08 +10:00
Levente Polyak
8ce142a255 makepkg: deterministic PKGINFO libprovides for multiple library versions
While iterating over the provides array, the find call for locating a
shared library may result in listing multiple entries which by itself
does not produce a stable deterministic order and may vary depending on
the underlying filesystem.
To provide a stable listing and a reproducible .PKGINFO file the result
of find is piped to sort with a static LC_ALL=C localisation.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-11 12:19:40 +10:00
Eli Schwartz
8e769ddb8a Log invalid conf settings as an error
This is not a warning, _parse_options() returns failure without even
parsing further lines and the attempted pacman/pacman-conf program
execution immediately aborts. Warnings are for when e.g. later on if we
don't recognize a setting at all, we skip over it and have enough
confidence in this to continue executing the program.

The current implementation results in pacman-conf aborting with:

warning: config file /etc/pacman.conf, line 60: invalid value for 'ParallelDownloads' : '2.5'
error parsing '/etc/pacman.conf'

or pacman -Syu aborting with the entirely more cryptic:

warning: config file /etc/pacman.conf, line 59: invalid value for 'ParallelDownloads' : '2.5'

and this isn't just a problem for the newly added ParallelDownloads
setting, either, you could get the same problem if you specified a
broken XferCommand, but that's harder as it's more accepting of input
and you probably don't hit this except with unbalanced quotes.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-11 12:19:40 +10:00
Eli Schwartz
7423b16604 pacman-conf: fix incomplete support for ILoveCandy
This was only partially implemented in the original implementation.
`pacman-conf | grep ILoveCandy` would tell you if it was set, but
querying directly by name would not.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-11 12:19:40 +10:00
Eli Schwartz
559590256c pacman-conf: add support for new ParallelDownloads config option
This was forgotten in the initial implementation, so it was impossible
to figure out the value from a script, or correctly roundtrip the
config file.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-11 12:19:40 +10:00
Anatol Pomozov
22a58f5420 Swap alpm_db_update() implementation to multiplexed version
Now when all callers of the old alpm_db_update() function are gone we can
remove this implementation. And then rename alpm_dbs_update() function to
alpm_db_update().

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:39 +10:00
Anatol Pomozov
557845bc97 Convert downloading databases to the new multiplexed API
Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:39 +10:00
Anatol Pomozov
0346e0eef2 Convert download packages logic to multiplexed API
Create a list of dload_payloads and pass it to the new _alpm_multi_*
interface.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:39 +10:00
Anatol Pomozov
b96e0df4dc Implement multibar UI
Multiplexed download requires ability to draw UI for multiple active progress
bars. To implement it we use ANSI codes to move cursor up/down and then
redraw the required progress bar.
`pacman_multibar_ui.active_downloads` field represents the list of active
downloads that correspond to progress bars.
`struct pacman_progress_bar` is a data structure for a progress bar.

In some cases (e.g. database downloads) we want to keep progress bars in order.
In some other cases (package downloads) we want to move completed items to the
top of the screen. Function `multibar_move_completed_up` allows to configure
such behavior.

Per discussion in the maillist we do not want to show download progress for
signature files.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:39 +10:00
Anatol Pomozov
c78eb48d91 Extend download callback interface with start/complete events
With the previous download interface the callback uses the first progress
event as 'download has started' signal. Unfortunately it does not work with
up-to-date files that never receive 'download progress' events.
Up-to-date database messages are currently handled in sync_syncdbs()
after the sequential download is completed and a result from ALPM is
received. But this is not going to work with multiplexed download
interface that returns the result only after all files are completed.

Another problem with 'first progress event is the beginning of the
download' is that such events time are unpredictable. Thus the UI progress
bar order might differ from what has been passed by client to
alpm_dbs_update() function. We actually want to keep the dbs progress bars
in a strict order.

To help to solve the given problems extend the download callback to
allow 2 more events - download started and completed. 'Download started'
events appear in the same order as in the list given by a client.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:21 +10:00
Anatol Pomozov
64c4669f57 Introduce event types for start/end database list download
Multiplexed database/files downloads will use multiple progress bars.
The UI logic is quite complicated and printing error messages while
handling multiple progress bars is going to be challenging.

Instead we are going to save all ALPM error messages to a list and flush
it at the end of the download process. Use on_progress variable that
blocks error messages printing.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:21 +10:00
Anatol Pomozov
6a331af27f Implement multiplexed download using mCURL
curl_multi_download_internal() is the main loop that creates up to
'ParallelDownloads' easy curl handles, adds them to mcurl and then
performs curl execution. This is when the paralled downloads happens.
Once any of the downloads complete the function checks its result.
In case if the download fails it initiates retry with the next server
from payload->servers list. At the download completion all the payload
resources are cleaned up.

curl_multi_check_finished_download() is essentially refactored version of
curl_download_internal() adopted for multi_curl. Once mcurl porting is
complete curl_download_internal() will be removed.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:21 +10:00
Anatol Pomozov
1d42a8f954 Implement _alpm_multi_download
It is an equivalent of _alpm_download but accepts a list of payloads.

curl_multi_download_internal() is a stub at this moment and will be
implemented in the later commits of this patch series.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:21 +10:00
Anatol Pomozov
fa68c33fa8 Inline dload_payload->curlerr field into a local variable
dload_payload->curlerr is a field that is used inside
curl_download_internal() function only. It can be converted to a local
variable.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:21 +10:00
Anatol Pomozov
dc98d0ea09 Add multi_curl handle to ALPM global context
To be able to run multiple download in parallel efficiently we need to
use curl_multi interface [1]. It introduces a set of APIs over new type
of handler 'CURLM'.

Create CURLM object at the application start and set it to global ALPM
context.

The 'single-download' CURL handle moves to payload struct. A new CURL
handle is created for each payload with intention to be processed by CURLM.

Note that curl_download_internal() is not ported to CURLM interface due
to the fact that the function will go away soon.

[1] https://curl.haxx.se/libcurl/c/libcurl-multi.html

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:21 +10:00
Anatol Pomozov
a8a1a1bb3e Introduce alpm_dbs_update() function for parallel db updates
This is an equivalent of alpm_db_update but for multiplexed (parallel)
download. The difference is that this function accepts list of
databases to update. And then ALPM internals download it in parallel if
possible.

Add a stub for _alpm_multi_download the function that will do parallel
payloads downloads in the future.

Introduce dload_payload->filepath field that contains url path to the
file we download. It is like fileurl field but does not contain
protocol/server part. The rationale for having this field is that with
the curl multidownload the server retry logic is going to move to a curl
callback. And the callback needs to be able to reconstruct the 'next'
fileurl. One will be able to do it by getting the next server url from
'servers' list and then concat with filepath. Once the 'parallel download'
refactoring is over 'fileurl' field will go away.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:21 +10:00
Anatol Pomozov
fe8e13341b Add config option to specify amount of parallel download streams
It includes pacman.conf new 'ParallelDownloads' option that
specifies how many concurrent downloads cURL starts in parallel.

Add alpm_option_set_parallel_downloads() ALPM function that
allows to set this config option programmatically.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:21 +10:00
Eli Schwartz
cffda331ad doc: remove vim modelines from BUILDINFO(5)
We (thought we) removed all modelines from the project in commit
860e4c4943, but apparently this one
sneaked in by virtue of this manpage being added to the project after
the "remove all the modelines" patch was submitted, but before it was
applied.

I must have failed to update the patch to remove it from this file also.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-09 11:58:21 +10:00
Eli Schwartz
411b12d09d editorconfig: set meson indentation style
meson.build gets two-space indents, but our global tabbed default was
overriding this.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-06 13:48:15 +10:00
Eli Schwartz
3a6c9220ff meson: use better check for debug builds
meson 0.48 added the 'debug' and 'optimization' builtin options, which
bidirectionally map to the buildtype, but in some cases where debug is
enabled, the builtype may be custom. Checking the 'debug' option lets us
detect every case currently detected, plus a few more, and does so in a
shorter and more concise manner.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-06 13:48:07 +10:00
Allan McRae
df30f10672 Convert gitlab valgrind runner to meson
Turns out environmental variables do get passed through fakechroot!

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-06 13:48:00 +10:00
Dave Reisner
cebda6d0ee meson: handle XFAIL tests outside of TAP
This change causes expected fail tests to actually fail by eliding the
'# TODO' from the test plan. In turn, we can now properly use
'should_fail' in the meson test() rule and see these expected fail
tests in the output:

Before:
  ...
  320/332 upgrade077.py                   OK 0.12679290771484375 s
  321/332 upgrade078.py                   OK 0.12620115280151367 s
  322/332 upgrade080.py                   OK 0.1252129077911377 s
  ...

  Ok:                 332
  Expected Fail:      0
  Fail:               0
  Unexpected Pass:    0
  Skipped:            0
  Timeout:            0

After:
  ...
  320/332 upgrade077.py                   OK 0.12679290771484375 s
  321/332 upgrade078.py                   EXPECTEDFAIL0.12620115280151367 s
  322/332 upgrade080.py                   OK 0.1252129077911377 s
  ...

  Ok:                 326
  Expected Fail:      6
  Fail:               0
  Unexpected Pass:    0
  Skipped:            0
  Timeout:            0

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-05 09:14:32 +10:00
Allan McRae
0b81fb64d3 Add Gitlab Runner configuration
Arch Linux is setting up a Gitlab instance.  This adds CI for the pacman
project, testing a range of configurations on Arch and basic builds on
Fedora and Debian.

Note that asciidoc is specifically not installed on the Debian run because
it is all sorts of broken...  Also, the defaults have been set to meson, with
two autotools tests that will soon be removed.

Original-file from: Andrew Gregory <andrew.gregory.8@gmail.com>
Altered-to-run-on-Arch-Gitlab by: Sven-Hendrik Haase <svenstaro@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-05 09:14:23 +10:00
Ivy Foster
969e1ab996 Add NoProgressbar to pacman.conf options
This is useful for dumb terminals that do not support escape
sequences.

Signed-off-by: Ivy Foster <escondida@iff.ink>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-04-29 13:57:53 +10:00
Rikard Falkeborn
2439222375 Constify some input pointers
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-04-29 13:57:45 +10:00
Allan McRae
3ea7fdd96c pacman.8: Fix typo
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-04-15 11:05:55 +10:00
Carson Black
b323528491 Dull version colour numbers in summary
Version colour numbers are dulled in the non-verbose transaction summary
when colours are enabled.

To prevent a regression, this patch also adds handling of strings with
ANSI codes to string_length as to not break the transaction summary's
output functions when colour codes are in the package name strings.

Signed-off-by: Carson Black <uhhadd@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-04-15 11:05:55 +10:00
Allan McRae
6ba250e400 Use GOTO_ERR throughout
The GOTO_ERR define was added in commit 80ae8014 for use in future commits.
There are plenty of places in the code base it can be used, so convert them.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-04-13 23:44:46 +10:00
Allan McRae
0eda92c5d4 Use STRDUP for error checking in more places
Use STRDUP() over strdup() to catch memory allocation errors.

There are still some instances of strdup left, but these are in functions
that currently have no error path and would require a larger rework.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-04-13 23:44:46 +10:00
Rikard Falkeborn
1b32897453 Add REALLOC macro to simplify realloc error handling
realloc can fail just like the other memory allocation functions. Add a
macro to simplify handling of realloc failures, similar to the already
existing MALLOC, CALLOC, etc.

Replace the existing realloc uses with the new macro, allowing us to
move tedious error handling to the macro. Also, in be_package and
be_sync, this fixes hypothetical memory leaks (and thereafter null
pointer dereferences) in case realloc fails to shrink the allocated
memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-04-13 23:44:46 +10:00
Earnestly
1d39557aa0 Use noextract with pacman-conf NoExtract
Current code accidently uses noupgrade for the NoExtract directive.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-04-13 23:44:46 +10:00
Anatol Pomozov
87b74fcd82 Hide cursor while pacman is running
Use ASCII control codes to hide cursor at the pacman start and then
show the cursor when pacman finishes.

It helps to avoid annoying blinking when progress bars are re-drawn.

Cursor is reenabled if pacman expects user's input.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-03-13 11:24:01 +10:00
Allan McRae
ddd5b0a462 Add file and line number to RET_ERR{,_VOID}
Following the example of the recently added GOTO_ERR, adding the file and
line number in addition to the function name in our debug messages is
potentially useful.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-03-13 11:23:36 +10:00
Anatol Pomozov
80ae80149a Add GOTO_ERR() macro to set error and then goto a label
This is a macro similar to RET_ERR but useful in the case when we need
to record an error and then jump to some cleanup section.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-03-09 16:34:17 +10:00
Allan McRae
0deff63efa Remove unneeded goto cleanup
Since commit 2ee7a8d8, there is no cleanup needed in this function. Just
return instead of jumping to the cleanup label.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-03-09 14:51:38 +10:00
Anatol Pomozov
e578903b60 Move flushing 'output' list into separate function
'output' is a list of messages that pacman received but delayed printing
to avoid messing with UI.

Such functionality is useful for the upcoming multi-line progress bar
UI. Let's move it to a separate function.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-03-06 09:28:13 +10:00
Anatol Pomozov
aff69f43b1 Do not download files if find_dl_candidates() fails
One reason why the function returns an error is some repo
does not have any servers.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-03-05 16:15:44 +10:00
Anatol Pomozov
130db5cc9e Simplify construction of payloads in download_files
Currently, download_files() creates payloads for all packages then
iterates over them, calling download_single_file.  This can be
simplified by looping over packages and constructing the payload as needed.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-02-24 11:27:23 +10:00
Dave Reisner
4246a4cc4f makepkg: drop duplicate reporting of missing dependencies
When pacman fails to satisfy deps, we might see output like the
following:

==> Making package: spiderfoot 3.0-1 (Thu 06 Feb 2020 12:45:10 PM CET)
==> Checking runtime dependencies...
==> Installing missing dependencies...
error: target not found: python-pygexf
==> ERROR: 'pacman' failed to install missing dependencies.
==> Missing dependencies:
  -> python-dnspython
  -> python-exifread
  -> python-cherrypy
  -> python-beautifulsoup4
  -> python-netaddr
  -> python-pysocks
  -> python-ipwhois
  -> python-ipaddress
  -> python-phonenumbers
  -> python-pypdf2
  -> python-stem
  -> python-whois
  -> python-future
  -> python-pyopenssl
  -> python-docx
  -> python-pptx
  -> python-networkx
  -> python-cryptography
  -> python-secure
  -> python-pygexf
  -> python-adblockparser
==> Checking buildtime dependencies...
==> ERROR: Could not resolve all dependencies.

This is misleading -- the only truly missing package is python-pygexf,
but we fail to remove sync-able deps from our deplist and report
everything as if it were missing. Simply drop this extra reporting
because pacman already tells us exactly what couldn't be resolved.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-02-12 18:37:44 +10:00
Allan McRae
e76ec94083 build-aux/update-copyright 2019 2020
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-02-10 10:46:03 +10:00
Allan McRae
033405c963 Add pacman-hooks.5 man page symlink
Improve discoverability of the alpm-hooks man page by adding a pacman-hooks
symlink.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-02-10 10:38:38 +10:00
Anatol Pomozov
886a6677a8 Eliminate extra loop over dbs_sync
Current flow looks like
  loop dbs_sync {
    loop pkgs {
      if pkg.db == db then process(pkg, db)
    }
  }

Package sync transaction always has a counterpart in the dbs_sync list
(I cannot come up with a use-case when it is not true). So the loop can
be simplified to:

  loop pkgs {
    process(pkg, pkg.db)
  }

Tested: 'ninja test' & manually by using pacman with this patch for a
week
Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-31 00:38:36 +10:00
morganamilo
d0c487d4dc Docs docs docs
libalpm: move docs from .c files into alpm.h And fix/expand some
along the way.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-28 10:46:27 +10:00
morganamilo
0a25548cd0 libalpm: fix alpm_option_set_assumeinstalled
It looks like this function has never actually worked. The current list
is never set to NULL after being freed. So the new deps were just
appended to the already freed list, leading to a segfault.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-28 10:46:27 +10:00
Allan McRae
21af798604 makepkg: add CRC checksums and set these to be the default
Checksums arrays should be filled with values provided by upstream.  We
currently have md5 set as an unsecure default, and are constantly asked to
change it to sha2.  However, just changing the default to a stronger checksum
gives the user the impression that "makepkg -g" checksums are perfect.

Instead, change the default checksum to a CRC, to make it clear that any
checksum generated purely by "makepkg -g" is not ideal.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-28 10:46:26 +10:00
Allan McRae
c3852ff425 Note that checksums from "makepkg -g" are not ideal
Generating checksums with "makepkg -g" only determines that the user of a
PKGBUILD has the same file as the packager (assuming no collision).  This
means an upstream source could be maliciously changed and passed on as valid
by a PKGBUILD.  To avoid this, it is essential that any checksums used in
a PKGBUILD are as provided by upstream.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-28 10:45:42 +10:00
Allan McRae
e54617c7d5 Fix "pacman -U <url>" operations
Commit e6a6d307 detected complete part files by comparing a payload's
max_size to initial_size.  However, these values are also equal when we
use pacman -U on a URL as max_size is set to 0 in that case.  Add a further
condition to avoid that.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-27 17:53:50 +10:00
Eli Schwartz
d626a17ef9 makepkg: make per-package files containing '$pkgname' consistently work
Extracting function variables containing arbitrarily scoped variables of
arbitrary nature is a disaster, but let's at least cover the common case
of using the actual '$pkgname' in an install/changelog file. It's the
odd case of actually being basically justified use of disambiguating
between the same variable used in multiple different split packages...
and also, --printsrcinfo already uses and overwrites the variable
'pkgname' in pkgbuild_extract_to_srcinfo, so this "works" in .SRCINFO
but doesn't work in .src.tar.gz

It doesn't work in lint_pkgbuild either, but in that case the problem is
being too permissive, not too restrictive -- we might end up checking
the same file twice, and printing that it is missing twice.

Fixes FS#64932

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-27 17:53:50 +10:00
Allan McRae
2856a7dea3 Increase maximum database size
We previously has the maximum database size as 25MB.  This was set in the days
before repos had as many packages as they do now, and before we started
distributing files databases.  Increase this limit to 128MB.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-27 17:53:50 +10:00
Allan McRae
2e32d51a26 Remove unneeded ltmain patch
Many moons ago, libtool was bad - I mean worse than today!  It gobbled all
--as-needed and we ended up with an overlinked libalpm.  This was annoying,
particularly when dealing with soname bumps in libraries pacman/libalpm had
no business linking to. Luckily we had a fix, stolen from GNOME I believe.
And with that fix, we lived in harmony with libtool for many years.  Until one
day, unbeknownst to us, libtool was "fixed".  We kept applying our patch,
because it still applied, but it did worse than nothing.  It gobbled up our
other LDFLAGS, and our libalpm started missing out on RELRO and BIND_NOW.
This made the Arch Security Team unhappy. We will make them happy again by
stopping the patch.

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-27 17:53:50 +10:00
Allan McRae
75bf8e887c Increase meson test timeout
Running the testsuite using "PACTEST_VALGRIND=1 ninja test -C build", I ran
into the following failure:

161/332 smoke001.py                             TIMEOUT 30.02 s

I figure an i7 @ 3.10GHz should be enough to run our testsuite... so boost
the meson test timeout to 120 seconds (which should be enough time for
anyone...).

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-27 17:53:50 +10:00
Allan McRae
0965023fc5 tests: Fix typo in test description 2020-01-27 17:53:50 +10:00
Eli Schwartz
acaed30e24 doc: reformat intro to VCS sources to distinguish the grammar
It's difficult to find it embedded inside a prose paragraph.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-07 11:40:32 +10:00
Eli Schwartz
ee8b4e9283 doc: clarify the format of a PKGBUILD source fragment
Currently, it could be misread to say that a fragment is literally
'commit', rather than 'commit=somehash'. Anecdotally this does not seem
to be obvious to everyone, and rewording it certainly doesn't hurt.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-07 11:40:32 +10:00
Eli Schwartz
435f5fc204 autotools: emit error message when autoconf-archive is missing
Forbid the AX_COMPARE_VERSION macro from being found in the output
configure script. If autoconf-archive is not installed when autoreconf
is run, the following error message is emitted:

configure.ac:231: error: possibly undefined macro: AX_COMPARE_VERSION
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-07 11:40:32 +10:00
Dave Reisner
9883015be2 Use c99 struct initialization to avoid memset calls
This is guaranteed less error prone than calling memset and hoping the
human gets the argument order correct.
2020-01-07 11:40:32 +10:00
Dave Reisner
ffb69c700a Ensure regex object is always initialized
This avoids a crash in filetarget_free() when regex support isn't
requested in files_search().
2020-01-07 11:40:32 +10:00
Ethan Sommer
56e0763c6d libmakepkg: use readelf instead of file for finding ELF file types
Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-12-11 11:02:15 +10:00
morganamilo
b7f61aa557 pacman: print error when -Fx is given invalid regex
When processing the targets for -Fx, compile all the regex ahead of
time, printing an error for each that failed to compile. Then, if they all
compiled successfully, continue with printing files.

Signed-off-by: morganamilo <morganamilo@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-12-02 13:56:11 +10:00
Eli Schwartz
0428f6213b makepkg: add the $startdir to package .BUILDINFO
This value is needed for reproducible builds. The reason is because
$BUILDDIR changes its behavior depending on whether it is the same as
$startdir, and the result is that we cannot know whether $srcdir (the
path that is potentially embedded into the final package) is actually
"$BUILDDIR/src" or "$BUILDDIR/$pkgbase/src".

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-26 11:49:24 +10:00
Allan McRae
1e23b45851 Fix documentation of alpm_mtree_next and remove libarchive exposure
The documentation of the return types of alpm_mtree_next was incorrect.
This extended into the relevant function in be_local.c.

Also, return explicit integer values, rather than the ARCHIVE_xxx values,
to avoid unnecessarily exposing frontends to libarchive internals (even
though it makes no functional difference).

Original-work-by: morganamilo <morganamilo@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-26 11:37:32 +10:00
Eli Schwartz
3073752bcd pactest: add environment option to run tests with valgrind
In autotools, if we wanted to run tests with valgrind, we used some Make
magic which passed arguments to pactest.py, but that doesn't work in
meson, because all arguments are encoded at configure time. Instead,
let's short-circuit the build runner logic entirely, and teach pactest
to default to running valgrind, when it detects an environment variable
set independent of the build system.

To run the tests with valgrind, we can now use:

PACTEST_VALGRIND=1 meson test -C builddir/

or

PACTEST_VALGRIND=1 make check

It is also possible, but confusing/inconsistent, to use

make check PY_LOG_FLAGS=--valgrind

We *could* add a meson option -Dvalgrind=true, but that is annoying to
reconfigure between test runs, and overall the consensus is it seems
simpler to opt in each time we want to run valgrind, as was already the
case.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-26 11:05:44 +10:00
Eli Schwartz
49a8e90bc7 meson: make non-symlink scripts install for real, and use a better wrapper
We now generate the scripts using their real name, install them using
meson's builtin facility instead of an install_script, and generate the
wrapper scripts in the root of the build directory, instead of a
subdirectory.

This gets us closer to resolving FS#64394.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-26 10:49:57 +10:00
Eli Schwartz
349c22d043 makepkg: fix regression that broke extraction of file:// sources
In commit 9c817b6549 we made these sources
extendable, and heuristically determined the correct extraction
functions to use. But our fallback for protos that didn't have an exact
extract_* function didn't take into account that 'extract_file' matches
an actual proto... so we passed the netfile in while the function
expected a file.

Solution: the function should expect a netfile too, thereby allowing us
to delay an attempted resolution of netfile -> file, to the one case
where it is actually used. This makes us slightly more efficient in the
non-file case, makes our functions a bit more consistent, and makes
file:// extraction work again.

Fixes FS#64648

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-26 10:22:16 +10:00
Allan McRae
55233b69c7 Improved documentation for alpm_db_search() parameters
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-22 09:35:31 +10:00
Allan McRae
8846574eda Fix leak in _alpm_db_search on error condition 2019-11-21 22:42:23 +10:00
Daniel T. Borelli
eaa2770c80 Dereference double pointer before assigning NULL
Daniel T. Borelli <danieltborelli@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-16 15:14:30 +10:00
Allan McRae
6fb233d0ee Add Eli to current maintainers
Also retire Dan into past major contributors.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-16 00:14:34 +10:00
Allan McRae
e6a6d30793 Handle .part files that are the size of the correct package
In rare cases, likely due to a well timed Ctrl+C, but possibly due to a
broken mirror, a ".part" file may have size at least that of the correct
package size.

When encountering this issue, currently pacman fails in different ways
depending on where the package falls in the list to download.  If last,
"wrong or NULL argument passed" error is reported, or a "invalid or
corrupt package" issue if not.

Capture these .part files, and remove the extension. This lets pacman
either use the package if valid, or offer to remove it if it fails checksum
or signature verification.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-15 23:29:20 +10:00
Allan McRae
b9faf65273 pactest: set package tar format to GNU_FORMAT
python-3.8 changed the default tar format to PAX_FORMAT. This caused
issues in our testsuite with package extraction of files with UTF-8
characters as we run the tests under the C locale.

sycn600.py:
error: error while reading package /tmp/pactest-xuhri4xa/var/cache/pacman/pkg/unicodechars-2.0-1.pkg.tar.gz: Pathname can't be converted from UTF-8 to current locale.

Set format back to GNU_FORMAT.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-12 16:14:57 +10:00
Allan McRae
540b19164b libalpm/sync.c: Do not download missing keys multiple times
We now store key structs of our missing key info, so can not search the list
for string matches. This caused missing keys to be downloaded once for every
package they signed.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-12 07:29:52 +10:00
morganamilo
27f354a787 pacman+libalpm: handle search errors
Previously, pacman treated no matches and an error during search the
same.

To fix this, alpm_db_search now returns its status as an int and
instead takes the to be returned list as a param. Allowing front ends to
easily differentiate between errors and no matches.

Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-08 16:32:55 +10:00
morganamilo
94982d0061 pacman: make exact_file an int
We only ever use it as a bool, no need to pass a char* around.

Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-07 21:43:15 +10:00
Ethan Sommer
1df22d3242 repo-add: use wc -c on stdin instead of file to avoid use of cut
Redirect file to stdin so wc -c doesn't print a file name that needs to
be stripped.

Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-07 21:40:44 +10:00
Eli Schwartz
7b73c4a75f build: remove use of handcrafted m4 in configuring scripts
Now that library/ is fully gone, we don't need this anymore.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-06 16:11:53 +10:00
Eli Schwartz
8c7043390f scripts/library: remove human_to_size
pkgdelta was the last user, and it is gone now.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-06 15:52:21 +10:00
Allan McRae
2dd7725f2a Remove "Generated from ...; do not edit by hand" from scripts
This is a useless piece of information.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-06 15:46:59 +10:00
Ethan Sommer
3a814ee6bc makepkg: replaces sed in-place with built in substitution
Reads PKGBUILD into an array and replaces the pkgver and pkgrel with
bash parameter substitution, then uses shell redirection to write to to
the file. Because shell redirection follows symlinks, this accomplishes
the same thing as the previous default of using the GNU-specific
--follow-symlinks sed flag.

Removes SEDPATH and SEDINPLACEFLAGS from the build systems as they are
not used elsewhere.

Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-06 12:03:38 +10:00
morganamilo
424129e8d1 pacman: clarify error when alpm fails to init
Currently pacman is hard coded to print the dbpath, then the error alpm
returned. Even though the error could really be caused by anything.

So instead just print the arugemnts given to alpm and not assume the
resulting error message is releated to either path.

Fixes FS#59595

Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-06 10:54:54 +10:00
Allan McRae
27955a0fee Move update-copyright into build-aux
This is a useful function to update all our copyright years. Move
it into build-aux so that it is not lost in the switch to meson.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-05 15:25:52 +10:00
Ethan Sommer
1bfae7d14a libmakepkg: fix empty arguments in parseopts
Previously parseopts checked if there was an argument by checking
that the string was non-empty, resulting in empty arguments being
incorrectly considered non-existent. This change makes parseopts check
if arguments exist at all, rather than checking that they are non-empty

Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-05 14:47:15 +10:00
Matthew Sexton
091b244d0f pacman-key: ignore already lsigned/deleted keys
Added two new functions, key_is_lsigned() and key_is_revoked()
that check whether a key has been locally signed or revoked
respectively during --populate. If the key is already signed
or revoked, it is quietly ignored.

Suggested-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Matthew Sexton <wsdmatty@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-05 14:16:31 +10:00
Matthew Sexton
e1f5f21983 pacman-key: hide lsign and revoke output behind --verbose
To cut down on spam during --populate, both locally signing and
revoking keys now hide the specific keys being signed or revoked,
but can be shown with --verbose. A count was added, to show the
number of keys signed/revoked during the process.

Partially Implements:
FS#64142 - pacman-key: make populate less noisy

Signed-off-by: Matthew Sexton <wsdmatty@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-05 14:13:10 +10:00
Ethan Sommer
7be7552329 libmakepkg: add optional argument support to parseopts
Adds a "?" suffix that can be used to indicate that an option's argument is
optional.

This allows options to have a default behaviour when the user doesn't
specify one, e.g.: --color=[when] being able to behave like --color=auto
when only --color is passed

Options with optional arguments given on the command line will be returned
in the form "--opt=optarg" and "-o=optarg". Despite that not being the
syntax for passing an argument with a shortopt (trying to pass -o=foo
would make -o's argument "=foo"), this is done to allow the caller to split
the option and its optarg easily

Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com>
Reviewed-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-04 10:55:23 +10:00
Allan McRae
f6564377a2 Release 5.2.1
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-01 10:57:09 +10:00
Allan McRae
c9613f3a0a Pull latest translations from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-01 10:54:12 +10:00
Allan McRae
fca2f7e598 Update NEWS for pacman-5.2.1
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-01 09:26:54 +10:00
Allan McRae
4d76cf6f07 Comma fail 2019-10-30 14:26:07 +10:00
Eli Schwartz
866a5cd431 autotools: be more templated when getting list of doc dist files
Distribute asciidoc sources for all manpages instead of remembering to
add files to both variables. Fixes regression in
377d47142f which broke building the
website from a dist tarball:

make: *** No rule to make target 'pacman-conf.8.html', needed by 'html'.  Stop.

(Technically this regression is already fixed by commit
942b909829, but this is just going to keep
happening, I suspect, so we should fix the root cause.)

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-30 10:05:28 +10:00
Eli Schwartz
5c2059db28 makepkg: only run --clean actions if we built a package
Fixes issue where users were allowed to run cleanup while running
--geninteg or --printsrcinfo or --packagelist, thus mixing invalid
responses into stdout.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-30 10:04:17 +10:00
Eli Schwartz
0272fca993 makepkg: do not count hard links multiple times when calculating pkg size
Exclude files with hardlinks when cat'ing all the files, and do a second
run to look at each file with hardlinks, keep track of the ones we've
already operated on, and only cat each inode once. Then use "wc -c" to get
the size of all (deduplicated) files the same way we were already doing.

Original-patch-by: Ronan Pigott <rpigott@berkeley.edu>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-30 10:03:46 +10:00
Eli Schwartz
a745d97c17 makepkg: protect against unexpected whitespace in filenames
zipman:

read -r protects against those evil manpages whose filenames contain
backslash escapes, (muahahaha?)

IFS= read protects against filenames with:

- leading whitespace (but no one is actually stupid enough to configure
  their MAN_DIRS=() in makepkg.conf with such silly directories, *right*?)

- trailing whitespace (but likewise, no one should be stupid enough to
  write an uncompressed manpage for section '1 ' or something)

Also fix several other cases where we read filenames without protecting
against surrounding whitespace, or without using null-delimited
filenames when we could trivially do so.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-30 09:47:28 +10:00
Eli Schwartz
99639dc27c meson: fix inodecmd for darwin/bsd
The BSD stat command uses %N, not %n, and was incorrectly ported to
meson.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-30 09:34:51 +10:00
Allan McRae
ae5cf26b5b Fix segfault importing PGP key for pacman -U operations
Use after free.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-27 19:05:27 +10:00
Evangelos Foutras
dc55701132 Add pacman-conf(8) to the documentation index
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-24 17:18:28 +10:00
Allan McRae
f37a3752b3 Update copyright years
make update-copyright OLD=2018 NEW=2019

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-23 22:06:54 +10:00
Allan McRae
a9835a38a3 Remove --force from completion
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-23 22:06:54 +10:00
Allan McRae
cd4f8f7530 Update completion for -F changes
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-23 22:06:45 +10:00
morganamilo
c58bf862b4 makepkg: don't warn when PACKAGER is unset
makepkg now complains when PACKAGER is not in the format
"name <email>".

Hide this warning when PACKAGER is unset but still warn if it is set to
something out of format.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-22 23:18:48 +10:00
Nick Cao
7df70e7fff Fix compression of package databases with zstd
Commit 7afe51171 attempted to add zstd compression support to repo-add,
but failed...

FS#64213

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-22 17:27:15 +10:00
Allan McRae
942b909829 Fix distribution of meson files
Also caught the source of a man page not being distributed.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-22 09:25:49 +10:00
281 changed files with 3033 additions and 4198 deletions

View File

@@ -16,5 +16,9 @@ indent_style = tab
[{NEWS,HACKING}]
indent_style = space
[meson.build]
indent_style = space
indent_size = 2
[*.py]
indent_style = space

21
.gitignore vendored
View File

@@ -1,24 +1,3 @@
*~
*.o
ABOUT-NLS
aclocal.m4
autom4te.cache
config.h
config.h.in
config.log
config.status
config.status.lineno
configure
configure.lineno
cov-int
cscope.in.out
cscope.out
cscope.po.out
intl
libtool
Makefile
Makefile.in
pacman-*.tar.gz
root
stamp-h1
tags

119
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,119 @@
variables:
MAKEFLAGS: "-j10"
VERBOSE: 1
PACMAN_OPTS: --needed --noconfirm --cachedir .pkg-cache
cache:
key: pkgs-v1
paths:
# For some reason Gitlab CI only supports storing cache/artifacts in a path relative to the build directory
- .pkg-cache
.arch-test:
image: archlinux/base
before_script:
- >
pacman -Syu $PACMAN_OPTS
base-devel git
gpgme libarchive curl
python
fakeroot fakechroot
meson
arch:
extends: .arch-test
script:
- meson build
- ninja -C build
- fakechroot meson test -C build
arch-debug:
extends: .arch-test
script:
- meson --buildtype=debug build
- ninja -C build
- fakechroot meson test -C build
arch-docs:
extends: .arch-test
script:
- pacman -Syu $PACMAN_OPTS asciidoc
- meson -Ddoc=enabled build
- ninja -C build
arch-clang:
extends: .arch-test
script:
- pacman -Syu $PACMAN_OPTS clang
- CC=clang meson build
- ninja -C build
- fakechroot meson test -C build
arch-valgrind:
extends: .arch-test
script:
- pacman -Syu --needed --noconfirm valgrind
- meson build
- ninja -C build
- PACTEST_VALGRIND=1 fakechroot meson test -C build
arch-nettle:
extends: .arch-test
script:
- meson -Dcrypto=nettle --buildtype=debug build
- ninja -C build
- fakechroot meson test -C build
arch-no-gpg:
extends: .arch-test
script:
- meson -Dgpgme=disabled --buildtype=debug build
- ninja -C build
- fakechroot meson test -C build
arch-no-curl:
extends: .arch-test
script:
- meson -Dcurl=disabled --buildtype=debug build
- ninja -C build
- fakechroot meson test -C build
arch-no-nls:
extends: .arch-test
script:
- meson -Di18n=false --buildtype=debug build
- ninja -C build
- fakechroot meson test -C build
debian:
image: debian:bullseye
cache: {}
before_script:
- apt update
- >
apt -y install --no-install-recommends
git pkg-config meson gcc libtool
libgpgme-dev libarchive-dev libcurl4-openssl-dev libssl-dev curl
gettext python3 python3-setuptools dash gawk ca-certificates
fakeroot fakechroot
script:
- meson --buildtype=debug build
- ninja -C build
- fakechroot meson test -C build
fedora:
image: fedora
cache: {}
before_script:
- >
dnf -y install
git findutils patch sed
meson gcc libtool
gpgme-devel libarchive-devel libcurl-devel openssl-devel gettext-devel
asciidoc python3 dash gawk
fakeroot fakechroot
perl-Module-Load-Conditional
script:
- meson --buildtype=debug build
- ninja -C build
- fakechroot meson test -C build

13
HACKING
View File

@@ -176,16 +176,3 @@ For pacman:
-------------------------------------------
Never directly include config.h. This will always be added via Makefiles.
GDB and Valgrind Usage
~~~~~~~~~~~~~~~~~~~~~~
When using GDB or valgrind on pacman, you will want to run it on the actual
binary rather than the shell script wrapper produced by libtool. The actual
binary lives at `src/pacman/.libs/lt-pacman`, and will exist after running
`./src/pacman/pacman` at least once.
For example, to run valgrind:
./src/pacman/pacman
valgrind --leak-check=full -- src/pacman/.libs/lt-pacman -Syu

370
INSTALL
View File

@@ -1,370 +0,0 @@
Installation Instructions
*************************
Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without warranty of any kind.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX `make' updates targets which have the same time stamps as
their prerequisites, which makes it generally unusable when shipped
generated files such as `configure' are involved. Use GNU `make'
instead.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf limitation. Until the limitation is lifted, you can use
this workaround:
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
`--help=short'
`--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
`--no-create'
`-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@@ -1,85 +0,0 @@
SUBDIRS = lib/libalpm src/util src/pacman scripts etc test/pacman test/util test/scripts
if WANT_DOC
SUBDIRS += doc
endif
DIST_SUBDIRS = $(SUBDIRS) src/common
ACLOCAL_AMFLAGS = -I m4 --install
AM_MAKEFLAGS = --no-print-directory
# Make sure we test and build manpages when doing distcheck
DISTCHECK_CONFIGURE_FLAGS = --enable-doc --disable-git-version \
bashcompdir='$${prefix}/share/bash-completion/completions'
# Some files automatically included, so they aren't specified below:
# AUTHORS, COPYING, NEWS, README
EXTRA_DIST = \
HACKING test/tap.sh \
meson.build meson_options.txt \
build-aux/edit-script.sh.in \
build-aux/meson-install-script.sh \
build-aux/meson-make-symlink.sh \
build-aux/script-wrapper.sh.in
# Sample makepkg prototype files
pkgdatadir = ${datadir}/${PACKAGE}
dist_pkgdata_DATA = \
proto/PKGBUILD.proto \
proto/PKGBUILD-split.proto \
proto/PKGBUILD-vcs.proto \
proto/proto.install
$(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py)
@printf "TESTS += %s\n" $^ | LC_ALL=C sort -u > "$@"
TESTS = test/scripts/parseopts_test.sh \
test/scripts/human_to_size_test.sh \
test/scripts/makepkg-template_test.sh \
test/scripts/pacman-db-upgrade-v9.py \
test/util/vercmptest.sh
include $(top_srcdir)/test/pacman/tests/TESTS
TEST_SUITE_LOG = test/test-suite.log
TEST_EXTENSIONS = .py
AM_TESTS_ENVIRONMENT = \
PMTEST_UTIL_DIR=$(top_builddir)/src/util/; export PMTEST_UTIL_DIR; \
PMTEST_SCRIPT_DIR=$(top_builddir)/scripts/; export PMTEST_SCRIPT_DIR; \
PMTEST_SCRIPTLIB_DIR=$(top_srcdir)/scripts/library/; export PMTEST_SCRIPTLIB_DIR; \
PMTEST_LIBMAKEPKG_DIR=$(top_builddir)/scripts/libmakepkg/; export PMTEST_LIBMAKEPKG_DIR;
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/build-aux/tap-driver.sh
PY_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/build-aux/tap-driver.sh
PY_LOG_COMPILER = $(PYTHON) $(top_srcdir)/test/pacman/pactest.py
AM_PY_LOG_FLAGS = \
--scriptlet-shell $(SCRIPTLET_SHELL) \
--ldconfig $(LDCONFIG) \
--bindir $(top_builddir)/src/pacman \
--bindir $(top_builddir)/scripts
if !HAVE_LIBGPGME
AM_PY_LOG_FLAGS += --without-gpg
endif
if !HAVE_LIBCURL
AM_PY_LOG_FLAGS += --without-curl
endif
# create the pacman DB, cache, makepkg-template and system hook directories upon install
install-data-local:
for dir in "$(DESTDIR)$(localstatedir)/lib/pacman" "$(DESTDIR)$(localstatedir)/cache/pacman/pkg" \
"$(DESTDIR)$(datarootdir)/makepkg-template" "$(DESTDIR)$(datarootdir)/libalpm/hooks"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
update-po:
$(MAKE) -C lib/libalpm/po update-po
$(MAKE) -C scripts/po update-po
$(MAKE) -C src/pacman/po update-po
update-copyright:
for file in $(shell sh -c 'git grep -l "Copyright .* Pacman Development" | grep -v "\.po"'); do \
sed -i -e "/Copyright (/s/-$(OLD)/-$(NEW)/" -e "/Copyright (/s/ $(OLD)/ $(OLD)-$(NEW)/" "$$file"; \
done
.PHONY: update-po update-copyright

11
NEWS
View File

@@ -1,5 +1,16 @@
VERSION DESCRIPTION
-----------------------------------------------------------------------------
5.2.1 - fix segfault on importing PGP keys for -U operations
- fix distribution of meson files
- fix inode command for darwin/bsd
- distribute all documentation files
- update bash/zsh completion for -F changes, remove --force
- makepkg:
- fix calculation of package sizes in presence of hardlinks
- do not warn about PACKAGER format if not set
- only run --clean when a package is built
- repo-add:
- fix compression of databases with zstd
5.2.0 - completely remove delta support (CVE-2019-18183)
- add support to pacman and pacman-key for downloading PGP
signing keys using the WKD protocol (FS#63171)

14
README
View File

@@ -655,3 +655,17 @@ API CHANGES BETWEEN 5.1 AND 5.2
- alpm_errno_t - added member ALPM_ERR_MISSING_CAPABILITY_SIGNATURES
- alpm_sync_newversion() replaced with alpm_sync_get_new_version() which
does not filter on any ALPM_DB_USAGE_*.
API CHANGES BETWEEN 5.2 AND 6.0
===============================
[REMOVED]
- ALPM_EVENT_PKGDOWNLOAD_START, ALPM_EVENT_PKGDOWNLOAD_DONE, ALPM_EVENT_PKGDOWNLOAD_FAILED
[CHANGED]
- alpm_db_update() changed its signature and now accepts a list of databases
rather than a single database. This is need to handle database downloading
in a multiplexed way.
[ADDED]

View File

@@ -1,22 +1,21 @@
The following checklist should be used for making a pacman release.
- Ensure "make distcheck" succeeds
- Ensure "ninja dist" succeeds
- Call a freeze to development.
- Send translation updates to Transifex at least two weeks before a major
release (see below). At this stage, strings can only be changed for a
major issue.
- Update NEWS and README files
- Pull translation updates from Transifex
- Update version in configure.ac as described in file
- Update version in meson.build as described in file
- Update doc/index.asciidoc
- Create a signed git tag (git tag -s vX.Y.Z -m "commit message")
- Create and sign release tarballs (generate with "make distcheck")
- In addition to the standard autotools toolchain, autoconf-archive is needed
- Create and sign release tarballs (generate with "ninja dist")
- Update pacman website
Transifex updates are handled using the transifex client. The basic process is:
- Pull updates from transifex ("tx pull -a -f --minimum-perc 75")
- Update po files ("make update-po")
- Update po files ("./build-aux/update-po")
- Fix all translation errors found
- Add any new locales to the relevant LINGUAS file
- Optional: Make any manual changes needed (e.g. fixing spacing in a string)

View File

@@ -1,6 +0,0 @@
#!/bin/sh -x
autoreconf -i
patch -d build-aux -Np0 -i ltmain-asneeded.patch
exit 0

View File

@@ -20,9 +20,6 @@ mode=$3
-e "s|@DEBUGSUFFIX[@]|@DEBUGSUFFIX@|g" \
-e "s|@INODECMD[@]|@INODECMD@|g" \
-e "s|@FILECMD[@]|@FILECMD@|g" \
-e "s|@SEDINPLACEFLAGS[@]|@SEDINPLACEFLAGS@|g" \
-e "s|@SEDPATH[@]|@SEDPATH@|g" \
-e "s|@configure_input[@]|Generated from ${input##*/}; do not edit by hand.|g" \
"$input" >"$output"
if [[ $mode ]]; then

View File

@@ -1,33 +0,0 @@
--- ltmain.sh.orig 2013-06-26 14:31:53.472627840 +1000
+++ ltmain.sh 2013-06-26 14:30:56.137038936 +1000
@@ -5800,6 +5800,14 @@
arg=$func_stripname_result
;;
+ -Wl,*--as-needed*)
+ deplibs="$deplibs $wl--as-needed"
+ ;;
+
+ -Wl,*--no-as-needed*)
+ deplibs="$deplibs $wl--no-as-needed"
+ ;;
+
-Wl,*)
func_stripname '-Wl,' '' "$arg"
args=$func_stripname_result
@@ -6160,6 +6168,15 @@
lib=
found=no
case $deplib in
+ -Wl,--as-needed|-Wl,--no-as-needed)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ fi
+ continue
+ ;;
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
|-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
if test "$linkmode,$pass" = "prog,link"; then

View File

@@ -1,6 +0,0 @@
#!/bin/sh
built_script=$1
dest_path=$2
install -Dm755 "$built_script" "$DESTDIR/$dest_path"

8
build-aux/update-copyright Executable file
View File

@@ -0,0 +1,8 @@
#! /bin/sh
OLD=$1
NEW=$2
for file in $(git grep -l "Copyright .* Pacman Development" | grep -v "\.po"); do \
sed -i -e "/Copyright (/s/-${OLD}/-${NEW}/" -e "/Copyright (/s/ ${OLD}/ ${OLD}-${NEW}/" "$file"
done

View File

@@ -1,604 +0,0 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# Minimum version of autoconf required
AC_PREREQ(2.64)
# UPDATING VERSION NUMBERS FOR RELEASES
#
# libalpm:
# current
# The most recent interface number that this library implements.
# revision
# The implementation number of the current interface.
# age
# The difference between the newest and oldest interfaces that this library
# implements. In other words, the library implements all the interface
# numbers in the range from number current - age to current.
#
# 1. Start with version information of `0:0:0' for each libtool library.
# 2. Update the version information only immediately before a public release of
# your software. More frequent updates are unnecessary, and only guarantee
# that the current interface number gets larger faster.
# 3. If the library source code has changed at all since the last update, then
# increment revision (`c:r:a' becomes `c:r+1:a').
# 4. If any interfaces have been added, removed, or changed since the last
# update, increment current, and set revision to 0.
# 5. If any interfaces have been added since the last public release, then
# increment age.
# 6. If any interfaces have been removed since the last public release, then
# set age to 0.
#
# pacman:
# Extreme huge major changes:
# pacman_version_major += 1
# pacman_version_minor = 0
# pacman_version_micro = 0
#
# Real releases:
# pacman_version_minor += 1
# pacman_version_micro = 0
#
# Bugfix releases:
# pacman_version_micro += 1
m4_define([lib_current], [12])
m4_define([lib_revision], [0])
m4_define([lib_age], [0])
m4_define([pacman_version_major], [5])
m4_define([pacman_version_minor], [2])
m4_define([pacman_version_micro], [0])
m4_define([pacman_version],
[pacman_version_major.pacman_version_minor.pacman_version_micro])
# Autoconf initialization
AC_INIT([pacman], [pacman_version], [pacman-dev@archlinux.org])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.11 foreign])
AM_SILENT_RULES([yes])
LT_INIT
LIB_VERSION=`expr lib_current - lib_age`.lib_age.lib_revision
LIB_VERSION_INFO="lib_current:lib_revision:lib_age"
# Respect empty CFLAGS during compiler tests
if test "x$CFLAGS" = "x"; then
CFLAGS=""
fi
# Set substitution values for version stuff in Makefiles and anywhere else,
# and put LIB_VERSION in config.h
AC_SUBST(LIB_VERSION)
AC_SUBST(LIB_VERSION_INFO)
AC_DEFINE_UNQUOTED([LIB_VERSION], ["$LIB_VERSION"], [libalpm version number])
# Help line for root directory
AC_ARG_WITH(root-dir,
AS_HELP_STRING([--with-root-dir=path], [set the location of the root operating directory]),
[ROOTDIR=$withval], [ROOTDIR=/])
# Help line for package extension
AC_ARG_WITH(pkg-ext,
AS_HELP_STRING([--with-pkg-ext=ext], [set the file extension used by packages]),
[PKGEXT=$withval], [PKGEXT=.pkg.tar.gz])
# Help line for source package directory
AC_ARG_WITH(src-ext,
AS_HELP_STRING([--with-src-ext=ext], [set the file extension used by source packages]),
[SRCEXT=$withval], [SRCEXT=.src.tar.gz])
# Help line for buildscript filename
AC_ARG_WITH(buildscript,
AS_HELP_STRING([--with-buildscript=name], [set the build script name used by makepkg]),
[BUILDSCRIPT=$withval], [BUILDSCRIPT=PKGBUILD])
# Help line for buildscript filename
AC_ARG_WITH(makepkg-template-dir,
AS_HELP_STRING([--with-makepkg-template-dir=name], [set the template dir used by makepkg-template]),
[TEMPLATE_DIR=$withval], [TEMPLATE_DIR=${datarootdir}/makepkg-template])
# Help line for debug package suffix
AC_ARG_WITH(debug-suffix,
AS_HELP_STRING([--with-debug-suffix=name], [set the suffix for split debugging symbol packages used by makepkg]),
[DEBUGSUFFIX=$withval], [DEBUGSUFFIX=debug])
# Help line for changing shell used to run install scriptlets
AC_ARG_WITH(scriptlet-shell,
AS_HELP_STRING([--with-scriptlet-shell=shell],
[set the full path to the shell used to run install scriptlets]),
[SCRIPTLET_SHELL=$withval], [SCRIPTLET_SHELL=/bin/sh])
# Help line for ldconfig path
AC_ARG_WITH(ldconfig,
AS_HELP_STRING([--with-ldconfig=path],
[set the full path to ldconfig]),
[LDCONFIG=$withval], [LDCONFIG=/sbin/ldconfig])
# Help line for determining whether file is seccomp-enabled
AC_ARG_WITH(file-seccomp,
AS_HELP_STRING([--with-file-seccomp={yes|no|auto}],
[determine whether file is seccomp-enabled @<:@default=auto@:>@]),
[with_file_seccomp=$withval], [with_file_seccomp=auto])
# Help line for selecting a crypto library
AC_ARG_WITH(crypto,
AS_HELP_STRING([--with-crypto={openssl|nettle}],
[select crypto implementation @<:@default=openssl@:>@]),
[with_crypto=$withval], [with_crypto=openssl])
# Help line for using gpgme
AC_ARG_WITH(gpgme,
AS_HELP_STRING([--with-gpgme], [use GPGME for PGP signature verification]),
[], [with_gpgme=check])
# Help line for using libcurl
AC_ARG_WITH(libcurl,
AS_HELP_STRING([--with-libcurl], [use libcurl for the internal downloader]),
[], [with_libcurl=check])
# Help line for documentation
AC_ARG_ENABLE(doc,
AS_HELP_STRING([--disable-doc], [prevent make from looking at doc/ dir]),
[wantdoc=$enableval], [wantdoc=yes])
# Help line for doxygen
AC_ARG_ENABLE(doxygen,
AS_HELP_STRING([--enable-doxygen], [build your own API docs via Doxygen]),
[wantdoxygen=$enableval], [wantdoxygen=no])
# Help line for debug
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [enable debugging support]),
[debug=$enableval], [debug=no])
# Help line for compiler warning flags
AC_ARG_ENABLE(warningflags,
AS_HELP_STRING([--enable-warningflags], [enable extra compiler warning flags]),
[warningflags=$enableval], [warningflags=no])
# Help line for using git version in pacman version string
AC_ARG_ENABLE(git-version,
AS_HELP_STRING([--enable-git-version],
[enable use of git version in version string if available]),
[wantgitver=$enableval], [wantgitver=no])
# Enable large file support if available (must be enabled before
# testing compilation against gpgme).
AC_SYS_LARGEFILE
# Record large file flags in pkgconfig file
if test "$enable_largefile" != no; then
if test "$ac_cv_sys_file_offset_bits" != 'no'; then
LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
fi
fi
AC_SUBST(LFS_CFLAGS)
# Checks for programs.
AC_PROG_AWK
AC_PROG_CC_C99
AC_PROG_INSTALL
AC_CHECK_PROGS([PYTHON], [python3 python], [false])
AC_PATH_PROGS([BASH_SHELL], [bash bash4], [false])
# check for perl 5.10.1 (needed by makepkg-template)
AC_PATH_PROG([PERL],[perl])
AC_DEFUN([AX_PROG_PERL_VERSION],
[AC_CACHE_CHECK([for Perl version $1 or later], [ax_cv_prog_perl_version],
[AS_IF(["$PERL" -e 'require v$1;' >/dev/null 2>&1],
[ax_cv_prog_perl_version=yes],
[ax_cv_prog_perl_version=no])])
AS_IF([test x"$ax_cv_prog_perl_version" = xyes], [$2], [$3])])
AX_PROG_PERL_VERSION([5.10.1], [], [AC_MSG_ERROR([perl is too old])])
AS_IF([test "x$BASH_SHELL" = "xfalse"],
AC_MSG_WARN([*** bash >= 4.4.0 is required for pacman scripts]),
[bash_version_major=`$BASH_SHELL -c 'echo "${BASH_VERSINFO[[0]]}"'`
bash_version_minor=`$BASH_SHELL -c 'echo "${BASH_VERSINFO[[1]]}"'`
ok=yes
if test "$bash_version_major" -lt 4; then
ok=no
fi
if test "$bash_version_major" -eq 4 && test "$bash_version_minor" -lt 4; then
ok=no
fi
if test "$ok" = "no"; then
AC_MSG_ERROR([*** bash >= 4.4.0 is required for pacman scripts])
fi
unset bash_version_major bash_version_minor ok])
# find installed gettext
AM_GNU_GETTEXT([external], [need-ngettext])
AM_GNU_GETTEXT_VERSION(0.13.1)
AC_CHECK_LIB([m], [fabs], ,
AC_MSG_ERROR([libm is needed to compile pacman!]))
PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], ,
bashcompdir="${datarootdir}/bash-completion/completions")
# Check for libarchive
PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 3.0.0], ,
AC_MSG_ERROR([*** libarchive >= 3.0.0 is needed to compile pacman!]))
# Check file for seccomp
if test "x$with_file_seccomp" = "xauto"; then
file_version="$(file --version| sed -n 's/^file-\(.*\)/\1/p')"
AX_COMPARE_VERSION([$file_version], [ge], [5.38], [with_file_seccomp=yes])
fi
if test "x$with_file_seccomp" = "xyes"; then
FILECMD="file -S"
else
FILECMD="file"
fi
AC_SUBST(FILECMD)
# Check for OpenSSL
have_openssl=no
have_nettle=no
if test "x$with_crypto" = "xnettle"; then
AC_SUBST(pc_crypto, [nettle])
PKG_CHECK_MODULES(NETTLE, [nettle],
[AC_DEFINE(HAVE_LIBNETTLE, 1, [Define whether to use nettle]) have_nettle=yes], have_nettle=no)
if test "x$have_nettle" = xno -a "x$with_crypto" = xnettle; then
AC_MSG_ERROR([*** nettle support requested but libraries not found])
fi
else if test "x$with_crypto" = "xopenssl"; then
AC_SUBST(pc_crypto, [libcrypto])
PKG_CHECK_MODULES(LIBSSL, [libcrypto],
[AC_DEFINE(HAVE_LIBSSL, 1, [Define if libcrypto is available]) have_openssl=yes], have_openssl=no)
if test "x$have_openssl" = xno; then
AC_MSG_ERROR([*** openssl support requested but libraries not found])
fi
else
AC_MSG_ERROR([*** unknown crypto support library requested - $with_crypto])
fi
fi
AM_CONDITIONAL(HAVE_LIBSSL, [test "$have_openssl" = "yes"])
AM_CONDITIONAL(HAVE_LIBNETTLE, [test "$have_nettle" = "yes"])
# Check for libcurl
have_libcurl=no
if test "x$with_libcurl" != "xno"; then
PKG_CHECK_MODULES(LIBCURL, [libcurl >= 7.32.0],
[AC_DEFINE(HAVE_LIBCURL, 1, [Define if libcurl is available]) have_libcurl=yes], have_libcurl=no)
if test "x$have_libcurl" = xno -a "x$with_libcurl" = xyes; then
AC_MSG_ERROR([*** libcurl >= 7.32.0 is required for internal downloader support])
fi
fi
AM_CONDITIONAL(HAVE_LIBCURL, [test "$have_libcurl" = "yes"])
# used to generate libalpm.pc
if test "x$have_libcurl" = xyes; then
AC_SUBST(pc_libcurl, [libcurl])
fi
# Check for gpgme
AC_MSG_CHECKING(whether to link with libgpgme)
AS_IF([test "x$with_gpgme" != "xno"],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
have_gpgme=no
if test "x$with_gpgme" != "xno"; then
PKG_CHECK_MODULES(GPGME, [gpgme],
[AC_DEFINE([HAVE_LIBGPGME], [1], [Define if gpgme should be used to provide GPG signature support.])
AC_SUBST(pc_gpgme, [gpgme])
have_gpgme=yes],
[AM_PATH_GPGME([1.3.0],
[LIBS_save="$LIBS"
CPPFLAGS_save="$CPPFLAGS"
CFLAGS_save="$CFLAGS"
LIBS="$LIBS $GPGME_LIBS"
CPPFLAGS="$CPPFLAGS $GPGME_CPPFLAGS"
CFLAGS="$CFLAGS $GPGME_CFLAGS"
AC_MSG_CHECKING([for sane gpgme])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <gpgme.h>]],
[[return gpgme_check_version("1.3.0");]])],
[AC_MSG_RESULT([yes])
have_gpgme=yes
AC_DEFINE([HAVE_LIBGPGME], [1], [Define if gpgme should be used to provide GPG signature support.])
AC_SUBST(pc_gpgme_libs, ["$GPGME_LIBS"])],
[AC_MSG_RESULT([no])
have_gpgme=no
unset GPGME_LIBS
unset GPGME_CFLAGS]
AS_IF([test "x$with_gpgme" = "xyes"],
[AC_MSG_FAILURE([*** gpgme >= 1.3.0 is needed for GPG signature support])])
)
LIBS="$LIBS_save"
CPPFLAGS="$CPPFLAGS_save"
CFLAGS="$CFLAGS_save"
unset CPPFLAGS_save
unset CFLAGS_save],)])
fi
AS_IF([test "x$have_gpgme" = xno -a "x$with_gpgme" = xyes],
[AC_MSG_FAILURE([--with-gpgme was given, but gpgme was not found])])
AM_CONDITIONAL([HAVE_LIBGPGME], [test "x$have_gpgme" = "xyes"])
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h float.h glob.h langinfo.h libintl.h limits.h \
locale.h mntent.h netinet/in.h netinet/tcp.h \
stddef.h string.h sys/ioctl.h \
sys/mnttab.h sys/mount.h \
sys/param.h sys/statvfs.h sys/time.h sys/types.h \
sys/ucred.h syslog.h termios.h wchar.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_INT64_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_STRUCT_TM
AC_TYPE_UID_T
AC_STRUCT_DIRENT_D_TYPE
PATH_MAX_DEFINED
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_GETMNTENT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_CHECK_FUNCS([dup2 getcwd getmntinfo gettimeofday memmove memset \
mkdir realpath regcomp rmdir setenv setlocale strcasecmp \
strchr strcspn strdup strerror strndup strnlen strrchr \
strsep strstr strtol swprintf tcflush wcwidth uname])
AC_CHECK_MEMBERS([struct stat.st_blksize],,,[[#include <sys/stat.h>]])
# For the diskspace code
FS_STATS_TYPE
AC_CHECK_MEMBERS([struct statvfs.f_flag],,,[[#include <sys/statvfs.h>]])
AC_CHECK_MEMBERS([struct statfs.f_flags],,,[[#include <sys/param.h>
#include <sys/mount.h>]])
# Check if we can use symbol visibility support in GCC
GCC_VISIBILITY_CC
# Host-dependant definitions
DEFAULT_SEDINPLACEFLAGS=" --follow-symlinks -i"
INODECMD="stat -c '%i %n'"
STRIP_BINARIES="--strip-all"
STRIP_SHARED="--strip-unneeded"
STRIP_STATIC="--strip-debug"
case "${host_os}" in
*bsd*)
INODECMD="stat -f '%i %N'"
DEFAULT_SEDINPLACEFLAGS=" -i \"\""
;;
darwin*)
host_os_darwin=yes
INODECMD="/usr/bin/stat -f '%i %N'"
DEFAULT_SEDINPLACEFLAGS=" -i ''"
STRIP_BINARIES=""
STRIP_SHARED="-S"
STRIP_STATIC="-S"
;;
esac
AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes")
AC_PATH_PROGS([SEDPATH], [sed], [sed], [/usr/bin$PATH_SEPARATOR/bin] )
AC_SUBST(INODECMD)
AC_SUBST(STRIP_BINARIES)
AC_SUBST(STRIP_SHARED)
AC_SUBST(STRIP_STATIC)
# Flags for sed in place
if test "${SEDINPLACEFLAGS+set}" != "set"; then
SEDINPLACEFLAGS="${DEFAULT_SEDINPLACEFLAGS}"
fi
AC_ARG_VAR(SEDINPLACEFLAGS, [flags for sed, overriding the default])
# Variables plugged into makepkg.conf
CARCH="${host%%-*}"
CHOST="${host}"
AC_SUBST(CARCH)
AC_SUBST(CHOST)
# Check for documentation support and status
AC_CHECK_PROGS([ASCIIDOC], [asciidoc])
AC_MSG_CHECKING([for building documentation])
if test "x$wantdoc" = "xyes" ; then
if test $ASCIIDOC ; then
AC_MSG_RESULT([yes, enabled by configure])
else
asciidoc="(warning : asciidoc not installed)"
AC_MSG_RESULT([yes $asciidoc])
fi
wantdoc=yes
else
AC_MSG_RESULT([no, disabled by configure])
wantdoc=no
fi
AM_CONDITIONAL(WANT_DOC, test "x$wantdoc" = "xyes")
# Check for doxygen support and status
AC_CHECK_PROGS([DOXYGEN], [doxygen])
AC_MSG_CHECKING([for doxygen])
if test "x$wantdoxygen" = "xyes" ; then
if test $DOXYGEN ; then
AC_MSG_RESULT([yes])
usedoxygen=yes
else
AC_MSG_RESULT([no, doxygen missing])
usedoxygen=no
fi
else
AC_MSG_RESULT([no, disabled by configure])
usedoxygen=no
fi
AM_CONDITIONAL(USE_DOXYGEN, test "x$usedoxygen" = "xyes")
# Enable or disable debug code
AC_MSG_CHECKING(for debug mode request)
if test "x$debug" = "xyes" ; then
AC_MSG_RESULT(yes)
AC_DEFINE([PACMAN_DEBUG], , [Enable debug code])
# Check for -fstack-protector availability
GCC_STACK_PROTECT_LIB
GCC_STACK_PROTECT_CC
GCC_STACK_CLASH_PROTECTION
GCC_FORTIFY_SOURCE_CC
WARNING_CFLAGS="-g -Wall -Werror"
else
AC_MSG_RESULT(no)
WARNING_CFLAGS="-Wall"
fi
# Enable or disable compiler warning flags
AC_MSG_CHECKING(for excessive compiler warning flags)
if test "x$warningflags" = "xyes" ; then
AC_MSG_RESULT(yes)
CFLAGS_ADD([-Wcast-align], [WARNING_CFLAGS])
CFLAGS_ADD([-Wclobbered], [WARNING_CFLAGS])
CFLAGS_ADD([-Wempty-body], [WARNING_CFLAGS])
CFLAGS_ADD([-Wfloat-equal], [WARNING_CFLAGS])
CFLAGS_ADD([-Wformat-nonliteral], [WARNING_CFLAGS])
CFLAGS_ADD([-Wformat-security], [WARNING_CFLAGS])
CFLAGS_ADD([-Wignored-qualifiers], [WARNING_CFLAGS])
CFLAGS_ADD([-Wimplicit-fallthrough], [WARNING_CFLAGS])
CFLAGS_ADD([-Winit-self], [WARNING_CFLAGS])
CFLAGS_ADD([-Wlogical-op], [WARNING_CFLAGS])
CFLAGS_ADD([-Wmissing-declarations], [WARNING_CFLAGS])
CFLAGS_ADD([-Wmissing-field-initializers], [WARNING_CFLAGS])
CFLAGS_ADD([-Wmissing-parameter-type], [WARNING_CFLAGS])
CFLAGS_ADD([-Wmissing-prototypes], [WARNING_CFLAGS])
CFLAGS_ADD([-Wold-style-declaration], [WARNING_CFLAGS])
CFLAGS_ADD([-Woverride-init], [WARNING_CFLAGS])
CFLAGS_ADD([-Wpointer-arith], [WARNING_CFLAGS])
CFLAGS_ADD([-Wredundant-decls], [WARNING_CFLAGS])
CFLAGS_ADD([-Wshadow], [WARNING_CFLAGS])
CFLAGS_ADD([-Wsign-compare], [WARNING_CFLAGS])
CFLAGS_ADD([-Wstrict-aliasing], [WARNING_CFLAGS])
CFLAGS_ADD([-Wstrict-overflow=5], [WARNING_CFLAGS])
CFLAGS_ADD([-Wstrict-prototypes], [WARNING_CFLAGS])
CFLAGS_ADD([-Wtype-limits], [WARNING_CFLAGS])
CFLAGS_ADD([-Wuninitialized], [WARNING_CFLAGS])
CFLAGS_ADD([-Wunused-but-set-parameter], [WARNING_CFLAGS])
CFLAGS_ADD([-Wunused-parameter], [WARNING_CFLAGS])
CFLAGS_ADD([-Wwrite-strings], [WARNING_CFLAGS])
else
AC_MSG_RESULT(no)
fi
# Enable or disable use of git version in pacman version string
AC_MSG_CHECKING(whether to use git version if available)
if test "x$wantgitver" = "xyes" ; then
AC_CHECK_PROGS([GIT], [git])
AC_CHECK_FILE([.git/], hasgitdir=yes)
usegitver=$ac_cv_file__git_
if test $GIT -a "x$hasgitdir" = "xyes"; then
AC_DEFINE([USE_GIT_VERSION], , [Use GIT version in version string])
fi
else
AC_MSG_RESULT([no, disabled by configure])
usegitver=no
fi
AM_CONDITIONAL(USE_GIT_VERSION, test "x$usegitver" = "xyes")
# Set root directory
AC_SUBST(ROOTDIR)
AC_DEFINE_UNQUOTED([ROOTDIR], "$ROOTDIR", [The location of the root operating directory])
# Set package file extension
AC_SUBST(PKGEXT)
AC_DEFINE_UNQUOTED([PKGEXT], "$PKGEXT", [The file extension used by pacman packages])
# Set source package file extension
AC_SUBST(SRCEXT)
AC_DEFINE_UNQUOTED([SRCEXT], "$SRCEXT", [The file extension used by pacman source packages])
# Set makepkg build script name
AC_SUBST(BUILDSCRIPT)
AC_DEFINE_UNQUOTED([BUILDSCRIPT], "$BUILDSCRIPT", [The build script name used by makepkg])
# Set makepkg-template template directory
AC_SUBST(TEMPLATE_DIR)
AC_DEFINE_UNQUOTED([TEMPLATE_DIR], "$TEMPLATE_DIR", [The template directory used by makepkg-teplate])
# Set makepkg split debugging symbol package suffix
AC_SUBST(DEBUGSUFFIX)
AC_DEFINE_UNQUOTED([DEBUGSUFFIX], "$DEBUGSUFFIX", [The suffix for debugging symbol packages used by makepkg])
# Set shell used by install scriptlets
AC_SUBST(SCRIPTLET_SHELL)
AC_DEFINE_UNQUOTED([SCRIPTLET_SHELL], "$SCRIPTLET_SHELL", [The full path of the shell used to run install scriptlets])
# Set ldconfig path
AC_SUBST(LDCONFIG)
AC_DEFINE_UNQUOTED([LDCONFIG], "$LDCONFIG", [The full path to ldconfig])
# Configuration files
AC_CONFIG_FILES([
lib/libalpm/Makefile
lib/libalpm/po/Makefile.in
lib/libalpm/libalpm.pc
src/common/Makefile
src/pacman/Makefile
src/pacman/po/Makefile.in
src/util/Makefile
scripts/Makefile
scripts/po/Makefile.in
doc/Makefile
etc/Makefile
test/pacman/Makefile
test/pacman/tests/Makefile
test/scripts/Makefile
test/util/Makefile
Makefile
])
AC_OUTPUT
echo "
${PACKAGE_NAME}:
Build information:
source code location : ${srcdir}
prefix : ${prefix}
sysconfdir : $(eval echo ${sysconfdir})
conf file : $(eval echo ${sysconfdir})/pacman.conf
localstatedir : $(eval echo ${localstatedir})
database dir : $(eval echo ${localstatedir})/lib/pacman/
cache dir : $(eval echo ${localstatedir})/cache/pacman/pkg/
compiler : ${CC}
preprocessor flags : ${CPPFLAGS}
compiler flags : ${WARNING_CFLAGS} ${CFLAGS}
library flags : ${LIBS} ${LIBSSL_LIBS} ${NETTLE_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} ${GPGME_LIBS}
linker flags : ${LDFLAGS}
Architecture : ${CARCH}
Host Type : ${CHOST}
File inode command : ${INODECMD}
In-place sed command : ${SEDPATH} ${SEDINPLACEFLAGS}
File seccomp command : ${FILECMD}
libalpm version : ${LIB_VERSION}
libalpm version info : ${LIB_VERSION_INFO}
pacman version : ${PACKAGE_VERSION}
using git version : ${usegitver}
Directory and file information:
root working directory : ${ROOTDIR}
package extension : ${PKGEXT}
source pkg extension : ${SRCEXT}
build script name : ${BUILDSCRIPT}
template directory : ${TEMPLATE_DIR}
Compilation options:
Use libcurl : ${have_libcurl}
Use GPGME : ${have_gpgme}
Use OpenSSL : ${have_openssl}
Use nettle : ${have_nettle}
Run make in doc/ dir : ${wantdoc} ${asciidoc}
Doxygen support : ${usedoxygen}
debug support : ${debug}
extra warning flags : ${warningflags}
use git version : ${wantgitver}
"

View File

@@ -1,6 +1,3 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
BUILDINFO(5)
============
@@ -53,6 +50,9 @@ BUILDINFO file format.
*builddir*::
The directory where the package was built.
*startdir*::
The directory from which makepkg was executed.
*buildenv (array)*::
The build environment specified in makepkg.conf.

View File

@@ -1,161 +0,0 @@
# We have to do some funny stuff here with the manpages. In order to ensure
# a dist tarball doesn't get put out there without manpages, we keep those
# files listed in EXTRA_DIST no matter what. However, we only add them to
# man_MANS if --enable-asciidoc and/or --enable-doxygen are used.
MANPAGES = \
alpm-hooks.5 \
pacman.8 \
makepkg.8 \
makepkg-template.1 \
repo-add.8 \
vercmp.8 \
pacman-key.8 \
PKGBUILD.5 \
makepkg.conf.5 \
pacman.conf.5 \
libalpm.3 \
BUILDINFO.5 \
pacman-conf.8
DOXYGEN_MANS = $(wildcard man3/*.3)
HTML_MANPAGES = $(addsuffix .html,$(MANPAGES))
HTML_OTHER = \
index.html \
submitting-patches.html \
translation-help.html \
HACKING.html
HTML_DOCS = \
$(HTML_MANPAGES) \
$(HTML_OTHER)
EXTRA_DIST = \
meson.build \
asciidoc.conf \
asciidoc-override.css \
alpm-hooks.5.asciidoc \
pacman.8.asciidoc \
makepkg.8.asciidoc \
makepkg-template.1.asciidoc \
repo-add.8.asciidoc \
vercmp.8.asciidoc \
pacman-key.8.asciidoc \
PKGBUILD.5.asciidoc \
PKGBUILD-example.txt \
makepkg.conf.5.asciidoc \
pacman.conf.5.asciidoc \
BUILDINFO.5.asciidoc \
libalpm.3.asciidoc \
footer.asciidoc \
index.asciidoc \
submitting-patches.asciidoc \
translation-help.asciidoc \
$(MANPAGES) \
$(DOXYGEN_MANS)
# Files that should be removed, but which Automake does not know.
MOSTLYCLEANFILES = *.xml $(MANPAGES) $(HTML_DOCS) repo-remove.8 website.tar.gz
# Ensure manpages are fresh when building a dist tarball
dist-hook:
$(MAKE) $(AM_MAKEFLAGS) clean
$(MAKE) $(AM_MAKEFLAGS) all
if USE_GIT_VERSION
GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//')
REAL_PACKAGE_VERSION = $(GIT_VERSION)
else
REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
endif
man_MANS =
dist_man_MANS = $(MANPAGES)
if USE_DOXYGEN
man_MANS += $(DOXYGEN_MANS)
all-local: doxygen.in
Doxyfile: Doxyfile.in
sed 's,@OUTPUT_DIRECTORY@,./,' Doxyfile.in >Doxyfile
doxygen.in: Doxyfile
$(DOXYGEN) $(srcdir)/Doxyfile
endif
man: $(MANPAGES)
html: $(HTML_DOCS)
website: website.tar.gz
.PHONY: html website
website.tar.gz: html
$(AM_V_GEN)bsdtar czf $@ $(HTML_DOCS) \
asciidoc-override.css \
-C /etc/asciidoc/stylesheets/ \
asciidoc.css \
-C /etc/asciidoc/javascripts/ \
asciidoc.js \
-C /etc/asciidoc/ \
images
pkgdatadir = ${datadir}/${PACKAGE}
ASCIIDOC_OPTS = \
-f $(srcdir)/asciidoc.conf \
-a pacman_version="$(REAL_PACKAGE_VERSION)" \
-a pacman_date="`date +%Y-%m-%d`" \
-a srcext="$(SRCEXT)" \
-a pkgext="$(PKGEXT)" \
-a pkgdatadir=$(pkgdatadir) \
-a localstatedir=$(localstatedir) \
-a sysconfdir=$(sysconfdir) \
-a datarootdir=$(datarootdir) \
-a rootdir=$(ROOTDIR)
A2X_OPTS = \
--no-xmllint \
-d manpage \
-f manpage \
--xsltproc-opts='-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0'
# Generate manpages
%: %.asciidoc asciidoc.conf footer.asciidoc Makefile.am
$(AM_V_GEN)a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS) --out-file=./$@.xml" $(srcdir)/$@.asciidoc
# Generate HTML pages
%.html: %.asciidoc asciidoc.conf footer.asciidoc Makefile.am
$(AM_V_GEN)asciidoc $(ASCIIDOC_OPTS) -o - $*.asciidoc | \
sed -e 's/\r$$//' > $@
HACKING.html: ../HACKING
$(AM_V_GEN)asciidoc $(ASCIIDOC_OPTS) -o - ../HACKING | \
sed -e 's/\r$$//' > $@
# Customizations for certain HTML docs
%.html: ASCIIDOC_OPTS += -a linkcss -a toc -a icons -a max-width=960px -a stylesheet=asciidoc-override.css
%.8.html: ASCIIDOC_OPTS += -d manpage
%.5.html: ASCIIDOC_OPTS += -d manpage
%.3.html: ASCIIDOC_OPTS += -d manpage
# Custom dependency rules
PKGBUILD.5 PKGBUILD.5.html: PKGBUILD.5.asciidoc PKGBUILD-example.txt
# Manpages as symlinks
repo-remove.8: repo-add.8
$(RM) repo-remove.8
$(LN_S) repo-add.8 repo-remove.8
install-data-hook:
cd $(DESTDIR)$(mandir)/man8 && \
$(RM) repo-remove.8 && \
( $(LN_S) repo-add.8 repo-remove.8 || \
ln repo-add.8 repo-remove.8 || \
cp repo-add.8 repo-remove.8 )
uninstall-hook:
$(RM) $(DESTDIR)$(mandir)/man8/repo-remove.8

View File

@@ -118,7 +118,7 @@ systems (see below).
+
Additional architecture-specific sources can be added by appending an
underscore and the architecture name e.g., 'source_x86_64=()'. There must be a
corresponding integrity array with checksums, e.g. 'md5sums_x86_64=()'.
corresponding integrity array with checksums, e.g. 'cksums_x86_64=()'.
+
It is also possible to change the name of the downloaded file, which is helpful
with weird URLs and for handling multiple source files with the same
@@ -146,17 +146,19 @@ contain whitespace characters.
listed here will not be extracted with the rest of the source files. This
is useful for packages that use compressed data directly.
*md5sums (array)*::
This array contains an MD5 hash for every source file specified in the
*cksums (array)*::
This array contains CRC checksums for every source file specified in the
source array (in the same order). makepkg will use this to verify source
file integrity during subsequent builds. If 'SKIP' is put in the array
in place of a normal hash, the integrity check for that source file will
be skipped. To easily generate md5sums, run ``makepkg -g >> PKGBUILD''.
If desired, move the md5sums line to an appropriate location.
be skipped. To easily generate cksums, run ``makepkg -g >> PKGBUILD''.
If desired, move the cksums line to an appropriate location. Note that
checksums generated by "makepkg -g" should be verified using checksum
values provided by the software developer.
*sha1sums, sha224sums, sha256sums, sha384sums, sha512sums, b2sums (arrays)*::
*md5sums, sha1sums, sha224sums, sha256sums, sha384sums, sha512sums, b2sums (arrays)*::
Alternative integrity checks that makepkg supports; these all behave
similar to the md5sums option described above. To enable use and generation
similar to the cksums option described above. To enable use and generation
of these checksums, be sure to set up the `INTEGRITY_CHECK` option in
linkman:makepkg.conf[5].
@@ -466,11 +468,13 @@ reference with all of the available functions defined.
Using VCS Sources[[VCS]]
------------------------
Building a developmental version of a package using sources from a version
control system (VCS) is enabled by specifying the source in the form
`source=('directory::url#fragment?query')`. Currently makepkg supports the
Bazaar, Git, Subversion, and Mercurial version control systems. For other
version control systems, manual cloning of upstream repositories must be done
in the `prepare()` function.
control system (VCS) is enabled by specifying the source in the form:
source=('directory::url#fragment?query')
Currently makepkg supports the Bazaar, Git, Subversion, and Mercurial version
control systems. For other version control systems, manual cloning of upstream
repositories must be done in the `prepare()` function.
The source URL is divided into four components:
@@ -488,13 +492,16 @@ The source URL is divided into four components:
*fragment*::
(optional) Allows specifying a revision number or branch for makepkg to checkout
from the VCS. For example, to checkout a given revision, the source line would
have the format `source=(url#revision=123)`. The available fragments depends on
the VCS being used:
from the VCS. A fragment has the form `type=value`, for example to checkout a
given revision the source line would be `source=(url#revision=123)`. The
available types depends on the VCS being used:
*bzr*;;
revision (see `'bzr help revisionspec'` for details)
*fossil*;;
branch, commit, tag
*git*;;
branch, commit, tag

View File

@@ -18,14 +18,15 @@ Current maintainers:
* Allan McRae <allan@archlinux.org>
* Andrew Gregory <andrew.gregory.8@gmail.com>
* Dan McGee <dan@archlinux.org>
* Dave Reisner <dreisner@archlinux.org>
* Eli Schwartz <eschwartz@archlinux.org>
Past major contributors:
* Judd Vinet <jvinet@zeroflux.org>
* Aurelien Foret <aurelien@archlinux.org>
* Aaron Griffin <aaron@archlinux.org>
* Dan McGee <dan@archlinux.org>
* Xavier Chantry <shiningxc@gmail.com>
* Nagy Gabor <ngaba@bibl.u-szeged.hu>

View File

@@ -51,6 +51,7 @@ configuration files dealing with pacman.
* linkman:makepkg.conf[5]
* linkman:pacman[8]
* linkman:pacman-key[8]
* linkman:pacman-conf[8]
* linkman:pacman.conf[5]
* linkman:repo-add[8]
* linkman:vercmp[8]
@@ -76,6 +77,7 @@ Releases
[frame="topbot",grid="none",options="header,autowidth"]
!======
!Version !Date
!5.2.1 !2019-11-01
!5.2.0 !2019-10-21
!5.1.3 !2019-03-01
!5.1.2 !2018-12-25
@@ -191,11 +193,11 @@ link:https://sources.archlinux.org/other/pacman/[]. To install, download the new
available source tarball, unpack it in a directory, and run the three magic
commands:
$ ./configure
$ make
# make install
$ meson build
$ ninja -C build
# ninja -C build install
You may wish to read the options presented by `./configure --help` in order to
You may wish to read the options presented by `meson` in order to
set appropriate paths and build options that are correct for your system.
Development
@@ -260,7 +262,7 @@ bugs under the Pacman project.
Copyright
---------
pacman is Copyright (C) 2006-2018 Pacman Development Team
pacman is Copyright (C) 2006-2020 Pacman Development Team
<pacman-dev@archlinux.org> and Copyright (C) 2002-2006 Judd Vinet
<jvinet@zeroflux.org> and is licensed through the GNU General Public License,
version 2 or later.

View File

@@ -274,7 +274,7 @@ Environment Variables
**GPGKEY=**"keyid"::
Specify a key to use when signing packages, overriding the GPGKEY setting
in linkman:makepkg.conf[5]
in linkman:makepkg.conf[5].
**SOURCE_DATE_EPOCH=**"<date>"::
Used for link:https://reproducible-builds.org/docs/[Reproducible Builds].
@@ -299,7 +299,7 @@ On exit, makepkg will return one of the following error codes.
Error in configuration file.
3::
User specified an invalid option
User specified an invalid option.
4::
Error in user-supplied function in PKGBUILD.

View File

@@ -192,7 +192,7 @@ Options
**INTEGRITY_CHECK=(**check1 ...**)**::
File integrity checks to use. Multiple checks may be specified; this
affects both generation and checking. The current valid options are:
`md5`, `sha1`, `sha224`, `sha256`, `sha384`, `sha512`, and `b2`.
`ck`, `md5`, `sha1`, `sha224`, `sha256`, `sha384`, `sha512`, and `b2`.
**STRIP_BINARIES=**"--strip-all"::
Options to be used when stripping binaries. See linkman:strip[1]

View File

@@ -129,6 +129,10 @@ meson.add_install_script(MESON_MAKE_SYMLINK,
'repo-add.8',
join_paths(MANDIR, 'man8/repo-remove.8'))
meson.add_install_script(MESON_MAKE_SYMLINK,
'alpm-hooks.5',
join_paths(MANDIR, 'man5/pacman-hooks.5'))
doxygen = find_program('doxygen', required : get_option('doxygen'))
if doxygen.found() and not get_option('doxygen').disabled()
doxyconf = configuration_data()

View File

@@ -141,7 +141,7 @@ Options
guest system. See '\--sysroot' instead.
*-v, \--verbose*::
Output paths such as as the Root, Conf File, DB Path, Cache Dirs, etc.
Output paths such as the Root, Conf File, DB Path, Cache Dirs, etc.
*\--arch* <arch>::
Specify an alternate architecture.
@@ -464,7 +464,7 @@ Database Options (apply to '-D')[[QO]]
*\--asexplicit* <package>::
Mark a package as explicitly installed; in other words, set their install
reason to be explicitly installed. This is useful it you want to keep a
reason to be explicitly installed. This is useful if you want to keep a
package installed even when it was initially installed as a dependency
of another package.

View File

@@ -186,6 +186,10 @@ Options
*Color*::
Automatically enable colors only when pacman's output is on a tty.
*NoProgressBar*::
Disables progress bars. This is useful for terminals which do
not support escape characters.
*TotalDownload*::
When downloading, display the amount downloaded, download rate, ETA,
and completed percentage of the entire download list rather
@@ -205,6 +209,11 @@ Options
Disable defaults for low speed limit and timeout on downloads. Use this
if you have issues downloading files with proxy and/or security gateway.
*ParallelDownloads*::
Specifies number of concurrent download streams. The value needs to be a
positive integer. If this config option is not set then only one download
stream is used (i.e. downloads happen sequentially).
Repository Sections
-------------------

View File

@@ -1,27 +0,0 @@
dist_sysconf_DATA = makepkg.conf pacman.conf
EXTRA_DIST = makepkg.conf.in pacman.conf.in
# Files that should be removed, but which Automake does not know.
MOSTLYCLEANFILES = $(dist_sysconf_DATA)
SED_PROCESS = \
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
$(SED) \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
-e 's|@localstatedir[@]|$(localstatedir)|g' \
-e 's|@prefix[@]|$(prefix)|g' \
-e 's|@PACKAGE_VERSION[@]|$(PACKAGE_VERSION)|g' \
-e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
-e 's|@PKGEXT[@]|$(PKGEXT)|g' \
-e 's|@SRCEXT[@]|$(SRCEXT)|g' \
-e 's|@STRIP_BINARIES[@]|$(STRIP_BINARIES)|g' \
-e 's|@STRIP_SHARED[@]|$(STRIP_SHARED)|g' \
-e 's|@STRIP_STATIC[@]|$(STRIP_STATIC)|g' \
-e 's|@CARCH[@]|$(CARCH)|g' \
-e 's|@CHOST[@]|$(CHOST)|g' \
-e 's|@ARCHSWITCH[@]|$(ARCHSWITCH)|g' \
-e 's|@ROOTDIR[@]|$(ROOTDIR)|g' \
< $< > $@
%.conf: %.conf.in Makefile
$(SED_PROCESS)

View File

@@ -24,6 +24,7 @@ DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
#-- The package required by makepkg to download VCS sources
# Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
'fossil::fossil'
'git::git'
'hg::mercurial'
'svn::subversion')
@@ -52,7 +53,7 @@ CHOST="@CHOST@"
# BUILD ENVIRONMENT
#########################################################################
#
# Defaults: BUILDENV=(!distcc !color !ccache check !sign)
# Makepkg defaults: BUILDENV=(!distcc !color !ccache check !sign)
# A negated environment option will do the opposite of the comments below.
#
#-- distcc: Use the Distributed C/C++/ObjC compiler
@@ -75,7 +76,7 @@ BUILDENV=(!distcc color !ccache check !sign)
# These are default values for the options=() settings
#########################################################################
#
# Default: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug)
# Makepkg defaults: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug)
# A negated option will do the opposite of the comments below.
#
#-- strip: Strip symbols from binaries/libraries
@@ -89,8 +90,8 @@ BUILDENV=(!distcc color !ccache check !sign)
#
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !debug)
#-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2
INTEGRITY_CHECK=(md5)
#-- File integrity checks to use. Valid: ck, md5, sha1, sha224, sha256, sha384, sha512, b2
INTEGRITY_CHECK=(ck)
#-- Options to be used when stripping binaries. See `man strip' for details.
STRIP_BINARIES="@STRIP_BINARIES@"
#-- Options to be used when stripping shared libraries. See `man strip' for details.

View File

@@ -31,9 +31,11 @@ Architecture = auto
# Misc options
#UseSyslog
#Color
#NoProgressBar
#TotalDownload
CheckSpace
#VerbosePkgLists
ParallelDownloads = 5
# PGP signature checking
#SigLevel = Optional

View File

@@ -1,78 +0,0 @@
AUTOMAKE_OPTIONS = gnu
SUBDIRS = po
EXTRA_DIST = meson.build po/meson.build
lib_LTLIBRARIES = libalpm.la
include_HEADERS = alpm_list.h alpm.h
AM_CPPFLAGS = \
-imacros $(top_builddir)/config.h \
-DSYSHOOKDIR=\"@datarootdir@/libalpm/hooks/\" \
-DLOCALEDIR=\"@localedir@\"
AM_CFLAGS = -pedantic -D_GNU_SOURCE $(WARNING_CFLAGS)
if ENABLE_VISIBILITY_CC
if DARWIN
AM_CFLAGS += -fvisibility=hidden
else
AM_CFLAGS += -fvisibility=internal
endif
endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libalpm.pc
libalpm_la_SOURCES = \
add.h add.c \
alpm.h alpm.c \
alpm_list.h alpm_list.c \
backup.h backup.c \
base64.h base64.c \
be_local.c \
be_package.c \
be_sync.c \
conflict.h conflict.c \
db.h db.c \
deps.h deps.c \
diskspace.h diskspace.c \
dload.h dload.c \
error.c \
filelist.h filelist.c \
graph.h graph.c \
group.h group.c \
handle.h handle.c \
hook.h hook.c \
ini.h ini.c \
libarchive-compat.h \
log.h log.c \
package.h package.c \
pkghash.h pkghash.c \
rawstr.c \
remove.h remove.c \
signing.c signing.h \
sync.h sync.c \
trans.h trans.c \
util.h util.c \
util-common.h util-common.c \
version.c
libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO)
libalpm_la_CFLAGS = \
$(AM_CFLAGS) \
$(GPGME_CFLAGS) \
$(LIBARCHIVE_CFLAGS) \
$(LIBCURL_CFLAGS) \
$(LIBSSL_CFLAGS) \
$(NETTLE_CFLAGS)
libalpm_la_LIBADD = \
$(LTLIBINTL) \
$(GPGME_LIBS) \
$(LIBARCHIVE_LIBS) \
$(LIBCURL_LIBS) \
$(LIBSSL_LIBS) \
$(NETTLE_LIBS)

View File

@@ -1,7 +1,7 @@
/*
* add.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -47,7 +47,6 @@
#include "remove.h"
#include "handle.h"
/** Add a package to the transaction. */
int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
{
const char *pkgname, *pkgver;
@@ -484,8 +483,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
/* set up fake remove transaction */
if(_alpm_remove_single_package(handle, oldpkg, newpkg, 0, 0) == -1) {
handle->pm_errno = ALPM_ERR_TRANS_ABORT;
ret = -1;
goto cleanup;
return -1;
}
}
@@ -496,15 +494,13 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
"error: could not create database entry %s-%s\n",
newpkg->name, newpkg->version);
handle->pm_errno = ALPM_ERR_DB_WRITE;
ret = -1;
goto cleanup;
return -1;
}
fd = _alpm_open_archive(db->handle, pkgfile, &buf,
&archive, ALPM_ERR_PKG_OPEN);
if(fd < 0) {
ret = -1;
goto cleanup;
return -1;
}
/* save the cwd so we can restore it later */
@@ -522,8 +518,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
close(cwdfd);
}
close(fd);
ret = -1;
goto cleanup;
return -1;
}
if(trans->flags & ALPM_TRANS_FLAG_DBONLY) {
@@ -607,8 +602,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
"error: could not update database entry %s-%s\n",
newpkg->name, newpkg->version);
handle->pm_errno = ALPM_ERR_DB_WRITE;
ret = -1;
goto cleanup;
return -1;
}
if(_alpm_db_add_pkgincache(db, newpkg) == -1) {
@@ -654,7 +648,6 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
event.type = ALPM_EVENT_PACKAGE_OPERATION_DONE;
EVENT(handle, &event);
cleanup:
return ret;
}

View File

@@ -1,7 +1,7 @@
/*
* add.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -1,7 +1,7 @@
/*
* alpm.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -32,19 +32,6 @@
#include "log.h"
#include "util.h"
/** \addtogroup alpm_interface Interface Functions
* @brief Functions to initialize and release libalpm
* @{
*/
/** Initializes the library.
* Creates handle, connects to database and creates lockfile.
* This must be called before any other functions are called.
* @param root the root path for all filesystem operations
* @param dbpath the absolute path to the libalpm database
* @param err an optional variable to hold any error return codes
* @return a context handle on success, NULL on error, err will be set if provided
*/
alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
alpm_errno_t *err)
{
@@ -83,6 +70,13 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
goto cleanup;
}
#ifdef HAVE_LIBCURL
curl_global_init(CURL_GLOBAL_ALL);
myhandle->curlm = curl_multi_init();
#endif
myhandle->parallel_downloads = 1;
#ifdef ENABLE_NLS
bindtextdomain("libalpm", LOCALEDIR);
#endif
@@ -99,14 +93,6 @@ cleanup:
return NULL;
}
/** Release the library.
* Disconnects from the database, removes handle and lockfile
* This should be the last alpm call you make.
* After this returns, handle should be considered invalid and cannot be reused
* in any way.
* @param myhandle the context handle
* @return 0 on success, -1 on error
*/
int SYMEXPORT alpm_release(alpm_handle_t *myhandle)
{
int ret = 0;
@@ -125,33 +111,22 @@ int SYMEXPORT alpm_release(alpm_handle_t *myhandle)
ret = -1;
}
_alpm_handle_unlock(myhandle);
_alpm_handle_free(myhandle);
#ifdef HAVE_LIBCURL
curl_multi_cleanup(myhandle->curlm);
curl_global_cleanup();
#endif
_alpm_handle_unlock(myhandle);
_alpm_handle_free(myhandle);
return ret;
}
/** @} */
/** @defgroup alpm_misc Miscellaneous Functions
* @brief Various libalpm functions
*/
/** Get the version of library.
* @return the library version, e.g. "6.0.4"
* */
const char SYMEXPORT *alpm_version(void)
{
return LIB_VERSION;
}
/** Get the capabilities of the library.
* @return a bitmask of the capabilities
* */
int SYMEXPORT alpm_capabilities(void)
{
return 0

View File

@@ -1,7 +1,7 @@
/*
* alpm.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -335,6 +335,11 @@ typedef enum _alpm_hook_when_t {
* Logging facilities
*/
/** \addtogroup alpm_log Logging Functions
* @brief Functions to log using libalpm
* @{
*/
/** Logging Levels */
typedef enum _alpm_loglevel_t {
ALPM_LOG_ERROR = 1,
@@ -345,9 +350,17 @@ typedef enum _alpm_loglevel_t {
typedef void (*alpm_cb_log)(alpm_loglevel_t, const char *, va_list);
/** A printf-like function for logging.
* @param handle the context handle
* @param prefix caller-specific prefix for the log
* @param fmt output format
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
int alpm_logaction(alpm_handle_t *handle, const char *prefix,
const char *fmt, ...) __attribute__((format(printf, 3, 4)));
/** @} */
/**
* Type of events.
*/
@@ -389,21 +402,18 @@ typedef enum _alpm_event_type_t {
/** Scriptlet has printed information; See alpm_event_scriptlet_info_t for
* arguments. */
ALPM_EVENT_SCRIPTLET_INFO,
/** Files will be downloaded from a repository. */
ALPM_EVENT_RETRIEVE_START,
/** Files were downloaded from a repository. */
ALPM_EVENT_RETRIEVE_DONE,
/** Not all files were successfully downloaded from a repository. */
ALPM_EVENT_RETRIEVE_FAILED,
/** A file will be downloaded from a repository; See alpm_event_pkgdownload_t
* for arguments */
ALPM_EVENT_PKGDOWNLOAD_START,
/** A file was downloaded from a repository; See alpm_event_pkgdownload_t
* for arguments */
ALPM_EVENT_PKGDOWNLOAD_DONE,
/** A file failed to be downloaded from a repository; See
* alpm_event_pkgdownload_t for arguments */
ALPM_EVENT_PKGDOWNLOAD_FAILED,
/** Database files will be downloaded from a repository. */
ALPM_EVENT_DB_RETRIEVE_START,
/** Database files were downloaded from a repository. */
ALPM_EVENT_DB_RETRIEVE_DONE,
/** Not all database files were successfully downloaded from a repository. */
ALPM_EVENT_DB_RETRIEVE_FAILED,
/** Package files will be downloaded from a repository. */
ALPM_EVENT_PKG_RETRIEVE_START,
/** Package files were downloaded from a repository. */
ALPM_EVENT_PKG_RETRIEVE_DONE,
/** Not all package files were successfully downloaded from a repository. */
ALPM_EVENT_PKG_RETRIEVE_FAILED,
/** Disk space usage will be computed for a package. */
ALPM_EVENT_DISKSPACE_START,
/** Disk space usage was computed for a package. */
@@ -696,13 +706,42 @@ typedef void (*alpm_cb_progress)(alpm_progress_t, const char *, int, size_t, siz
* Downloading
*/
/* File download events.
* These events are reported by ALPM via download callback.
*/
typedef enum {
ALPM_DOWNLOAD_INIT, /* alpm initializes file download logic */
ALPM_DOWNLOAD_PROGRESS, /* download progress reported */
ALPM_DOWNLOAD_COMPLETED /* alpm is about to release data related to the file */
} alpm_download_event_type_t;
typedef struct {
int optional; /* whether this file is optional and thus the errors could be ignored */
} alpm_download_event_init_t;
typedef struct {
off_t downloaded; /* amount of data downloaded */
off_t total; /* total amount need to be downloaded */
} alpm_download_event_progress_t;
typedef struct {
/* total bytes in file */
off_t total;
/* download result code:
* 0 - download completed successfully
* 1 - the file is up-to-date
* -1 - error
*/
int result;
} alpm_download_event_completed_t;
/** Type of download progress callbacks.
* @param filename the name of the file being downloaded
* @param xfered the number of transferred bytes
* @param total the total number of bytes to transfer
* @param event the event type
* @param data the event data of type alpm_download_event_*_t
*/
typedef void (*alpm_cb_download)(const char *filename,
off_t xfered, off_t total);
alpm_download_event_type_t event, void *data);
typedef void (*alpm_cb_totaldl)(off_t total);
@@ -716,12 +755,17 @@ typedef void (*alpm_cb_totaldl)(off_t total);
typedef int (*alpm_cb_fetch)(const char *url, const char *localpath,
int force);
/** Fetch a remote pkg.
/** Fetch a list of remote packages.
* @param handle the context handle
* @param url URL of the package to download
* @return the downloaded filepath on success, NULL on error
* @param urls list of package URLs to download
* @param fetched list of filepaths to the fetched packages, each item
* corresponds to one in `urls` list. This is an output parameter,
* the caller should provide a pointer to an empty list
* (*fetched === NULL) and the callee fills the list with data.
* @return 0 on success or -1 on failure
*/
char *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url);
int alpm_fetch_pkgurl(alpm_handle_t *handle, const alpm_list_t *urls,
alpm_list_t **fetched);
/** @addtogroup alpm_api_options Options
* Libalpm option getters and setters
@@ -890,6 +934,17 @@ int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, int level);
int alpm_option_set_disable_dl_timeout(alpm_handle_t *handle, unsigned short disable_dl_timeout);
int alpm_option_get_parallel_downloads(alpm_handle_t *handle);
/** Sets number of parallel streams to download database and package files.
* If the function is not called then the default value of '1' stream
* (i.e. sequential download) is used.
* @param handle the context handle
* @param num_streams number of parallel download streams
* @return 0 on success, -1 on error
*/
int alpm_option_set_parallel_downloads(alpm_handle_t *handle, unsigned int num_streams);
/** @} */
/** @addtogroup alpm_api_databases Database Functions
@@ -960,13 +1015,65 @@ int alpm_db_get_valid(alpm_db_t *db);
/** @name Accessors to the list of servers for a database.
* @{
*/
/** Get the list of servers assigned to this db.
* @param db pointer to the database to get the servers from
* @return a char* list of servers
*/
alpm_list_t *alpm_db_get_servers(const alpm_db_t *db);
/** Sets the list of servers for the database to use.
* @param db the database to set the servers
* @param a char* list of servers. Note: the database will
* take ownership of the list and it should no longer be
* freed by the caller
*/
int alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers);
/** Add a download server to a database.
* @param db database pointer
* @param url url of the server
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
int alpm_db_add_server(alpm_db_t *db, const char *url);
/** Remove a download server from a database.
* @param db database pointer
* @param url url of the server
* @return 0 on success, 1 on server not present,
* -1 on error (pm_errno is set accordingly)
*/
int alpm_db_remove_server(alpm_db_t *db, const char *url);
/** @} */
int alpm_db_update(int force, alpm_db_t *db);
/** Update package databases
*
* An update of the package databases in the list \a dbs will be attempted.
* Unless \a force is true, the update will only be performed if the remote
* databases were modified since the last update.
*
* This operation requires a database lock, and will return an applicable error
* if the lock could not be obtained.
*
* Example:
* @code
* alpm_list_t *dbs = alpm_get_syncdbs();
* ret = alpm_db_update(config->handle, dbs, force);
* if(ret < 0) {
* pm_printf(ALPM_LOG_ERROR, _("failed to synchronize all databases (%s)\n"),
* alpm_strerror(alpm_errno(config->handle)));
* }
* @endcode
*
* @note After a successful update, the \link alpm_db_get_pkgcache()
* package cache \endlink will be invalidated
* @param handle the context handle
* @param dbs list of package databases to update
* @param force if true, then forces the update, otherwise update only in case
* the databases aren't up to date
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
int alpm_db_update(alpm_handle_t *handle, alpm_list_t *dbs, int force);
/** Get a package entry from a package database.
* @param db pointer to the package database to get the package from
@@ -997,9 +1104,12 @@ alpm_list_t *alpm_db_get_groupcache(alpm_db_t *db);
/** Searches a database with regular expressions.
* @param db pointer to the package database to search in
* @param needles a list of regular expressions to search for
* @return the list of packages matching all regular expressions on success, NULL on error
* @param ret pointer to list for storing packages matching all
* regular expressions - must point to an empty (NULL) alpm_list_t *.
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
alpm_list_t *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
int alpm_db_search(alpm_db_t *db, const alpm_list_t *needles,
alpm_list_t **ret);
typedef enum _alpm_db_usage_t {
ALPM_DB_USAGE_SYNC = 1,
@@ -1066,7 +1176,20 @@ int alpm_pkg_free(alpm_pkg_t *pkg);
*/
int alpm_pkg_checkmd5sum(alpm_pkg_t *pkg);
/** Compare two version strings and determine which one is 'newer'. */
/** Compare two version strings and determine which one is 'newer'.
* Returns a value comparable to the way strcmp works. Returns 1
* if a is newer than b, 0 if a and b are the same version, or -1
* if b is newer than a.
*
* Different epoch values for version strings will override any further
* comparison. If no epoch is provided, 0 is assumed.
*
* Keep in mind that the pkgrel is only compared if it is available
* on both versions handed to this function. For example, comparing
* 1.5-1 and 1.5 will yield 0; comparing 1.5-1 and 1.5-2 will yield
* -1 as expected. This is mainly for supporting versioned dependencies
* that do not include the pkgrel.
*/
int alpm_pkg_vercmp(const char *a, const char *b);
/** Computes the list of packages requiring a given package.
@@ -1284,6 +1407,17 @@ alpm_db_t *alpm_pkg_get_db(alpm_pkg_t *pkg);
*/
const char *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg);
/** Extracts package signature either from embedded package signature
* or if it is absent then reads data from detached signature file.
* @param pkg a pointer to package.
* @param sig output parameter for signature data. Callee function allocates
* a buffer needed for the signature data. Caller is responsible for
* freeing this buffer.
* @param sig_len output parameter for the signature data length.
* @return 0 on success, negative number on error.
*/
int alpm_pkg_get_sig(alpm_pkg_t *pkg, unsigned char **sig, size_t *sig_len);
/** Returns the method used to validate a package during install.
* @param pkg a pointer to package
* @return an enum member giving the validation method
@@ -1314,11 +1448,15 @@ void *alpm_pkg_changelog_open(alpm_pkg_t *pkg);
size_t alpm_pkg_changelog_read(void *ptr, size_t size,
const alpm_pkg_t *pkg, void *fp);
/** Close a package changelog for reading.
* @param pkg the package to close the changelog of (either file or db)
* @return 0 on success, -1 on error
*/
int alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp);
/** Open a package mtree file for reading.
* @param pkg the local package to read the changelog of
* @return a archive structure for the package mtree file
* @param pkg the local package to read the mtree of
* @return an archive structure for the package mtree file
*/
struct archive *alpm_pkg_mtree_open(alpm_pkg_t *pkg);
@@ -1326,11 +1464,15 @@ struct archive *alpm_pkg_mtree_open(alpm_pkg_t *pkg);
* @param pkg the package that the mtree file is being read from
* @param archive the archive structure reading from the mtree file
* @param entry an archive_entry to store the entry header information
* @return 0 if end of archive is reached, non-zero otherwise.
* @return 0 on success, 1 if end of archive is reached, -1 otherwise.
*/
int alpm_pkg_mtree_next(const alpm_pkg_t *pkg, struct archive *archive,
struct archive_entry **entry);
/** Close a package mtree file.
* @param pkg the local package to close the mtree of
* @param the archive to close
*/
int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive);
/** Returns whether the package has an install scriptlet.
@@ -1338,8 +1480,7 @@ int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive);
*/
int alpm_pkg_has_scriptlet(alpm_pkg_t *pkg);
/** Returns the size of download.
* Returns the size of the files that will be downloaded to install a
/** Returns the size of the files that will be downloaded to install a
* package.
* @param newpkg the new package to upgrade to
* @return the size of the download
@@ -1377,15 +1518,48 @@ alpm_file_t *alpm_filelist_contains(alpm_filelist_t *filelist, const char *path)
* Signatures
*/
/**
* Check the PGP signature for the given package file.
* @param pkg the package to check
* @param siglist a pointer to storage for signature results
* @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred)
*/
int alpm_pkg_check_pgp_signature(alpm_pkg_t *pkg, alpm_siglist_t *siglist);
/**
* Check the PGP signature for the given database.
* @param db the database to check
* @param siglist a pointer to storage for signature results
* @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred)
*/
int alpm_db_check_pgp_signature(alpm_db_t *db, alpm_siglist_t *siglist);
/**
* Clean up and free a signature result list.
* Note that this does not free the siglist object itself in case that
* was allocated on the stack; this is the responsibility of the caller.
* @param siglist a pointer to storage for signature results
* @return 0 on success, -1 on error
*/
int alpm_siglist_cleanup(alpm_siglist_t *siglist);
/**
* Decode a loaded signature in base64 form.
* @param base64_data the signature to attempt to decode
* @param data the decoded data; must be freed by the caller
* @param data_len the length of the returned data
* @return 0 on success, -1 on failure to properly decode
*/
int alpm_decode_signature(const char *base64_data,
unsigned char **data, size_t *data_len);
/**
* Extract the Issuer Key ID from a signature
* @param sig PGP signature
* @param len length of signature
* @param keys a pointer to storage for key IDs
* @return 0 on success, -1 on error
*/
int alpm_extract_keyid(alpm_handle_t *handle, const char *identifier,
const unsigned char *sig, const size_t len, alpm_list_t **keys);
@@ -1393,12 +1567,22 @@ int alpm_extract_keyid(alpm_handle_t *handle, const char *identifier,
* Groups
*/
/** Find group members across a list of databases.
* If a member exists in several databases, only the first database is used.
* IgnorePkg is also handled.
* @param dbs the list of alpm_db_t *
* @param name the name of the group
* @return the list of alpm_pkg_t * (caller is responsible for alpm_list_free)
*/
alpm_list_t *alpm_find_group_pkgs(alpm_list_t *dbs, const char *name);
/*
* Sync
*/
/** Check for new version of pkg in sync repos
* (only the first occurrence is considered in sync)
*/
alpm_pkg_t *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync);
/** @addtogroup alpm_api_trans Transaction Functions
@@ -1531,12 +1715,49 @@ int alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg);
* @{
*/
/** Checks dependencies and returns missing ones in a list.
* Dependencies can include versions with depmod operators.
* @param handle the context handle
* @param pkglist the list of local packages
* @param remove an alpm_list_t* of packages to be removed
* @param upgrade an alpm_list_t* of packages to be upgraded (remove-then-upgrade)
* @param reversedeps handles the backward dependencies
* @return an alpm_list_t* of alpm_depmissing_t pointers.
*/
alpm_list_t *alpm_checkdeps(alpm_handle_t *handle, alpm_list_t *pkglist,
alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps);
/** Find a package satisfying a specified dependency.
* The dependency can include versions with depmod operators.
* @param pkgs an alpm_list_t* of alpm_pkg_t where the satisfier will be searched
* @param depstring package or provision name, versioned or not
* @return a alpm_pkg_t* satisfying depstring
*/
alpm_pkg_t *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring);
/** Find a package satisfying a specified dependency.
* First look for a literal, going through each db one by one. Then look for
* providers. The first satisfier that belongs to an installed package is
* returned. If no providers belong to an installed package then an
* alpm_question_select_provider_t is created to select the provider.
* The dependency can include versions with depmod operators.
*
* @param handle the context handle
* @param dbs an alpm_list_t* of alpm_db_t where the satisfier will be searched
* @param depstring package or provision name, versioned or not
* @return a alpm_pkg_t* satisfying depstring
*/
alpm_pkg_t *alpm_find_dbs_satisfier(alpm_handle_t *handle,
alpm_list_t *dbs, const char *depstring);
/**
* @brief Check the package conflicts in a database
*
* @param handle the context handle
* @param pkglist the list of packages to check
*
* @return an alpm_list_t of alpm_conflict_t
*/
alpm_list_t *alpm_checkconflicts(alpm_handle_t *handle, alpm_list_t *pkglist);
/** Returns a newly allocated string representing the dependency information.
@@ -1565,12 +1786,60 @@ void alpm_dep_free(alpm_depend_t *dep);
*/
/* checksums */
/** \addtogroup alpm_misc Miscellaneous Functions
* @brief Various libalpm functions
* @{
*/
/** Get the md5 sum of file.
* @param filename name of the file
* @return the checksum on success, NULL on error
*/
char *alpm_compute_md5sum(const char *filename);
/** Get the sha256 sum of file.
* @param filename name of the file
* @return the checksum on success, NULL on error
*/
char *alpm_compute_sha256sum(const char *filename);
/** @} */
/** \addtogroup alpm_interface Interface Functions
* @brief Functions to initialize and release libalpm
* @{
*/
/** Initializes the library.
* Creates handle, connects to database and creates lockfile.
* This must be called before any other functions are called.
* @param root the root path for all filesystem operations
* @param dbpath the absolute path to the libalpm database
* @param err an optional variable to hold any error return codes
* @return a context handle on success, NULL on error, err will be set if provided
*/
alpm_handle_t *alpm_initialize(const char *root, const char *dbpath,
alpm_errno_t *err);
/** Release the library.
* Disconnects from the database, removes handle and lockfile
* This should be the last alpm call you make.
* After this returns, handle should be considered invalid and cannot be reused
* in any way.
* @param myhandle the context handle
* @return 0 on success, -1 on error
*/
int alpm_release(alpm_handle_t *handle);
/** @} */
/** Remove the database lock file
* @param handle the context handle
* @return 0 on success, -1 on error
*
* @note Safe to call from inside signal handlers.
*/
int alpm_unlock(alpm_handle_t *handle);
enum alpm_caps {
@@ -1579,12 +1848,27 @@ enum alpm_caps {
ALPM_CAPABILITY_SIGNATURES = (1 << 2)
};
/** Get the version of library.
* @return the library version, e.g. "6.0.4"
* */
const char *alpm_version(void);
/* Return a bitfield of capabilities using values from 'enum alpm_caps' */
/** Get the capabilities of the library.
* @return a bitmask of the capabilities
* */
int alpm_capabilities(void);
/**
* Free a fileconflict and its members.
* @param conflict the fileconflict to free
*/
void alpm_fileconflict_free(alpm_fileconflict_t *conflict);
void alpm_depmissing_free(alpm_depmissing_t *miss);
/**
* Free a conflict and its members.
* @param conflict the conflict to free
*/
void alpm_conflict_free(alpm_conflict_t *conflict);
/* End of alpm_api */

View File

@@ -1,7 +1,7 @@
/*
* alpm_list.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -1,7 +1,7 @@
/*
* alpm_list.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -1,7 +1,7 @@
/*
* backup.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2005 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>

View File

@@ -1,7 +1,7 @@
/*
* backup.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -1,7 +1,7 @@
/*
* be_local.c : backend for the local database
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -256,8 +256,7 @@ static struct archive *_cache_mtree_open(alpm_pkg_t *pkg)
}
if((mtree = archive_read_new()) == NULL) {
pkg->handle->pm_errno = ALPM_ERR_LIBARCHIVE;
goto error;
GOTO_ERR(pkg->handle, ALPM_ERR_LIBARCHIVE, error);
}
_alpm_archive_read_support_filter_all(mtree);
@@ -266,9 +265,8 @@ static struct archive *_cache_mtree_open(alpm_pkg_t *pkg)
if((r = _alpm_archive_read_open_file(mtree, mtfile, ALPM_BUFFER_SIZE))) {
_alpm_log(pkg->handle, ALPM_LOG_ERROR, _("error while reading file %s: %s\n"),
mtfile, archive_error_string(mtree));
pkg->handle->pm_errno = ALPM_ERR_LIBARCHIVE;
_alpm_archive_read_free(mtree);
goto error;
GOTO_ERR(pkg->handle, ALPM_ERR_LIBARCHIVE, error);
}
free(mtfile);
@@ -284,12 +282,26 @@ error:
* @param pkg the package that the mtree file is being read from
* @param archive the archive structure reading from the mtree file
* @param entry an archive_entry to store the entry header information
* @return 0 if end of archive is reached, non-zero otherwise.
* @return 0 on success, 1 if end of archive is reached, -1 otherwise.
*/
static int _cache_mtree_next(const alpm_pkg_t UNUSED *pkg,
struct archive *mtree, struct archive_entry **entry)
{
return archive_read_next_header(mtree, entry);
int ret;
ret = archive_read_next_header(mtree, entry);
switch(ret) {
case ARCHIVE_OK:
return 0;
break;
case ARCHIVE_EOF:
return 1;
break;
default:
break;
}
return -1;
}
/**
@@ -680,7 +692,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info,
static int local_db_read(alpm_pkg_t *info, int inforeq)
{
FILE *fp = NULL;
char line[1024];
char line[1024] = {0};
alpm_db_t *db = info->origin_data.db;
/* bitmask logic here:
@@ -703,9 +715,6 @@ static int local_db_read(alpm_pkg_t *info, int inforeq)
"loading package data for %s : level=0x%x\n",
info->name, inforeq);
/* clear out 'line', to be certain - and to make valgrind happy */
memset(line, 0, sizeof(line));
/* DESC */
if(inforeq & INFRQ_DESC && !(info->infolevel & INFRQ_DESC)) {
char *path = _alpm_local_db_pkgpath(db, info, "desc");
@@ -832,12 +841,7 @@ static int local_db_read(alpm_pkg_t *info, int inforeq)
}
/* attempt to hand back any memory we don't need */
if(files_count > 0) {
alpm_file_t *newfiles;
newfiles = realloc(files, sizeof(alpm_file_t) * files_count);
if(newfiles != NULL) {
files = newfiles;
}
REALLOC(files, sizeof(alpm_file_t) * files_count, (void)0);
} else {
FREE(files);
}

View File

@@ -1,7 +1,7 @@
/*
* be_package.c : backend for packages
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -164,9 +164,8 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
char *ptr = NULL;
char *key = NULL;
int ret, linenum = 0;
struct archive_read_buffer buf;
struct archive_read_buffer buf = {0};
memset(&buf, 0, sizeof(buf));
/* 512K for a line length seems reasonable */
buf.max_line_size = 512 * 1024;
@@ -202,11 +201,15 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
} else if(strcmp(key, "pkgdesc") == 0) {
STRDUP(newpkg->desc, ptr, return -1);
} else if(strcmp(key, "group") == 0) {
newpkg->groups = alpm_list_add(newpkg->groups, strdup(ptr));
char *tmp = NULL;
STRDUP(tmp, ptr, return -1);
newpkg->groups = alpm_list_add(newpkg->groups, tmp);
} else if(strcmp(key, "url") == 0) {
STRDUP(newpkg->url, ptr, return -1);
} else if(strcmp(key, "license") == 0) {
newpkg->licenses = alpm_list_add(newpkg->licenses, strdup(ptr));
char *tmp = NULL;
STRDUP(tmp, ptr, return -1);
newpkg->licenses = alpm_list_add(newpkg->licenses, tmp);
} else if(strcmp(key, "builddate") == 0) {
newpkg->builddate = _alpm_parsedate(ptr);
} else if(strcmp(key, "packager") == 0) {
@@ -308,7 +311,7 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
}
}
if(syncpkg && !has_sig) {
if(syncpkg && (!has_sig || !syncpkg->base64_sig)) {
if(syncpkg->md5sum && !syncpkg->sha256sum) {
_alpm_log(handle, ALPM_LOG_DEBUG, "md5sum: %s\n", syncpkg->md5sum);
_alpm_log(handle, ALPM_LOG_DEBUG, "checking md5sum for %s\n", pkgfile);
@@ -448,18 +451,15 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str
char *mtree_data = NULL;
struct archive *mtree;
struct archive_entry *mtree_entry = NULL;
alpm_filelist_t filelist;
alpm_filelist_t filelist = {0};
_alpm_log(handle, ALPM_LOG_DEBUG,
"found mtree for package %s, getting file list\n", pkg->filename);
memset(&filelist, 0, sizeof(alpm_filelist_t));
/* create a new archive to parse the mtree and load it from archive into memory */
/* TODO: split this into a function */
if((mtree = archive_read_new()) == NULL) {
handle->pm_errno = ALPM_ERR_LIBARCHIVE;
goto error;
GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error);
}
_alpm_archive_read_support_filter_all(mtree);
@@ -478,8 +478,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str
if(size < 0) {
_alpm_log(handle, ALPM_LOG_DEBUG, _("error while reading package %s: %s\n"),
pkg->filename, archive_error_string(archive));
handle->pm_errno = ALPM_ERR_LIBARCHIVE;
goto error;
GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error);
}
if(size == 0) {
break;
@@ -492,8 +491,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str
_alpm_log(handle, ALPM_LOG_DEBUG,
_("error while reading mtree of package %s: %s\n"),
pkg->filename, archive_error_string(mtree));
handle->pm_errno = ALPM_ERR_LIBARCHIVE;
goto error;
GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error);
}
while((ret = archive_read_next_header(mtree, &mtree_entry)) == ARCHIVE_OK) {
@@ -516,8 +514,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str
if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occurred */
_alpm_log(handle, ALPM_LOG_DEBUG, _("error while reading mtree of package %s: %s\n"),
pkg->filename, archive_error_string(mtree));
handle->pm_errno = ALPM_ERR_LIBARCHIVE;
goto error;
GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error);
}
/* throw away any files we loaded directly from the archive */
@@ -582,11 +579,9 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
newpkg = _alpm_pkg_new();
if(newpkg == NULL) {
handle->pm_errno = ALPM_ERR_MEMORY;
goto error;
GOTO_ERR(handle, ALPM_ERR_MEMORY, error);
}
STRDUP(newpkg->filename, pkgfile,
handle->pm_errno = ALPM_ERR_MEMORY; goto error);
STRDUP(newpkg->filename, pkgfile, GOTO_ERR(handle, ALPM_ERR_MEMORY, error));
newpkg->size = st.st_size;
_alpm_log(handle, ALPM_LOG_DEBUG, "starting package load for %s\n", pkgfile);
@@ -636,8 +631,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
if(archive_read_data_skip(archive)) {
_alpm_log(handle, ALPM_LOG_ERROR, _("error while reading package %s: %s\n"),
pkgfile, archive_error_string(archive));
handle->pm_errno = ALPM_ERR_LIBARCHIVE;
goto error;
GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error);
}
/* if we are not doing a full read, see if we have all we need */
@@ -649,8 +643,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occurred */
_alpm_log(handle, ALPM_LOG_ERROR, _("error while reading package %s: %s\n"),
pkgfile, archive_error_string(archive));
handle->pm_errno = ALPM_ERR_LIBARCHIVE;
goto error;
GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error);
}
if(!config) {
@@ -663,7 +656,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
/* internal fields for package struct */
newpkg->origin = ALPM_PKG_FROM_FILE;
newpkg->origin_data.file = strdup(pkgfile);
STRDUP(newpkg->origin_data.file, pkgfile, goto error);
newpkg->ops = get_file_pkg_ops();
newpkg->handle = handle;
newpkg->infolevel = INFRQ_BASE | INFRQ_DESC | INFRQ_SCRIPTLET;
@@ -672,8 +665,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
if(full) {
if(newpkg->files.files) {
/* attempt to hand back any memory we don't need */
newpkg->files.files = realloc(newpkg->files.files,
sizeof(alpm_file_t) * newpkg->files.count);
REALLOC(newpkg->files.files, sizeof(alpm_file_t) * newpkg->files.count, (void)0);
/* "checking for conflicts" requires a sorted list, ensure that here */
_alpm_log(handle, ALPM_LOG_DEBUG,
"sorting package filelist for %s\n", pkgfile);
@@ -760,14 +752,14 @@ int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int ful
pkg_temp = _alpm_pkg_load_internal(handle, filename, full);
if(pkg_temp) {
packager = pkg_temp->packager;
_alpm_pkg_free(pkg_temp);
} else {
packager = NULL;
}
if(_alpm_key_import(handle, packager, key) == -1) {
fail = 1;
}
free(packager);
_alpm_pkg_free(pkg_temp);
}
}
FREELIST(keys);

View File

@@ -1,7 +1,7 @@
/*
* be_sync.c : backend for sync databases
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -136,178 +136,86 @@ valid:
return 0;
}
/** Update a package database
*
* An update of the package database \a db will be attempted. Unless
* \a force is true, the update will only be performed if the remote
* database was modified since the last update.
*
* This operation requires a database lock, and will return an applicable error
* if the lock could not be obtained.
*
* Example:
* @code
* alpm_list_t *syncs = alpm_get_syncdbs();
* for(i = syncs; i; i = alpm_list_next(i)) {
* alpm_db_t *db = alpm_list_getdata(i);
* result = alpm_db_update(0, db);
*
* if(result < 0) {
* printf("Unable to update database: %s\n", alpm_strerrorlast());
* } else if(result == 1) {
* printf("Database already up to date\n");
* } else {
* printf("Database updated\n");
* }
* }
* @endcode
*
* @ingroup alpm_databases
* @note After a successful update, the \link alpm_db_get_pkgcache()
* package cache \endlink will be invalidated
* @param force if true, then forces the update, otherwise update only in case
* the database isn't up to date
* @param db pointer to the package database to update
* @return 0 on success, -1 on error (pm_errno is set accordingly), 1 if up to
* to date
*/
int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
{
int SYMEXPORT alpm_db_update(alpm_handle_t *handle, alpm_list_t *dbs, int force) {
char *syncpath;
const char *dbext;
const char *dbext = handle->dbext;
alpm_list_t *i;
int updated = 0;
int ret = -1;
mode_t oldmask;
alpm_handle_t *handle;
int siglevel;
alpm_list_t *payloads = NULL;
alpm_event_t event;
/* Sanity checks */
ASSERT(db != NULL, return -1);
handle = db->handle;
CHECK_HANDLE(handle, return -1);
ASSERT(dbs != NULL, return -1);
handle->pm_errno = ALPM_ERR_OK;
ASSERT(db != handle->db_local, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
ASSERT(db->servers != NULL, RET_ERR(handle, ALPM_ERR_SERVER_NONE, -1));
if(!(db->usage & ALPM_DB_USAGE_SYNC)) {
return 0;
}
syncpath = get_sync_dir(handle);
if(!syncpath) {
return -1;
}
/* force update of invalid databases to fix potential mismatched database/signature */
if(db->status & DB_STATUS_INVALID) {
force = 1;
}
ASSERT(syncpath != NULL, return -1);
/* make sure we have a sane umask */
oldmask = umask(0022);
siglevel = alpm_db_get_siglevel(db);
/* attempt to grab a lock */
if(_alpm_handle_lock(handle)) {
free(syncpath);
umask(oldmask);
RET_ERR(handle, ALPM_ERR_HANDLE_LOCK, -1);
GOTO_ERR(handle, ALPM_ERR_HANDLE_LOCK, cleanup);
}
dbext = db->handle->dbext;
for(i = db->servers; i; i = i->next) {
const char *server = i->data, *final_db_url = NULL;
struct dload_payload payload;
for(i = dbs; i; i = i->next) {
alpm_db_t *db = i->data;
int dbforce = force;
struct dload_payload *payload = NULL;
size_t len;
int sig_ret = 0;
int siglevel;
memset(&payload, 0, sizeof(struct dload_payload));
if(!(db->usage & ALPM_DB_USAGE_SYNC)) {
continue;
}
/* set hard upper limit of 25MiB */
payload.max_size = 25 * 1024 * 1024;
ASSERT(db != handle->db_local, GOTO_ERR(handle, ALPM_ERR_WRONG_ARGS, cleanup));
ASSERT(db->servers != NULL, GOTO_ERR(handle, ALPM_ERR_SERVER_NONE, cleanup));
/* force update of invalid databases to fix potential mismatched database/signature */
if(db->status & DB_STATUS_INVALID) {
dbforce = 1;
}
siglevel = alpm_db_get_siglevel(db);
CALLOC(payload, 1, sizeof(*payload), GOTO_ERR(handle, ALPM_ERR_MEMORY, cleanup));
payload->servers = db->servers;
/* print server + filename into a buffer */
len = strlen(server) + strlen(db->treename) + strlen(dbext) + 2;
MALLOC(payload.fileurl, len,
{
free(syncpath);
umask(oldmask);
RET_ERR(handle, ALPM_ERR_MEMORY, -1);
}
);
snprintf(payload.fileurl, len, "%s/%s%s", server, db->treename, dbext);
payload.handle = handle;
payload.force = force;
payload.unlink_on_fail = 1;
ret = _alpm_download(&payload, syncpath, NULL, &final_db_url);
_alpm_dload_payload_reset(&payload);
updated = (updated || ret == 0);
if(ret != -1 && updated && (siglevel & ALPM_SIG_DATABASE)) {
/* an existing sig file is no good at this point */
char *sigpath = _alpm_sigpath(handle, _alpm_db_path(db));
if(!sigpath) {
ret = -1;
break;
}
unlink(sigpath);
free(sigpath);
/* check if the final URL from internal downloader looks reasonable */
if(final_db_url != NULL) {
if(strlen(final_db_url) < 3
|| strcmp(final_db_url + strlen(final_db_url) - strlen(dbext),
dbext) != 0) {
final_db_url = NULL;
}
}
/* if we downloaded a DB, we want the .sig from the same server */
if(final_db_url != NULL) {
/* print final_db_url into a buffer (leave space for .sig) */
len = strlen(final_db_url) + 5;
} else {
/* print server + filename into a buffer (leave space for separator and .sig) */
len = strlen(server) + strlen(db->treename) + strlen(dbext) + 6;
}
MALLOC(payload.fileurl, len,
{
free(syncpath);
umask(oldmask);
RET_ERR(handle, ALPM_ERR_MEMORY, -1);
}
);
if(final_db_url != NULL) {
snprintf(payload.fileurl, len, "%s.sig", final_db_url);
} else {
snprintf(payload.fileurl, len, "%s/%s%s.sig", server, db->treename, dbext);
}
payload.handle = handle;
payload.force = 1;
payload.errors_ok = (siglevel & ALPM_SIG_DATABASE_OPTIONAL);
/* set hard upper limit of 16KiB */
payload.max_size = 16 * 1024;
sig_ret = _alpm_download(&payload, syncpath, NULL, NULL);
/* errors_ok suppresses error messages, but not the return code */
sig_ret = payload.errors_ok ? 0 : sig_ret;
_alpm_dload_payload_reset(&payload);
}
if(ret != -1 && sig_ret != -1) {
break;
}
len = strlen(db->treename) + strlen(dbext) + 1;
MALLOC(payload->filepath, len,
FREE(payload); GOTO_ERR(handle, ALPM_ERR_MEMORY, cleanup));
snprintf(payload->filepath, len, "%s%s", db->treename, dbext);
payload->handle = handle;
payload->force = dbforce;
payload->unlink_on_fail = 1;
payload->download_signature = (siglevel & ALPM_SIG_DATABASE);
payload->signature_optional = (siglevel & ALPM_SIG_DATABASE_OPTIONAL);
/* set hard upper limit of 128 MiB */
payload->max_size = 128 * 1024 * 1024;
payloads = alpm_list_add(payloads, payload);
}
if(updated) {
event.type = ALPM_EVENT_DB_RETRIEVE_START;
EVENT(handle, &event);
ret = _alpm_download(handle, payloads, syncpath);
if(ret < 0) {
event.type = ALPM_EVENT_DB_RETRIEVE_FAILED;
EVENT(handle, &event);
goto cleanup;
}
event.type = ALPM_EVENT_DB_RETRIEVE_DONE;
EVENT(handle, &event);
for(i = dbs; i; i = i->next) {
alpm_db_t *db = i->data;
if(!(db->usage & ALPM_DB_USAGE_SYNC)) {
continue;
}
/* Cache needs to be rebuilt */
_alpm_db_free_pkgcache(db);
@@ -318,21 +226,29 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
db->status &= ~DB_STATUS_MISSING;
/* if the download failed skip validation to preserve the download error */
if(ret != -1 && sync_db_validate(db) != 0) {
if(sync_db_validate(db) != 0) {
_alpm_log(handle, ALPM_LOG_DEBUG, "failed to validate db: %s\n",
db->treename);
/* pm_errno should be set */
ret = -1;
}
}
cleanup:
_alpm_handle_unlock(handle);
if(ret == -1) {
/* pm_errno was set by the download code */
_alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync db: %s\n",
_alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync dbs: %s\n",
alpm_strerror(handle->pm_errno));
} else {
handle->pm_errno = ALPM_ERR_OK;
}
_alpm_handle_unlock(handle);
if(payloads) {
alpm_list_free_inner(payloads, (alpm_list_fn_free)_alpm_dload_payload_reset);
FREELIST(payloads);
}
free(syncpath);
umask(oldmask);
return ret;
@@ -501,9 +417,8 @@ static int sync_db_populate(alpm_db_t *db)
db->pkgcache = _alpm_pkghash_create(est_count);
if(db->pkgcache == NULL) {
db->handle->pm_errno = ALPM_ERR_MEMORY;
ret = -1;
goto cleanup;
GOTO_ERR(db->handle, ALPM_ERR_MEMORY, cleanup);
}
while((archive_ret = archive_read_next_header(archive, &entry)) == ARCHIVE_OK) {
@@ -522,9 +437,8 @@ static int sync_db_populate(alpm_db_t *db)
_alpm_log(db->handle, ALPM_LOG_ERROR, _("could not read db '%s' (%s)\n"),
db->treename, archive_error_string(archive));
_alpm_db_free_pkgcache(db);
db->handle->pm_errno = ALPM_ERR_LIBARCHIVE;
ret = -1;
goto cleanup;
GOTO_ERR(db->handle, ALPM_ERR_LIBARCHIVE, cleanup);
}
count = alpm_list_count(db->pkgcache->list);
@@ -601,7 +515,7 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
{
const char *entryname, *filename;
alpm_pkg_t *pkg;
struct archive_read_buffer buf;
struct archive_read_buffer buf = {0};
entryname = archive_entry_pathname(entry);
if(entryname == NULL) {
@@ -613,7 +527,6 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
_alpm_log(db->handle, ALPM_LOG_FUNCTION, "loading package data from archive entry %s\n",
entryname);
memset(&buf, 0, sizeof(buf));
/* 512K for a line length seems reasonable */
buf.max_line_size = 512 * 1024;
@@ -727,7 +640,7 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
}
/* attempt to hand back any memory we don't need */
if(files_count > 0) {
files = realloc(files, sizeof(alpm_file_t) * files_count);
REALLOC(files, sizeof(alpm_file_t) * files_count, (void)0);
} else {
FREE(files);
}

View File

@@ -1,7 +1,7 @@
/*
* conflict.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
@@ -63,9 +63,6 @@ error:
return NULL;
}
/**
* @brief Free a conflict and its members.
*/
void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict)
{
ASSERT(conflict != NULL, return);
@@ -243,14 +240,6 @@ alpm_list_t *_alpm_outerconflicts(alpm_db_t *db, alpm_list_t *packages)
return baddeps;
}
/**
* @brief Check the package conflicts in a database
*
* @param handle the context handle
* @param pkglist the list of packages to check
*
* @return an alpm_list_t of alpm_conflict_t
*/
alpm_list_t SYMEXPORT *alpm_checkconflicts(alpm_handle_t *handle,
alpm_list_t *pkglist)
{
@@ -300,9 +289,6 @@ error:
RET_ERR(handle, ALPM_ERR_MEMORY, conflicts);
}
/**
* @brief Frees a conflict and its members.
*/
void SYMEXPORT alpm_fileconflict_free(alpm_fileconflict_t *conflict)
{
ASSERT(conflict != NULL, return);

View File

@@ -1,7 +1,7 @@
/*
* conflict.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -1,7 +1,7 @@
/*
* db.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -37,12 +37,6 @@
#include "package.h"
#include "group.h"
/** \addtogroup alpm_databases Database Functions
* @brief Functions to query and manipulate the database of libalpm
* @{
*/
/** Register a sync database of packages. */
alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
const char *treename, int siglevel)
{
@@ -81,7 +75,6 @@ void _alpm_db_unregister(alpm_db_t *db)
_alpm_db_free(db);
}
/** Unregister all package databases. */
int SYMEXPORT alpm_unregister_all_syncdbs(alpm_handle_t *handle)
{
alpm_list_t *i;
@@ -102,7 +95,6 @@ int SYMEXPORT alpm_unregister_all_syncdbs(alpm_handle_t *handle)
return 0;
}
/** Unregister a package database. */
int SYMEXPORT alpm_db_unregister(alpm_db_t *db)
{
int found = 0;
@@ -139,14 +131,12 @@ int SYMEXPORT alpm_db_unregister(alpm_db_t *db)
return 0;
}
/** Get the serverlist of a database. */
alpm_list_t SYMEXPORT *alpm_db_get_servers(const alpm_db_t *db)
{
ASSERT(db != NULL, return NULL);
return db->servers;
}
/** Set the serverlist of a database. */
int SYMEXPORT alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers)
{
ASSERT(db != NULL, return -1);
@@ -168,11 +158,6 @@ static char *sanitize_url(const char *url)
return newurl;
}
/** Add a download server to a database.
* @param db database pointer
* @param url url of the server
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
int SYMEXPORT alpm_db_add_server(alpm_db_t *db, const char *url)
{
char *newurl;
@@ -193,12 +178,6 @@ int SYMEXPORT alpm_db_add_server(alpm_db_t *db, const char *url)
return 0;
}
/** Remove a download server from a database.
* @param db database pointer
* @param url url of the server
* @return 0 on success, 1 on server not present,
* -1 on error (pm_errno is set accordingly)
*/
int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
{
char *newurl, *vdata = NULL;
@@ -227,14 +206,12 @@ int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
return ret;
}
/** Get the name of a package database. */
const char SYMEXPORT *alpm_db_get_name(const alpm_db_t *db)
{
ASSERT(db != NULL, return NULL);
return db->treename;
}
/** Get the signature verification level for a database. */
int SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
{
ASSERT(db != NULL, return -1);
@@ -245,7 +222,6 @@ int SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
}
}
/** Check the validity of a database. */
int SYMEXPORT alpm_db_get_valid(alpm_db_t *db)
{
ASSERT(db != NULL, return -1);
@@ -253,7 +229,6 @@ int SYMEXPORT alpm_db_get_valid(alpm_db_t *db)
return db->ops->validate(db);
}
/** Get a package entry from a package database. */
alpm_pkg_t SYMEXPORT *alpm_db_get_pkg(alpm_db_t *db, const char *name)
{
alpm_pkg_t *pkg;
@@ -269,7 +244,6 @@ alpm_pkg_t SYMEXPORT *alpm_db_get_pkg(alpm_db_t *db, const char *name)
return pkg;
}
/** Get the package cache of a package database. */
alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(alpm_db_t *db)
{
ASSERT(db != NULL, return NULL);
@@ -277,7 +251,6 @@ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(alpm_db_t *db)
return _alpm_db_get_pkgcache(db);
}
/** Get a group entry from a package database. */
alpm_group_t SYMEXPORT *alpm_db_get_group(alpm_db_t *db, const char *name)
{
ASSERT(db != NULL, return NULL);
@@ -288,7 +261,6 @@ alpm_group_t SYMEXPORT *alpm_db_get_group(alpm_db_t *db, const char *name)
return _alpm_db_get_groupfromcache(db, name);
}
/** Get the group cache of a package database. */
alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db)
{
ASSERT(db != NULL, return NULL);
@@ -297,16 +269,16 @@ alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db)
return _alpm_db_get_groupcache(db);
}
/** Searches a database. */
alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
int SYMEXPORT alpm_db_search(alpm_db_t *db, const alpm_list_t *needles,
alpm_list_t **ret)
{
ASSERT(db != NULL, return NULL);
ASSERT(db != NULL && ret != NULL && *ret == NULL,
RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
db->handle->pm_errno = ALPM_ERR_OK;
return _alpm_db_search(db, needles);
return _alpm_db_search(db, needles, ret);
}
/** Sets the usage bitmask for a repo */
int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, int usage)
{
ASSERT(db != NULL, return -1);
@@ -314,7 +286,6 @@ int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, int usage)
return 0;
}
/** Gets the usage bitmask for a repo */
int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, int *usage)
{
ASSERT(db != NULL, return -1);
@@ -323,9 +294,6 @@ int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, int *usage)
return 0;
}
/** @} */
alpm_db_t *_alpm_db_new(const char *treename, int is_local)
{
alpm_db_t *db;
@@ -396,13 +364,13 @@ int _alpm_db_cmp(const void *d1, const void *d2)
return strcmp(db1->treename, db2->treename);
}
alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
int _alpm_db_search(alpm_db_t *db, const alpm_list_t *needles,
alpm_list_t **ret)
{
const alpm_list_t *i, *j, *k;
alpm_list_t *ret = NULL;
if(!(db->usage & ALPM_DB_USAGE_SEARCH)) {
return NULL;
return 0;
}
/* copy the pkgcache- we will free the list var after each needle */
@@ -415,12 +383,15 @@ alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
if(i->data == NULL) {
continue;
}
ret = NULL;
*ret = NULL;
targ = i->data;
_alpm_log(db->handle, ALPM_LOG_DEBUG, "searching for target '%s'\n", targ);
if(regcomp(&reg, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) {
RET_ERR(db->handle, ALPM_ERR_INVALID_REGEX, NULL);
db->handle->pm_errno = ALPM_ERR_INVALID_REGEX;
alpm_list_free(list);
alpm_list_free(*ret);
return -1;
}
for(j = list; j; j = j->next) {
@@ -463,18 +434,18 @@ alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
_alpm_log(db->handle, ALPM_LOG_DEBUG,
"search target '%s' matched '%s' on package '%s'\n",
targ, matched, name);
ret = alpm_list_add(ret, pkg);
*ret = alpm_list_add(*ret, pkg);
}
}
/* Free the existing search list, and use the returned list for the
* next needle. This allows for AND-based package searching. */
alpm_list_free(list);
list = ret;
list = *ret;
regfree(&reg);
}
return ret;
return 0;
}
/* Returns a new package cache from db.

View File

@@ -1,7 +1,7 @@
/*
* db.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -87,7 +87,8 @@ alpm_db_t *_alpm_db_new(const char *treename, int is_local);
void _alpm_db_free(alpm_db_t *db);
const char *_alpm_db_path(alpm_db_t *db);
int _alpm_db_cmp(const void *d1, const void *d2);
alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
int _alpm_db_search(alpm_db_t *db, const alpm_list_t *needles,
alpm_list_t **ret);
alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle);
alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
int level);

View File

@@ -1,7 +1,7 @@
/*
* deps.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -286,12 +286,6 @@ static int no_dep_version(alpm_handle_t *handle)
return (handle->trans->flags & ALPM_TRANS_FLAG_NODEPVERSION);
}
/** Find a package satisfying a specified dependency.
* The dependency can include versions with depmod operators.
* @param pkgs an alpm_list_t* of alpm_pkg_t where the satisfier will be searched
* @param depstring package or provision name, versioned or not
* @return a alpm_pkg_t* satisfying depstring
*/
alpm_pkg_t SYMEXPORT *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring)
{
alpm_depend_t *dep = alpm_dep_from_string(depstring);
@@ -303,15 +297,6 @@ alpm_pkg_t SYMEXPORT *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstri
return pkg;
}
/** Checks dependencies and returns missing ones in a list.
* Dependencies can include versions with depmod operators.
* @param handle the context handle
* @param pkglist the list of local packages
* @param remove an alpm_list_t* of packages to be removed
* @param upgrade an alpm_list_t* of packages to be upgraded (remove-then-upgrade)
* @param reversedeps handles the backward dependencies
* @return an alpm_list_t* of alpm_depmissing_t pointers.
*/
alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle,
alpm_list_t *pkglist, alpm_list_t *rem, alpm_list_t *upgrade,
int reversedeps)
@@ -763,18 +748,6 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
return NULL;
}
/** Find a package satisfying a specified dependency.
* First look for a literal, going through each db one by one. Then look for
* providers. The first satisfier that belongs to an installed package is
* returned. If no providers belong to an installed package then an
* alpm_question_select_provider_t is created to select the provider.
* The dependency can include versions with depmod operators.
*
* @param handle the context handle
* @param dbs an alpm_list_t* of alpm_db_t where the satisfier will be searched
* @param depstring package or provision name, versioned or not
* @return a alpm_pkg_t* satisfying depstring
*/
alpm_pkg_t SYMEXPORT *alpm_find_dbs_satisfier(alpm_handle_t *handle,
alpm_list_t *dbs, const char *depstring)
{
@@ -889,11 +862,6 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs,
return ret;
}
/** Reverse of splitdep; make a dep string from a alpm_depend_t struct.
* The string must be freed!
* @param dep the depend to turn into a string
* @return a string-formatted dependency with operator if necessary
*/
char SYMEXPORT *alpm_dep_compute_string(const alpm_depend_t *dep)
{
const char *name, *opr, *ver, *desc_delim, *desc;

View File

@@ -1,7 +1,7 @@
/*
* deps.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>

View File

@@ -1,7 +1,7 @@
/*
* diskspace.c
*
* Copyright (c) 2010-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2010-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -359,7 +359,7 @@ static int check_mountpoint(alpm_handle_t *handle, alpm_mountpoint_t *mp)
}
int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir,
size_t num_files, off_t *file_sizes)
size_t num_files, const off_t *file_sizes)
{
alpm_list_t *mount_points;
alpm_mountpoint_t *cachedir_mp;

View File

@@ -1,7 +1,7 @@
/*
* diskspace.h
*
* Copyright (c) 2010-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2010-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -58,6 +58,6 @@ typedef struct __alpm_mountpoint_t {
int _alpm_check_diskspace(alpm_handle_t *handle);
int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir,
size_t num_files, off_t *file_sizes);
size_t num_files, const off_t *file_sizes);
#endif /* ALPM_DISKSPACE_H */

View File

@@ -1,7 +1,7 @@
/*
* dload.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
@@ -49,6 +50,10 @@
#include "handle.h"
#ifdef HAVE_LIBCURL
static int curl_add_payload(alpm_handle_t *handle, CURLM *curlm,
struct dload_payload *payload, const char *localpath);
static const char *get_filename(const char *url)
{
char *filename = strrchr(url, '/');
@@ -72,31 +77,24 @@ static char *get_fullpath(const char *path, const char *filename,
return filepath;
}
static CURL *get_libcurl_handle(alpm_handle_t *handle)
{
if(!handle->curl) {
curl_global_init(CURL_GLOBAL_SSL);
handle->curl = curl_easy_init();
}
return handle->curl;
}
enum {
ABORT_SIGINT = 1,
ABORT_OVER_MAXFILESIZE
};
static int dload_interrupted;
static void inthandler(int UNUSED signum)
{
dload_interrupted = ABORT_SIGINT;
}
static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow,
curl_off_t UNUSED ultotal, curl_off_t UNUSED ulnow)
{
struct dload_payload *payload = (struct dload_payload *)file;
off_t current_size, total_size;
alpm_download_event_progress_t cb_data = {0};
/* do not print signature files progress bar */
if(payload->signature) {
return 0;
}
/* avoid displaying progress bar for redirects with a body */
if(payload->respcode >= 300) {
@@ -108,6 +106,11 @@ static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow,
return 1;
}
if(dlnow < 0 || dltotal <= 0 || dlnow > dltotal) {
/* bogus values : stop here */
return 0;
}
current_size = payload->initial_size + dlnow;
/* is our filesize still under any set limit? */
@@ -123,30 +126,15 @@ static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow,
total_size = payload->initial_size + dltotal;
if(dltotal == 0 || payload->prevprogress == total_size) {
if(payload->prevprogress == total_size) {
return 0;
}
/* initialize the progress bar here to avoid displaying it when
* a repo is up to date and nothing gets downloaded.
* payload->handle->dlcb will receive the remote_name
* and the following arguments:
* 0, -1: download initialized
* 0, 0: non-download event
* x {x>0}, x: download complete
* x {x>0, x<y}, y {y > 0}: download progress, expected total is known */
if(!payload->cb_initialized) {
payload->handle->dlcb(payload->remote_name, 0, -1);
payload->cb_initialized = 1;
}
if(payload->prevprogress == current_size) {
payload->handle->dlcb(payload->remote_name, 0, 0);
} else {
/* do NOT include initial_size since it wasn't part of the package's
* download_size (nor included in the total download size callback) */
payload->handle->dlcb(payload->remote_name, dlnow, dltotal);
}
cb_data.total = dltotal;
cb_data.downloaded = dlnow;
payload->handle->dlcb(payload->remote_name, ALPM_DOWNLOAD_PROGRESS, &cb_data);
payload->prevprogress = current_size;
return 0;
@@ -195,9 +183,10 @@ static int curl_gethost(const char *url, char *buffer, size_t buf_len)
static int utimes_long(const char *path, long seconds)
{
if(seconds != -1) {
struct timeval tv[2];
memset(&tv, 0, sizeof(tv));
tv[0].tv_sec = tv[1].tv_sec = seconds;
struct timeval tv[2] = {
{ .tv_sec = seconds, },
{ .tv_sec = seconds, },
};
return utimes(path, tv);
}
return 0;
@@ -240,7 +229,7 @@ static size_t dload_parseheader_cb(void *ptr, size_t size, size_t nmemb, void *u
}
}
curl_easy_getinfo(payload->handle->curl, CURLINFO_RESPONSE_CODE, &respcode);
curl_easy_getinfo(payload->curl, CURLINFO_RESPONSE_CODE, &respcode);
if(payload->respcode != respcode) {
payload->respcode = respcode;
}
@@ -248,8 +237,7 @@ static size_t dload_parseheader_cb(void *ptr, size_t size, size_t nmemb, void *u
return realsize;
}
static void curl_set_handle_opts(struct dload_payload *payload,
CURL *curl, char *error_buffer)
static void curl_set_handle_opts(CURL *curl, struct dload_payload *payload)
{
alpm_handle_t *handle = payload->handle;
const char *useragent = getenv("HTTP_USER_AGENT");
@@ -259,7 +247,7 @@ static void curl_set_handle_opts(struct dload_payload *payload,
* to reset the handle's parameters for each time it's used. */
curl_easy_reset(curl);
curl_easy_setopt(curl, CURLOPT_URL, payload->fileurl);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, payload->error_buffer);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 10L);
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
@@ -278,12 +266,14 @@ static void curl_set_handle_opts(struct dload_payload *payload,
curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 60L);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_easy_setopt(curl, CURLOPT_PRIVATE, (void *)payload);
_alpm_log(handle, ALPM_LOG_DEBUG, "url: %s\n", payload->fileurl);
_alpm_log(handle, ALPM_LOG_DEBUG, "%s: url is %s\n",
payload->remote_name, payload->fileurl);
if(payload->max_size) {
_alpm_log(handle, ALPM_LOG_DEBUG, "maxsize: %jd\n",
(intmax_t)payload->max_size);
_alpm_log(handle, ALPM_LOG_DEBUG, "%s: maxsize %jd\n",
payload->remote_name, (intmax_t)payload->max_size);
curl_easy_setopt(curl, CURLOPT_MAXFILESIZE_LARGE,
(curl_off_t)payload->max_size);
}
@@ -292,42 +282,25 @@ static void curl_set_handle_opts(struct dload_payload *payload,
curl_easy_setopt(curl, CURLOPT_USERAGENT, useragent);
}
if(!payload->allow_resume && !payload->force && payload->destfile_name &&
if(!payload->force && payload->destfile_name &&
stat(payload->destfile_name, &st) == 0) {
/* start from scratch, but only download if our local is out of date. */
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
curl_easy_setopt(curl, CURLOPT_TIMEVALUE, (long)st.st_mtime);
_alpm_log(handle, ALPM_LOG_DEBUG,
"using time condition: %ld\n", (long)st.st_mtime);
"%s: using time condition %ld\n",
payload->remote_name, (long)st.st_mtime);
} else if(stat(payload->tempfile_name, &st) == 0 && payload->allow_resume) {
/* a previous partial download exists, resume from end of file. */
payload->tempfile_openmode = "ab";
curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, (curl_off_t)st.st_size);
_alpm_log(handle, ALPM_LOG_DEBUG,
"tempfile found, attempting continuation from %jd bytes\n",
(intmax_t)st.st_size);
"%s: tempfile found, attempting continuation from %jd bytes\n",
payload->remote_name, (intmax_t)st.st_size);
payload->initial_size = st.st_size;
}
}
static void mask_signal(int signum, void (*handler)(int),
struct sigaction *origaction)
{
struct sigaction newaction;
newaction.sa_handler = handler;
sigemptyset(&newaction.sa_mask);
newaction.sa_flags = 0;
sigaction(signum, NULL, origaction);
sigaction(signum, &newaction, NULL);
}
static void unmask_signal(int signum, struct sigaction *sa)
{
sigaction(signum, sa, NULL);
}
static FILE *create_tempfile(struct dload_payload *payload, const char *localpath)
{
int fd;
@@ -362,115 +335,105 @@ static FILE *create_tempfile(struct dload_payload *payload, const char *localpat
/* RFC1123 states applications should support this length */
#define HOSTNAME_SIZE 256
static int curl_download_internal(struct dload_payload *payload,
const char *localpath, char **final_file, const char **final_url)
/* Return 0 if retry was successful, -1 otherwise */
static int curl_retry_next_server(CURLM *curlm, CURL *curl, struct dload_payload *payload)
{
int ret = -1;
FILE *localf = NULL;
char *effective_url;
char hostname[HOSTNAME_SIZE];
char error_buffer[CURL_ERROR_SIZE] = {0};
struct stat st;
long timecond, remote_time = -1;
double remote_size, bytes_dl;
struct sigaction orig_sig_pipe, orig_sig_int;
/* shortcut to our handle within the payload */
const char *server;
size_t len;
alpm_handle_t *handle = payload->handle;
CURL *curl = get_libcurl_handle(handle);
handle->pm_errno = ALPM_ERR_OK;
/* make sure these are NULL */
FREE(payload->tempfile_name);
FREE(payload->destfile_name);
FREE(payload->content_disp_name);
payload->tempfile_openmode = "wb";
if(!payload->remote_name) {
STRDUP(payload->remote_name, get_filename(payload->fileurl),
RET_ERR(handle, ALPM_ERR_MEMORY, -1));
if(payload->servers) {
payload->servers = payload->servers->next;
}
if(curl_gethost(payload->fileurl, hostname, sizeof(hostname)) != 0) {
_alpm_log(handle, ALPM_LOG_ERROR, _("url '%s' is invalid\n"), payload->fileurl);
RET_ERR(handle, ALPM_ERR_SERVER_BAD_URL, -1);
if(!payload->servers) {
_alpm_log(payload->handle, ALPM_LOG_DEBUG,
"%s: no more servers to retry\n", payload->remote_name);
return -1;
}
server = payload->servers->data;
if(payload->remote_name && strlen(payload->remote_name) > 0 &&
strcmp(payload->remote_name, ".sig") != 0) {
payload->destfile_name = get_fullpath(localpath, payload->remote_name, "");
payload->tempfile_name = get_fullpath(localpath, payload->remote_name, ".part");
if(!payload->destfile_name || !payload->tempfile_name) {
goto cleanup;
}
} else {
/* URL doesn't contain a filename, so make a tempfile. We can't support
* resuming this kind of download; partial transfers will be destroyed */
payload->unlink_on_fail = 1;
localf = create_tempfile(payload, localpath);
if(localf == NULL) {
goto cleanup;
/* regenerate a new fileurl */
FREE(payload->fileurl);
len = strlen(server) + strlen(payload->filepath) + 2;
MALLOC(payload->fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(payload->fileurl, len, "%s/%s", server, payload->filepath);
if(payload->unlink_on_fail) {
/* we keep the file for a new retry but remove its data if any */
fflush(payload->localf);
if(ftruncate(fileno(payload->localf), 0)) {
RET_ERR(handle, ALPM_ERR_SYSTEM, -1);
}
fseek(payload->localf, 0, SEEK_SET);
}
curl_set_handle_opts(payload, curl, error_buffer);
/* Set curl with the new URL */
curl_easy_setopt(curl, CURLOPT_URL, payload->fileurl);
if(localf == NULL) {
localf = fopen(payload->tempfile_name, payload->tempfile_openmode);
if(localf == NULL) {
handle->pm_errno = ALPM_ERR_RETRIEVE;
_alpm_log(handle, ALPM_LOG_ERROR,
_("could not open file %s: %s\n"),
payload->tempfile_name, strerror(errno));
goto cleanup;
}
}
curl_multi_remove_handle(curlm, curl);
curl_multi_add_handle(curlm, curl);
_alpm_log(handle, ALPM_LOG_DEBUG,
"opened tempfile for download: %s (%s)\n", payload->tempfile_name,
payload->tempfile_openmode);
return 0;
}
curl_easy_setopt(curl, CURLOPT_WRITEDATA, localf);
/* Returns 2 if download retry happened
* Returns 1 if the file is up-to-date
* Returns 0 if current payload is completed successfully
* Returns -1 if an error happened for a required file
* Returns -2 if an error happened for an optional file
*/
static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
const char *localpath)
{
alpm_handle_t *handle = NULL;
struct dload_payload *payload = NULL;
CURL *curl = msg->easy_handle;
CURLcode curlerr;
char *effective_url;
long timecond;
double remote_size, bytes_dl = 0;
long remote_time = -1;
struct stat st;
char hostname[HOSTNAME_SIZE];
int ret = -1;
/* Ignore any SIGPIPE signals. With libcurl, these shouldn't be happening,
* but better safe than sorry. Store the old signal handler first. */
mask_signal(SIGPIPE, SIG_IGN, &orig_sig_pipe);
dload_interrupted = 0;
mask_signal(SIGINT, &inthandler, &orig_sig_int);
curlerr = curl_easy_getinfo(curl, CURLINFO_PRIVATE, &payload);
ASSERT(curlerr == CURLE_OK, RET_ERR(handle, ALPM_ERR_LIBCURL, -1));
handle = payload->handle;
/* perform transfer */
payload->curlerr = curl_easy_perform(curl);
_alpm_log(handle, ALPM_LOG_DEBUG, "curl returned error %d from transfer\n",
payload->curlerr);
/* disconnect relationships from the curl handle for things that might go out
* of scope, but could still be touched on connection teardown. This really
* only applies to FTP transfers. */
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, (char *)NULL);
curl_gethost(payload->fileurl, hostname, sizeof(hostname));
curlerr = msg->data.result;
_alpm_log(handle, ALPM_LOG_DEBUG, "%s: curl returned result %d from transfer\n",
payload->remote_name, curlerr);
/* was it a success? */
switch(payload->curlerr) {
switch(curlerr) {
case CURLE_OK:
/* get http/ftp response code */
_alpm_log(handle, ALPM_LOG_DEBUG, "response code: %ld\n", payload->respcode);
_alpm_log(handle, ALPM_LOG_DEBUG, "%s: response code %ld\n",
payload->remote_name, payload->respcode);
if(payload->respcode >= 400) {
payload->unlink_on_fail = 1;
if(!payload->errors_ok) {
handle->pm_errno = ALPM_ERR_RETRIEVE;
/* non-translated message is same as libcurl */
snprintf(error_buffer, sizeof(error_buffer),
snprintf(payload->error_buffer, sizeof(payload->error_buffer),
"The requested URL returned error: %ld", payload->respcode);
_alpm_log(handle, ALPM_LOG_ERROR,
_("failed retrieving file '%s' from %s : %s\n"),
payload->remote_name, hostname, error_buffer);
payload->remote_name, hostname, payload->error_buffer);
}
if(curl_retry_next_server(curlm, curl, payload) == 0) {
return 2;
} else {
goto cleanup;
}
goto cleanup;
}
break;
case CURLE_ABORTED_BY_CALLBACK:
/* handle the interrupt accordingly */
if(dload_interrupted == ABORT_OVER_MAXFILESIZE) {
payload->curlerr = CURLE_FILESIZE_EXCEEDED;
curlerr = CURLE_FILESIZE_EXCEEDED;
payload->unlink_on_fail = 1;
handle->pm_errno = ALPM_ERR_LIBCURL;
_alpm_log(handle, ALPM_LOG_ERROR,
@@ -483,24 +446,32 @@ static int curl_download_internal(struct dload_payload *payload,
handle->pm_errno = ALPM_ERR_SERVER_BAD_URL;
_alpm_log(handle, ALPM_LOG_ERROR,
_("failed retrieving file '%s' from %s : %s\n"),
payload->remote_name, hostname, error_buffer);
goto cleanup;
payload->remote_name, hostname, payload->error_buffer);
if(curl_retry_next_server(curlm, curl, payload) == 0) {
return 2;
} else {
goto cleanup;
}
default:
/* delete zero length downloads */
if(fstat(fileno(localf), &st) == 0 && st.st_size == 0) {
if(fstat(fileno(payload->localf), &st) == 0 && st.st_size == 0) {
payload->unlink_on_fail = 1;
}
if(!payload->errors_ok) {
handle->pm_errno = ALPM_ERR_LIBCURL;
_alpm_log(handle, ALPM_LOG_ERROR,
_("failed retrieving file '%s' from %s : %s\n"),
payload->remote_name, hostname, error_buffer);
payload->remote_name, hostname, payload->error_buffer);
} else {
_alpm_log(handle, ALPM_LOG_DEBUG,
"failed retrieving file '%s' from %s : %s\n",
payload->remote_name, hostname, error_buffer);
payload->remote_name, hostname, payload->error_buffer);
}
if(curl_retry_next_server(curlm, curl, payload) == 0) {
return 2;
} else {
goto cleanup;
}
goto cleanup;
}
/* retrieve info about the state of the transfer */
@@ -510,30 +481,6 @@ static int curl_download_internal(struct dload_payload *payload,
curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &timecond);
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effective_url);
if(final_url != NULL) {
*final_url = effective_url;
}
/* time condition was met and we didn't download anything. we need to
* clean up the 0 byte .part file that's left behind. */
if(timecond == 1 && DOUBLE_EQ(bytes_dl, 0)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "file met time condition\n");
ret = 1;
unlink(payload->tempfile_name);
goto cleanup;
}
/* remote_size isn't necessarily the full size of the file, just what the
* server reported as remaining to download. compare it to what curl reported
* as actually being transferred during curl_easy_perform() */
if(!DOUBLE_EQ(remote_size, -1) && !DOUBLE_EQ(bytes_dl, -1) &&
!DOUBLE_EQ(bytes_dl, remote_size)) {
handle->pm_errno = ALPM_ERR_RETRIEVE;
_alpm_log(handle, ALPM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"),
payload->remote_name, (intmax_t)bytes_dl, (intmax_t)remote_size);
goto cleanup;
}
if(payload->trust_remote_name) {
if(payload->content_disp_name) {
/* content-disposition header has a better name for our file */
@@ -542,6 +489,7 @@ static int curl_download_internal(struct dload_payload *payload,
get_filename(payload->content_disp_name), "");
} else {
const char *effective_filename = strrchr(effective_url, '/');
if(effective_filename && strlen(effective_filename) > 2) {
effective_filename++;
@@ -558,28 +506,79 @@ static int curl_download_internal(struct dload_payload *payload,
}
}
/* Let's check if client requested downloading accompanion *.sig file */
if(!payload->signature && payload->download_signature && curlerr == CURLE_OK && payload->respcode < 400) {
struct dload_payload *sig = NULL;
int len = strlen(effective_url) + 5;
CALLOC(sig, 1, sizeof(*sig), GOTO_ERR(handle, ALPM_ERR_MEMORY, cleanup));
MALLOC(sig->fileurl, len, FREE(sig); GOTO_ERR(handle, ALPM_ERR_MEMORY, cleanup));
snprintf(sig->fileurl, len, "%s.sig", effective_url);
if(payload->trust_remote_name) {
/* In this case server might provide a new name for the main payload.
* Choose *.sig filename based on this new name.
*/
const char* realname = payload->destfile_name ? payload->destfile_name : payload->tempfile_name;
const char *final_file = get_filename(realname);
int remote_name_len = strlen(final_file) + 5;
MALLOC(sig->remote_name, remote_name_len, FREE(sig->fileurl); FREE(sig); GOTO_ERR(handle, ALPM_ERR_MEMORY, cleanup));
snprintf(sig->remote_name, remote_name_len, "%s.sig", final_file);
}
sig->signature = 1;
sig->handle = handle;
sig->force = payload->force;
sig->unlink_on_fail = payload->unlink_on_fail;
sig->errors_ok = payload->signature_optional;
/* set hard upper limit of 16KiB */
sig->max_size = 16 * 1024;
curl_add_payload(handle, curlm, sig, localpath);
}
/* time condition was met and we didn't download anything. we need to
* clean up the 0 byte .part file that's left behind. */
if(timecond == 1 && DOUBLE_EQ(bytes_dl, 0)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "%s: file met time condition\n",
payload->remote_name);
ret = 1;
unlink(payload->tempfile_name);
goto cleanup;
}
/* remote_size isn't necessarily the full size of the file, just what the
* server reported as remaining to download. compare it to what curl reported
* as actually being transferred during curl_easy_perform() */
if(!DOUBLE_EQ(remote_size, -1) && !DOUBLE_EQ(bytes_dl, -1) &&
!DOUBLE_EQ(bytes_dl, remote_size)) {
_alpm_log(handle, ALPM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"),
payload->remote_name, (intmax_t)bytes_dl, (intmax_t)remote_size);
GOTO_ERR(handle, ALPM_ERR_RETRIEVE, cleanup);
}
ret = 0;
cleanup:
if(localf != NULL) {
fclose(localf);
/* disconnect relationships from the curl handle for things that might go out
* of scope, but could still be touched on connection teardown. This really
* only applies to FTP transfers. */
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, (char *)NULL);
if(payload->localf != NULL) {
fclose(payload->localf);
utimes_long(payload->tempfile_name, remote_time);
}
if(ret == 0) {
const char *realname = payload->tempfile_name;
if(payload->destfile_name) {
realname = payload->destfile_name;
if(rename(payload->tempfile_name, payload->destfile_name)) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
payload->tempfile_name, payload->destfile_name, strerror(errno));
ret = -1;
}
}
if(ret != -1 && final_file) {
STRDUP(*final_file, strrchr(realname, '/') + 1,
RET_ERR(handle, ALPM_ERR_MEMORY, -1));
}
}
if((ret == -1 || dload_interrupted) && payload->unlink_on_fail &&
@@ -587,45 +586,245 @@ cleanup:
unlink(payload->tempfile_name);
}
/* restore the old signal handlers */
unmask_signal(SIGINT, &orig_sig_int);
unmask_signal(SIGPIPE, &orig_sig_pipe);
/* if we were interrupted, trip the old handler */
if(dload_interrupted == ABORT_SIGINT) {
raise(SIGINT);
if(handle->dlcb && !payload->signature) {
alpm_download_event_completed_t cb_data = {0};
cb_data.total = bytes_dl;
cb_data.result = ret;
handle->dlcb(payload->remote_name, ALPM_DOWNLOAD_COMPLETED, &cb_data);
}
curl_multi_remove_handle(curlm, curl);
curl_easy_cleanup(curl);
payload->curl = NULL;
FREE(payload->fileurl);
if(ret == -1 && payload->errors_ok) {
ret = -2;
}
if(payload->signature) {
/* free signature payload memory that was allocated earlier in dload.c */
_alpm_dload_payload_reset(payload);
FREE(payload);
}
return ret;
}
/* Returns 0 in case if a new download transaction has been successfully started
* Returns -1 if am error happened while starting a new download
*/
static int curl_add_payload(alpm_handle_t *handle, CURLM *curlm,
struct dload_payload *payload, const char *localpath)
{
size_t len;
CURL *curl = NULL;
char hostname[HOSTNAME_SIZE];
int ret = -1;
curl = curl_easy_init();
payload->curl = curl;
if(payload->fileurl) {
ASSERT(!payload->servers, GOTO_ERR(handle, ALPM_ERR_WRONG_ARGS, cleanup));
ASSERT(!payload->filepath, GOTO_ERR(handle, ALPM_ERR_WRONG_ARGS, cleanup));
} else {
const char *server;
ASSERT(payload->servers, GOTO_ERR(handle, ALPM_ERR_SERVER_NONE, cleanup));
ASSERT(payload->filepath, GOTO_ERR(handle, ALPM_ERR_WRONG_ARGS, cleanup));
server = payload->servers->data;
len = strlen(server) + strlen(payload->filepath) + 2;
MALLOC(payload->fileurl, len, GOTO_ERR(handle, ALPM_ERR_MEMORY, cleanup));
snprintf(payload->fileurl, len, "%s/%s", server, payload->filepath);
}
payload->tempfile_openmode = "wb";
if(!payload->remote_name) {
STRDUP(payload->remote_name, get_filename(payload->fileurl),
GOTO_ERR(handle, ALPM_ERR_MEMORY, cleanup));
}
if(curl_gethost(payload->fileurl, hostname, sizeof(hostname)) != 0) {
_alpm_log(handle, ALPM_LOG_ERROR, _("url '%s' is invalid\n"), payload->fileurl);
GOTO_ERR(handle, ALPM_ERR_SERVER_BAD_URL, cleanup);
}
if(payload->remote_name && strlen(payload->remote_name) > 0) {
payload->destfile_name = get_fullpath(localpath, payload->remote_name, "");
payload->tempfile_name = get_fullpath(localpath, payload->remote_name, ".part");
if(!payload->destfile_name || !payload->tempfile_name) {
goto cleanup;
}
} else {
/* URL doesn't contain a filename, so make a tempfile. We can't support
* resuming this kind of download; partial transfers will be destroyed */
payload->unlink_on_fail = 1;
payload->localf = create_tempfile(payload, localpath);
if(payload->localf == NULL) {
goto cleanup;
}
}
curl_set_handle_opts(curl, payload);
if(payload->max_size == payload->initial_size && payload->max_size != 0) {
/* .part file is complete */
ret = 0;
goto cleanup;
}
if(payload->localf == NULL) {
payload->localf = fopen(payload->tempfile_name, payload->tempfile_openmode);
if(payload->localf == NULL) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("could not open file %s: %s\n"),
payload->tempfile_name, strerror(errno));
GOTO_ERR(handle, ALPM_ERR_RETRIEVE, cleanup);
}
}
_alpm_log(handle, ALPM_LOG_DEBUG,
"%s: opened tempfile for download: %s (%s)\n",
payload->remote_name,
payload->tempfile_name,
payload->tempfile_openmode);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, payload->localf);
curl_multi_add_handle(curlm, curl);
return 0;
cleanup:
curl_easy_cleanup(curl);
return ret;
}
static int curl_download_internal(alpm_handle_t *handle,
alpm_list_t *payloads /* struct dload_payload */,
const char *localpath)
{
int active_downloads_num = 0;
bool recheck_downloads = false;
int err = 0;
int max_streams = handle->parallel_downloads;
CURLM *curlm = handle->curlm;
while(active_downloads_num > 0 || payloads || recheck_downloads) {
CURLMcode mc;
for(; active_downloads_num < max_streams && payloads; active_downloads_num++) {
struct dload_payload *payload = payloads->data;
if(curl_add_payload(handle, curlm, payload, localpath) == 0) {
if(handle->dlcb && !payload->signature) {
alpm_download_event_init_t cb_data = {.optional = payload->errors_ok};
handle->dlcb(payload->remote_name, ALPM_DOWNLOAD_INIT, &cb_data);
}
payloads = payloads->next;
} else {
/* The payload failed to start. Do not start any new downloads.
* Wait until all active downloads complete.
*/
_alpm_log(handle, ALPM_LOG_ERROR, _("failed to setup a download payload for %s\n"), payload->remote_name);
payloads = NULL;
err = -1;
}
}
mc = curl_multi_perform(curlm, &active_downloads_num);
if(mc == CURLM_OK) {
mc = curl_multi_wait(curlm, NULL, 0, 1000, NULL);
}
if(mc != CURLM_OK) {
_alpm_log(handle, ALPM_LOG_ERROR, _("curl returned error %d from transfer\n"), mc);
payloads = NULL;
err = -1;
}
recheck_downloads = false;
while(true) {
int msgs_left = 0;
CURLMsg *msg = curl_multi_info_read(curlm, &msgs_left);
if(!msg) {
break;
}
if(msg->msg == CURLMSG_DONE) {
int ret = curl_check_finished_download(curlm, msg, localpath);
if(ret == -1) {
/* if current payload failed to download then stop adding new payloads but wait for the
* current ones
*/
payloads = NULL;
err = -1;
}
/* curl_multi_check_finished_download() might add more payloads e.g. in case of a retry
* from the next mirror. We need to execute curl_multi_perform() at least one more time
* to make sure new payload requests are processed.
*/
recheck_downloads = true;
} else {
_alpm_log(handle, ALPM_LOG_ERROR, _("curl transfer error: %d\n"), msg->msg);
}
}
}
_alpm_log(handle, ALPM_LOG_DEBUG, "curl_download_internal return code is %d\n", err);
return err;
}
#endif
/** Download a file given by a URL to a local directory.
* Does not overwrite an existing file if the download fails.
* @param payload the payload context
* @param localpath the directory to save the file in
* @param final_file the real name of the downloaded file (may be NULL)
* @return 0 on success, -1 on error (pm_errno is set accordingly if errors_ok == 0)
*/
int _alpm_download(struct dload_payload *payload, const char *localpath,
char **final_file, const char **final_url)
int _alpm_download(alpm_handle_t *handle,
alpm_list_t *payloads /* struct dload_payload */,
const char *localpath)
{
alpm_handle_t *handle = payload->handle;
if(handle->fetchcb == NULL) {
#ifdef HAVE_LIBCURL
return curl_download_internal(payload, localpath, final_file, final_url);
return curl_download_internal(handle, payloads, localpath);
#else
/* work around unused warnings when building without libcurl */
(void)final_file;
(void)final_url;
RET_ERR(handle, ALPM_ERR_EXTERNAL_DOWNLOAD, -1);
#endif
} else {
int ret = handle->fetchcb(payload->fileurl, localpath, payload->force);
if(ret == -1 && !payload->errors_ok) {
RET_ERR(handle, ALPM_ERR_EXTERNAL_DOWNLOAD, -1);
alpm_list_t *p;
for(p = payloads; p; p = p->next) {
struct dload_payload *payload = p->data;
alpm_list_t *s;
int success = 0;
if(payload->fileurl) {
if (handle->fetchcb(payload->fileurl, localpath, payload->force) != -1) {
success = 1;
break;
}
} else {
for(s = payload->servers; s; s = s->next) {
const char *server = s->data;
char *fileurl;
int ret;
size_t len = strlen(server) + strlen(payload->filepath) + 2;
MALLOC(fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(fileurl, len, "%s/%s", server, payload->filepath);
ret = handle->fetchcb(fileurl, localpath, payload->force);
free(fileurl);
if (ret != -1) {
success = 1;
break;
}
}
}
if(!success && !payload->errors_ok) {
RET_ERR(handle, ALPM_ERR_EXTERNAL_DOWNLOAD, -1);
}
}
return ret;
return 0;
}
}
@@ -645,84 +844,91 @@ static char *filecache_find_url(alpm_handle_t *handle, const char *url)
return _alpm_filecache_find(handle, filebase);
}
/** Fetch a remote pkg. */
char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
int SYMEXPORT alpm_fetch_pkgurl(alpm_handle_t *handle, const alpm_list_t *urls,
alpm_list_t **fetched)
{
char *filepath;
const char *cachedir, *final_pkg_url = NULL;
char *final_file = NULL;
struct dload_payload payload;
int ret = 0;
const char *cachedir;
alpm_list_t *payloads = NULL;
const alpm_list_t *i;
alpm_event_t event;
CHECK_HANDLE(handle, return NULL);
ASSERT(url, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL));
CHECK_HANDLE(handle, return -1);
ASSERT(*fetched == NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
/* find a valid cache dir to download to */
cachedir = _alpm_filecache_setup(handle);
memset(&payload, 0, sizeof(struct dload_payload));
for(i = urls; i; i = i->next) {
char *url = i->data;
/* attempt to find the file in our pkgcache */
filepath = filecache_find_url(handle, url);
if(filepath == NULL) {
STRDUP(payload.fileurl, url, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
payload.allow_resume = 1;
payload.handle = handle;
payload.trust_remote_name = 1;
/* attempt to find the file in our pkgcache */
char *filepath = filecache_find_url(handle, url);
if(filepath) {
/* the file is locally cached so add it to the output right away */
alpm_list_append(fetched, filepath);
} else {
struct dload_payload *payload = NULL;
/* download the file */
ret = _alpm_download(&payload, cachedir, &final_file, &final_pkg_url);
_alpm_dload_payload_reset(&payload);
if(ret == -1) {
_alpm_log(handle, ALPM_LOG_WARNING, _("failed to download %s\n"), url);
free(final_file);
return NULL;
ASSERT(url, GOTO_ERR(handle, ALPM_ERR_WRONG_ARGS, err));
CALLOC(payload, 1, sizeof(*payload), GOTO_ERR(handle, ALPM_ERR_MEMORY, err));
STRDUP(payload->fileurl, url, FREE(payload); GOTO_ERR(handle, ALPM_ERR_MEMORY, err));
payload->allow_resume = 1;
payload->handle = handle;
payload->trust_remote_name = 1;
payload->download_signature = (handle->siglevel & ALPM_SIG_PACKAGE);
payload->signature_optional = (handle->siglevel & ALPM_SIG_PACKAGE_OPTIONAL);
payloads = alpm_list_add(payloads, payload);
}
_alpm_log(handle, ALPM_LOG_DEBUG, "successfully downloaded %s\n", url);
}
/* attempt to download the signature */
if(ret == 0 && final_pkg_url && (handle->siglevel & ALPM_SIG_PACKAGE)) {
char *sig_filepath, *sig_final_file = NULL;
size_t len;
if(payloads) {
event.type = ALPM_EVENT_PKG_RETRIEVE_START;
EVENT(handle, &event);
if(_alpm_download(handle, payloads, cachedir) == -1) {
_alpm_log(handle, ALPM_LOG_WARNING, _("failed to retrieve some files\n"));
event.type = ALPM_EVENT_PKG_RETRIEVE_FAILED;
EVENT(handle, &event);
len = strlen(final_pkg_url) + 5;
MALLOC(payload.fileurl, len, free(final_file); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
snprintf(payload.fileurl, len, "%s.sig", final_pkg_url);
GOTO_ERR(handle, ALPM_ERR_RETRIEVE, err);
} else {
event.type = ALPM_EVENT_PKG_RETRIEVE_DONE;
EVENT(handle, &event);
}
sig_filepath = filecache_find_url(handle, payload.fileurl);
if(sig_filepath == NULL) {
payload.handle = handle;
payload.trust_remote_name = 1;
payload.force = 1;
payload.errors_ok = (handle->siglevel & ALPM_SIG_PACKAGE_OPTIONAL);
for(i = payloads; i; i = i->next) {
struct dload_payload *payload = i->data;
char *filepath;
/* set hard upper limit of 16KiB */
payload.max_size = 16 * 1024;
ret = _alpm_download(&payload, cachedir, &sig_final_file, NULL);
if(ret == -1 && !payload.errors_ok) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("failed to download %s\n"), payload.fileurl);
/* Warn now, but don't return NULL. We will fail later during package
* load time. */
} else if(ret == 0) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"successfully downloaded %s\n", payload.fileurl);
if(payload->signature) {
continue;
}
if(payload->destfile_name) {
const char *filename = mbasename(payload->destfile_name);
filepath = _alpm_filecache_find(handle, filename);
} else {
STRDUP(filepath, payload->tempfile_name, GOTO_ERR(handle, ALPM_ERR_MEMORY, err));
}
if(filepath) {
alpm_list_append(fetched, filepath);
} else {
_alpm_log(handle, ALPM_LOG_WARNING, _("download completed successfully but no file in the cache\n"));
GOTO_ERR(handle, ALPM_ERR_RETRIEVE, err);
}
FREE(sig_final_file);
}
free(sig_filepath);
_alpm_dload_payload_reset(&payload);
alpm_list_free_inner(payloads, (alpm_list_fn_free)_alpm_dload_payload_reset);
FREELIST(payloads);
}
/* we should be able to find the file the second time around */
if(filepath == NULL) {
filepath = _alpm_filecache_find(handle, final_file);
}
free(final_file);
return 0;
return filepath;
err:
alpm_list_free_inner(payloads, (alpm_list_fn_free)_alpm_dload_payload_reset);
FREELIST(payloads);
FREELIST(*fetched);
return -1;
}
void _alpm_dload_payload_reset(struct dload_payload *payload)
@@ -734,16 +940,6 @@ void _alpm_dload_payload_reset(struct dload_payload *payload)
FREE(payload->destfile_name);
FREE(payload->content_disp_name);
FREE(payload->fileurl);
memset(payload, '\0', sizeof(*payload));
}
void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload)
{
ASSERT(payload, return);
FREE(payload->fileurl);
payload->initial_size += payload->prevprogress;
payload->prevprogress = 0;
payload->unlink_on_fail = 0;
payload->cb_initialized = 0;
FREE(payload->filepath);
*payload = (struct dload_payload){0};
}

View File

@@ -1,7 +1,7 @@
/*
* dload.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -30,7 +30,13 @@ struct dload_payload {
char *tempfile_name;
char *destfile_name;
char *content_disp_name;
/* client has to provide either
* 1) fileurl - full URL to the file
* 2) pair of (servers, filepath), in this case ALPM iterates over the
* server list and tries to download "$server/$filepath"
*/
char *fileurl;
char *filepath; /* download URL path */
alpm_list_t *servers;
long respcode;
off_t initial_size;
@@ -41,16 +47,20 @@ struct dload_payload {
int errors_ok;
int unlink_on_fail;
int trust_remote_name;
int cb_initialized;
int download_signature; /* specifies if an accompanion *.sig file need to be downloaded*/
int signature_optional; /* *.sig file is optional */
#ifdef HAVE_LIBCURL
CURLcode curlerr; /* last error produced by curl */
CURL *curl;
char error_buffer[CURL_ERROR_SIZE];
FILE *localf; /* temp download file */
int signature; /* specifies if this payload is for a signature file */
#endif
};
void _alpm_dload_payload_reset(struct dload_payload *payload);
void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload);
int _alpm_download(struct dload_payload *payload, const char *localpath,
char **final_file, const char **final_url);
int _alpm_download(alpm_handle_t *handle,
alpm_list_t *payloads /* struct dload_payload */,
const char *localpath);
#endif /* ALPM_DLOAD_H */

View File

@@ -1,7 +1,7 @@
/*
* error.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -1,7 +1,7 @@
/*
* filelist.c
*
* Copyright (c) 2012-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2012-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/*
* filelist.h
*
* Copyright (c) 2012-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2012-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/*
* graph.c - helpful graph structure and setup/teardown methods
*
* Copyright (c) 2007-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/*
* graph.h - helpful graph structure and setup/teardown methods
*
* Copyright (c) 2007-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/*
* group.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -1,7 +1,7 @@
/*
* group.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -1,7 +1,7 @@
/*
* handle.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -64,11 +64,6 @@ void _alpm_handle_free(alpm_handle_t *handle)
closelog();
}
#ifdef HAVE_LIBCURL
/* release curl handle */
curl_easy_cleanup(handle->curl);
#endif
#ifdef HAVE_LIBGPGME
FREELIST(handle->known_keys);
#endif
@@ -105,7 +100,7 @@ int _alpm_handle_lock(alpm_handle_t *handle)
ASSERT(handle->lockfd < 0, return 0);
/* create the dir of the lockfile first */
dir = strdup(handle->lockfile);
STRDUP(dir, handle->lockfile, return -1);
ptr = strrchr(dir, '/');
if(ptr) {
*ptr = '\0';
@@ -123,12 +118,6 @@ int _alpm_handle_lock(alpm_handle_t *handle)
return (handle->lockfd >= 0 ? 0 : -1);
}
/** Remove the database lock file
* @param handle the context handle
* @return 0 on success, -1 on error
*
* @note Safe to call from inside signal handlers.
*/
int SYMEXPORT alpm_unlock(alpm_handle_t *handle)
{
ASSERT(handle != NULL, return -1);
@@ -311,6 +300,16 @@ const char SYMEXPORT *alpm_option_get_dbext(alpm_handle_t *handle)
return handle->dbext;
}
int SYMEXPORT alpm_option_get_parallel_downloads(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBCURL
return handle->parallel_downloads;
#else
return 1;
#endif
}
int SYMEXPORT alpm_option_set_logcb(alpm_handle_t *handle, alpm_cb_log cb)
{
CHECK_HANDLE(handle, return -1);
@@ -690,6 +689,7 @@ int SYMEXPORT alpm_option_set_assumeinstalled(alpm_handle_t *handle, alpm_list_t
if(handle->assumeinstalled) {
alpm_list_free_inner(handle->assumeinstalled, (alpm_list_fn_free)alpm_dep_free);
alpm_list_free(handle->assumeinstalled);
handle->assumeinstalled = NULL;
}
while(deps) {
if(alpm_option_add_assumeinstalled(handle, deps->data) != 0) {
@@ -861,3 +861,16 @@ int SYMEXPORT alpm_option_set_disable_dl_timeout(alpm_handle_t *handle,
#endif
return 0;
}
int SYMEXPORT alpm_option_set_parallel_downloads(alpm_handle_t *handle,
unsigned int num_streams)
{
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBCURL
ASSERT(num_streams >= 1, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
handle->parallel_downloads = num_streams;
#else
(void)num_streams; /* silence unused variable warnings */
#endif
return 0;
}

View File

@@ -1,7 +1,7 @@
/*
* handle.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -59,8 +59,9 @@ struct __alpm_handle_t {
#ifdef HAVE_LIBCURL
/* libcurl handle */
CURL *curl; /* reusable curl_easy handle */
CURLM *curlm;
unsigned short disable_dl_timeout;
unsigned int parallel_downloads; /* number of download streams */
#endif
#ifdef HAVE_LIBGPGME

View File

@@ -1,7 +1,7 @@
/*
* hook.c
*
* Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2015-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/*
* hook.h
*
* Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2015-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1 +0,0 @@
../../src/common/ini.c

View File

@@ -1 +0,0 @@
../../src/common/ini.h

View File

@@ -10,4 +10,4 @@ Version: @LIB_VERSION@
Requires.private: libarchive @pc_crypto@ @pc_libcurl@ @pc_gpgme@
Cflags: -I${includedir} @LFS_CFLAGS@
Libs: -L${libdir} -lalpm
Libs.private: @LIBS@ @pc_gpgme_libs@
Libs.private: @LIBS@ @pc_gpgme_libs@ @LIBINTL@

View File

@@ -4,7 +4,7 @@
/*
* libarchive-compat.h
*
* Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2013-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/*
* log.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -30,11 +30,6 @@
#include "util.h"
#include "alpm.h"
/** \addtogroup alpm_log Logging Functions
* @brief Functions to log using libalpm
* @{
*/
static int _alpm_log_leader(FILE *f, const char *prefix)
{
time_t t = time(NULL);
@@ -47,12 +42,6 @@ static int _alpm_log_leader(FILE *f, const char *prefix)
return fprintf(f, "[%s] [%s] ", timestamp, prefix);
}
/** A printf-like function for logging.
* @param handle the context handle
* @param prefix caller-specific prefix for the log
* @param fmt output format
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *prefix,
const char *fmt, ...)
{
@@ -109,8 +98,6 @@ int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *prefix,
return ret;
}
/** @} */
void _alpm_log(alpm_handle_t *handle, alpm_loglevel_t flag, const char *fmt, ...)
{
va_list args;

View File

@@ -1,7 +1,7 @@
/*
* log.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -1,7 +1,7 @@
/*
* package.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu>
@@ -34,12 +34,6 @@
#include "handle.h"
#include "deps.h"
/** \addtogroup alpm_packages Package Functions
* @brief Functions to manipulate libalpm packages
* @{
*/
/** Free a package. */
int SYMEXPORT alpm_pkg_free(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
@@ -52,7 +46,6 @@ int SYMEXPORT alpm_pkg_free(alpm_pkg_t *pkg)
return 0;
}
/** Check the integrity (with md5) of a package from the sync cache. */
int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
{
char *fpath;
@@ -275,6 +268,44 @@ const char SYMEXPORT *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg)
return pkg->base64_sig;
}
int SYMEXPORT alpm_pkg_get_sig(alpm_pkg_t *pkg, unsigned char **sig, size_t *sig_len)
{
ASSERT(pkg != NULL, return -1);
if(pkg->base64_sig) {
int ret = alpm_decode_signature(pkg->base64_sig, sig, sig_len);
if(ret != 0) {
RET_ERR(pkg->handle, ALPM_ERR_SIG_INVALID, -1);
}
return 0;
} else {
char *pkgpath = NULL, *sigpath = NULL;
alpm_errno_t err;
int ret = -1;
pkgpath = _alpm_filecache_find(pkg->handle, pkg->filename);
if(!pkgpath) {
GOTO_ERR(pkg->handle, ALPM_ERR_PKG_NOT_FOUND, cleanup);
}
sigpath = _alpm_sigpath(pkg->handle, pkgpath);
if(!sigpath || _alpm_access(pkg->handle, NULL, sigpath, R_OK)) {
GOTO_ERR(pkg->handle, ALPM_ERR_SIG_MISSING, cleanup);
}
err = _alpm_read_file(sigpath, sig, sig_len);
if(err == ALPM_ERR_OK) {
_alpm_log(pkg->handle, ALPM_LOG_DEBUG, "found detached signature %s with size %ld\n",
sigpath, *sig_len);
} else {
GOTO_ERR(pkg->handle, err, cleanup);
}
ret = 0;
cleanup:
FREE(pkgpath);
FREE(sigpath);
return ret;
}
}
const char SYMEXPORT *alpm_pkg_get_arch(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
@@ -397,7 +428,6 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
return pkg->origin_data.db;
}
/** Open a package changelog for reading. */
void SYMEXPORT *alpm_pkg_changelog_open(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
@@ -405,7 +435,6 @@ void SYMEXPORT *alpm_pkg_changelog_open(alpm_pkg_t *pkg)
return pkg->ops->changelog_open(pkg);
}
/** Read data from an open changelog 'file stream'. */
size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
const alpm_pkg_t *pkg, void *fp)
{
@@ -414,7 +443,6 @@ size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
return pkg->ops->changelog_read(ptr, size, pkg, fp);
}
/** Close a package changelog for reading. */
int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
{
ASSERT(pkg != NULL, return -1);
@@ -422,7 +450,6 @@ int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
return pkg->ops->changelog_close(pkg, fp);
}
/** Open a package mtree file for reading. */
struct archive SYMEXPORT *alpm_pkg_mtree_open(alpm_pkg_t * pkg)
{
ASSERT(pkg != NULL, return NULL);
@@ -430,7 +457,6 @@ struct archive SYMEXPORT *alpm_pkg_mtree_open(alpm_pkg_t * pkg)
return pkg->ops->mtree_open(pkg);
}
/** Read entry from an open mtree file. */
int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archive,
struct archive_entry **entry)
{
@@ -439,7 +465,6 @@ int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archiv
return pkg->ops->mtree_next(pkg, archive, entry);
}
/** Close a package mtree file for reading. */
int SYMEXPORT alpm_pkg_mtree_close(const alpm_pkg_t * pkg, struct archive *archive)
{
ASSERT(pkg != NULL, return -1);
@@ -510,21 +535,16 @@ static alpm_list_t *compute_requiredby(alpm_pkg_t *pkg, int optional)
return reqs;
}
/** Compute the packages requiring a given package. */
alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(alpm_pkg_t *pkg)
{
return compute_requiredby(pkg, 0);
}
/** Compute the packages optionally requiring a given package. */
alpm_list_t SYMEXPORT *alpm_pkg_compute_optionalfor(alpm_pkg_t *pkg)
{
return compute_requiredby(pkg, 1);
}
/** @} */
alpm_file_t *_alpm_file_copy(alpm_file_t *dest,
const alpm_file_t *src)
{
@@ -764,16 +784,6 @@ alpm_pkg_t SYMEXPORT *alpm_pkg_find(alpm_list_t *haystack, const char *needle)
return NULL;
}
/** Test if a package should be ignored.
*
* Checks if the package is ignored via IgnorePkg, or if the package is
* in a group ignored via IgnoreGroup.
*
* @param handle the context handle
* @param pkg the package to test
*
* @return 1 if the package should be ignored, 0 otherwise
*/
int SYMEXPORT alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg)
{
alpm_list_t *groups = NULL;

View File

@@ -1,7 +1,7 @@
/*
* package.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>

View File

@@ -1,7 +1,7 @@
/*
* pkghash.c
*
* Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2011-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/*
* pkghash.h
*
* Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2011-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/*
* remove.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -46,14 +46,6 @@
#include "handle.h"
#include "filelist.h"
/**
* @brief Add a package removal action to the transaction.
*
* @param handle the context handle
* @param pkg the package to uninstall
*
* @return 0 on success, -1 on error
*/
int SYMEXPORT alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
{
const char *pkgname;

View File

@@ -1,7 +1,7 @@
/*
* remove.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -1,7 +1,7 @@
/*
* signing.c
*
* Copyright (c) 2008-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2008-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,14 +35,6 @@
#include "alpm.h"
#include "handle.h"
/**
* Decode a loaded signature in base64 form.
* @param base64_data the signature to attempt to decode
* @param data the decoded data; must be freed by the caller
* @param data_len the length of the returned data
* @return 0 on success, -1 on failure to properly decode
*/
int SYMEXPORT alpm_decode_signature(const char *base64_data,
unsigned char **data, size_t *data_len)
{
@@ -217,7 +209,7 @@ gpg_error:
int _alpm_key_in_keychain(alpm_handle_t *handle, const char *fpr)
{
gpgme_error_t gpg_err;
gpgme_ctx_t ctx;
gpgme_ctx_t ctx = {0};
gpgme_key_t key;
int ret = -1;
@@ -231,7 +223,6 @@ int _alpm_key_in_keychain(alpm_handle_t *handle, const char *fpr)
goto error;
}
memset(&ctx, 0, sizeof(ctx));
gpg_err = gpgme_new(&ctx);
CHECK_ERR();
@@ -267,12 +258,11 @@ error:
static int key_import_wkd(alpm_handle_t *handle, const char *email)
{
gpgme_error_t gpg_err;
gpgme_ctx_t ctx;
gpgme_ctx_t ctx = {0};
gpgme_keylist_mode_t mode;
gpgme_key_t key;
int ret = -1;
memset(&ctx, 0, sizeof(ctx));
gpg_err = gpgme_new(&ctx);
CHECK_ERR();
@@ -309,7 +299,7 @@ static int key_search_keyserver(alpm_handle_t *handle, const char *fpr,
alpm_pgpkey_t *pgpkey)
{
gpgme_error_t gpg_err;
gpgme_ctx_t ctx;
gpgme_ctx_t ctx = {0};
gpgme_keylist_mode_t mode;
gpgme_key_t key;
int ret = -1;
@@ -322,7 +312,6 @@ static int key_search_keyserver(alpm_handle_t *handle, const char *fpr,
MALLOC(full_fpr, fpr_len + 3, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
sprintf(full_fpr, "0x%s", fpr);
memset(&ctx, 0, sizeof(ctx));
gpg_err = gpgme_new(&ctx);
CHECK_ERR();
@@ -431,7 +420,7 @@ gpg_error:
static int key_import_keyserver(alpm_handle_t *handle, alpm_pgpkey_t *key)
{
gpgme_error_t gpg_err;
gpgme_ctx_t ctx;
gpgme_ctx_t ctx = {0};
gpgme_key_t keys[2];
gpgme_import_result_t result;
int ret = -1;
@@ -442,7 +431,6 @@ static int key_import_keyserver(alpm_handle_t *handle, alpm_pgpkey_t *key)
return -1;
}
memset(&ctx, 0, sizeof(ctx));
gpg_err = gpgme_new(&ctx);
CHECK_ERR();
@@ -479,7 +467,7 @@ static int email_from_uid(const char *uid, char **email)
char *start, *end;
if (uid == NULL) {
email = NULL;
*email = NULL;
return -1;
}
@@ -492,7 +480,7 @@ static int email_from_uid(const char *uid, char **email)
STRNDUP(*email, start+1, end-start-1, return -1);
return 0;
} else {
email = NULL;
*email = NULL;
return -1;
}
}
@@ -507,7 +495,7 @@ static int email_from_uid(const char *uid, char **email)
int _alpm_key_import(alpm_handle_t *handle, const char *uid, const char *fpr)
{
int ret = -1;
alpm_pgpkey_t fetch_key;
alpm_pgpkey_t fetch_key = {0};
char *email;
if(_alpm_access(handle, handle->gpgdir, "pubring.gpg", W_OK)) {
@@ -516,7 +504,6 @@ int _alpm_key_import(alpm_handle_t *handle, const char *uid, const char *fpr)
return -1;
}
memset(&fetch_key, 0, sizeof(fetch_key));
STRDUP(fetch_key.uid, uid, return -1);
STRDUP(fetch_key.fingerprint, fpr, return -1);
@@ -576,8 +563,8 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
{
int ret = -1, sigcount;
gpgme_error_t gpg_err = 0;
gpgme_ctx_t ctx;
gpgme_data_t filedata, sigdata;
gpgme_ctx_t ctx = {0};
gpgme_data_t filedata = {0}, sigdata = {0};
gpgme_verify_result_t verify_result;
gpgme_signature_t gpgsig;
char *sigpath = NULL;
@@ -599,16 +586,14 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|| (sigfile = fopen(sigpath, "rb")) == NULL) {
_alpm_log(handle, ALPM_LOG_DEBUG, "sig path %s could not be opened\n",
sigpath);
handle->pm_errno = ALPM_ERR_SIG_MISSING;
goto error;
GOTO_ERR(handle, ALPM_ERR_SIG_MISSING, error);
}
}
/* does the file we are verifying exist? */
file = fopen(path, "rb");
if(file == NULL) {
handle->pm_errno = ALPM_ERR_NOT_A_FILE;
goto error;
GOTO_ERR(handle, ALPM_ERR_NOT_A_FILE, error);
}
if(init_gpgme(handle)) {
@@ -618,10 +603,6 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
_alpm_log(handle, ALPM_LOG_DEBUG, "checking signature for %s\n", path);
memset(&ctx, 0, sizeof(ctx));
memset(&sigdata, 0, sizeof(sigdata));
memset(&filedata, 0, sizeof(filedata));
gpg_err = gpgme_new(&ctx);
CHECK_ERR();
@@ -636,8 +617,7 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
int decode_ret = alpm_decode_signature(base64_sig,
&decoded_sigdata, &data_len);
if(decode_ret) {
handle->pm_errno = ALPM_ERR_SIG_INVALID;
goto gpg_error;
GOTO_ERR(handle, ALPM_ERR_SIG_INVALID, error);
}
gpg_err = gpgme_data_new_from_mem(&sigdata,
(char *)decoded_sigdata, data_len, 0);
@@ -654,15 +634,14 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
CHECK_ERR();
if(!verify_result || !verify_result->signatures) {
_alpm_log(handle, ALPM_LOG_DEBUG, "no signatures returned\n");
handle->pm_errno = ALPM_ERR_SIG_MISSING;
goto gpg_error;
GOTO_ERR(handle, ALPM_ERR_SIG_MISSING, gpg_error);
}
for(gpgsig = verify_result->signatures, sigcount = 0;
gpgsig; gpgsig = gpgsig->next, sigcount++);
_alpm_log(handle, ALPM_LOG_DEBUG, "%d signatures returned\n", sigcount);
CALLOC(siglist->results, sigcount, sizeof(alpm_sigresult_t),
handle->pm_errno = ALPM_ERR_MEMORY; goto gpg_error);
GOTO_ERR(handle, ALPM_ERR_MEMORY, gpg_error));
siglist->count = sigcount;
for(gpgsig = verify_result->signatures, sigcount = 0; gpgsig;
@@ -699,7 +678,7 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
gpg_err = GPG_ERR_NO_ERROR;
/* we dupe the fpr in this case since we have no key to point at */
STRDUP(result->key.fingerprint, gpgsig->fpr,
handle->pm_errno = ALPM_ERR_MEMORY; goto gpg_error);
GOTO_ERR(handle, ALPM_ERR_MEMORY, gpg_error));
} else {
CHECK_ERR();
if(key->uids) {
@@ -1008,12 +987,6 @@ int _alpm_process_siglist(alpm_handle_t *handle, const char *identifier,
return retry;
}
/**
* Check the PGP signature for the given package file.
* @param pkg the package to check
* @param siglist a pointer to storage for signature results
* @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred)
*/
int SYMEXPORT alpm_pkg_check_pgp_signature(alpm_pkg_t *pkg,
alpm_siglist_t *siglist)
{
@@ -1025,12 +998,6 @@ int SYMEXPORT alpm_pkg_check_pgp_signature(alpm_pkg_t *pkg,
pkg->base64_sig, siglist);
}
/**
* Check the PGP signature for the given database.
* @param db the database to check
* @param siglist a pointer to storage for signature results
* @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred)
*/
int SYMEXPORT alpm_db_check_pgp_signature(alpm_db_t *db,
alpm_siglist_t *siglist)
{
@@ -1041,13 +1008,6 @@ int SYMEXPORT alpm_db_check_pgp_signature(alpm_db_t *db,
return _alpm_gpgme_checksig(db->handle, _alpm_db_path(db), NULL, siglist);
}
/**
* Clean up and free a signature result list.
* Note that this does not free the siglist object itself in case that
* was allocated on the stack; this is the responsibility of the caller.
* @param siglist a pointer to storage for signature results
* @return 0 on success, -1 on error
*/
int SYMEXPORT alpm_siglist_cleanup(alpm_siglist_t *siglist)
{
ASSERT(siglist != NULL, return -1);
@@ -1098,7 +1058,7 @@ static int parse_subpacket(alpm_handle_t *handle, const char *identifier,
if(length_check(len, spos, 2, handle, identifier) != 0){
return -1;
}
slen = (sig[spos] << 8) | sig[spos + 1];
slen = ((sig[spos] - 192) << 8) + sig[spos + 1] + 192;
spos = spos + 2;
} else {
if(length_check(len, spos, 5, handle, identifier) != 0) {
@@ -1128,13 +1088,6 @@ static int parse_subpacket(alpm_handle_t *handle, const char *identifier,
return 0;
}
/**
* Extract the Issuer Key ID from a signature
* @param sig PGP signature
* @param len length of signature
* @param keys a pointer to storage for key IDs
* @return 0 on success, -1 on error
*/
int SYMEXPORT alpm_extract_keyid(alpm_handle_t *handle, const char *identifier,
const unsigned char *sig, const size_t len, alpm_list_t **keys)
{

View File

@@ -1,7 +1,7 @@
/*
* signing.h
*
* Copyright (c) 2008-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2008-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/*
* sync.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -22,6 +22,7 @@
*/
#include <sys/types.h> /* off_t */
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -52,10 +53,6 @@ struct keyinfo_t {
char* keyid;
};
/** Check for new version of pkg in sync repos
* (only the first occurrence is considered in sync)
*/
alpm_pkg_t SYMEXPORT *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync)
{
alpm_list_t *i;
@@ -200,7 +197,6 @@ static alpm_list_t *check_replacers(alpm_handle_t *handle, alpm_pkg_t *lpkg,
return replacers;
}
/** Search for packages to upgrade and add them to the transaction. */
int SYMEXPORT alpm_sync_sysupgrade(alpm_handle_t *handle, int enable_downgrade)
{
alpm_list_t *i, *j;
@@ -256,13 +252,6 @@ int SYMEXPORT alpm_sync_sysupgrade(alpm_handle_t *handle, int enable_downgrade)
return 0;
}
/** Find group members across a list of databases.
* If a member exists in several databases, only the first database is used.
* IgnorePkg is also handled.
* @param dbs the list of alpm_db_t *
* @param name the name of the group
* @return the list of alpm_pkg_t * (caller is responsible for alpm_list_free)
*/
alpm_list_t SYMEXPORT *alpm_find_group_pkgs(alpm_list_t *dbs,
const char *name)
{
@@ -468,11 +457,10 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
}
} else {
/* pm_errno was set by resolvedeps, callback may have overwrote it */
handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS;
alpm_list_free(resolved);
alpm_list_free(unresolvable);
ret = -1;
goto cleanup;
GOTO_ERR(handle, ALPM_ERR_UNSATISFIED_DEPS, cleanup);
}
}
@@ -673,11 +661,6 @@ cleanup:
return ret;
}
/** Returns the size of the files that will be downloaded to install a
* package.
* @param newpkg the new package to upgrade to
* @return the size of the download
*/
off_t SYMEXPORT alpm_pkg_download_size(alpm_pkg_t *newpkg)
{
if(!(newpkg->infolevel & INFRQ_DSIZE)) {
@@ -705,32 +688,27 @@ static int prompt_to_delete(alpm_handle_t *handle, const char *filepath,
};
QUESTION(handle, &question);
if(question.remove) {
char *sig_filepath;
unlink(filepath);
sig_filepath = _alpm_sigpath(handle, filepath);
unlink(sig_filepath);
FREE(sig_filepath);
}
return question.remove;
}
static struct dload_payload *build_payload(alpm_handle_t *handle,
const char *filename, size_t size, alpm_list_t *servers)
static int find_dl_candidates(alpm_handle_t *handle, alpm_list_t **files)
{
struct dload_payload *payload;
CALLOC(payload, 1, sizeof(*payload), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
STRDUP(payload->remote_name, filename, FREE(payload); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
payload->max_size = size;
payload->servers = servers;
return payload;
}
static int find_dl_candidates(alpm_db_t *repo, alpm_list_t **files)
{
alpm_list_t *i;
alpm_handle_t *handle = repo->handle;
for(i = handle->trans->add; i; i = i->next) {
for(alpm_list_t *i = handle->trans->add; i; i = i->next) {
alpm_pkg_t *spkg = i->data;
if(spkg->origin != ALPM_PKG_FROM_FILE && repo == spkg->origin_data.db) {
if(spkg->origin != ALPM_PKG_FROM_FILE) {
alpm_db_t *repo = spkg->origin_data.db;
bool need_download;
int siglevel = alpm_db_get_siglevel(alpm_pkg_get_db(spkg));
if(!repo->servers) {
handle->pm_errno = ALPM_ERR_SERVER_NONE;
_alpm_log(handle, ALPM_LOG_ERROR, "%s: %s\n",
@@ -738,12 +716,27 @@ static int find_dl_candidates(alpm_db_t *repo, alpm_list_t **files)
return 1;
}
if(spkg->download_size != 0) {
struct dload_payload *payload;
ASSERT(spkg->filename != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1));
payload = build_payload(handle, spkg->filename, spkg->size, repo->servers);
ASSERT(payload, return -1);
*files = alpm_list_add(*files, payload);
ASSERT(spkg->filename != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1));
need_download = spkg->download_size != 0 || !_alpm_filecache_exists(handle, spkg->filename);
/* even if the package file in the cache we need to check for
* accompanion *.sig file as well.
* If *.sig is not cached then force download the package + its signature file.
*/
if(!need_download && (siglevel & ALPM_SIG_PACKAGE)) {
char *sig_filename = NULL;
int len = strlen(spkg->filename) + 5;
MALLOC(sig_filename, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(sig_filename, len, "%s.sig", spkg->filename);
need_download = !_alpm_filecache_exists(handle, sig_filename);
FREE(sig_filename);
}
if(need_download) {
*files = alpm_list_add(*files, spkg);
}
}
}
@@ -751,47 +744,13 @@ static int find_dl_candidates(alpm_db_t *repo, alpm_list_t **files)
return 0;
}
static int download_single_file(alpm_handle_t *handle, struct dload_payload *payload,
const char *cachedir)
{
alpm_event_pkgdownload_t event = {
.type = ALPM_EVENT_PKGDOWNLOAD_START,
.file = payload->remote_name
};
const alpm_list_t *server;
payload->handle = handle;
payload->allow_resume = 1;
EVENT(handle, &event);
for(server = payload->servers; server; server = server->next) {
const char *server_url = server->data;
size_t len;
/* print server + filename into a buffer */
len = strlen(server_url) + strlen(payload->remote_name) + 2;
MALLOC(payload->fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(payload->fileurl, len, "%s/%s", server_url, payload->remote_name);
if(_alpm_download(payload, cachedir, NULL, NULL) != -1) {
event.type = ALPM_EVENT_PKGDOWNLOAD_DONE;
EVENT(handle, &event);
return 0;
}
_alpm_dload_payload_reset_for_retry(payload);
}
event.type = ALPM_EVENT_PKGDOWNLOAD_FAILED;
EVENT(handle, &event);
return -1;
}
static int download_files(alpm_handle_t *handle)
{
const char *cachedir;
alpm_list_t *i, *files = NULL;
int errors = 0;
int ret = 0;
alpm_event_t event;
alpm_list_t *payloads = NULL;
cachedir = _alpm_filecache_setup(handle);
handle->trans->state = STATE_DOWNLOADING;
@@ -809,8 +768,9 @@ static int download_files(alpm_handle_t *handle)
handle->totaldlcb(total_size);
}
for(i = handle->dbs_sync; i; i = i->next) {
errors += find_dl_candidates(i->data, &files);
ret = find_dl_candidates(handle, &files);
if(ret != 0) {
goto finish;
}
if(files) {
@@ -818,7 +778,6 @@ static int download_files(alpm_handle_t *handle)
if(handle->checkspace) {
off_t *file_sizes;
size_t idx, num_files;
int ret;
_alpm_log(handle, ALPM_LOG_DEBUG, "checking available disk space for download\n");
@@ -826,36 +785,59 @@ static int download_files(alpm_handle_t *handle)
CALLOC(file_sizes, num_files, sizeof(off_t), goto finish);
for(i = files, idx = 0; i; i = i->next, idx++) {
const struct dload_payload *payload = i->data;
file_sizes[idx] = payload->max_size;
const alpm_pkg_t *pkg = i->data;
file_sizes[idx] = pkg->size;
}
ret = _alpm_check_downloadspace(handle, cachedir, num_files, file_sizes);
free(file_sizes);
if(ret != 0) {
errors++;
goto finish;
}
}
event.type = ALPM_EVENT_RETRIEVE_START;
event.type = ALPM_EVENT_PKG_RETRIEVE_START;
EVENT(handle, &event);
event.type = ALPM_EVENT_RETRIEVE_DONE;
for(i = files; i; i = i->next) {
if(download_single_file(handle, i->data, cachedir) == -1) {
errors++;
event.type = ALPM_EVENT_RETRIEVE_FAILED;
_alpm_log(handle, ALPM_LOG_WARNING, _("failed to retrieve some files\n"));
}
alpm_pkg_t *pkg = i->data;
int siglevel = alpm_db_get_siglevel(alpm_pkg_get_db(pkg));
struct dload_payload *payload = NULL;
CALLOC(payload, 1, sizeof(*payload), GOTO_ERR(handle, ALPM_ERR_MEMORY, finish));
STRDUP(payload->remote_name, pkg->filename, FREE(payload); GOTO_ERR(handle, ALPM_ERR_MEMORY, finish));
STRDUP(payload->filepath, pkg->filename,
FREE(payload->remote_name); FREE(payload);
GOTO_ERR(handle, ALPM_ERR_MEMORY, finish));
payload->max_size = pkg->size;
payload->servers = pkg->origin_data.db->servers;
payload->handle = handle;
payload->allow_resume = 1;
payload->download_signature = (siglevel & ALPM_SIG_PACKAGE);
payload->signature_optional = (siglevel & ALPM_SIG_PACKAGE_OPTIONAL);
payloads = alpm_list_add(payloads, payload);
}
ret = _alpm_download(handle, payloads, cachedir);
if(ret != 0) {
event.type = ALPM_EVENT_PKG_RETRIEVE_FAILED;
EVENT(handle, &event);
_alpm_log(handle, ALPM_LOG_WARNING, _("failed to retrieve some files\n"));
goto finish;
}
event.type = ALPM_EVENT_PKG_RETRIEVE_DONE;
EVENT(handle, &event);
}
finish:
if(payloads) {
alpm_list_free_inner(payloads, (alpm_list_fn_free)_alpm_dload_payload_reset);
FREELIST(payloads);
}
if(files) {
alpm_list_free_inner(files, (alpm_list_fn_free)_alpm_dload_payload_reset);
FREELIST(files);
alpm_list_free(files);
}
for(i = handle->trans->add; i; i = i->next) {
@@ -869,10 +851,18 @@ finish:
handle->totaldlcb(0);
}
return errors;
return ret;
}
#ifdef HAVE_LIBGPGME
static int key_cmp(const void *k1, const void *k2) {
const struct keyinfo_t *key1 = k1;
const char *key2 = k2;
return strcmp(key1->keyid, key2);
}
static int check_keyring(alpm_handle_t *handle)
{
size_t current = 0, numtargs;
@@ -898,19 +888,19 @@ static int check_keyring(alpm_handle_t *handle)
}
level = alpm_db_get_siglevel(alpm_pkg_get_db(pkg));
if((level & ALPM_SIG_PACKAGE) && pkg->base64_sig) {
unsigned char *decoded_sigdata = NULL;
size_t data_len;
int decode_ret = alpm_decode_signature(pkg->base64_sig,
&decoded_sigdata, &data_len);
if(decode_ret == 0) {
if((level & ALPM_SIG_PACKAGE)) {
unsigned char *sig = NULL;
size_t sig_len;
int ret = alpm_pkg_get_sig(pkg, &sig, &sig_len);
if(ret == 0) {
alpm_list_t *keys = NULL;
if(alpm_extract_keyid(handle, pkg->name, decoded_sigdata,
data_len, &keys) == 0) {
if(alpm_extract_keyid(handle, pkg->name, sig,
sig_len, &keys) == 0) {
alpm_list_t *k;
for(k = keys; k; k = k->next) {
char *key = k->data;
if(!alpm_list_find_str(errors, key) &&
_alpm_log(handle, ALPM_LOG_DEBUG, "found signature key: %s\n", key);
if(!alpm_list_find(errors, key, key_cmp) &&
_alpm_key_in_keychain(handle, key) == 0) {
keyinfo = malloc(sizeof(struct keyinfo_t));
if(!keyinfo) {
@@ -923,8 +913,8 @@ static int check_keyring(alpm_handle_t *handle)
}
FREELIST(keys);
}
free(decoded_sigdata);
}
free(sig);
}
}
@@ -940,7 +930,7 @@ static int check_keyring(alpm_handle_t *handle)
alpm_list_t *k;
for(k = errors; k; k = k->next) {
keyinfo = k->data;
if(_alpm_key_import(handle, keyinfo->uid, keyinfo->keyid) == -1) {
if(_alpm_key_import(handle, keyinfo->uid, keyinfo->keyid) == -1) {
fail = 1;
}
free(keyinfo->uid);

View File

@@ -1,7 +1,7 @@
/*
* sync.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>

View File

@@ -1,7 +1,7 @@
/*
* trans.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -42,12 +42,6 @@
#include "deps.h"
#include "hook.h"
/** \addtogroup alpm_trans Transaction Functions
* @brief Functions to manipulate libalpm transactions
* @{
*/
/** Initialize the transaction. */
int SYMEXPORT alpm_trans_init(alpm_handle_t *handle, int flags)
{
alpm_trans_t *trans;
@@ -97,7 +91,6 @@ static alpm_list_t *check_arch(alpm_handle_t *handle, alpm_list_t *pkgs)
return invalid;
}
/** Prepare a transaction. */
int SYMEXPORT alpm_trans_prepare(alpm_handle_t *handle, alpm_list_t **data)
{
alpm_trans_t *trans;
@@ -156,7 +149,6 @@ int SYMEXPORT alpm_trans_prepare(alpm_handle_t *handle, alpm_list_t **data)
return 0;
}
/** Commit a transaction. */
int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
{
alpm_trans_t *trans;
@@ -233,9 +225,6 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
return 0;
}
/** Interrupt a transaction.
* @note Safe to call from inside signal handlers.
*/
int SYMEXPORT alpm_trans_interrupt(alpm_handle_t *handle)
{
alpm_trans_t *trans;
@@ -253,7 +242,6 @@ int SYMEXPORT alpm_trans_interrupt(alpm_handle_t *handle)
return 0;
}
/** Release a transaction. */
int SYMEXPORT alpm_trans_release(alpm_handle_t *handle)
{
alpm_trans_t *trans;

View File

@@ -1,7 +1,7 @@
/*
* trans.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>

View File

@@ -1 +0,0 @@
../../src/common/util-common.c

View File

@@ -1 +0,0 @@
../../src/common/util-common.h

View File

@@ -1,7 +1,7 @@
/*
* util.c
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -350,7 +350,8 @@ int _alpm_unpack(alpm_handle_t *handle, const char *path, const char *prefix,
/* If specific files were requested, skip entries that don't match. */
if(list) {
char *entry_prefix = strdup(entryname);
char *entry_prefix = NULL;
STRDUP(entry_prefix, entryname, ret = 1; goto cleanup);
char *p = strstr(entry_prefix,"/");
if(p) {
*(p + 1) = '\0';
@@ -833,6 +834,20 @@ char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename)
return NULL;
}
/** Check whether a filename exists in a registered alpm cachedir.
* @param handle the context handle
* @param filename name of file to find
* @return 0 if the filename was not found, 1 otherwise
*/
int _alpm_filecache_exists(alpm_handle_t *handle, const char *filename)
{
int res;
char *fpath = _alpm_filecache_find(handle, filename);
res = (fpath != NULL);
FREE(fpath);
return res;
}
/** Check the alpm cachedirs for existence and find a writable one.
* If no valid cache directory can be found, use /tmp.
* @param handle the context handle
@@ -1005,7 +1020,7 @@ static int sha256_file(const char *path, unsigned char output[32])
* @return a NULL terminated string with the hexadecimal representation of
* bytes or NULL on error. This string must be freed.
*/
static char *hex_representation(unsigned char *bytes, size_t size)
static char *hex_representation(const unsigned char *bytes, size_t size)
{
static const char *hex_digits = "0123456789abcdef";
char *str;
@@ -1023,11 +1038,6 @@ static char *hex_representation(unsigned char *bytes, size_t size)
return str;
}
/** Get the md5 sum of file.
* @param filename name of the file
* @return the checksum on success, NULL on error
* @addtogroup alpm_misc
*/
char SYMEXPORT *alpm_compute_md5sum(const char *filename)
{
unsigned char output[16];
@@ -1041,11 +1051,6 @@ char SYMEXPORT *alpm_compute_md5sum(const char *filename)
return hex_representation(output, 16);
}
/** Get the sha256 sum of file.
* @param filename name of the file
* @return the checksum on success, NULL on error
* @addtogroup alpm_misc
*/
char SYMEXPORT *alpm_compute_sha256sum(const char *filename)
{
unsigned char output[32];
@@ -1191,7 +1196,7 @@ cleanup:
{
int ret = b->ret;
FREE(b->line);
memset(b, 0, sizeof(struct archive_read_buffer));
*b = (struct archive_read_buffer){0};
return ret;
}
}
@@ -1437,22 +1442,15 @@ int _alpm_fnmatch(const void *pattern, const void *string)
*/
void *_alpm_realloc(void **data, size_t *current, const size_t required)
{
char *newdata;
newdata = realloc(*data, required);
if(!newdata) {
_alpm_alloc_fail(required);
return NULL;
}
REALLOC(*data, required, return NULL);
if (*current < required) {
/* ensure all new memory is zeroed out, in both the initial
* allocation and later reallocs */
memset(newdata + *current, 0, required - *current);
memset((char*)*data + *current, 0, required - *current);
}
*current = required;
*data = newdata;
return newdata;
return *data;
}
/** This automatically grows data based on current/required.
@@ -1491,3 +1489,40 @@ void _alpm_alloc_fail(size_t size)
{
fprintf(stderr, "alloc failure: could not allocate %zu bytes\n", size);
}
/** This functions reads file content.
*
* Memory buffer is allocated by the callee function. It is responsibility
* of the caller to free the buffer.
*
* @param filepath filepath to read
* @param data pointer to output buffer
* @param data_len size of the output buffer
* @return error code for the operation
*/
alpm_errno_t _alpm_read_file(const char *filepath, unsigned char **data, size_t *data_len)
{
struct stat st;
FILE *fp;
if((fp = fopen(filepath, "rb")) == NULL) {
return ALPM_ERR_NOT_A_FILE;
}
if(fstat(fileno(fp), &st) != 0) {
fclose(fp);
return ALPM_ERR_NOT_A_FILE;
}
*data_len = st.st_size;
MALLOC(*data, *data_len, fclose(fp); return ALPM_ERR_MEMORY);
if(fread(*data, *data_len, 1, fp) != 1) {
FREE(*data);
fclose(fp);
return ALPM_ERR_SYSTEM;
}
fclose(fp);
return ALPM_ERR_OK;
}

View File

@@ -1,7 +1,7 @@
/*
* util.h
*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -53,6 +53,7 @@ void _alpm_alloc_fail(size_t size);
#define MALLOC(p, s, action) do { p = malloc(s); if(p == NULL) { _alpm_alloc_fail(s); action; } } while(0)
#define CALLOC(p, l, s, action) do { p = calloc(l, s); if(p == NULL) { _alpm_alloc_fail(l * s); action; } } while(0)
#define REALLOC(p, s, action) do { void* np = realloc(p, s); if(np == NULL) { _alpm_alloc_fail(s); action; } else { p = np; } } while(0)
/* This strdup macro is NULL safe- copying NULL will yield NULL */
#define STRDUP(r, s, action) do { if(s != NULL) { r = strdup(s); if(r == NULL) { _alpm_alloc_fail(strlen(s)); action; } } else { r = NULL; } } while(0)
#define STRNDUP(r, s, l, action) do { if(s != NULL) { r = strndup(s, l); if(r == NULL) { _alpm_alloc_fail(l); action; } } else { r = NULL; } } while(0)
@@ -62,15 +63,20 @@ void _alpm_alloc_fail(size_t size);
#define ASSERT(cond, action) do { if(!(cond)) { action; } } while(0)
#define RET_ERR_VOID(handle, err) do { \
_alpm_log(handle, ALPM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \
_alpm_log(handle, ALPM_LOG_DEBUG, "returning error %d from %s (%s: %d) : %s\n", err, __func__, __FILE__, __LINE__, alpm_strerror(err)); \
(handle)->pm_errno = (err); \
return; } while(0)
#define RET_ERR(handle, err, ret) do { \
_alpm_log(handle, ALPM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \
_alpm_log(handle, ALPM_LOG_DEBUG, "returning error %d from %s (%s: %d) : %s\n", err, __func__, __FILE__, __LINE__, alpm_strerror(err)); \
(handle)->pm_errno = (err); \
return (ret); } while(0)
#define GOTO_ERR(handle, err, label) do { \
_alpm_log(handle, ALPM_LOG_DEBUG, "got error %d at %s (%s: %d) : %s\n", err, __func__, __FILE__, __LINE__, alpm_strerror(err)); \
(handle)->pm_errno = (err); \
goto label; } while(0)
#define RET_ERR_ASYNC_SAFE(handle, err, ret) do { \
(handle)->pm_errno = (err); \
return (ret); } while(0)
@@ -130,6 +136,8 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
int _alpm_ldconfig(alpm_handle_t *handle);
int _alpm_str_cmp(const void *s1, const void *s2);
char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename);
/* Checks whether a file exists in cache */
int _alpm_filecache_exists(alpm_handle_t *handle, const char *filename);
const char *_alpm_filecache_setup(alpm_handle_t *handle);
/* Unlike many uses of alpm_pkgvalidation_t, _alpm_test_checksum expects
* an enum value rather than a bitfield. */
@@ -147,6 +155,7 @@ int _alpm_fnmatch_patterns(alpm_list_t *patterns, const char *string);
int _alpm_fnmatch(const void *pattern, const void *string);
void *_alpm_realloc(void **data, size_t *current, const size_t required);
void *_alpm_greedy_grow(void **data, size_t *current, const size_t required);
alpm_errno_t _alpm_read_file(const char *filepath, unsigned char **data, size_t *data_len);
#ifndef HAVE_STRSEP
char *strsep(char **, const char *);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -216,20 +216,6 @@ cleanup:
return ret;
}
/** Compare two version strings and determine which one is 'newer'.
* Returns a value comparable to the way strcmp works. Returns 1
* if a is newer than b, 0 if a and b are the same version, or -1
* if b is newer than a.
*
* Different epoch values for version strings will override any further
* comparison. If no epoch is provided, 0 is assumed.
*
* Keep in mind that the pkgrel is only compared if it is available
* on both versions handed to this function. For example, comparing
* 1.5-1 and 1.5 will yield 0; comparing 1.5-1 and 1.5-2 will yield
* -1 as expected. This is mainly for supporting versioned dependencies
* that do not include the pkgrel.
*/
int SYMEXPORT alpm_pkg_vercmp(const char *a, const char *b)
{
char *full1, *full2;

3
m4/.gitignore vendored
View File

@@ -1,3 +0,0 @@
*.m4
!acinclude.m4
!gpgme.m4

View File

@@ -1,179 +0,0 @@
dnl acinclude.m4 - configure macros used by pacman and libalpm
dnl Add some custom macros for pacman and libalpm
dnl GCC_STACK_PROTECT_LIB
dnl adds -lssp to LIBS if it is available
dnl ssp is usually provided as part of libc, but was previously a separate lib
dnl It does not hurt to add -lssp even if libc provides SSP - in that case
dnl libssp will simply be ignored.
AC_DEFUN([GCC_STACK_PROTECT_LIB],[
AC_CACHE_CHECK([whether libssp exists], ssp_cv_lib,
[ssp_old_libs="$LIBS"
LIBS="$LIBS -lssp"
AC_TRY_LINK(,, ssp_cv_lib=yes, ssp_cv_lib=no)
LIBS="$ssp_old_libs"
])
if test $ssp_cv_lib = yes; then
LIBS="$LIBS -lssp"
fi
])
dnl GCC_STACK_PROTECT_CC
dnl checks -fstack-protector-all with the C compiler, if it exists then updates
dnl CFLAGS and defines ENABLE_SSP_CC
AC_DEFUN([GCC_STACK_PROTECT_CC],[
AC_LANG_ASSERT(C)
if test "X$CC" != "X"; then
AC_CACHE_CHECK([whether ${CC} accepts -fstack-protector-all],
ssp_cv_cc,
[ssp_old_cflags="$CFLAGS"
CFLAGS="$CFLAGS -fstack-protector-all"
AC_TRY_COMPILE(,, ssp_cv_cc=yes, ssp_cv_cc=no)
CFLAGS="$ssp_old_cflags"
])
if test $ssp_cv_cc = yes; then
CFLAGS="$CFLAGS -fstack-protector-all"
AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
fi
fi
])
dnl GCC_STACK_CLASH_PROTECTION
dnl check -fstack-clash-protection with the C compiler, if it exists then
dnl updates CFLAGS
AC_DEFUN([GCC_STACK_CLASH_PROTECTION],[
AC_LANG_ASSERT(C)
if test "X$CC" != "X"; then
AC_CACHE_CHECK([whether ${CC} accepts -fstack-clash-protection],
scp_cv_cc,
[scp_old_cflags="$CFLAGS"
CFLAGS="$CFLAGS -fstack-clash-protection"
AC_TRY_COMPILE(,, scp_cv_cc=yes, scp_cv_cc=no)
CFLAGS="$scp_old_cflags"
])
if test $scp_cv_cc = yes; then
CFLAGS="$CFLAGS -fstack-clash-protection"
fi
fi
])
dnl GCC_FORTIFY_SOURCE_CC
dnl checks -D_FORTIFY_SOURCE with the C compiler, if it exists then updates
dnl CPPFLAGS
AC_DEFUN([GCC_FORTIFY_SOURCE_CC],[
AC_LANG_ASSERT(C)
if test "X$CC" != "X"; then
AC_MSG_CHECKING(for FORTIFY_SOURCE support)
fs_old_cppflags="$CPPFLAGS"
fs_old_cflags="$CFLAGS"
CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
CFLAGS="$CFLAGS -Werror"
AC_TRY_COMPILE([#include <features.h>], [
int main() {
#if !(__GNUC_PREREQ (4, 1) )
#error No FORTIFY_SOURCE support
#endif
return 0;
}
], [
AC_MSG_RESULT(yes)
CFLAGS="$fs_old_cflags"
], [
AC_MSG_RESULT(no)
CPPFLAGS="$fs_old_cppflags"
CFLAGS="$fs_old_cflags"
])
fi
])
dnl GCC_VISIBILITY_CC
dnl checks -fvisibility=internal with the C compiler, if it exists then
dnl defines ENABLE_VISIBILITY_CC in both configure script and Makefiles
AC_DEFUN([GCC_VISIBILITY_CC],[
AC_LANG_ASSERT(C)
if test "X$CC" != "X"; then
AC_CACHE_CHECK([whether ${CC} accepts -fvisibility=internal],
visibility_cv_cc,
[visibility_old_cflags="$CFLAGS"
CFLAGS="$CFLAGS -fvisibility=internal"
AC_TRY_COMPILE(,, visibility_cv_cc=yes, visibility_cv_cc=no)
CFLAGS="$visibility_old_cflags"
])
if test $visibility_cv_cc = yes; then
AC_DEFINE([ENABLE_VISIBILITY_CC], 1, [Define if symbol visibility C support is enabled.])
fi
AM_CONDITIONAL([ENABLE_VISIBILITY_CC], test "x$visibility_cv_cc" = "xyes")
fi
])
dnl CFLAGS_ADD(PARAMETER, VARIABLE)
dnl Adds parameter to VARIABLE if the compiler supports it. For example,
dnl CFLAGS_ADD([-Wall],[WARN_FLAGS]).
AC_DEFUN([CFLAGS_ADD],
[AS_VAR_PUSHDEF([my_cflags], [cflags_cv_warn_$1])dnl
AC_CACHE_CHECK([whether compiler handles $1], [my_cflags], [
save_CFLAGS="$CFLAGS"
CFLAGS="${CFLAGS} -Werror=unknown-warning-option"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[],
[CFLAGS="$save_CFLAGS"])
CFLAGS="${CFLAGS} $1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AS_VAR_SET([my_cflags], [yes])],
[AS_VAR_SET([my_cflags], [no])])
CFLAGS="$save_CFLAGS"
])
AS_VAR_PUSHDEF([new_cflags], [[$2]])dnl
AS_VAR_IF([my_cflags], [yes], [AS_VAR_APPEND([new_cflags], [" $1"])])
AS_VAR_POPDEF([new_cflags])dnl
AS_VAR_POPDEF([my_cflags])dnl
m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
])
dnl Checks for getmntinfo and determines whether it uses statfs or statvfs
AC_DEFUN([FS_STATS_TYPE],
[AC_CACHE_CHECK([filesystem statistics type], fs_stats_cv_type,
[AC_CHECK_FUNC(getmntinfo,
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
# include <sys/param.h>
# include <sys/mount.h>
#if HAVE_SYS_UCRED_H
#include <sys/ucred.h>
#endif
extern int getmntinfo (struct statfs **, int);
]],
[])],
[fs_stats_cv_type="struct statfs"],
[fs_stats_cv_type="struct statvfs"])],
[AC_CHECK_FUNC(getmntent,
[fs_stats_cv_type="struct statvfs"])]
)]
)
AC_DEFINE_UNQUOTED(FSSTATSTYPE, [$fs_stats_cv_type],
[Defined as the filesystem stats type ('statvfs' or 'statfs')])
if test $ac_cv_func_getmntinfo = yes; then
if test "$fs_stats_cv_type" = "struct statvfs"; then
AC_DEFINE([HAVE_GETMNTINFO_STATVFS], 1, [Define if getmntinfo() uses statvfs.])
else
AC_DEFINE([HAVE_GETMNTINFO_STATFS], 1, [Define if getmntinfo() uses statfs.])
fi
fi
])
dnl Checks for PATH_MAX and defines it if not present
AC_DEFUN([PATH_MAX_DEFINED],
[AC_CACHE_CHECK([PATH_MAX defined], path_max_cv_defined,
[AC_EGREP_CPP(yes, [[
#include <limits.h>
#if defined(PATH_MAX)
yes
#endif
]],
[path_max_cv_defined=yes],
[path_max_cv_defined=no])]
)
if test $path_max_cv_defined = no; then
AC_DEFINE([PATH_MAX], 4096, [Define if PATH_MAX is undefined by limits.h.])
fi
])

View File

@@ -1,238 +0,0 @@
# gpgme.m4 - autoconf macro to detect GPGME.
# Copyright (C) 2002, 2003, 2004 g10 Code GmbH
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AC_DEFUN([_AM_PATH_GPGME_CONFIG],
[ AC_ARG_WITH(gpgme-prefix,
AC_HELP_STRING([--with-gpgme-prefix=PFX],
[prefix where GPGME is installed (optional)]),
gpgme_config_prefix="$withval", gpgme_config_prefix="")
if test "x$gpgme_config_prefix" != x ; then
GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config"
fi
AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
if test "$GPGME_CONFIG" != "no" ; then
gpgme_version=`$GPGME_CONFIG --version`
fi
gpgme_version_major=`echo $gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
gpgme_version_minor=`echo $gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
gpgme_version_micro=`echo $gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
])
dnl AM_PATH_GPGME([MINIMUM-VERSION,
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS.
dnl
AC_DEFUN([AM_PATH_GPGME],
[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
tmp=ifelse([$1], ,1:0.4.2,$1)
if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
else
req_gpgme_api=0
min_gpgme_version="$tmp"
fi
AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
ok=no
if test "$GPGME_CONFIG" != "no" ; then
req_major=`echo $min_gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
req_minor=`echo $min_gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
req_micro=`echo $min_gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
if test "$gpgme_version_major" -gt "$req_major"; then
ok=yes
else
if test "$gpgme_version_major" -eq "$req_major"; then
if test "$gpgme_version_minor" -gt "$req_minor"; then
ok=yes
else
if test "$gpgme_version_minor" -eq "$req_minor"; then
if test "$gpgme_version_micro" -ge "$req_micro"; then
ok=yes
fi
fi
fi
fi
fi
fi
if test $ok = yes; then
# If we have a recent GPGME, we should also check that the
# API is compatible.
if test "$req_gpgme_api" -gt 0 ; then
tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
if test "$tmp" -gt 0 ; then
if test "$req_gpgme_api" -ne "$tmp" ; then
ok=no
fi
fi
fi
fi
if test $ok = yes; then
GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
GPGME_LIBS=`$GPGME_CONFIG --libs`
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
GPGME_CFLAGS=""
GPGME_LIBS=""
AC_MSG_RESULT(no)
ifelse([$3], , :, [$3])
fi
AC_SUBST(GPGME_CFLAGS)
AC_SUBST(GPGME_LIBS)
])
dnl AM_PATH_GPGME_PTHREAD([MINIMUM-VERSION,
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
dnl Test for libgpgme and define GPGME_PTHREAD_CFLAGS
dnl and GPGME_PTHREAD_LIBS.
dnl
AC_DEFUN([AM_PATH_GPGME_PTHREAD],
[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
tmp=ifelse([$1], ,1:0.4.2,$1)
if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
else
req_gpgme_api=0
min_gpgme_version="$tmp"
fi
AC_MSG_CHECKING(for GPGME pthread - version >= $min_gpgme_version)
ok=no
if test "$GPGME_CONFIG" != "no" ; then
if `$GPGME_CONFIG --thread=pthread 2> /dev/null` ; then
req_major=`echo $min_gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
req_minor=`echo $min_gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
req_micro=`echo $min_gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
if test "$gpgme_version_major" -gt "$req_major"; then
ok=yes
else
if test "$gpgme_version_major" -eq "$req_major"; then
if test "$gpgme_version_minor" -gt "$req_minor"; then
ok=yes
else
if test "$gpgme_version_minor" -eq "$req_minor"; then
if test "$gpgme_version_micro" -ge "$req_micro"; then
ok=yes
fi
fi
fi
fi
fi
fi
fi
if test $ok = yes; then
# If we have a recent GPGME, we should also check that the
# API is compatible.
if test "$req_gpgme_api" -gt 0 ; then
tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
if test "$tmp" -gt 0 ; then
if test "$req_gpgme_api" -ne "$tmp" ; then
ok=no
fi
fi
fi
fi
if test $ok = yes; then
GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --thread=pthread --cflags`
GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --thread=pthread --libs`
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
GPGME_PTHREAD_CFLAGS=""
GPGME_PTHREAD_LIBS=""
AC_MSG_RESULT(no)
ifelse([$3], , :, [$3])
fi
AC_SUBST(GPGME_PTHREAD_CFLAGS)
AC_SUBST(GPGME_PTHREAD_LIBS)
])
dnl AM_PATH_GPGME_GLIB([MINIMUM-VERSION,
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
dnl Test for libgpgme-glib and define GPGME_GLIB_CFLAGS and GPGME_GLIB_LIBS.
dnl
AC_DEFUN([AM_PATH_GPGME_GLIB],
[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
tmp=ifelse([$1], ,1:0.4.2,$1)
if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
else
req_gpgme_api=0
min_gpgme_version="$tmp"
fi
AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
ok=no
if test "$GPGME_CONFIG" != "no" ; then
req_major=`echo $min_gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
req_minor=`echo $min_gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
req_micro=`echo $min_gpgme_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
if test "$gpgme_version_major" -gt "$req_major"; then
ok=yes
else
if test "$gpgme_version_major" -eq "$req_major"; then
if test "$gpgme_version_minor" -gt "$req_minor"; then
ok=yes
else
if test "$gpgme_version_minor" -eq "$req_minor"; then
if test "$gpgme_version_micro" -ge "$req_micro"; then
ok=yes
fi
fi
fi
fi
fi
fi
if test $ok = yes; then
# If we have a recent GPGME, we should also check that the
# API is compatible.
if test "$req_gpgme_api" -gt 0 ; then
tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
if test "$tmp" -gt 0 ; then
if test "$req_gpgme_api" -ne "$tmp" ; then
ok=no
fi
fi
fi
fi
if test $ok = yes; then
GPGME_GLIB_CFLAGS=`$GPGME_CONFIG --glib --cflags`
GPGME_GLIB_LIBS=`$GPGME_CONFIG --glib --libs`
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
GPGME_GLIB_CFLAGS=""
GPGME_GLIB_LIBS=""
AC_MSG_RESULT(no)
ifelse([$3], , :, [$3])
fi
AC_SUBST(GPGME_GLIB_CFLAGS)
AC_SUBST(GPGME_GLIB_LIBS)
])

View File

@@ -1,6 +1,6 @@
project('pacman',
'c',
version : '5.2.0',
version : '5.2.1',
license : 'GPLv2+',
default_options : [
'c_std=gnu99',
@@ -10,7 +10,7 @@ project('pacman',
],
meson_version : '>= 0.51')
libalpm_version = '12.0.0'
libalpm_version = '12.0.1'
cc = meson.get_compiler('c')
@@ -28,12 +28,10 @@ LIBMAKEPKGDIR = join_paths(PREFIX, DATAROOTDIR, 'makepkg')
PKGDATADIR = join_paths(PREFIX, DATAROOTDIR, meson.project_name())
PYTHON = import('python').find_installation('python3')
M4 = find_program('m4')
SED = find_program('sed')
DU = find_program('du')
LDCONFIG = get_option('ldconfig')
MESON_MAKE_SYMLINK = join_paths(meson.source_root(), 'build-aux/meson-make-symlink.sh')
MESON_INSTALL_SCRIPT = join_paths(meson.source_root(), 'build-aux/meson-install-script.sh')
BASH = find_program('bash4', 'bash')
if BASH.found()
@@ -79,9 +77,13 @@ conf.set_quoted('CACHEDIR', join_paths(LOCALSTATEDIR, 'cache/pacman/pkg/'))
conf.set_quoted('HOOKDIR', join_paths(SYSCONFDIR, 'pacman.d/hooks/'))
conf.set_quoted('ROOTDIR', ROOTDIR)
libintl = dependency('', required: false)
if get_option('i18n')
if not cc.has_function('ngettext')
error('ngettext not found but NLS support requested')
libintl = cc.find_library('intl', required : false, static: get_option('buildstatic'))
if not libintl.found()
error('ngettext not found but NLS support requested')
endif
endif
conf.set('ENABLE_NLS', 1)
endif
@@ -179,7 +181,7 @@ elif conf.has('HAVE_STRUCT_STATFS_F_FLAGS')
conf.set('FSSTATSTYPE', 'struct statfs')
endif
if get_option('buildtype').startswith('debug')
if get_option('debug')
extra_cflags = [
'-Wcast-align',
'-Wclobbered',
@@ -221,7 +223,6 @@ config_h = configure_file(
add_project_arguments('-include', 'config.h', language : 'c')
filecmd = 'file'
default_sedinplaceflags = ' --follow-symlinks -i'
inodecmd = 'stat -c \'%i %n\''
strip_binaries = '--strip-all'
strip_shared = '--strip-unneeded'
@@ -236,19 +237,12 @@ endif
os = host_machine.system()
if os.startswith('darwin')
inodecmd = '/usr/bin/stat -f \'%i %n\''
default_sedinplaceflags = ' -i \'\''
inodecmd = '/usr/bin/stat -f \'%i %N\''
strip_binaries = ''
strip_shared = '-s'
strip_static = '-s'
elif os.contains('bsd') or os == 'dragonfly'
inodecmd = 'stat -f \'%i %n\''
default_sedinplaceflags = ' -i \'\''
endif
sedinplaceflags = get_option('sedinplaceflags')
if sedinplaceflags == 'auto'
sedinplaceflags = default_sedinplaceflags
inodecmd = 'stat -f \'%i %N\''
endif
chost = run_command(cc, '-dumpmachine').stdout().strip()
@@ -258,7 +252,6 @@ carch = chost.split('-')[0]
# largely identical, but which distinguishes between quoting needs.
substs = configuration_data()
substs.set('SED', SED.path())
substs.set('M4', M4.path())
substs.set('CARCH', carch)
substs.set('CHOST', chost)
substs.set('PKGEXT', get_option('pkg-ext'))
@@ -277,8 +270,6 @@ substs.set('TEMPLATE_DIR', get_option('makepkg-template-dir'))
substs.set('DEBUGSUFFIX', get_option('debug-suffix'))
substs.set('INODECMD', inodecmd)
substs.set('FILECMD', filecmd)
substs.set('SEDINPLACEFLAGS', sedinplaceflags)
substs.set('SEDPATH', SED.path())
substs.set('LIBMAKEPKGDIR', LIBMAKEPKGDIR)
substs.set('STRIP_BINARIES', strip_binaries)
substs.set('STRIP_SHARED', strip_shared)
@@ -314,7 +305,7 @@ libcommon = static_library(
include_directories : includes,
install : false)
alpm_deps = [crypto_provider, libarchive, libcurl, gpgme]
alpm_deps = [crypto_provider, libarchive, libcurl, libintl, gpgme]
libalpm_a = static_library(
'alpm_objlib',
@@ -378,6 +369,21 @@ executable(
install : true,
)
foreach wrapper : script_wrappers
cdata = configuration_data()
cdata.set_quoted('BASH', BASH.path())
cdata.set_quoted('BUILDDIR', wrapper[2])
cdata.set_quoted('REAL_PROGPATH', wrapper[1].full_path())
# Create a wrapper script that bootstraps the real script within the build
# directory. Use configure_file instead of a custom_target to ensure that
# permissions on the input script wrapper are preserved.
configure_file(
input : join_paths(meson.source_root(), 'build-aux', 'script-wrapper.sh.in'),
output : wrapper[0],
configuration : cdata)
endforeach
configure_file(
input : 'etc/makepkg.conf.in',
output : 'makepkg.conf',
@@ -430,7 +436,6 @@ message('\n '.join([
' Architecture : @0@'.format(carch),
' Host Type : @0@'.format(chost),
' File inode command : @0@'.format(inodecmd),
' In-place sed command : @0@ @1@'.format(SED.path(), sedinplaceflags),
' File seccomp command : @0@'.format(filecmd),
' libalpm version : @0@'.format(libalpm_version),
' pacman version : @0@'.format(PACKAGE_VERSION),

View File

@@ -54,6 +54,3 @@ option('i18n', type : 'boolean', value : true,
# tools
option('file-seccomp', type: 'feature', value: 'auto',
description: 'determine whether file is seccomp-enabled')
option('sedinplaceflags', type : 'string', value : 'auto',
description : 'flags to pass to sed to edit a file in-place')

View File

@@ -1,291 +0,0 @@
# enforce that all scripts have a --help and --version option
AUTOMAKE_OPTIONS = std-options
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = \
$(WRAPPER)
SUBDIRS = po
pkgconfigdir = $(datarootdir)/pkgconfig
pkgconfig_DATA = libmakepkg.pc
bin_SCRIPTS = \
$(OURSCRIPTS) \
makepkg-template \
repo-remove \
repo-elephant \
$(WRAPPER)
OURSCRIPTS = \
makepkg \
pacman-db-upgrade \
pacman-key \
repo-add
EXTRA_DIST = \
meson.build \
libmakepkg.pc.in \
makepkg.sh.in \
makepkg-template.pl.in \
pacman-db-upgrade.sh.in \
pacman-key.sh.in \
repo-add.sh.in \
wrapper.sh.in \
$(COMPLETION_DIST) \
$(LIBRARY) \
$(LIBMAKEPKG_DIST)
LIBRARY = \
library/human_to_size.sh
libmakepkgdir = $(datarootdir)/makepkg
LIBMAKEPKGDIRS = \
buildenv \
executable \
integrity \
lint_config \
lint_package \
lint_pkgbuild \
source \
tidy \
util
LIBMAKEPKG_IN = \
libmakepkg/executable.sh \
libmakepkg/executable/ccache.sh \
libmakepkg/executable/checksum.sh \
libmakepkg/executable/distcc.sh \
libmakepkg/executable/fakeroot.sh \
libmakepkg/executable/gpg.sh \
libmakepkg/executable/gzip.sh \
libmakepkg/executable/pacman.sh \
libmakepkg/executable/strip.sh \
libmakepkg/executable/sudo.sh \
libmakepkg/executable/vcs.sh \
libmakepkg/buildenv.sh \
libmakepkg/buildenv/buildflags.sh \
libmakepkg/buildenv/compiler.sh \
libmakepkg/buildenv/debugflags.sh \
libmakepkg/buildenv/makeflags.sh \
libmakepkg/integrity.sh \
libmakepkg/integrity/generate_checksum.sh \
libmakepkg/integrity/generate_signature.sh \
libmakepkg/integrity/verify_checksum.sh \
libmakepkg/integrity/verify_signature.sh \
libmakepkg/lint_config.sh \
libmakepkg/lint_config/ext.sh \
libmakepkg/lint_config/paths.sh \
libmakepkg/lint_config/source_date_epoch.sh \
libmakepkg/lint_config/variable.sh \
libmakepkg/lint_package.sh \
libmakepkg/lint_package/build_references.sh \
libmakepkg/lint_package/dotfiles.sh \
libmakepkg/lint_package/file_names.sh \
libmakepkg/lint_package/missing_backup.sh \
libmakepkg/lint_pkgbuild.sh \
libmakepkg/lint_pkgbuild/arch.sh \
libmakepkg/lint_pkgbuild/arch_specific.sh \
libmakepkg/lint_pkgbuild/backup.sh \
libmakepkg/lint_pkgbuild/changelog.sh \
libmakepkg/lint_pkgbuild/checkdepends.sh \
libmakepkg/lint_pkgbuild/conflicts.sh \
libmakepkg/lint_pkgbuild/depends.sh \
libmakepkg/lint_pkgbuild/epoch.sh \
libmakepkg/lint_pkgbuild/fullpkgver.sh \
libmakepkg/lint_pkgbuild/install.sh \
libmakepkg/lint_pkgbuild/makedepends.sh \
libmakepkg/lint_pkgbuild/optdepends.sh \
libmakepkg/lint_pkgbuild/options.sh \
libmakepkg/lint_pkgbuild/package_function.sh \
libmakepkg/lint_pkgbuild/package_function_variable.sh \
libmakepkg/lint_pkgbuild/pkgbase.sh \
libmakepkg/lint_pkgbuild/pkglist.sh \
libmakepkg/lint_pkgbuild/pkgname.sh \
libmakepkg/lint_pkgbuild/pkgrel.sh \
libmakepkg/lint_pkgbuild/pkgver.sh \
libmakepkg/lint_pkgbuild/provides.sh \
libmakepkg/lint_pkgbuild/source.sh \
libmakepkg/lint_pkgbuild/util.sh \
libmakepkg/lint_pkgbuild/variable.sh \
libmakepkg/source.sh \
libmakepkg/source/bzr.sh \
libmakepkg/source/file.sh \
libmakepkg/source/git.sh \
libmakepkg/source/hg.sh \
libmakepkg/source/local.sh \
libmakepkg/source/svn.sh \
libmakepkg/srcinfo.sh \
libmakepkg/tidy.sh \
libmakepkg/tidy/docs.sh \
libmakepkg/tidy/emptydirs.sh \
libmakepkg/tidy/libtool.sh \
libmakepkg/tidy/purge.sh \
libmakepkg/tidy/staticlibs.sh \
libmakepkg/tidy/strip.sh \
libmakepkg/tidy/zipman.sh \
libmakepkg/util.sh \
libmakepkg/util/compress.sh \
libmakepkg/util/config.sh \
libmakepkg/util/error.sh \
libmakepkg/util/message.sh \
libmakepkg/util/option.sh \
libmakepkg/util/parseopts.sh \
libmakepkg/util/pkgbuild.sh \
libmakepkg/util/schema.sh \
libmakepkg/util/source.sh \
libmakepkg/util/util.sh
LIBMAKEPKG_DIST = \
$(addprefix libmakepkg/, $(addsuffix /meson.build, $(LIBMAKEPKGDIRS))) \
$(addsuffix .in, $(LIBMAKEPKG_IN))
WRAPPER = \
makepkg-wrapper \
pacman-db-upgrade-wrapper \
pacman-key-wrapper \
repo-add-wrapper
COMPLETION_IN = \
completion/bash_completion \
completion/zsh_completion
COMPLETION_DIST = \
$(addsuffix .in, $(COMPLETION_IN))
# Files that should be removed, but which Automake does not know.
MOSTLYCLEANFILES = $(bin_SCRIPTS) $(LIBMAKEPKG_IN) $(COMPLETION_IN) libmakepkg.pc
clean-local:
$(AM_V_at)$(RM) -r .lib
if USE_GIT_VERSION
GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//')
REAL_PACKAGE_VERSION = $(GIT_VERSION)
else
REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
endif
#### Taken from the autoconf scripts Makefile.am ####
edit = sed \
-e 's|@rootdir[@]|$(ROOTDIR)|g' \
-e 's|@localedir[@]|$(localedir)|g' \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
-e 's|@localstatedir[@]|$(localstatedir)|g' \
-e 's|@libmakepkgdir[@]|$(libmakepkgdir)|g' \
-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
-e 's|@prefix[@]|$(prefix)|g' \
-e '1s|!/bin/bash|!$(BASH_SHELL)|g' \
-e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \
-e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \
-e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
-e 's|@BUILDSCRIPT[@]|$(BUILDSCRIPT)|g' \
-e 's|@TEMPLATE_DIR[@]|$(TEMPLATE_DIR)|g' \
-e 's|@DEBUGSUFFIX[@]|$(DEBUGSUFFIX)|g' \
-e "s|@INODECMD[@]|$(INODECMD)|g" \
-e "s|@FILECMD[@]|$(FILECMD)|g" \
-e 's|@SEDINPLACEFLAGS[@]|$(SEDINPLACEFLAGS)|g' \
-e 's|@SEDPATH[@]|$(SEDPATH)|g' \
-e 's|@SCRIPTNAME[@]|$@|g' \
-e 's|@configure_input[@]|Generated from $<; do not edit by hand.|g'
## All the scripts depend on Makefile so that they are rebuilt when the
## prefix etc. changes. Use chmod -w to prevent people from editing the
## wrong file by accident.
$(OURSCRIPTS): %: %.sh.in wrapper.sh.in $(LIBMAKEPKG_IN) Makefile
$(AM_V_at)$(RM) $@
$(AM_V_GEN)test -f $(srcdir)/$@.sh.in && m4 -P -I $(srcdir) $(srcdir)/$@.sh.in | $(edit) >$@
$(AM_V_at)chmod +x,a-w $@
@$(BASH_SHELL) -O extglob -n $@
$(LIBMAKEPKG_IN): %: %.in Makefile
$(AM_V_at)$(RM) $@
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)test -f $(srcdir)/$@.in && $(edit) $(srcdir)/$@.in >$@
$(AM_V_at)chmod a-w $@
@$(BASH_SHELL) -O extglob -n $@
$(COMPLETION_IN) libmakepkg.pc: %: %.in Makefile
$(AM_V_at)$(RM) $@
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@
$(AM_V_at)chmod a-w $@
all-am: $(COMPLETION_IN)
makepkg-template: \
$(srcdir)/makepkg-template.pl.in \
Makefile
$(AM_V_at)$(RM) -f makepkg-template
$(AM_V_GEN)$(edit) $< > $@
$(AM_V_at)chmod +x,a-w $@
repo-remove repo-elephant: repo-add
$(AM_V_at)$(RM) $@
$(AM_V_at)$(LN_S) repo-add $@
.SECONDEXPANSION:
$(WRAPPER): \
$(srcdir)/wrapper.sh.in \
$$(subst -wrapper,,$$@)
$(AM_V_at)$(MKDIR_P) .lib
$(AM_V_at)mv -f $(subst -wrapper,,$@) .lib
$(AM_V_at)$(RM) $@
$(AM_V_GEN)sed \
-e "s|@PWD[@]|$$(pwd)|" \
-e "s|@PROGNAME[@]|$(subst -wrapper,,$@)|g" \
-e '1s|!/bin/bash|!$(BASH_SHELL)|g' \
$(srcdir)/wrapper.sh.in > $@
$(AM_V_at)chmod +x,a-w $@
$(AM_V_at)$(LN_S) $@ $(subst -wrapper,,$@)
install-data-local:
$(MKDIR_P) $(DESTDIR)$(bashcompdir)
$(INSTALL_DATA) completion/bash_completion $(DESTDIR)/$(bashcompdir)/pacman
for completion in makepkg pacman-key; do \
$(LN_S) pacman $(DESTDIR)/$(bashcompdir)/$$completion; \
done
$(MKDIR_P) $(DESTDIR)$(datarootdir)/zsh/site-functions/
$(INSTALL_DATA) completion/zsh_completion $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
uninstall-local:
$(RM) $(DESTDIR)$(bashcompdir)/makepkg
$(RM) $(DESTDIR)$(bashcompdir)/pacman
$(RM) $(DESTDIR)$(bashcompdir)/pacman-key
$(RM) $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
install-exec-hook:
for wrapper in $(WRAPPER); do \
$(RM) $(DESTDIR)$(bindir)/$${wrapper}; \
$(INSTALL) .lib/$${wrapper%-wrapper} $(DESTDIR)$(bindir)/$${wrapper%-wrapper}; \
done
for dir in $(LIBMAKEPKGDIRS); do \
$(MKDIR_P) $(DESTDIR)$(libmakepkgdir)/$$dir; \
done
for lib in $(LIBMAKEPKG); do \
$(INSTALL) $(srcdir)/$$lib $(DESTDIR)$(libmakepkgdir)/$${lib#libmakepkg}; \
done
for lib in $(LIBMAKEPKG_IN); do \
$(INSTALL) $$lib $(DESTDIR)$(libmakepkgdir)/$${lib#libmakepkg}; \
done
cd $(DESTDIR)$(bindir) && \
$(RM) repo-elephant && \
( $(LN_S) repo-add repo-elephant || \
ln repo-add repo-elephant || \
cp repo-add repo-elephant )
cd $(DESTDIR)$(bindir) && \
$(RM) repo-remove && \
( $(LN_S) repo-add repo-remove || \
ln repo-add repo-remove || \
cp repo-add repo-remove )
uninstall-hook:
cd $(DESTDIR)$(bindir) && \
$(RM) repo-remove repo-elephant
for lib in $(LIBMAKEPKG) $(LIBMAKEPKG_IN); do \
$(RM) $(DESTDIR)$(libmakepkgdir)/$${lib#libmakepkg}; \
done
for dir in $(LIBMAKEPKGDIRS); do \
$(RM) -r $(DESTDIR)$(libmakepkgdir)/$$dir; \
done

View File

@@ -109,14 +109,14 @@ _pacman() {
local cur prev words cword
_init_completion || return
database=('asdeps asexplicit')
files=('list machinereadable owns search refresh regex' 'l o s x y')
files=('list machinereadable refresh regex' 'l x y')
query=('changelog check deps explicit file foreign groups info list native owns
search unrequired upgrades' 'c e g i k l m n o p s t u')
remove=('cascade dbonly nodeps assume-installed nosave print recursive unneeded' 'c n p s u')
sync=('asdeps asexplicit clean dbonly downloadonly force groups ignore ignoregroup
sync=('asdeps asexplicit clean dbonly downloadonly groups ignore ignoregroup
info list needed nodeps assume-installed print refresh recursive search sysupgrade'
'c g i l p s u w y')
upgrade=('asdeps asexplicit force needed nodeps assume-installed print recursive' 'p')
upgrade=('asdeps asexplicit needed nodeps assume-installed print recursive' 'p')
common=('arch cachedir color config confirm dbpath debug gpgdir help hookdir logfile
noconfirm noprogressbar noscriptlet quiet root verbose' 'b d h q r v')
core=('database files help query remove sync upgrade version' 'D F Q R S U V h')
@@ -136,7 +136,6 @@ _pacman() {
_pacman_pkg Qq;;
F)
{ _arch_incomp 'l list' && _pacman_pkg Slq ; } ||
_arch_incomp 'o owns' ||
compopt +o default;;
Q)
{ _arch_incomp 'g groups' && _pacman_pkg Qg sort; } ||

View File

@@ -1,4 +1,4 @@
#compdef pacman pacman.static=pacman pacman-key makepkg
#compdef pacman pacman.static=pacman pacman-conf pacman-key makepkg
# copy this file to /usr/share/zsh/site-functions/_pacman
@@ -44,7 +44,6 @@ _pacman_opts_pkgfile=(
'*--nodeps[Skip dependency checks]'
'*--assume-installed[Add virtual package to satisfy dependencies]'
'--dbonly[Only remove database entry, do not remove files]'
'--force[Overwrite conflicting files]'
'--needed[Do not reinstall up to date packages]'
'--asdeps[mark packages as non-explicitly installed]'
'--asexplicit[mark packages as explicitly installed]'
@@ -101,8 +100,6 @@ _pacman_opts_database=(
_pacman_opts_files=(
{-l,--list}'[List the files owned by the queried package]:package:_pacman_completions_all_packages'
{-o,--owns}'[Query the package that owns]:files:_files'
{-s,--search}'[Search package file names for matching strings]:files:_files'
{-x,--regex}'[Enable searching using regular expressions]:regex:'
{-y,--refresh}'[Download fresh files databases from the server]'
'--machinereadable[Produce machine-readable output]'
@@ -135,7 +132,6 @@ _pacman_opts_sync_modifiers=(
'*--ignoregroup[Ignore a group upgrade]:package group:_pacman_completions_all_groups'
'--asdeps[Install packages as non-explicitly installed]'
'--asexplicit[Install packages as explicitly installed]'
'--force[Overwrite conflicting files]'
'--print-format[Specify how the targets should be printed]'
)
@@ -500,6 +496,97 @@ _pacman_zsh_comp() {
esac
}
_pacman_conf_general_directives=(
'RootDir'
'DBPath'
'CacheDir'
'HookDir'
'GPGDir'
'LogFile'
'HoldPkg'
'IgnorePkg'
'NoUpgrade'
'NoExtract'
'Architecture'
'XferCommand'
'UseSyslog'
'Color'
'TotalDownload'
'CheckSpace'
'VerbosePkgLists'
'DisableDownloadTimeout'
'NoProgressBar'
'ParallelDownloads'
'CleanMethod'
'SigLevel'
'LocalFileSigLevel'
'RemoteFileSigLevel'
)
_pacman_conf_repo_directives=(
'Server'
'SigLevel'
'Usage'
)
_pacman_conf_completions_repositories() {
local -a repositories
# If the user specified an alternate config, use those repos
repositories=($(pacman-conf ${(kv)opt_args[(I)-c|--config]} --repo-list ))
typeset -U repositories
compadd "$@" -a repositories
}
_pacman_conf_directive() {
# Directives use a case-insensitive matcher-list
local casematch="m:{[:lower:][:upper:]}={[:upper:][:lower:]}"
if [[ -n ${opt_args[(I)-r|--repo]} ]]; then
compadd -M "$casematch" "$@" -a _pacman_conf_repo_directives
else
if [[ $words[$CURRENT] == [iI][lL]* ]]; then
compadd -M "$casematch" "$@" ILoveCandy # Secret completion!
else
compadd -M "$casematch" "$@" -a _pacman_conf_general_directives
fi
fi
}
_pacman_conf_commands=(
{-l,--repo-list}'[List configured repositories]:*: :->repo_list'
{-h,--help}'[Output systax and command line options]:*: :->complete'
{-V,--version}'[Display version and exit]:*: :->complete'
)
_pacman_conf_options=(
'(-r --repo)'{-r,--repo=}'[Query options for a specific repository]:package repo:_pacman_conf_completions_repositories'
'(-v --verbose)'{-v,--verbose}'[Always show directive names]'
)
_pacman_conf_options_common=(
'*'{-c,--config=}'[Specify an alternate configuration file]: :_files'
'*'{-R,--rootdir=}'[Specify an alternate insallation root]: :_files'
)
_pacman_conf() {
_arguments -s : \
"$_pacman_conf_commands[@]" \
"$_pacman_conf_options_common[@]" \
"$_pacman_conf_options[@]" \
'*:pacman directive:_pacman_conf_directive'
case $state in
repo_list)
_arguments -s \
'(-l --repo-list)'{-l,--repo-list} \
"$_pacman_conf_options_common[@]"
;;
*)
_message "no more arguments"
;;
esac
}
_key_shortopts=(
'-h[show help]'
'-a[Add the specified keys (empty for stdin)]: :_files'
@@ -708,6 +795,9 @@ _pacman_comp() {
makepkg)
_makepkg "$@"
;;
pacman-conf)
_pacman_conf "$@"
;;
pacman-key)
_pacman_key "$@"
;;

View File

@@ -3,7 +3,7 @@
# buildenv.sh - functions for altering the build environment before
# compilation
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -2,7 +2,7 @@
#
# buildflags.sh - Clear user-specified buildflags if requested
#
# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2011-2020 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -4,7 +4,7 @@
# ccache - Cache compilations and reuse them to save time on repetitions
# distcc - Distribute compilation of C and C++ across machines
#
# Copyright (c) 2007-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2007-2020 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -3,7 +3,7 @@
# debugflags.sh - Specify flags for building a package with debugging
# symbols
#
# Copyright (c) 2012-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2012-2020 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -2,7 +2,7 @@
#
# makeflags.sh - Clear user-specified makeflags if requested
#
# Copyright (c) 2007-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2007-2020 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -2,7 +2,7 @@
#
# executable.sh - confirm presence of dependent executables
#
# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2018-2020 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -2,7 +2,7 @@
#
# ccache.sh - Confirm presence of ccache binary
#
# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2011-2020 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -2,7 +2,7 @@
#
# checksum.sh - Confirm presence of binaries for checksum operations
#
# Copyright (c) 2016-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2016-2020 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

Some files were not shown because too many files have changed in this diff Show More