Commit Graph

1681 Commits

Author SHA1 Message Date
Dan McGee 1a8c792e8f Fix an outdated comment
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-29 02:20:54 -05:00
Dan McGee 4a3cd364d0 Temporary fix for new warnings from gcc 4.6
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-27 20:48:26 -05:00
Dan McGee 3f269503d5 Merge branch 'maint'
Conflicts:
	lib/libalpm/deps.c
2011-03-27 20:41:23 -05:00
Dave Reisner a9fb4d9d5b lib/dload: abstract out helper function to set utimes
This greatly simplifies the cleanup fallthrough in our download function
and we'll be able to reuse this for signatures.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-27 20:14:47 -05:00
Dave Reisner 98c8ab18ff lib/dload: remove proxy debug output
Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-27 20:14:20 -05:00
Dave Reisner 33c08ac91e lib/dload: code simplification
Based on the fact that localf always points to the same file, there's no
need to code in multiple fopen calls with varying results. Instead,
track the desired file open mode and make a single call to fopen.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-27 20:14:10 -05:00
Dave Reisner fd64988c80 lib/dload: merge get_{destfile,tempfile} into get_fullpath
Create a more general function that allows appending a suffix to a
filepath.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-27 20:12:51 -05:00
Dave Reisner 55f790ebe4 pacman/pacman.c: fix setting of useragent string
libcurl doesn't natively honor the HTTP_USER_AGENT environment variable.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-27 20:12:29 -05:00
Dave Reisner 283bf7e87c lib/dload: pass a struct with filename and size to curl_progress
This lets us determine the real size of the file on disk so that we can
properly bump the progress bar when we're resuming a download.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-27 20:12:17 -05:00
Dan McGee 68701a98af Ensure reported missing dependencies show correct version comparison
This addresses FS#23424. The -dd backend code was introduced in commit
b6ec9019d7, and unfortunately the munged depend used for comparison did
not carry through to the eventual display of this version. To fix this,
we undo some of the depcmp_tolerant() business introduced, and instead
make a new pmdepend_t object if necessary when the no dependency version
flag is set. This results in the correct depend being copied to the
missing depend passed onto the frontend.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-25 15:43:08 -05:00
Dan McGee 3bc3999bd2 Mark various functions in deps.c static
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-25 15:40:12 -05:00
Dan McGee 5a9a570dda Move alpm_find_dbs_satisfier() function down in deps.c
This will make sense for a later commit when static/non-static
properties of other functions are changed.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-25 15:40:12 -05:00
Dan McGee c40fc6b80d Rework find_requiredby() to not use _alpm_dep_edge()
And move the sort after the final loop; we don't need to sort once for
each database we look at.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-25 15:40:12 -05:00
Dan McGee 7f480ccc0d Don't include version in dep string if mod == ANY
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-25 15:40:12 -05:00
Dan McGee 86e7f60756 Merge branch 'maint' 2011-03-24 21:18:09 -05:00
Dave Reisner e68e994eb2 alpm/db: do not close local DB in alpm_db_unregister_all
pacman 3.5.0 removed alpm_db_register_local, so calling
alpm_db_unregister_all leaves the front end in a position where there's
no local db, and no way to re-register it.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-24 17:18:24 -05:00
Allan McRae a8b22e16ef Do not reuse old signature
After updating a database, remove the old signature to prevent it
being used in validation if the new signature fails to download.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-03-23 22:58:32 -05:00
Allan McRae 38da050f31 Download and verify package database signatures
If signature verification is needed, attempt to download a signature
file for a repo when it is updated. Return an error if unable to
download signature only when checking is mandatory, or if signature is
invalid.

TODO: At the moment the database signature is only checked on download.
Should we do anything with a database if it fails to be verified to prevent
its future usage?

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-03-23 22:58:00 -05:00
Dan McGee 9a3325a56d Refactor signature loading code into common function
We can use this for both standalone package signatures as well as
standalone database signatures.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 22:56:54 -05:00
Allan McRae ed6fda2f98 Add functions for verifying database signature
Add a pmpgpsig_t struct to the database entry struct and functions for
the lazy loading of database signatures.  Add a function for checking
database signatures, reusing (and generalizing) the code currently used
for checking package signatures.

TODO: The code for reading in signature files from the filesystem is
duplicated for local packages and database and needs refactoring.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-03-23 22:22:33 -05:00
Dave Reisner b9263fb4e1 lib/dload.c: Check for dlcb == NULL earlier
Our curl callback does a whole lot of work for nothing if the front end
never defined a callback to receive the data we'd calculate for it.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 11:04:42 -05:00
Dave Reisner 47e41b2023 lib/dload.c: don't use deprecated curl symbols
CURLINFO_HTTP_CODE is deprecated in favor of CURLINFO_RESPONSE_CODE.
Both yield the same values.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:44:16 -05:00
Dave Reisner e29301954c lib/dload.c: don't request compressed transport
The files we transfer are generally compressed already, so this just
adds unnecessary overhead.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:44:10 -05:00
Dave Reisner 82fb7a0202 lib/dload.c: Fix progress callback issues on download
Use a static variable to effectively track the initialization state of
the progress callback via the last byte amount reported as downloaded by
libcurl.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:43:58 -05:00
Dave Reisner 768451c5e3 lib/dload.c: fix compiler warnings generated by -Wfloat-equal
* introduces new macro in util.h (DOUBLE_EQ) for properly comparing
  floating point values

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:43:53 -05:00
Dave Reisner db49c4a7f0 buildsys: use libcurl's m4 macro for buildtime detection
Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:43:17 -05:00
Allan McRae 2f060dec6a Report output from signature checking to debug log
Move the (possibly still temporary) output generated during signature
checking into the --debug output.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:36:48 -05:00
Xavier Chantry f9505063f8 Added gpg verification options per repo to the config file.
Once we do this, add support for VerifySig to pactest. We just check if
the repo name contains Always, Never or Optional to determine the value
of VerifySig. The default is Never. pacman uses Always by default but
this is not suitable for pactest.

Original-work-by: shankar <jatheendra@gmail.com>
Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:35:50 -05:00
Dan McGee 18c6946961 Remove unnecessary sanity check on db->setserver
We pass in a db object, so no need to go looking for it in the list on
the handle. This is a remnant of when we passed in a treename, more than
likely.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:33:31 -05:00
Dan McGee 39c75c7000 Integrate GPGME into libalpm
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:16:29 -05:00
Dan McGee 061948597d Add some error codes for signature verification
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:16:29 -05:00
Dan McGee 4ae902ec5f Add signature directory as option on libalpm handle
This will serve as the home directory we pass to GPGME when making calls so
we can have a libalpm-utilized keyring.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:16:29 -05:00
Dan McGee 39ce9b3afc Actually read PGPSIG field in sync DB code
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 03:07:08 -05:00
Dan McGee f7b577dc77 Merge branch 'gpg-libalpm-basics' 2011-03-23 02:34:51 -05:00
Dan McGee 8584c25903 Remove libfetch error code
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 02:29:35 -05:00
Dan McGee 88746ec067 Read in .sig files when opening a package file
If a .sig file sits side-by-side on the filesystem with a package archive,
read it in during the package struct creation process so we can verify it at
a later time if necessary.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-03-23 02:22:00 -05:00
Dan McGee 60159c2e77 Allow PGP signature to be read from sync database
Add a new field to the package struct to hold PGP information and
instruct db_read to pick it up from the database. It is currently unused
internally but this is the first step.

Due to the fact that we store the PGP sig as binary data, we need to store
both the data and the length so we have a small utility struct to assist us.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-03-23 02:22:00 -05:00
Dan McGee 9f2a3023f8 Add base64 algorithms from PolarSSL to libalpm
We will need these for GPG functionality (decoding the base64 encoded
signature stored in the databases).

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-03-23 02:22:00 -05:00
Dan McGee 0908533127 Merge branch 'gpg-build-tools' 2011-03-23 02:18:57 -05:00
Dan McGee a31d091fb3 repo-add: add sha256sum values to repo database
Implements FS#23103. Also modify libalpm so it ignores this value
without any warning as we know it is likely to exist.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 02:18:48 -05:00
Dan McGee 3df49acb30 Merge branch 'maint' 2011-03-23 02:16:13 -05:00
Dan McGee 87fbbdc649 Updated 3.5.1 translations from Transifex
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 02:12:36 -05:00
Slobodan Terzić 02945ca7ad Add new Serbian translation from Transifex
Thanks!

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23 02:12:21 -05:00
Dan McGee 7b60a639d1 Minor code cleanups
Wrap lines of long length, noticed while creating and messing around
with some of the other maint branch patches.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-21 09:02:03 -05:00
Dan McGee 110eb314f0 Ensure package removal list does not contain duplicates
Noticed with the openoffice/libreoffice replacement scheme where many
packages are listed as replacements to one package, thus electing it for
removal multiple times. Ensure a given package is not already present
before placing it in the removal list.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-21 08:59:59 -05:00
Dan McGee 834ba4da93 Fix line_offset not being reset in _alpm_archive_fgets()
This is a rather serious data corruption issue that luckily manifested
itself today in a noticable way. A package in testing had replaces
entries read in as ["%RE pkgname", "%RE"] which was clearly wrong. This
happens when we hit the end of an archive block, do not have a newline,
and have to continue reading from the next block to complete the line.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-21 08:52:24 -05:00
Dan McGee 0ff52b6845 Merge branch 'maint'
Conflicts due to change in return calling style.

Conflicts:
	src/pacman/pacman.c
	src/pacman/sync.c
2011-03-21 07:53:13 -05:00
Lukas Fleischer c67c864ffd Don't initialize progress to zero before calling curl_easy_perform().
Drawing progress bars before calling curl_easy_perform() is needless as
the curl progress callback is called with zero progress before actually
downloading the file anyways. Fixes display of "0%" progress bars when
sync'ing package databases that are already up to date.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-21 07:51:27 -05:00
Dan McGee 488f341f57 Ensure dlcb is defined before calling it
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-21 07:50:31 -05:00
Dan McGee 451f9493f5 Update source translation files in prep for 3.5.1
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 23:08:22 -05:00
Dan McGee 32e35d4028 Fix comparison to 0 rather than NULL
Another fix found by Coccinelle example semantic patches.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 20:10:19 -05:00
Dan McGee bdc1508a06 Fix assignment before NULL check
Easy fix, found using null_ref.cocci example Coccinelle script.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 19:56:55 -05:00
Dan McGee 0303b26b1e Style change: return(x) --> return x
This was discussed and more or less agreed upon on the mailing list. A
huge checkin, but if we just do it and let people adjust the pain will
end soon enough. Rebasing should be relatively straighforward for anyone
that sees conflicts; just be sure you use the new return style if
possible.

The following semantic patch was used to do the change, along with some
hand-massaging in order to preserve parenthesis where appropriate:

The semantic match that finds this problem is as follows, although some
hand-massaging was done in order to keep parenthesis where appropriate:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression a;
@@
- return(a);
+ return a;

// </smpl>

A macros_file was also provided with the following content:

Additional steps taken, mainly for ASSERT() macros:
$ sed -i -e 's#return(NULL)#return NULL#' lib/libalpm/*.c
$ sed -i -e 's#return(-1)#return -1#' lib/libalpm/*.c

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 19:49:45 -05:00
Dave Reisner 0cf05c77ad lib/dload.c: fix opening braces to conform with coding style
Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 18:49:01 -05:00
Dan McGee b2fde01c54 Merge branch 'maint' 2011-03-20 11:49:42 -05:00
Dan McGee 67c0e9cab3 Add missing include for size_t
Needed for things like our strndup() substitute function.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 11:45:17 -05:00
Dave Reisner 352b799efc lib/dload.c: remove lingering libfetch specific headers
Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 11:32:02 -05:00
Allan McRae f6716ae94a Use sane umask for repo db downloads
Fixes FS#23343.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 11:17:00 -05:00
tuxce b48f718417 Correctly parse %DELTAS% entries in sync DB
We erroniously dropped the call to _alpm_delta_parse() when macro-izing,
causing segfaults for repos that provide deltas. Addresses FS#23314.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-17 10:51:44 -05:00
Dave Reisner 0da6c591c0 Fix triple progress bars on download
Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-17 10:05:26 -05:00
Dan McGee e47fc2d7c6 Ensure we have a root partition when checking space
Partially addresses the "why doesn't CheckSpace work in a chroot" issue.
We can't make it work, but we can at least detect when it won't work by
checking for a partition for our given installation root. If we can't
determine the mountpoint for this, bail out with an error.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-17 09:33:04 -05:00
Dan McGee e6c9076a74 Merge branch 'maint' 2011-03-16 19:55:28 -05:00
Dave Reisner deed0286ef alpm_list: fix typo in doxygen comment
Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-16 19:52:54 -05:00
Dan McGee e28c47ade3 Update translations for message with added newline
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-16 19:52:54 -05:00
Allan McRae 771c002c98 Add missing newline to warning message
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-16 19:52:54 -05:00
Dan McGee cff36093f3 Merge branch 'download' 2011-03-16 19:25:35 -05:00
Dan McGee 9ae6ee0f09 Updated translations for 3.5.0 from Transifex
Thanks to all translators that contributed!

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-16 10:30:02 -05:00
Dave Reisner f2eac18a6e Remove all traces of libfetch
Signed-off-by: Dave Reisner <d@falconindy.com>
2011-03-09 15:22:32 -05:00
Dave Reisner 4ad4527d10 dload: temp patch to allow curl/fetch coexistance
this is just some debuggery to allow pacman to operate with both fetch
and curl at the same time. use the PACMANDL variable to control which
library is used.

Signed-off-by: Dave Reisner <d@falconindy.com>
2011-03-09 15:22:32 -05:00
Dave Reisner 96e458b705 dload.c: add curl_download_internal
This is a feature complete re-implementation of the fetch based internal
downloader, with a few improvements:

* support for SSL
* gzip and deflate compression on HTTP connections
* reuses a single connection over the entire session for lower resource
  usage.

Signed-off-by: Dave Reisner <d@falconindy.com>
2011-03-09 15:22:32 -05:00
Dave Reisner 8a58648471 handle error case for PM_ERR_LIBCURL
Add PM_ERR_LIBCURL to error enum and handle case in error.c by returning
curl_easy_strerror() based on the error number carried by the gloabl alpm
handle.

Signed-off-by: Dave Reisner <d@falconindy.com>
2011-03-09 15:22:32 -05:00
Dave Reisner a5b6a75787 share code between libfetch and libcurl
no actual code changes here. change preprocessor logic to include
get_tempfile, get_destfile, signal handler enum, and the interrupt
handler logic when either HAVE_LIBCURL or HAVE_LIBFETCH are defined.

Signed-off-by: Dave Reisner <d@falconindy.com>
2011-03-09 15:22:32 -05:00
Dave Reisner 159e1b06a5 prefix fetch based functions with fetch_
Do this in preparation for implementing similar curl based
functionality. We want the ability to test these side by side.

Signed-off-by: Dave Reisner <d@falconindy.com>
2011-03-09 15:22:32 -05:00
Dave Reisner 278c847106 handle: Add CURL* and CURLcode vars to struct
Adding the CURLcode is necessary in order to return an error string from
pm_error. Unlike libfetch, curl returns numerical error numbers and does
not maintain a staticly allocated string with the last error generated.

Adding the curl object itself to the handle is advantageous (and
encouraged by curl_easy_perform(3)) because the handle is reusable for
successive operations. This cuts back on overhead when downloading
multiple files in a single transaction.

Signed-off-by: Dave Reisner <d@falconindy.com>
2011-03-09 15:22:32 -05:00
Dave Reisner 75bfe825fc add curl to alpm initialization and teardown routines
Signed-off-by: Dave Reisner <d@falconindy.com>
2011-03-09 15:22:32 -05:00
Allan McRae f2023176f6 Do not print warning with files entry in sync db
repo-add can add a "files" entry into the sync db.  Currently we
do nothing with this file, so explicitly skip it to prevent
unknown database file warnings.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-07 13:54:38 -06:00
Dan McGee 0b6aa428cf Fix gettext plural detection
Our keywords were all screwed up in this regard. Fix it so our
ngettext() shortcut calls are actually recognized and respected.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-03 11:10:14 -06:00
Xavier Chantry 79f8cfb529 libalpm/diskspace.c: remove bogus parenthesis
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-01 18:16:52 -06:00
Dan McGee b12be99c89 Ensure d_type is not DT_UNKNOWN before relying on it
Fixes FS#23090, a rather serious problem where the user was completely
unable to read the local database. Even if entry->d_type is available,
the given filesystem providing it may not fill the contents, in which
case we should fall back to a stat() as we did before. In this case, the
filesystem was XFS but there may be others.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-01 13:39:43 -06:00
Dan McGee 09ce8b446c Fix some easy to find double translations
A lot of these were places that should have used the same message but
didn't, or were very easy to convert to using the same message and
letting some of the burden off of the translators.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 17:50:23 -06:00
Dan McGee 07538b948a Update translation template files
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 11:11:19 -06:00
Dan McGee f45369800a Check local DB version before continuing transaction
Ensure we have a local DB version that is up to par with what we expect
before we go down any road that might modify it. This should prevent
stupid mistakes with the 3.5.X upgrade and people not running
pacman-db-upgrade after the transaction as they will need to.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 10:46:00 -06:00
Dan McGee 5ea4706f57 Move locking functions to where they are needed
We only call these from the transaction init and teardown, so move them
to that file, mark them static, and push more of the logic of handle
manipulation into these functions.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 10:43:36 -06:00
Dan McGee 1eccae3d93 Fix trans no-argument function definitions
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 10:41:32 -06:00
Jonathan Conder acd9269478 Fix double close of the lock file
According to FOPEN(3), using fclose on an fdopen'd file stream also
closes the underlying file descriptor. This happened in _alpm_lckmk
(util.c), which meant that when alpm_trans_release closed it again, the
log file (which reused the original file descriptor) was closed instead.

Signed-off-by: Jonathan Conder <jonno.conder@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-27 13:32:41 -06:00
Dave Reisner 1fcc496756 alpm: alpm_db_get_pkgcache_list => alpm_db_get_pkgcache
This avoids needless breakage of the public API.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25 09:46:36 -06:00
Dave Reisner eefe8c8364 alpm: remove public visibility of pmpkghash_t
There's no API functions exposed which allow manipulation of this type,
so remove it from public view. Also, rename the public and private
alpm_db_get_pkgcache symbol to alpm_db_get_pkgcache_has.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25 09:45:13 -06:00
Dan McGee 2f96764058 Continue resolving dependencies rather than bailing on first error
This allows error messages emitted by the frontend to be a bit more
descriptive and not have the annoying "well why didn't you tell me that
the first time" problem. If a package had multiple missing deps, we
would bail on the first one before rather than finish processing all
missing dependencies, and only print one error message. Instead,
continue through this entire set of missing deps and append all eventual
errors.

The added pactest tests this case, as the to be installed package has
two missing dependencies. However, pactest does not actually test or see
the difference in output from before and after, so it passes in both
cases, but it is clearly visible in the logs.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25 07:55:16 -06:00
Dan McGee d4d304cdb7 Various small spelling fixes and small tweaks
Nothing that changes behavior here. Spelling fixes and pushing a
variable down to the scope it is used.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25 07:53:11 -06:00
Dan McGee 7c14e48776 Mark log callback format string const
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-24 09:38:59 -06:00
Dan McGee 6735807c0f Remove trans->skip_add
This is old code that has since gone stale; we no longer ever add
anything to this list so no need to keep it around and check the
contents during extraction.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-22 16:48:51 -06:00
Dan McGee cfa7602032 Don't generate filelist unless we are going to use it
We throw it away if !full, so no need to waste time creating the list in the
first place.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-16 20:57:07 -06:00
Dan McGee 00c393d49f Conflict checking code cleanup
* Make conflict_isin() static; it is used nowhere else.
* Remove does_conflict(): it turns out to be replaceable by a single call to
  _alpm_depcmp(). By pushing it up, we can reduce calls to _alpm_splitdep()
  from 60,368 to 16,940 during one test -Su operation I ran.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-16 20:57:07 -06:00
Dan McGee d1cc1ef6c3 Fix some database size estimation problems
* Use stat() and not lstat(); we don't care for the size of the symlink if
  it is one, we want the size of the reference file.
* FS#22896, fix local database estimation on platforms that don't abide by
  the nlink assumption for number of children.
* Fix a missing newline on an error message.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-15 16:58:08 -06:00
Pang Yan Han 62a2e45b12 Use CALLOC for _alpm_graph_new()
Change _alpm_graph_new() to use CALLOC to avoid explicit zeroing out of fields
in pmgraph_t.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-15 16:23:36 -06:00
Dan McGee 30f338cce6 diskspace: allow used flag to be toggled for both remove and install
Turn it into an enum rather than a boolean, and use a bitmask like we do for
reading DB entries. The relevant flag is turned on in our two calculate
loops, and anything reading the used flag later can decided which flag (or
either) is relevant.

This will allow the read-only partition code to be triggered on a
remove-only operation, e.g. if /boot was read-only and one tried to remove
grub in a sync transaction. Of course, right now, we don't actually run the
diskspace check code in the '-R' codepath.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-11 10:51:59 -06:00
Dan McGee 3afe3b6dfb Check mountpoint read-only status when checking space
This is a bit of a stopgap solution for the problem, but an easier one than
revamping the file conflict checking code to support the same stuff. Using
some more gross autoconf magic, figure out which struct field we need to
look at to determine read-only status and store that on our mountpoint
struct. If we find out we needed this partition after calculating size
requirements, then toss an error.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-11 10:38:58 -06:00
Dan McGee 1358a4a80f diskspace: use calloc instead of malloc
Prevents us from having to manually zero out several of our fields.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-11 10:36:41 -06:00
Dan McGee 0eac60cd9d Fix mount dir length calculation
In the getmntinfo() section, the local variable mnt doesn't exist; this
would have caused a compile error if I had tested the code on such a
platform. Unify both codepaths to just run strlen() on the already copied
mount path instead.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-11 10:34:37 -06:00
Dan McGee 06cbb516c3 Avoid a memmove by advancing value pointer
In packages, our description file contains:
key = value is here
type entries, and we passed "key " and " value is here" to our strtrim
function, causing us to always memmove the value portion to remove the
space. Since this is a throwaway buffer, do the advancing on our own before
trimming to save the need to shift memory around; "value is here" will now
be passed and strtrim will be responsible for trailing whitespace.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-11 10:23:43 -06:00
Dan McGee 56721c12ce Fix fileconflict progress with only one package
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-11 10:23:43 -06:00
Dan McGee 942bb9e64a Skip diskspace checking for symlinks and directories in all cases
We did this in some but not all cases, assuming the 0 value coming out of
libarchive would not be a problem. However, this does not work for "fake"
filesystems such as rpc_pipefs, which reports a free block and total block
count of zero.

Fix this by not ever counting symlinks or directories, and adding a note
explaining that if we someday do count directories, their size needs to be
attributed to the proper place.

This patch also includes a few cleanups/performance tweaks- avoid calling
strlen() on the mountpoint directory string as much by storing this size in
our mountpoint struct, and push the snprintf() call up to the calculate
functions since we were already doing it here in the remove case.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-08 09:28:24 -06:00
Pang Yan Han da3b934602 Refactor out common code in pkghash add functions
The overlapping code in _alpm_pkghash_add() and _alpm_pkghash_add_sorted()
are now in a new static function pkghash_add_pkg(). This function has a
third flag parameter which determines whether the package should be added in
sorted order.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-07 20:26:11 -06:00
Pang Yan Han be9a60a338 Handle null pkgcache for local/sync db_populate()
In sync_db_populate() and local_db_populate(), a NULL db->pkgcache is not
caught, allowing the functions to continue instead of exiting.

A later alpm_list_msort() call which uses alpm_list_nth() will thus traverse
invalid pointers in a non-existent db->pkgcache->list.

pm_errno is set to PM_ERR_MEMORY as _alpm_pkghash_create() will only return
NULL when we run out of memory / exceed max hash table size. The local/sync
db_populate() functions are also exited.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-07 20:21:34 -06:00
Dan McGee 3cf870eda5 Merge branch 'maint' 2011-02-06 12:52:20 -06:00
Pang Yan Han 3865352d23 Remove redundant _alpm_strtrim() in be_local.c
When reading the "desc" file in _alpm_local_db_read(), some
strings are trimmed and checked for length > 0 before their
use/duplication subsequently. They are then trimmed again
when there is no need to.

The following code snippet should illustrate it clearly:

while(fgets(line, sizeof(line), fp) &&
	strlen(_alpm_strtrim(line))) {

	char *linedup;
	STRDUP(linedup, _alpm_strtrim(line), goto error);
	info->groups = alpm_list_add(info->groups, linedup);
}

This patch removes the redundant _alpm_strtrim() calls in
_alpm_local_db_read() such as the one inside the STRDUP shown
above.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-06 12:50:46 -06:00
Pang Yan Han 30bb969ace Handle PM_ERR_WRITE in alpm_strerror()
PM_ERR_WRITE is defined in alpm.h but not handled in
alpm_strerror(). This patch corrects that.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 14:21:43 -06:00
Dan McGee e17c4fe611 Add new translations from Transifex
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 14:20:02 -06:00
Dan McGee fafa909a2d Update translation file indexes and Makevars
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 09:15:51 -06:00
Dan McGee 7664a58d4e Add comment about download file resolution
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 09:15:22 -06:00
Dan McGee e34fc4eddf Merge remote-tracking branch 'allan/hash' 2011-02-04 09:10:25 -06:00
Dan McGee c12ccbfb2c Add more error checking and logging
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 09:00:47 -06:00
Dan McGee 7467fb9e76 Ensure found files are actually files
We located files in a few places but didn't check if they were files or
directories. Ensure they are actually files using stat() and S_ISREG(); this
showed itself when trying to download to the directory name itself in
FS#22645.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 08:42:55 -06:00
Dan McGee 6b0d4674bb Improve pkghash_remove algorithm
Rather than potentially move every item to the next NULL, attempt to move at
most one item at a time by iterating backwards from the NULL location in the
hash array. If we move an item, we repeat the process on the now shorter
"chain" until no more items need moving.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 10:03:04 +10:00
Dan McGee 1f145bcd1a Use alpm_list_remove_item in pkghash_remove
Removes the code that was duplicated and has now been refactored into a
separate method.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 09:55:46 +10:00
Dan McGee 14fd1e63a2 Add new alpm_list_remove_item() function
This takes in the list and a list item, and does the pointer dance necessary
to remove it from the list regardless of whether it is first, last, or
somewhere in the middle. It is useful for callers that already know what
item needs to be removed and have a pointer to it rather than doing a search
by data that the plain alpm_list_remove() does.

Refactor alpm_list_remove() to use this function as well.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 09:55:46 +10:00
Allan McRae 01c3c7e4f2 Actually remove packages from pkghash on removal
Fully removes a package from the hash.  Also unify prototype with
removal from an alpm_list_t, fixing issues when removing a package
from the pkgcache.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae 11e5e86151 Refactor finding position for new hash entry
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae 9320786349 Rehash efficiently
Rehash without recreating the hash table list or reallocating the
memory for holding the list nodes.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae c9820ec97b Slightly more efficient rehash size selection
While probably still not optimal in terms of everyday usage in
pacman, this reduces the absolute size increase to "more reasonable"
levels.  For databases greater than 5000 in size, the minimum size
increase is used which is still on the order of a 10% increase.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae d843c86b7b Error handling for maximum database size
Check that the requested size of a pkghash is not beyond the maximum
prime.  Also check for successful creation of a new hash before
rehashing.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Dan McGee 021085624e Change default sync hash table sizing to 66% full
Since the sync database never changes size once we initialize it, we
allow it to be filled a bit more. This reduces the overall memory
footprint needed by the hash table.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 09:55:45 +10:00
Dan McGee ce54715112 Implement a quick and dirty rehash function
This allows us to get through the rehash required by smoke001 and pass
all pactests. It is by no means the best or most efficient
implementation but it does do the job.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae f8fdce6cb0 Read pkgcache into hash
Read the package information for sync/local databases into a pmpkghash_t
structure.

Provide a alpm_db_get_pkgcache_list() method that returns the list from
the hash object.  Most usages of alpm_db_get_pkgcache are converted to
this at this stage for ease of implementation.  Review whether these are
better accessing the hash table directly at a later stage.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Dan McGee 5dae577a87 Get estimated package count when populating databases
This works for both local and sync databases in slightly different ways. For
the local database, we can use the directory hard link count on the local/
folder. For sync databases, we use the archive size coupled with some
computed average per-package sizes to determine an estimate.

This is currently a dead assignment once calculated, but could be used to
set the initial size of a hash table.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae e17b0446bd Add a hash table for holding packages
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Dan McGee 87240dae6d Fix locale.h/setlocale inclusion with --disable-nls
Noted in FS#22697. When I factored out _alpm_parsedate() into a common
function, I didn't move the <locale.h> include properly, causing a build
failure when NLS is disabled and this header isn't automatically included
everywhere.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-01 09:59:12 -06:00
Xavier Chantry b6ec9019d7 alpm/depcmp: new NODEPVERSION flag
This flag allows to disable version checking in dependency resolving
code.

depcmp_tolerant respects the NODEPVERSION flag but we still keep the
original strict depcmp. The idea is to reduce the impact of the
NODEPVERSION flag by using it in fewer places.

I replaced almost all depcmp calls by depcmp_tolerant in deps.c (except
in the public find_satisfier used by deptest / pacman -T), but I kept
depcmp in sync.c and conflict.c

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-31 10:49:39 -06:00
Xavier Chantry ed1aef7bc5 libalpm: fix db_update documentation
return codes were mixed up

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-31 09:36:30 -06:00
Xavier Chantry e263cf7231 alpm: drop old target interfaces
It's likely that these interfaces will break sooner or later, now that
pacman no longer uses them.

So better force the two people who use them to migrate their code to the
new add_pkg/remove_pkg interface, which is very easy anyway.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:40:08 +01:00
Xavier Chantry 2a90dbe3a8 alpm: deprecate old interface
Old interface is marked as deprecated:
int alpm_sync_target(char *target);
int alpm_sync_dbtarget(char *db, char *target);
int alpm_add_target(char *target);
int alpm_remove_target(char *target);

New recommended interface:
int alpm_add_pkg(pmpkg_t *pkg);
int alpm_remove_pkg(pmpkg_t *pkg);

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:39:06 +01:00
Xavier Chantry 953e0d48d7 alpm: new alpm_remove_pkg interface
For consistency with alpm_add_pkg.

The new recommended interface is alpm_add_pkg / alpm_remove_pkg, all
others interfaces are deprecated.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:33:16 +01:00
Xavier Chantry 1767a569c6 alpm: add alpm_find_grp_pkgs
This group function is meant to help group handling from frontend : it
scans all dbs, handling ignored packages and duplicate members (the
first repo where a member is found has the priority).

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:33:16 +01:00
Xavier Chantry fb7e1b4b9b alpm: new alpm_add_pkg interface
This new function is meant to deprecate all existing
sync/add target functions :
int alpm_sync_target(char *target);
int alpm_sync_dbtarget(char *db, char *target);
int alpm_add_target(char *target);

Rather than dropping these 3 interfaces, it might be better to rewrite
them using alpm_add_pkg for now.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:33:15 +01:00
Xavier Chantry b8590ed634 alpm/dep: add alpm_find_dbs_satisfier
This is a public interface for resolvedep. It looks nicer to expose it
this way rather than through sync_target.

This function can also be helpful for external tools as it should give
good results close to how pacman select a package for satisfying a given
dep.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:33:15 +01:00
Xavier Chantry 4097c98c1e Add interactive provider selection
If there are multiple providers in one db, pacman used to just stop at
the first one (both during dependency resolution or for pacman -S
'provision' which uses the same code).

This adds a new conversation callback so that the user can choose which
provider to install. By default (user press enter or --noconfirm), the
first provider is still chosen, so for example the behavior of sync402
and 403 is preserved. But at least the user now has the possibility to
make the right choice in a manual run.

If one of the provider is already installed, it is picked for
reinstall/upgrade, so that provision 002/003 pactest now pass.

$ pacman -S community/smtp-server
:: There are 3 providers available for smtp-server:
   1) courier-mta  2) esmtp  3) exim

Which one do you want to install?
Enter a number (default=1):

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:33:15 +01:00
Dan McGee ba97a22ce1 Merge branch 'maint' 2011-01-29 12:16:11 -06:00
Dan McGee ef86da97f5 Remove need to explicitly register the local DB
Perform the cheap struct and string setup of the local DB at handle
initialization time to match the teardown we do when releasing the handle.
If the local DB is not needed, all real initialization is done lazily after
DB paths and other things have been configured anyway.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-29 12:13:56 -06:00
Dan McGee 9b876fff09 Ignore known but unused package descfile fields
We explicitly place 'pkgbase' (and used to place 'force') fields inside
PKGINFO files, so ignore them silently instead of printing an error for
them. Also make the error message for unknown keys actually contain the key.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-28 17:34:06 -06:00
Thomas Bächler 272f7cf25e libalpm: Fix a missing "nicht" (not) in German translation.
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-28 16:41:21 -06:00
Dan McGee fe76c353af Fix memory leak and error code in DB reading
We were returning a package error code rather than a DB one, and we
would leak the archive memory if the database file didn't exist.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-24 21:46:42 -06:00
Dan McGee 36ea02cc48 Compute download size for sync packages only
Neither packages from files nor packages from the local database will ever
have a download size.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-22 11:11:29 -06:00
Dan McGee c4332c8091 Merge branch 'maint' 2011-01-22 10:12:46 -06:00
Dan McGee bf46e04614 Remove epoch as an independent field
Instead, go the same route we have always taken with version-release in
libalpm and treat it all as one piece of information. Makepkg is the only
script that knows about epoch as a distinct value; from there on out we will
parse out the components as necessary.

This makes the code a lot simpler as far as epoch handling goes. The
downside here is that we are tossing some compatibility to the wind;
packages using force will have to be rebuilt with an incremented epoch to
keep their special status.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-21 19:30:45 -06:00
Dan McGee 5c46ba14f7 Allow version comparison to contain epoch specifier
Adapting from RPM, follow the [epoch:]version[-release] syntax. We can also
borrow some of their parsing code for our purposes (thanks!).  Add some new
tests to our vercmp shell script tester for epoch comparisons, and then make
the code work with these newfangled epoch specifiers.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-21 19:30:45 -06:00
Dan McGee 76735e6519 Copy new backend translation over from frontend translation
Since it is the same string. Done with some bash looping and sed magic.

    for src in po/*.po; do
        echo $src
        newtrans=$(grep -A1 "msgid.*$1" $src | tail -n1)
        newtrans=${newtrans//\\/\\\\}
        echo "$newtrans"
        fname=${src##*/}
        dest=lib/libalpm/po/$fname
        sed -i -e "/msgid.*$1/{N; s/msgstr.*$/$newtrans/}" $dest
    done

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-21 11:04:52 -06:00
Dan McGee 3863e48788 Add a likely_pkg hint argument to sync_db_read
In most (all?) cases, we will process all files for a given sync database
entry sequentially. The code currently does an _alpm_pkg_find() for every
file in the database, but we had the "current" package readily available.
Shift some local variables around a bit to expose this to sync_db_read() and
use it if the package is the correct one.

On my system, this cuts calls to _alpm_pkg_find() from 20,769 to 10,349
calls during a -Qu operation, and results in a ~30% speedup of the same
operation (0.35 sec -> 0.27 sec). This benefit should be apparent anywhere
we read in the full contents of the sync databases.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-21 10:11:59 -06:00
Dan McGee c86ff120c8 Improve splitname memory allocation
We don't need to create a temporary copy of the string if we are smart with
our pointer manipulation and string copying. This saves a bunch of string
duplication during database parsing, both local and sync.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-21 09:14:47 -06:00
Dan McGee 01c8f39ab8 Improve depends string parsing
Remove the need for an unconditional string duplication by using pointer
arithmetic instead, and strndup() instead of an unspecified-length strdup().
This should reduce memory churn a fair amount as this is called pretty
frequently during database loads.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-21 09:14:47 -06:00
Dan McGee aff3e63c45 Add strndup fallback function to libalpm util
The same fallback we are currently using in the pacman frontend.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-21 09:14:47 -06:00