Commit Graph

2601 Commits

Author SHA1 Message Date
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
Andrew Gregory 916c7085d8 alpm_sync_sysupgrade: skip packages being removed
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
Wolfgang Bumiller 20127e732c Close file descirptor before fork
FreeBSD chroot(2) fails with EPERM when a directory file descriptor is open
with either `kern.chroot_allow_open_directories` being 0, or when the process
already is inside a chroot.  This is exposed in alpm_run_chroot that uses
opendir() to open a file descriptor to the current directory before doing
the forking and chrooting.  Since the file descriptor is not used in the
forked process, we close it.

Fixes FS#36161.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-12-15 20:09:37 +10:00
Jason St. John 230bd5c2fd Fix whitespace and other formatting issues
This commit:
-- replaces space-based indents with tabs per the coding standards
-- removes extraneous whitespace (e.g. extra spaces between function args)
-- adds missing braces for a one-line if statement

Signed-off-by: Jason St. John <jstjohn@purdue.edu>
2013-11-15 11:02:27 +10:00
Andrew Gregory d78f45ae0c log important events from the backend
This ensures that important events will be logged and consistent
regardless of the frontend.  The need for global context in the event
callback is also removed.  The event is logged before any post_* scripts
run, so this also moves the post_* script output underneath the event in
the log.

Fixes FS#36504

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-15 11:02:27 +10:00
Allan McRae 0da98ec6ba Ignore makedepend and checkdepend entries when parsing .PKGINFO file
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-15 11:02:27 +10:00
Andrew Gregory 57090d8cba alpm_handle: store lock file descriptor
There was a brief window between opening the file descriptor and
creating a stream to it.  If the process was interrupted during that
window the lock file would not be removed correctly.

The pid is no longer printed to the lock file as this was virtually
meaningless for lock files on NFS.

Fixes FS#35603

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-08 09:28:05 +10:00
Andrew Gregory af284d5fdb support ALPM_SIG_USE_DEFAULT for file siglevels
This brings file siglevels in line with how db siglevels are handled.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-08 09:28:05 +10:00
Jason St. John 88df07717d Remove spaces between the opening "if" and the opening parenthesis
Signed-off-by: Jason St. John <jstjohn@purdue.edu>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-08 09:28:05 +10:00
Dave Reisner 0c180cb7cc version: fix formatting in file to RPM upstream
This reverts a portion of 86eefc1a3a.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-08 09:28:05 +10:00
Andrew Gregory c3493360af deps.c: pass alpm_list** to _alpm_recursedeps
Improves consistency and makes it clear that targs will be modified by
_alpm_recursedeps.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:03 +10:00
Andrew Gregory 8f5dbd5614 libalpm/db.c: default to ALPM_DB_USAGE_ALL
This allows existing front-ends other than pacman to continue working
normally.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:02 +10:00
Andrew Gregory c2134fde2b sortbydeps: include local pkgs in dep graph
Detecting indirect dependencies by traversing a package's entire
dependency tree is prohibitively slow for larger transactions.  Instead
add local packages to the dependency graph.  This additionally requires
delaying dependency ordering for sync operations so that removed
packages may be excluded from dependency detection.

tests/sync012.py was also updated to ensure that the dependency cycle
was actually detected.

Fixes FS#37380

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:02 +10:00
Allan McRae 23923200c3 Expose alpm_pkg_should_ignore
This function is useful for frontends to annotate package upgrades
that will be ignored.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:02 +10:00
Allan McRae c7f159c1c9 Make functions to decode a signature and extract keyid public
These are useful for frontends.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31 16:20:02 +10:00
Allan McRae e049bb8bd6 Ensure packages have a valid version
Currently you can manually create and then install a package with a
version not containing a pkgrel.  The created local database entry is
invalid as the directory name can not be split by _alpm_splitname due
to the assumtion of hyphens separating name-pkgver-pkgrel.

Ensure the package has a valid version when it is loaded. Fixes FS#35514.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-15 12:40:53 +10:00
Allan McRae dcfc247a2c Fix progress bar overflow while checking package integrity
On 32bit systems, the progress bar intergrity checking can show values
greater than 100% with large transactions.  This is due to the total
size of all package files being greater than a size_t.  Use uint64_t
for these sizes.

Fixes FS#36608

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-15 12:40:53 +10:00
Allan McRae ed511b141f Report which package is missing a signature
If any package in a sync transaction is missing a required signature,
we give an uninformative error message (which may or may not state that
the missing signature is the issue).  Always output the package with
the missing signature.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-15 12:40:53 +10:00
slavomir vlcek e5f23e0ebb libalpm: move function pointer condition
Function pointer gets uselessly compared for NULL in
every iteration. Move the condition to do it just once.

Signed-off-by: slavomir vlcek <svlc@inventati.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-14 13:01:15 +10:00
Christian Hesse 3b3152fc50 dload: avoid renaming files downloaded via sync operations
If the server redirects from ${repo}.db to ${repo}.db.tar.gz pacman gets
this wrong: It saves to new filename and fails when accessing
${repo}.db.

We need the remote filename only when downloading remote files with
pacman's -U operation. This introduces a new field 'trust_remote_name'
to payload. If set pacman downloads to the filename given by the server.

The field trust_remote_name is set in alpm_fetch_pkgurl().

Fixes FS#36791 ([pacman] downloads to wrong filename with redirect).

[dave: remove redundant assignment leading to memory leak]

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-09-18 14:28:03 +10:00
Dave Reisner 106d0fc541 libalpm: introduce a usage level for repos
This defines a level of interest a user has in a repository. These are
described by the bitmask flags in the alpm_db_usage_t enum:

  ALPM_DB_USAGE_SEARCH: repo is valid for searching
  ALPM_DB_USAGE_INSTALL: repo is valid for installs (e.g. -S pkg)
  ALPM_DB_USAGE_UPGRADE: repo is valid for sysupgrades
  ALPM_DB_USAGE_ALL: all of the above are valid

Explicitly listing the contents of a repo will always be valid, and the
repo will always be refreshed appropriately on sync operations.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-09-04 09:51:20 +10:00
Sami Kerola aade18cf3b libalpm: avoid name space conflict
The symbol 'err' refers to err() from err.h, and is wisest to be avoided
as a variable name.

Reference: http://man7.org/linux/man-pages/man3/err.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-09-04 09:51:20 +10:00
Dave Reisner 3a2a752e1e alpm: log errors for scriptlets terminated by a signal
Fixes FS#36618.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-09-04 09:51:19 +10:00
Andrew Gregory d8c2ab0e6f conflict.c: fix directory ownership check
* append "/" to directories before searching package file lists
* use lstat over stat so symlinks aren't resolved
* fix the inverted check for stat's return value

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:13:46 +10:00
Allan McRae 247b9af02b Do not refer to FlySpray numbers
These references to bug numbers assume we will forever be using that bug
tracker. It is better to properly comment the code instead (which was
done in almost all cases anyway).

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21 11:12:30 +10:00
Allan McRae d7bd40045c Remove setlocale usage from the backend
Using setlocale in the backend is bound to lead to frontend issues
and we have have been using epoch in our databases since April 2007
(commit 47622eef).  Remove support for old style times.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-30 13:01:26 +10:00
Allan McRae e81faa9d6d Warn when directory ownership differs between filesystem and package
We currently only warn if a directory's permissions differ, but using -Qkk
on my system shows that directory permissions tend to change in packages
reasonably frequently without notice.  Provide a warning in such cases
so that it can be altered.  Example output:

(1/1) reinstalling nginx
warning: directory ownership differs on /var/lib/nginx/proxy/
filesystem: 33:0  package: 0:0

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-30 13:01:11 +10:00
Allan McRae 96a4d1ca04 Update gitignore files for use with autoreconf
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-22 13:27:23 +10:00
Allan McRae df9d19ba73 Remove autotools files
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-22 13:27:07 +10:00
Dave Reisner 24abcddc57 be_sync: avoid crashing on files in the root of a DB
If a sync DB is malformed and contains entries in the root of the
archive, load_pkg_for_entry will leave the 'filename' variable empty,
leading to a crash in the ensuing strcmp() calls which determine the DB
fragment being examined.

While this isn't a read error, this should be reported to the user so
that it can be addressed by the creator of the DB.

As seen: https://bbs.archlinux.org/viewtopic.php?pid=1297766

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2013-07-22 13:26:56 +10:00
Allan McRae ef6b6fe065 Hide unused parameter warnings when building without libcurl
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-22 13:26:42 +10:00
Allan McRae 5cc099a8ab Add missing header
Exposed when building with --without-libcurl

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-22 13:26:30 +10:00
Andrew Gregory 897e2b121a use full path when checking for mountpoints
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-05 14:34:58 +10:00
Dave Reisner eb19d41d5f do not check error from close(2)
On operating systems we support, the behavior is always such that the
kernel will do the right thing as far as invalidating the file
descriptor, regardless of the eventual return value. Therefore,
potentially looping and calling close multiple times is wrong.

At best, we call close again on an invalid FD and throw a spurious EBADF
error. At worst, we might close an FD which doesn't belong to us when a
multi-threaded application opens its own file descriptor between
iterations of the loop.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-05 14:32:23 +10:00
Patrick Steinhardt dfcea1456d Enable inverted patterns in NoExtract and NoUpgrade.
It is now possible to invert patterns in NoExtract and NoUpgrade.
This feature allows users to whitelist certain files that were
previously blacklisted by another entry.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-26 15:32:16 +10:00
Andrew Gregory ec831e05f5 deps.c: check for indirect deps when ordering
On upgrades, indirect dependencies were not being detected if there was
a dependency in between them that was not part of the transaction.  For
example, with the dependency chain: pkg1 -> pkg2 -> pkg3, if pkg1 and
pkg3 are being upgraded but not pkg2 pacman would not order pkg1 and
pkg3 properly.

This was particularly problematic when replacements were involved
because the replaced package(s) would be removed at the start of the
transaction.  If an install script required the replacer and lacked
a direct dependency, it could fail.

Fixes FS#32764.

Partially fixes FS#23011.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-26 15:32:15 +10:00
Patrick Steinhardt d7d4f47d63 Install unchanged backup files to get correct timestamps.
Fixes FS#35515.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-26 15:32:15 +10:00
Allan McRae 71328479f3 Merge branch 'maint' 2013-06-18 13:59:18 +10:00
Allan McRae d985a62172 Pull translation updates
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-18 13:17:30 +10:00
Allan McRae 37e85c0031 Document alpm_list files are to be stand alone
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-06 13:47:32 +10:00
Allan McRae 9574bfd6c8 Merge branch 'maint' 2013-06-06 13:47:26 +10:00
Allan McRae 450be928da Pull translation updates and regenerate
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-06 13:12:20 +10:00
Simon Gomizelj dd62fde53e validate %FILEPATH% when parsing repo dbs
Currently we make no effort to validate the %FILENAME% field in the
repo db. This allows for relative paths to be considered valid.

A carefully crafted db entry with a malicious relative path,
(e.g. `../../../../etc/passwd`) will cause pacman to to
overwrite _any_ file on the target's machine.

Add the following validation:

- doesn't start with '.'
- doesn't contain a '/'
- won't overflow PATH_MAX

Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-04 13:45:12 +10:00
Andrew Gregory cbbd3781c2 improve dir->file transition conflict resolution
Packages removed due to conflicts are always removed at the beginning of
the transaction and as such can be included in the check for whether all
owners of a directory will be removed in a transaction.  Installed
versions of packages being upgraded, other than the one with the
conflict, cannot be used because our transaction ordering is not
intelligent enough to ensure that they are removed prior to the
installation of the conflicted package.

Also, return false from dir_belongsto_pkgs on errors.  Previously, we
simply continued which could return true even if we were unable to
actually establish that the package owned the entire tree.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03 13:33:47 +10:00
Andrew Gregory b1e495b88d unlink_file: treat symlinks like normal files
We always want to work with the package file itself, not its target if
it's a symlink.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03 13:33:47 +10:00
Andrew Gregory bc3e73fc8f extract_single_file: consolidate symlink cases
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03 13:33:47 +10:00
Andrew Gregory c91d948486 conflict.c: check for file -> dir replacements
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03 13:33:47 +10:00
Andrew Gregory 0b3d04719d conflict.c: exclude trailing slash from file path
After the initial checks, we either use the path as a directory and have
to append the trailing slash anyway or use it as a file in which case
the trailing slash should be excluded.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03 13:33:47 +10:00
Andrew Gregory aa7e42db11 conflict.c: do not ignore symlink<->dir conflicts
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03 13:33:47 +10:00
Andrew Gregory 5cfa4ec47e alpm_filelist: remove resolved_path
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03 13:33:47 +10:00
Allan McRae dc08eca368 Improve error message when package is missing required signature
When attempting to install a package (either via -S or -U) and the
signature is missing, the current error message "invalid or corrupted
package (PGP signature)" is very unclear.  Instead inform the user
that the package is missing the required signature.

Partial fix for FS#34741.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-29 14:08:03 +10:00
Andrew Gregory e5dd8c2ac5 add.c: refactor backup file modification checks
The previous implementation was overly complex with unnecessary checks
and nested conditionals.  By reordering the tests and changing them to
all be checks for positive hash matches rather than non-matches, we can
collapse several cases and make the process much more linear.  This
removes the need to set hash_orig = "" just to reach some of the checks
and corrects a faulty assumption that files are equivalent when the
hashing process fails.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-29 14:08:03 +10:00
Allan McRae 84ac55b052 Merge branch 'maint' 2013-05-29 14:02:56 +10:00
Allan McRae 1ed881fed3 Fix comment typo
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-18 22:43:12 +10:00
Allan McRae 0f988beff8 Merge branch 'maint' 2013-05-07 12:59:44 +10:00
Allan McRae 35289bc17e More translation updates
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-07 12:53:23 +10:00
Andrew Gregory c5716d0e72 conflict.c: compare package pointers directly
p1 and p2 both come directly from the upgrade list without being copied
so they can be compared directly instead of comparing their names.

Also fix minor style violation.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-05 07:45:33 +10:00
Allan McRae 0aa9628560 Pull translation updates from transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-30 21:18:42 +10:00
Allan McRae c1dfdd2010 Use libalpm version in pkg-config file
We currently use the pacman version number in the libalpm.pc file. It makes
more sense to use the libalpm version.

Fixes FS#34967.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-26 12:43:53 +10:00
Connor Behan b8c8447971 Remove ALPM_QUESTION_LOCAL_NEWER
Remove a question that hasn't been used since the 3.0 days. To prevent
us from having an ugly enum of questions that is missing a bitmask, this
changes the API of the hidden --ask option.

Signed-off-by: Connor Behan <connor.behan@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-24 13:47:19 +10:00
Anatol Pomozov 769facca22 Fix spelling errors using 'codespell' tool
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-18 13:20:13 +10:00
Allan McRae e9639ad172 Update translations from transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-01 15:53:12 +10:00
Richard Pougnet c85d155f3a Improve documentation of libalpm interface functions
Add details to the doxygen for the initialization and relase functions
of the library.

Signed-off-by: Richard Pougnet <richard@pougnet.ca>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-31 11:08:54 +10:00
Allan McRae 3eee3d67af More translation updating
Pull updates from transifex.  Add new "id" translation.  Regerate po
files with updated filelists...

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-17 13:53:38 +10:00
Allan McRae 47a7ea8c86 Update POTFILES.in for libalpm and pacman
Be complete with files listed. Comment out files where code is used
or heavily based on other projects so will never have translatable
strings.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-17 13:53:38 +10:00
Allan McRae aa550a85f1 Merge updates from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-15 13:21:32 +10:00
Allan McRae a97f792d3c Remove Indonesian translation
I imported this translation from transifex without realising that there
was no strings translated despite being "acitve" on transifex for quite
some time.  Remove it until translation begins...

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-15 13:21:32 +10:00
Dan McGee 163c36bdcd Save and restore old locale when manipulating via setlocale
We shouldn't assume a frontend program didn't explicitly set the LC_TIME
setting to a value not in the environment, which is what we previously
assumed. Save the old locale before forcing the 'C' locale and restore
it when we are done.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-14 11:47:11 +10:00
Andrew Gregory d35a7fb6f3 alpm/remove.c: add newlines to debug output
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-14 11:47:11 +10:00
Allan McRae 1e21aa589d Update all translations files to push to Transifex
Run update-po and fix the few errors reported.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 13:32:11 +10:00
Allan McRae c5652361fb Pull updated translations from transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 13:32:10 +10:00
Allan McRae 1366da57fa Add new languages from Transifex
Languages: eo, nl, hr, ko, ja, fa, ar, sl, gl, id

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 13:32:10 +10:00
Simon Gomizelj ce9fd69eba make status/log messages reflect version change
Currently pacman either prints 'adding' or 'upgrading' when installing
a package. This make pacman print and log the other possible actions:
'downgrade' and 'reinstall'

Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 09:01:56 +10:00
Dave Reisner 08a1244f4e libalpm/sync: remove useless intermediate variable
This also rearranges some code to ensure that declarations and code
aren't mixed.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10 09:01:56 +10:00
Olivier Brunel 017184fab5 libalpm: Search for replacers before literals
Since 882bff36 literals would be searched before replacers, resulting in a
package being replaced by another not actually being replaced under certain
conditions (e.g. they're both in the same repo).

This change effectively reversed the expectations in test sync132. This patch
switches the order back to replacers first, thus making sure if a package is
replacing another one, the change will always happen, even if both are in the
same repo.

Note that a package replacing another one in a repo with higher priority will
not be done, see FS#11737 and test sync1105

Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07 15:38:47 +10:00
Olivier Brunel 1b39653e96 libalpm: Fix installing update of a replaced package
During a sysupgrade, if a package is replaced by another, and an update for the
former package is found (on another repo) the replaced package would be
re-installed.

Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07 15:38:47 +10:00
Allan McRae e6b8d5189f Do not resolve every local package filelist on remove
Although technically correct, this results in my system taking ~30 seconds
to resolve all filelists when removing a package that has a directory not
owned by any package.  The check for if any package own the empty directory
is a rare enough occurance, and it will be even rarer when that directory
has a directory symlink in its path, so just revert this at this stage.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07 15:38:47 +10:00
Andrew Gregory 8e2648bf02 add SYMEXPORT to alpm_filelist_contains
alpm_filelist_contains is listed in alpm.h and should be public but was
not exported.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24 13:11:54 +10:00
Dave Reisner 3d142fe8ef dload: don't download sig if package is found in cache
Avoids the segfault seen in FS#33911.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24 13:11:54 +10:00
Richard Pougnet 63baba13ec Provide full path names in warning messages
Fix FS#31556 by printing filename instead of entryname. Thus,
removing a lot of confusion from the output.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24 13:11:54 +10:00
Allan McRae 34749e177d Perform limited conflict checking with --force
Pacman currently bails when trying to extract a file over a directory
when using --force.  Instead of ignoring all conflict, perform the
check and skip any file-file conflicts. Conflicts between directories
and files are still flagged and cause the transation to abort.

As a bonus, we now know about files changing packages when using
--force, so we can skip removing them fixing upgrade046.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24 13:11:54 +10:00
Andrew Gregory 19754b34a3 use resolved_path for filelist_contains
alpm_filelist_contains was being used to search for resolved paths, but
searching in the unresolved paths, causing it to miss matches.  We
always search unresolved paths and search the resolved paths if
available because _alpm_filelist_resolve is not public and requires
a context handle, so it can't be called from alpm_filelist_contains.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24 13:11:54 +10:00
Andrew Gregory 083ac51816 return resolved paths from filelist_difference
We were comparing files based on resolved paths but returning the
original file_t structures, which were not necessarily in the same
order.  The extra file_t information was only being used to determine if
the file was a directory which can be accomplished by testing for
a trailing slash, so just return the resolved path.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24 13:11:54 +10:00
Andrew Gregory 9995510dc8 return resolved paths from filelist_intersection
We were comparing files based on resolved paths but returning the
original file_t structures, which were not necessarily in the same
order.  The additional file_t information was never used, so just return
the resolved path.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24 13:11:54 +10:00
Andrew Gregory 0bbc406ee8 use alpm_list_free on filelist intersection
alpm_filelist_intersection returns a list of pointers to internal file_t
struct's, so only the list itself should be freed.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24 13:11:54 +10:00
Andrew Gregory bc747fbfbf fix off-by-one error in _alpm_filelist_resolve
'/' should not be appended to the resolved root when root is "/".

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-16 11:06:43 +10:00
Andrew Gregory d5a5a6b512 fix style violations
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-16 11:06:43 +10:00
Andrew Gregory 578dfcd977 fix alpm_validation_t comment
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-16 11:06:43 +10:00
Andrew Gregory c1a84c03b2 find_fileconflicts: reduce path resolution calls
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-16 11:06:43 +10:00
Dave Reisner 26a79cb29d libalpm: never attempt to remove a mountpoint
Arch Linux typically runs into this with /sys when upgrading the
filesystem package in build chroots, but LXC users might also run into
this, since their /sys is shared from the host and must, for security
reasons, be mounted RO.

I've neglected to add any tests for this because they would require root
in order to run. Current tests all pass with this patch and I've
confirmed the desired behavior in a VM. Incidentally, the first hunk of
this patch (skipping can_remove_file checks for directories) resolves the
case of API mountpoints being removed since they eventually fall into
unlink_file and fail with "contains files". However, this patch should
still be the Right Thing To Do™, as we can't possibly remove a directory
that is also a mountpoint.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>

[Allan] Do not skip checking if directories can be removed. Instead test
if directories are mountpoints in can_remove_file.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-16 11:06:43 +10:00
Allan McRae 8fe8233dfa Fix registering database with non-gpgme builds
We record whether the default SigLevel is set in order to add upon
it for the *FileSigLevel entries.  When using the only valid value
of "SigLevel = Never" with non-gpgme builds, we need to ignore
the ALPM_SIG_PACKAGE_SET flag when determining if we have a valid
value for the database SigLevel.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-13 11:50:33 +10:00
Allan McRae 87ffc648b7 Fix --without-gpgme build
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-13 11:50:33 +10:00
Allan McRae 3fa2830829 Add format attributes to all required functions
Fixes all clang warnings with -Wformat-literal.

Also, fix genuine formating issue discovered once adding these attributes
and add a cast to prevent a gcc warning.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-13 11:50:33 +10:00
Allan McRae bafee395a6 Fix compilation error on clang
This also lead me to notice that in _alpm_gpgme_checksig many things
were not being cleaned up.  Fix this by having CHECK_ERR goto gpg_error
and make the required adjustments.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-13 11:50:32 +10:00
Allan McRae 17d4ec5ed8 Skip reading sync db deltas files if UseDelta is unset
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:37 +10:00
Allan McRae 5f5469c774 Import key if needed when installing package from file
When installing a package with "pacman -U" that has a detached
signature, check if the needed key is in the keyring and download
if necessary.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:37 +10:00
Allan McRae 0d89c10f4b Prompt to delete packages with signature fails
Offer to remove the bad package when a signature fails to validate
as is done for checksum failures.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:37 +10:00
Allan McRae 4ccf16dff5 Remove retry path from signature validation
Now that the keyring is checked for all needed keys before the
validation, we can not reach a point of a missing key when doing
validity checks for sync operations.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:37 +10:00
Allan McRae 31b9b264c1 Check keys are in keyring before package validation
Keys used to create signatures are checked for presence in the keyring
before package validation is performed.

Signed-off-by: Allan McRae <allan@archlinux.org>

Conflicts:
	lib/libalpm/alpm.h

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:37 +10:00
Allan McRae 198154962b Make decode_signature available to the library
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:37 +10:00
Allan McRae 05745089ac Add function to extract key id from signatures
This does not support all possibilities of RFC4880, but it does
cover every key currently used in Arch Linux.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:37 +10:00
Allan McRae 4ec6848f91 Move key importing into separate function
This will be useful for checking the availablity of all keys before
perfoming validation in sync operations and for downloading a needed
key in upgrade operations.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:36 +10:00
Allan McRae 45b6d36cf7 Make key_in_keychain available in library
In preparation for checking key presence and downloading needed keys
before conflict checking.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-09 12:43:36 +10:00
Dave Reisner 7edd262a06 inline libarchive compat wrappers
Suggested-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-07 10:48:11 +10:00
Allan McRae 33b3b6d9b8 Add configuration option for Upgrade operation SigLevel
Add LocalFileSigLevel and RemoteFileSigLevel to control the signature
checking for "pacman -U <file>" and "pacman -U <url>" operations
respectively. The starting value for both these options is SigLevel,
if it is specified in the [options] section, or the built-in system
default. The specified values override and/or supplement this initial
value. Note there is no distinction between setting "Required" and
"PackageRequired" as there are no database options for Upgrade
operations.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-07 10:48:11 +10:00
Dan McGee 3aece8f0ee Restore libarchive 2.8.x compatibility
We still call some of these 'deprecated' methods elsewhere, so this
shouldn't present a problem. When we decide 2.x support is to be dropped,
we should update all of the code to not call deprecated methods.

Allan: Adjusted with respect to previous patches adding libarchive
compatibilty layer.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-29 13:37:32 +10:00
Dave Reisner e1e4bbb79d Use libarchive compat header for relevant symbols
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-29 13:37:32 +10:00
Dave Reisner 2a57c2068c add libarchive compatability object
This allows us to support both libarchive 2.8.x as well as 3.x without
deprecation warnings on compile.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-29 13:37:32 +10:00
Dave Reisner 27067b1372 dload: pass back the effective URL to callers of _alpm_download
I suspect that eventually we're going to end up returning a pointer to
an allocated struct to describe the download result, but that's for
another patch when the need arises...

Fixes FS#33508.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-29 13:36:58 +10:00
LANGLOIS Olivier PIS -EXT f21e1f54aa Relax requirement of what constitutes a dead connection
Users have hit issues behind corporate firewalls that initially throttle
downloads to ~1B/sec.

Signed-off-by: Olivier Langlois < olivier.pis.langlois@transport.alstom.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-29 13:36:58 +10:00
Andrew Gregory 66a9b53141 add caller prefix to alpm_logaction
prefix defaults to "UNKOWN" if null or an empty string is provided.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-28 23:38:46 +10:00
Andrew Gregory 6bbf6e8fa1 add doxygen comments to conflict.c
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-28 23:38:46 +10:00
Allan McRae 89ecf8cabe Make path to ldconfig configurable
The FHS (2.3) says having ldconfig in /sbin is optional and it is usually
located in /usr/sbin.  So /sbin/ldconfig should not be hard coded in
pacman.  Instead, provide a configure option --with-ldconfig that defaults
to the current path.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-28 23:38:46 +10:00
Allan McRae ad280e1b56 Revert execvp and related commits
This reverts commit 4a8c2852a8.
This reverts commit 993700bc6b.
This reverts commit bb4d2b72c1.
This reverts commit 60b192e383.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-28 23:30:40 +10:00
Dave Reisner 132e1ac10c dload: avoid showing progress bars on some redirects
RFC 2616 doesn't forbid a 301 or 302 repsonse from having a body, and
servers exist in the wild that show this behavior. In order to prevent
pacman from showing a progress bar when we aren't actually downloading a
package (and merely following one of these pain in the butt redirects),
capture the server response code in the response header, rather than
waiting to peel it off the handle after the download has finished.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Reported-by: Alexandre Filgueira <alexfilgueira@cinnarch.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-17 22:32:54 +10:00
Allan McRae bb4d2b72c1 Do not use full path for ldconfig
The ldconfig binary is not guaranteed to be in /sbin. Change to calling
just "ldconfig" rather than using the full path.

This removed the check that the ldconfig binary exists. However, it is
a reasonable assumption that it will exist if its configuration file
does.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-17 22:32:54 +10:00
Allan McRae 60b192e383 Use execvp for running programs in chroot
This makes us more robust to utilities changing paths.  There is no
functional change when a full path is specified.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-17 22:32:54 +10:00
Gerardo Exequiel Pozzi 86eefc1a3a Fix space between control structure and open parens
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04 21:49:38 +10:00
Gerardo Exequiel Pozzi b5709b8171 Fix open braces style
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04 21:49:37 +10:00
Gerardo Exequiel Pozzi e13a3bf599 Fix missing spaces in operators
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04 21:49:37 +10:00
Pang Yan Han b6320de4be Save backup files with extension .pacsave.n
Teach pacman to save backup files with extension .pacsave.n, where n is a
positive integer. The current backup file shall be saved as <name>.pacsave,
while existing .pacsave.n files will be renamed to <name>.pacsave.n+1

Example:
1. You have subversion installed in your local repo. /etc/conf.d/svnserve
   is a file to be backed up. It contains local modifications

2. You remove subversion from your repo. /etc/conf.d/svnserve is backed up as
   /etc/conf.d/svnserve.pacsave

2. You install subversion again

3. You edit /etc/conf.d/svnserve

4. You remove subversion. The existing /etc/conf.d/svnserve.pacsave is renamed
   to /etc/conf.d/svnserve.pacsave.1 and /etc/conf.d/svnserve is backed up as
   /etc/conf.d/svnserve.pacsave

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>

Rebased from original email and adjusted for util-common usage.
Signed-off-by: Florian Pritz <bluewind@xinu.at>

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04 21:49:37 +10:00
Allan McRae 27d9c25ee2 Split common utility functions for libalpm and pacman
There is duplicated code in the util.c files in the libalpm and pacman
source code. Split this into a separate file so that it can be shared
via a symlink. This prevents code divergence between the two code bases.

Also, move mbasename and mdirname from pacman/util.c into util-common.c
in preparation for the following patch that uses them to add an extension
to pacsave files.

Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04 21:49:37 +10:00
Dan McGee 2616cb5fdc Use a defined constant in delta.c for num_matches
This allows compiling in both clang and gcc without running into
oddities regarding const vs. defined constant values.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-03 12:03:10 +10:00
Allan McRae 1dd3405813 Update copyright year for 2013
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-03 12:03:09 +10:00
Allan McRae 097d5a478b Add public functions for accessing mtree data
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 13:45:12 +10:00
Allan McRae 0445c68d9b Add internal functions for reading mtree file from local db
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 13:45:12 +10:00
Allan McRae da3a0333de Extract .MTREE file into local package database
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 13:45:12 +10:00
Allan McRae f5d904d97f Do not warn about missing database if being downloaded
When a configured repo database is not already downloaded, a warning
message such as "warning: database file for 'testing' does not exist"
is printed.  Disable this warning when the database is scheduled to
be downloaded in the transaction.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae 422a4021e4 Fix future signature timestamp warning
The warning given for a signature timstamp being in the future compared
to the system time stated the opposite.

Also, move this warning to debug output.  It is useless in its current
form as the package or database that is giving the error is not
mentioned and so other debug output is needed to find the offending
signature.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Andrew Gregory 964640fbfc Plug various minor memory leaks
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae 62f1c590fc Make alpm_pkg_find public
This function is particularly useful, so make it public.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae d0e5cd2c7f Add "Optional for" to package information output
Much like packages that require a give package are displayed in the
"Required by" field of its information output, alos display packages
that optionally require the package.

Inspired-by: Benedikt Morbach <benedikt.morbach@googlemail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae eb9e74ecc7 Notify of removed package required as optdepend
When a package is being removed, provide a notification (via a callback)
if any local package requires it as an optdepend.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae 0c2edbdd49 It turns out we do care about directories...
This is a bug that has been around since at least 2007.  On a package
upgrade (either by -S or -U) a new directory could overwrite any file.
This is caused by the filelist difference calculation ignoring all
directories and thus no new directories were checked for conflicting
files on the filesystem.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Andrew Gregory 5a247ccbd4 Fix overzealous package removal with unmet dependencies
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>

[Allan: Remove expected failure from fixed pactests]
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Andrew Gregory 9cd7ff807d _alpm_filelist_resolve: add useful return code
Return -1 if a path is too long to resolve or we run out of memory.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae 948f135a73 Avoid upgrade conflict with unchanged effective path
This applies to a case such as when /lib is a symlink to /usr/lib. If a
package is installed which contains /lib/libfoo.so, pacman will complain
if this package is then "fixed" to contain /usr/lib/libfoo.so. Since
these have the same effective path and it exists within the same
package, ignore the conflict.

Fixes FS#30681.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae 88e7ea421e Resolve file paths during inter-package conflict check
File paths are resolved if necessary during inter-package conflict
checks so that packages carrying the same effective file due to
directory symlinks on the filesystem are flagged as conflicting.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Andrew Gregory 28d404f16a _alpm_filelist_resolve: use original filenames where possible
If a filename isn't resolved, the original can be used instead of strdup()ing
it.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Andrew Gregory 80bc89c147 Add _alpm_filelist_resolve
The _alpm_filelist_resolve function takes a filelist and creates
a list with any symlinks in directory paths resolved.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae 2fad78974d Add resolved_path to alpm_filelist_t
Add an array to hold the resolved paths of the files in alpm_filelist_t.
When the file name and its resolved file name are identical, the pointer
to the original file name is used to avoid duplicate memory allocation.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Allan McRae c1abfeae1e Detect inter-package conflicts between files and directories
Detect a conflict between a file/symlink in one package and a directory
in another when both are being installed at once.

A side effect is the creation of conflicts between a directory symlink
and a real directory (e.g lib -> usr/lib in pkg1 and /lib in pkg2).
Given we can not guarantee pkg1 is installed before pkg2, this is a
genuine conflict.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Paul Barbu Gheorghe b25dda737b fixed erroneous memory access to newurl in alpm_db_remove_server
Signed-off-by: Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27 15:16:15 +10:00
Dave Reisner 40d6894910 buildsys: eschew use of DEFS, prefer AM_CPPFLAGS
This is redundant, and any usage of -D should belong to CPPFLAGS.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-11-27 15:16:15 +10:00
Dan McGee 369c5aa7dd Merge branch 'maint' 2012-09-18 08:36:10 -05:00
Florian Pritz f7558856b1 signing.c: warn if time went backwards
GPG signatures have a timestamp which is checked and if it's in the
future, verification will fail.

Dan: slight wording change.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2012-09-18 08:35:53 -05:00
Allan McRae 87f9377b32 Fix documentation typo
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-09-18 08:30:05 -05:00
Allan McRae e32d129967 Remove incorrect documentation for unlink_file
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-09-18 08:29:55 -05:00
Barbu Paul - Gheorghe c52bb7030c removed the condition in alpm_db_set_servers since FREELIST is NULL safe
Signed-off-by: Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-07 20:56:57 -05:00
Dan McGee 0c95b294e9 Merge branch 'maint' 2012-08-07 20:54:59 -05:00
Florian Pritz 8853a6f282 coding style fixes
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-07 20:32:30 -05:00
Allan McRae c9b31ad622 Print repo being search for replaces in debug output
Given the message is repeated for each repo, it is a good idea to
print the repo name in the output.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-07 20:30:54 -05:00
Allan McRae d46bb6b27b Split _alpm_filelist_operation function
To improve conflict checking, we will need to make these functions
diverge to an extent where having two separate functions will be
preferable.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-02 09:40:44 -05:00
Dan McGee 72d3713cc7 Move filelist functions into separate source file
We have a few of these and might as well gather them together. This also
cleans up the code a bit by using an enum instead of integer values, as
well as makes a "search for file in filelist" function public so
frontends can do better than straight linear search of the filelists.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-02 09:39:08 -05:00
Dan McGee 7193ce1ecd Merge branch 'maint' 2012-08-01 09:21:33 -05:00
Barbu Paul - Gheorghe e94876089a Fix wrong parameter name in alpm_db_update's signature
Signed-off-by: Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com>
2012-08-01 09:14:52 -05:00
Dave Reisner ddbd36103d util: fix line length calc in _alpm_archive_fgets
74274b5dc3 which added the real_line_size to the buffer struct
didn't properly account for what happens when archive_fgets has to loop
more than once to find the end of a line. In most cases, this isn't a
problem, but could potentially cause a longer line such as PGP signature
to be improperly read.

This patch fixes the oversight and focuses on only calculating the line
length when we hit the end of line marker. The effective length is then
calculated via pointer arithmetic as:

  (start_of_last_read + read_length) - start_of_line

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-08-01 08:53:10 -05:00
Dave Reisner 35ac4e7ef3 lib/conflict: use a binary search within filelists
Take advantage of the fact that our filelists are arrays sorted by
filename with a known length and use a binary search. This should speed
up file conflict checking, particularly when larger packages are
involved.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01 08:53:10 -05:00
Dave Reisner c5e7eeece7 lib/be_local: ensure local filelists are sorted
This may very well be a no-op, but better safe than sorry.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01 08:53:10 -05:00
Dave Reisner 8fe383860e lib/be_package: use qsort instead of our own msort
On the assumption that these arrays are already mostly sorted, use the
standard quicksort method to sort the files arrays. The files_msort
function name is tweaked to give it a more general name to reflect this
change.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01 08:53:10 -05:00
Dan McGee 7520c0facb Add more debug logging to dir_belongsto_pkg() function
Now that we pass in the handle, we might as well add logging.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01 08:52:41 -05:00
Dan McGee e41ca0f2f6 Merge branch 'maint'
Conflicts:
	etc/makepkg.conf.in
2012-07-10 08:41:18 -05:00
Dave Reisner e0daaea38c update comments referring to alpm_option_get_syncdbs
This function was renamed alpm_get_syncdbs as part of b488f229d.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-07-10 08:37:59 -05:00
Dave Reisner ea3439f928 diskspace: log errors when opening the mount table fails
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-10 08:33:33 -05:00
Allan McRae 44e9fdd0e8 Check empty subdirectory ownership
When checking if a package owns a directory, it is important to check
not only that all the files in the directory are part of the package,
but also if the directory is part of a package.  This catches empty
subdirectories during conflict checking for directory to file/symlink
replacements.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-10 08:31:48 -05:00
Allan McRae 717fdb8ee0 Add conflict for replacing owned empty directory
When two packages own an empty directory, pacman finds no conflict when
one of those packages wants to replace the directory with a file or a
symlink.  When it comes to actually extracting the new file/symlink,
pacman sees the directory is still there (we do not remove empty
directories if they are owned by a package) and refuses to extract.

Detect this potential conflict early and bail. Note that it is a
_potential_ conflict and not a guaranteed one as the other package owning
the directory could be updated or removed first which would remove
the conflict.  However, pacman currently can not sort package installation
order to ensure this, so this conflict requires manual upgrade ordering.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-10 08:29:37 -05:00
Dave Reisner e183522e31 diskspace: only load filesystem info on demand
Only load filesystem details for the mount points that we're actually
going to write to. This reduces our syscall count considerably. In the
case of installation, we would actually stat every mountpoint twice (an
extra round for download diskspace) which means (on my system) a total
of 60 syscalls to write to 3 partitions when installing the kernel
package. This change reduces the 60 syscalls down to the expected 3.

A slight debug output change is added here to discern between a
mountpoint added to our linked list versus when we actually load the fs
info.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-06-25 23:37:10 -05:00
Dave Reisner 82c999a8bf diskspace: dedupe code for loading FS usage
add mount_point_load_fsinfo() for platforms using getmntent().

Dan: move the #ifdef slightly so we don't have unused functions on
certain platforms (e.g., OS X).

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-06-25 23:26:50 -05:00
Allan McRae e253968b4d repo-add: add checkdepends information
Similar to the case for makedepends, it is useful to be able to
access this information without parsing a PKGBUILD.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-06-25 23:08:15 -05:00
Dave Reisner f556fe8b4a add line length parameter to _alpm_strip_newline
If known, callers can pass the line size to this function in order to
avoid an strlen call. Otherwise, they simply pass 0 and
_alpm_strip_newline will do the call instead.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-06-25 23:04:31 -05:00
Dave Reisner 74274b5dc3 add real_line_size to alpm_read_buffer
We inevitably call strlen() or similar on the line returned from
_alpm_archive_fgets(), so include the line size of the interesting line
in the struct.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-06-25 23:04:24 -05:00
Dave Reisner 6a5370b634 check proper variable for NULL
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-06-25 23:01:28 -05:00
Dave Reisner 9ce4f80db4 diskspace: canonicalize path to download dir
With lazy loading in place, it's now quite obvious that we aren't
necessarily checking the right mountpoint for necessary download space.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-06-25 23:00:12 -05:00
Andrew Gregory ac990b96e7 libalpm/remove.c - add doxygen
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-21 00:03:20 -05:00
Allan McRae 81bc390dc1 repo-add: add makedepends information
This is useful for tools that automatically rebuild packages and
thus require to generate a build order. These entries are skipped
by pacman.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-20 19:03:43 -05:00
Dave Reisner e533478e02 fix -Wshadow warnings as reported by gcc 4.4.3
Apparently gcc 4.7 has decided that -Wshadow warnings aren't worth
reporting anymore even with the flag enabled. These were found on
an Ubuntu 10.04 install.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-20 17:54:42 -05:00
Dan McGee 9f6a67fee7 Merge branch 'maint'
Conflicts:
	scripts/pacman-key.sh.in
2012-05-20 17:41:21 -05:00
Dan McGee 1bf05e706b Ensure pre_upgrade scriptlet gets old package version
This was accidentally broken in the refactor done in commit 73139ccb.

Fixes FS#29371.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-04 11:41:40 -05:00
Dan McGee 5a9f5c60da Convert ALLOC_FAIL macro into a function
This path is rarely (read: never) taken in any normal run of the code,
so injecting the fprintf() call everywhere with the macro is a bit
overkill. Instead, add a lightweight _alpm_alloc_fail() function that
gets called instead.

This does have a reasonable effect on the size of the generated code;
most places using the macros provided by util.c have their code size
reduced.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-29 23:40:06 -05:00
Dan McGee 4d31709787 be_local: use the right length value for filename in all cases
Increment the strlen() provided value by 1 for the NULL byte so we use
the right value in all three places we later reference it.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-29 23:23:54 -05:00
Dan McGee 8c7202ca19 Merge remote-tracking branch 'dave/buildsys' 2012-04-29 20:27:32 -05:00
Dan McGee 52a9a5240a Move short-lived realpath buffers to the stack
There is little reason here to grab 4K from the heap only to return it a
few lines later. Instead, just use the stack to hold the returned value
saving ourselves the malloc/free cycle.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-29 20:14:10 -05:00
Dave Reisner 82b7122542 libalpm: add pkg-config file
No one seems to do this "correctly", but for the sake of having an easy
method of detecting the presence and version of libalpm on a given
system, we provide a straightforward .pc file.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-25 20:02:36 -04:00
Dan McGee e0afd81d18 Pointer coding style cleanups
'foo_type_t *variable' rather than 'foo_type_t* variable'.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-24 21:05:51 -05:00
Dan McGee dbc58d9386 be_local: write all single-valued attributes first
There isn't a whole lot of reason other than code clarity for this, but
it makes it a bit more obvious where multivalued attributes start.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-24 21:01:55 -05:00
Dan McGee d7b728591a Merge branch 'maint' 2012-04-12 08:57:26 -05:00
Dan McGee ded66fbb62 Fix issues with unintialized variable value usage
Detected by clang scan-build static code analyzer.

* Don't attempt to free an uninitialized gpgme key variable
* Initialize answer variable before asking frontend a question
* Pass by reference instead of value if uninitialized fields are
  possible in download signal handler code
* Ensure we never call strlen() on NULL payload->remote_name value

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-09 00:46:54 -05:00
Dan McGee c27a946769 Fix a signed overflow error on i686 with GCC 4.7.0
Not sure why this one wasn't showing up on x86_64, but this fixes the
compile on i686.

    diskspace.c: In function 'calculate_removed_size':
    diskspace.c:247:4: error: assuming signed overflow does not occur when negating a division [-Werror=strict-overflow]
    cc1: all warnings being treated as errors

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-08 22:32:49 -05:00
Dan McGee a8a1b093eb Various tweaks to support building with excessive GCC warning flags
This fixes a bunch of small issues in order to enable a clean
successful build with a crazy number of GCC warning flags. A lot of
these changes are covered by -Wshadow, -Wformat-security, and
-Wstrict-overflow=5.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-08 22:28:45 -04:00
Dave Reisner 793eff3704 buildsys: define warning CFLAGS in separate var
Continue the trend of not touching the environment CFLAGS, ensuring that
the user always has the final say.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-08 22:28:45 -04:00
Dave Reisner cb5b66367d buildsys: cleanup gpgme compile time check
- handle gpgme libs and cflags separately rather than appending to
  CFLAGS and LDFLAGS
- be consistent in AC_LINK_IFELSE check for gpgme 1.3.0 (though this is
  irrelephant since we don't actually run)
- be consistent with usage of "have" and "with" variables (this
  actually ends up reducing SLOC)
- when voluntary detection fails, unset GPGME_CFLAGS and GPGME_LIBS
- when requested support fails the version check, complain about the min
  version.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-08 22:28:41 -04:00
Dave Reisner b2226ed11b buildsys: use pkg-config for libcurl detection
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-08 18:48:31 -04:00
Dave Reisner 059c572ca5 buildsys: use pkg-config for libarchive detection
This also introduces a versioned dependency of >=2.8.0.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-08 18:48:31 -04:00
Dave Reisner c5d951846d buildsys: use pkg-config for openssl detection
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-08 18:48:31 -04:00
Allan McRae 3be02aa27c Prefix alpm_pkgfrom_t members with ALPM_
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-07 11:29:55 -05:00
Dan McGee 42d408e0c2 Return more useful error codes on package open failures
Failure isn't always due to the package file location not existing;
permission issues can also play a part on something like a FUSE-based
filesystem inaccessible to root.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-07 11:29:11 -05:00
Allan McRae b5043dd6c3 Make selecting scriptlet shell work
The initial patch to implement this achieved nothing apart from
adding a configure option.  This patch makes that configure option
do what it advertises.

Note that specifing any shell apart from /bin/sh causes testsuite
failures as /bin/sh is the only shell in the testing environment.

Bug-found-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-07 11:27:56 -05:00
Dan McGee 4ca6590af5 Merge branch 'maint'
Conflicts:
	lib/libalpm/signing.c
	lib/libalpm/sync.c
2012-04-07 11:23:55 -05:00
Dave Reisner 391769ff89 sync: fix crash on failed downloads
Dan was right. This should have been FREE(), not free().

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-07 10:13:38 -05:00
Dan McGee 72ba4fb83f Updates from Transifex
This encompasses a few languages that have had changes since 4.0.2
available on Transifex.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-07 10:13:37 -05:00
Dan McGee 1eeab12228 Update all translation files
Pull updates from transifex, run update-po on all files, fix a few
errors, and push them back to Transifex.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-28 18:05:06 -05:00
Dave Reisner be0e044404 signing: cope with gpg2's failure at life
For key searches only, gpg2 will fail to lookup any and all keys that
are not prefixed with 0x.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-28 09:55:14 -05:00
Dan McGee e6f72c61a0 Merge branch 'maint'
Conflicts:
	lib/libalpm/sync.c
2012-03-16 12:08:10 -05:00
Dan McGee 930e93b892 Prefer fputs/fputc over fprintf when writing local database
Using fputs should be faster as no format string parsing is required. It
also prevents silly errors related to unescaped '%' signs, and removes
the need to double them up in a lot of places.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-16 09:49:31 -05:00
Dan McGee 89f4dd88d7 Extract a write_deps function from local database writing
This reduces a lot of code duplication in the write function, which
cleans it up a bit.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-16 09:49:31 -05:00