Commit Graph

2409 Commits

Author SHA1 Message Date
Allan McRae b9f98ae97c Add compatibility with gpgme-1.5.0
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-06-02 10:31:25 +10:00
Dave Reisner 7a5e41925f dload: avoid using CURLOPT_FAILONERROR
Use of this flag causes connections to be closed on 404s -- a common
occurrence when your config sets DatabaseOptional. Handle the error
gracefully, so that the connection can be reused.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-05-22 15:52:22 +10:00
Andrew Gregory dd694f433b register_syncdb: reject db names that contain /
alpm downloads databases based on basename causing [foo] and [bar/foo]
to silently overwrite each other.

Also remove an extra tab

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-05-04 16:14:44 +10:00
Allan McRae ee72c016ab Always supply base name and version info in .PKGFILE if needed
Provide pkgbase information for non-split packages with pkgbase set.
Also record the version of the "base" package.  This is useful for
matching package files to source packages.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-27 15:24:22 +10:00
Allan McRae ffdc2c5396 Use MALLOC throughtout libalpm
Use MALLOC instead of malloc for safety in libalpm.  Some changes are pure
refactoring, but for others this provides a success check for memory
allocation.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-08 16:58:30 +10:00
Andrew Gregory 2330a64589 sync_prepare: ignore explicitly removed conflicts
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-04 13:57:02 +10:00
Allan McRae b2488eb356 Fix warnings with strict-overflow in gcc-4.9
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:55 +10:00
Olivier Brunel cfaff6e0c1 Add events on pacnew/pacsave/pacorig file creation
ALPM still adds a warning to the log, but doesn't emit an event about
said warning, instead using a specific event to let the frontend what
happened/how to inform the user.

Note that there are 2 cases for installing a .pacnew file, to not
overwrite user changes and because file is in NoUpgrade. In the later case
the warning was a bit different: it happened before and said "extracting"
instead of "installed." Now both happen after and are phrased the same.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:55 +10:00
Andrew Gregory 9bfd6ff275 restrict transaction package origins
This moves the "wrong args" error up from trans_commit to add_pkg when
used with a local pkg and adds the error for remove_pkg when used with
a sync pkg, which currently just removes the db entry.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:54 +10:00
Olivier Brunel bd3d1a17c2 Add events _PKGDOWNLOAD_{START, DONE, FAILED}
These will be emmitted when download a package file from a repository,
indicating that the download starts, and whether it was successfull or
not.

Note that when multiple servers are available, no event is emmitted when
switching to another server.

(This doesn't apply to alpm_fetch_pkgurl(), but since it is called by
the frontend, it shouldn't have problems knowing when the download
starts and when it ends.)

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:54 +10:00
Olivier Brunel 01cc55a1f4 Add events ALPM_EVENT_RETRIEVE_{DONE, FAILED}
To go along with RETRIEVE_START, one other event will be emmitted once
the downloads are done: RETRIEVE_DONE if all files were successfully
downloaded, else RETRIEVE_FAILED.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:54 +10:00
Olivier Brunel cd793c5ab7 Remove log_cb, add ALPM_EVENT_LOG instead
When ALPM emits a log message, it still goes through _alpm_log() but
instead of calling a specific log callback, it goes as an event.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:54 +10:00
Olivier Brunel 28dbd5551e Update the event callback
Instead of using two void* arguments for all events, we now send one
pointer to an alpm_event_t struct. This contains the type of event that
was triggered.

With this information, the pointer can then be typecasted to the
event-specific struct in order to get additional arguments.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03 11:25:54 +10:00
Florian Pritz b6f6a165c4 be_local: Use alpm_greedy_grow
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2014-03-03 11:25:54 +10:00
Florian Pritz 5acfa65ffb be_package: Build the file list from MTREE if possible
This greatly speeds up file list generation times by avoiding
uncompressing the whole package.

pacman -S base with a deliberate file conflict:
before: 9.1 seconds
after:  2.2 seconds

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2014-03-03 11:25:54 +10:00
Florian Pritz 8e60adc916 be_package: Refactor code adding a file to the files list
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2014-03-03 11:25:54 +10:00
Florian Pritz 11fb1d30f4 be_package: Refactor handling of simple path checks
This is used to deduplicate code when using the mtree as the file list
source.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2014-03-03 11:25:54 +10:00
Florian Pritz 42f4a5081e util: Add _alpm_realloc() and _alpm_greedy_grow()
These will be used in the following patches.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2014-03-03 11:25:54 +10:00
Florian Pritz f27fad9b89 Check if a file is in the package's file list before extracting
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2014-03-03 11:25:54 +10:00
Andrew Gregory a7da2a47c3 _alpm_sync_prepare: fix unresolvable packages leak
If the user opted not to remove the unresolvable packages from the
transaction, the list was neither free'd nor saved to the transaction to
be free'd in trans_release.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-02-08 09:55:35 +10:00
Andrew Gregory b9601b1e59 alpm: export *_free functions
Front-ends should be able to free memory that alpm hands them.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-02-04 13:48:37 +10:00
Rafael Ferreira 236f1795e9 Do not remove source code references in PO/POT files
FS#34240.  This is useful for translators and has little cost to us since
we moved to transifex for translations.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-02-02 16:32:55 +10:00
Andrew Gregory c2edd31eae _alpm_resolvedeps: free targ inside loop
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-30 14:12:06 +10:00
Andrew Gregory fac9ac6c40 sync_prepare: manually set pm_errno
_alpm_resolvedeps resets pm_errno to 0 by calling alpm_checkdeps.
Whenever the last call succeeded, pm_errno was not properly set,
preventing pacman from properly handling the error and leaking
additional memory.  We know pm_errno should be ALPM_ERR_UNSATISFIED_DEPS
if resolvedeps has failed, so just set it manually.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-30 14:02:31 +10:00
Andrew Gregory 6be08f76f6 local_db_populate: initialize empty pkgcache
If the db directory did not exist when local_db_populate was called, the
pkgcache wouldn't be initialized, causing pkghash_add_pkg to fail.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-30 13:45:53 +10:00
Florian Pritz cd2370754a Remove ts and sw from vim modeline when noet is set
Forcing vim users to view files with a tabstop of 2 seems really
unnecessary when noet is set. I find it much easier to read code with
ts=4 and I dislike having to override the modeline by hand.

Command run:
find . -type f -exec sed -i '/vim.* noet/s# ts=2 sw=2##' {} +

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-28 20:19:25 +10:00
Olivier Brunel 4e9d88aa05 Rename ALPM_EVENT_OPTDEP_REQUIRED to _OPTDEP_REMOVAL
Because this event is triggered when an optdepend for another package is
being removed.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-28 20:10:49 +10:00
Andrew Gregory 8a434aeb46 sync_prepare: treat from_sync as a boolean
We only care that packages are being installed from a repo, not how
many.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-15 16:05:31 +10:00
Andrew Gregory 62c76cf825 base64.c: comment out unused variable
Commit e47eb9a7 commented out base64_encode, which left base64_enc_map
unused, causing warnings under clang.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-15 15:54:56 +10:00
Andrew Gregory b01c2aefd9 package.h: convert scriptlet field to int
It's a boolean, so signedness doesn't matter, and the public API already
exposes it as an int through alpm_pkg_has_scriptlet().

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-15 15:52:51 +10:00
Allan McRae bce495e56f Consistently use #ifdef
Fix the occurances of #if to be #ifdef for consistency.
2014-01-10 14:32:38 +10:00
Allan McRae 1d3b17e251 Fix build with --disable-gpgme
The alpm_decode_signature function was made available for frontends to
display signature information, but this required libalpm to be build with
gpgme support.  As that function did not require anything from gpgme,
have it build unconditionally.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-10 14:30:05 +10:00
Dan McGee 5097b162fc Fix compile warnings on systems without getmntent
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-10 14:30:05 +10:00
Andrew Gregory 480a9ff82f check_keyring: plug memory leak
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:51 +10:00
Dan McGee 6c917e433e Reorder and reshape the package struct for better packing
This shrinks down the total size of the package struct by a handful of
bytes, saving us some memory and cache pressure when we are loading up
the entirety of the sync and local databases.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:51 +10:00
Dan McGee 30740d9d2f Minor struct member reordering for packing concerns
Noticed using clang and `-Wpadded`.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:50 +10:00
Dan McGee 086bbc5b62 Use O_CLOEXEC as much as possible when opening files
When calling open(), use O_CLOEXEC as much as possible to ensure the
file descriptor is closed when and if a process using libalpm forks.

For most of these cases, and especially in utility functions, the file
descriptor is opened and closed in the same function, so we don't have
too much to worry about. However, for things like the log file and
database lock file, we should ensure descriptors aren't left hanging
around for children to touch.

This patch is inspired by the problem in FS#36161, where an open file
descriptor to the current working directory prevents chroot() from
working on FreeBSD. We don't need this file descriptor in the child
process, so open it (and now several others) with O_CLOEXEC.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:50 +10:00
Dan McGee 8bec8a3f6a Log more in search debug message
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:50 +10:00
Dan McGee bad86247f7 Remove -fgnu89-inline from compile options
This was a hack done by me in commit d8e88aa017 back in 2007 that is
no longer necessary, given a sufficiently smart compiler and one that
supports the inline keyword.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:50 +10:00
Dan McGee e205003635 Clear up definition of INFRQ_ALL
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:50 +10:00
Allan McRae 3bb3b1555a Update copyright years for 2014
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:50 +10:00
Allan McRae 77268f352f Copy validation field in _alpm_pkg_dup
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:49 +10:00
Allan McRae 7fa35f32d8 Update comment for local db entry creation
Mention mtree files do not need creation in addtion to install files.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:49 +10:00
Andrew Gregory 6f468c2465 deps.c: remove filtered_depend functions
filtered_dep was duplicating an alpm_depend_t solely for the purpose of
overriding its depmod and would effectively cause alpm_checkdeps to
ignore ALPM_TRANS_FLAG_NODEPVERSION if the duplication failed.  Manually
overriding/restoring the depmod for the original depend removes the
duplication as a point of failure and fixes a memory leak where the
duplicated depend was not being properly freed.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:49 +10:00
Allan McRae 452ee39de1 Fix build warnings with --disable-nls
The gettext functions return a "char *", so do the same for the defines
in the case where gettext is unavailable.  This prevents a number of
warnings about const being dropped.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:49 +10:00
Andrew Gregory 2f8be5f8db trans_prepare: always sort trans->remove by deps
Packages can be removed during a sync transaction either directly or
due to conflicts and need to be sorted.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-12-19 15:19:52 +10:00
Dave Reisner 714609639f dload: allow curl to response to any auth challenge
Previously, we only allowed the default of responding to basic auth
challenges. Mirrors requiring authorization are far and away the edge
case, but there's no sense in preventing access to them.

Implements FS#38184.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-12-19 15:17:58 +10:00
Olivier Brunel 9652c27710 alpm: Rename a variable for future clarity
We will be adding event structs in the following patches.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-12-15 21:58:30 +10:00
Andrew Gregory e8ec7e54e5 remove useless continue
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-12-15 20:09:37 +10:00
Andrew Gregory 841c60f2b3 db.c: require unique database names
Allowing multiple databases with the same name causes conflicts as they
both point to the same database file but may use different servers,
usages, or siglevels.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-12-15 20:09:37 +10:00