1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00
Commit Graph

1917 Commits

Author SHA1 Message Date
Dan McGee
af357d6ab0 Allow fileconflict if unowned file moving into backup array
The bulk of this commit is adding new tests to ensure the new behavior
works without disrupting old behavior. This is a relatively sane maneuver
when a package adds a conf file (e.g. '/etc/mercurial/hgrc') that was
not previously in the package, but it is placed in the backup array. In
essence, we can treat the existing file as having always been a part of
the package and do our normal compare/install as pacnew logic checks.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-14 15:34:04 -05:00
Dan McGee
00628c7268 Unify package removal code
This code duplication has always been a rather clumsy casuality of
fixing some past upgrade issues. Unify the removal code across upgrade
and remove operations into  a new _alpm_remove_single_package() method
wihch makes it very clear how we handle upgrade and remove differently,
via several conditionals on newpkg.

This commit highlights interesting behavior such as the fact that the
implicit removal in every package upgrade never gets transaction events
or progress callbacks.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-06 09:26:09 -05:00
Dan McGee
1d53dd716d include util.h in rawstr.c
Fixes "error: no previous prototype for '_alpm_raw_cmp'
[-Werror=missing-prototypes]" warnings, and also prevents someone from
getting the prototypes and functions out of sync.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 22:36:40 -05:00
Dan McGee
b678e00271 Merge remote-tracking branch 'dave/download' 2011-07-05 22:01:29 -05:00
Dave Reisner
57eac093c4 absorb fileinfo struct into dload_payload
This transitional struct becomes delicious noms for dload_payload.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-07-05 23:00:03 -04:00
Dave Reisner
3eec745910 absorb some _alpm_download params into payload struct
Restore some sanity to the number of arguments passed to _alpm_download
and curl_download_internal.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-07-05 23:00:02 -04:00
Dave Reisner
6dc71926f9 lib/dload: prevent large file attacks
This means creating a new struct which can pass more descriptive data
from the back end sync functions to the downloader. In particular, we're
interested in the download size read from the sync DB. When the remote
server reports a size larger than this (via a content-length header),
abort the transfer.

In cases where the size is unknown, we set a hard upper limit of:

* 25MiB for a sync DB
* 16KiB for a signature

For reference, 25MiB is more than twice the size of all of the current
binary repos (with files) combined, and 16KiB is a truly gargantuan
signature.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-07-05 22:58:55 -04:00
Dave Reisner
6c9b82e72a dload: handle irregular URLs
URLs might end with a slash and follow redirects, or could be a
generated by a script such as /getpkg.php?id=12345. In both cases, we
may have a better filename that we can write to, taken from either
content-disposition header, or the effective URL.

Specific to the first case, we write to a temporary file of the format
'alpmtmp.XXXXXX', where XXXXXX is randomized by mkstemp(3). Since this
is a randomly generated file, we cannot support resuming and the file is
unlinked in the event of an interrupt.

We also run into the possibility of changing out the filename from under
alpm on a -U operation, so callers of _alpm_download can optionally pass
a pointer to a *char to be filled in by curl_download_internal with the
actual filename we wrote to. Any sync operation will pass a NULL pointer
here, as we rely on specific names for packages from a mirror.

Fixes FS#22645.

Signed-off-by: Dave Reisner <d@falconindy.com>
2011-07-05 22:58:27 -04:00
Dan McGee
ae7139adcf Remove most usages of strncmp()
The supposed safety blanket of this function is better handled by
explicit length checking and usages of strlen() on known NULL-terminated
strings rather than hoping things fit in a buffer. We also have no need
to fully fill a PATH_MAX length variable with NULLs every time as long
as a single terminating byte is there. Remove usages of it by using
strcpy() or memcpy() as appropriate, after doing length checks via
strlen().

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 21:29:02 -05:00
Dave Reisner
44889da5b7 dload: rearrange code to avoid extra cpp block
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-07-05 17:18:23 -04:00
Dave Reisner
6cce517f1a lib/rawstr: borrow raw string functions from curl
We'll need these functions to do locale agnostic and case insensitive
string comparisons.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-07-05 17:18:23 -04:00
Allan McRae
24324ff0e1 Simplify alpm_list_previous
We can readily detect the first node in a list by checking if
node->prev->next is NULL. So there is no need to pass the head
of the list to this function and its prototype now looks like
all the other item accessors.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:22:11 -05:00
Allan McRae
97103f860d Remove alpm_list_first
The only thing this accessor did was remove the const qualifier
given our entire list implementation requires passing around the
head anyway.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:22:05 -05:00
Dan McGee
c748eadc80 Allow invalid sync DBs to be returned by the library
They are placeholders, but important for things like trying to re-sync a
database missing a signature. By using the alpm_db_validity() method at
the right time, a client can take the appropriate action with these
invalid databases as necessary.

In pacman's case, we disallow just about anything that involves looking
at a sync database outside of an '-Sy' operation (although we do check
the validity immediately after). A few operations are still permitted-
'-Q' ops that don't touch sync databases as well as '-R'.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:13:20 -05:00
Dan McGee
07502f2d82 Allow frontend access to signature verification information
Show output in -Qip for each package signature, which includes the UID
string from the key ("Joe User <joe@example.com>") and the validity of
said key. Example output:

Signatures     : Valid signature from "Dan McGee <dpmcgee@gmail.com>"
                 Unknown signature from "<Key Unknown>"
                 Invalid signature from "Dan McGee <dpmcgee@gmail.com>"

Also add a backend alpm_sigresult_cleanup() function since memory
allocation took place on this object, and we need some way of freeing
it.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:13:20 -05:00
Dan McGee
e8443b1685 Correctly check the GPG error codes
The error code is in fact a bitmask value of an error code and an error
source, so use the proper function to get only the relevant bits. For
the no error case, this shouldn't ever matter, but it bit me when I was
trying to compare the error code to other values and wondered why it
wasn't working, so set a good example.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:13:20 -05:00
Dan McGee
7af0ab1cde signing: move to new signing verification and return scheme
This gives us more granularity than the former Never/Optional/Always
trifecta. The frontend still uses these values temporarily but that will
be changed in a future patch.

* Use 'siglevel' consistenly in method names, 'level' as variable name
* The level becomes an enum bitmask value for flexibility
* Signature check methods now return a array of status codes rather than
  a simple integer success/failure value. This allows callers to
  determine whether things such as an unknown signature are valid.
* Specific signature error codes mostly disappear in favor of the above
  returned status code; pm_errno is now set only to PKG_INVALID_SIG or
  DB_INVALID_SIG as appropriate.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:13:20 -05:00
Dan McGee
1ce7f39ad7 Merge remote-tracking branch 'allan/ALPM'
Conflicts:
	lib/libalpm/be_local.c
	lib/libalpm/be_package.c
	lib/libalpm/conflict.c
	lib/libalpm/diskspace.c
	lib/libalpm/dload.c
	lib/libalpm/remove.c
2011-07-03 14:44:57 -05:00
Dan McGee
c839415e3f conflict code tweaks and cleanups
We can take advantage of a few things on our new and improved filelist
in this code.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 14:29:30 -05:00
Dan McGee
26195f8da1 diskspace: remove all libarchive usage
Now that the filelists capture mode and size information, we can read
the data from there and prevent having to loop through and uncompress
every archive to check required diskspace usage.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 14:29:30 -05:00
Dan McGee
6a6fc3107f Move alpm filelists to a struct object
This allows us to capture size and mode data when building filelists
from package files. Future patches will take advantage of this newly
available information, and frontends can use it as well.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 14:29:30 -05:00
Dan McGee
06840f14b4 Fix debug logger without a newline
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 13:44:26 -05:00
Allan McRae
a7b02d07f4 Do not replicate files list when removing packages
This saves replicating the potentially large list of files in a package
that is being removed.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 13:42:43 -05:00
Allan McRae
ab79b13079 Add alpm_list_previous method
Helper function to get the previous item in a list

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 13:42:24 -05:00
Dan McGee
f612e5ede7 checkdeps: remove unnecessary list join and copy
We can just perform the same search operation on both lists.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 13:39:13 -05:00
Dan McGee
925d74f38d be_local: use macros in database loading similar to be_sync
This removes some of the repetition in the code for reading and parsing
database file lines.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 13:37:04 -05:00
Dan McGee
de8b9a85a5 be_sync: make READ_NEXT() a no-arg macro
We passed in 'line', but not 'buf.line'. In addition, the macros
building off of READ_NEXT() assume variable names anyway. Since we only
use these macros in one function, might as well simplify them.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 13:07:19 -05:00
Allan McRae
afc96f2ab3 Prefix _alpm_errno_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:39 +10:00
Allan McRae
bd88a8d551 Prefix alpm_transprog_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:39 +10:00
Allan McRae
495ba26e63 Prefix alpm_transconv_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:39 +10:00
Allan McRae
3189d3bc4a Prefix alpm_transevt_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:39 +10:00
Allan McRae
39262acab6 Prefix alpm_transflag_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:39 +10:00
Allan McRae
ca43fdd92f Prefix alpm_loglevel_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:38 +10:00
Allan McRae
d796d1cdda Prefix alpm_fileconflicttype_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:38 +10:00
Allan McRae
f818f570c5 Prefix alpm_depmod_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:38 +10:00
Allan McRae
eb39a9482b Prefix alpm_pkgreason_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:38 +10:00
Dan McGee
cf1401a04d signing: check validity of all available signatures
Change the check into a loop over all signatures present and returned by
GPGME. Also modify the return values and checks slightly now that I know
a little bit more about what type of values are returned.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 17:25:53 -05:00
Dan McGee
23a2d2c16a Make alpm_db_get_sigverify_level() public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 16:16:41 -05:00
Dan McGee
68284da0d7 Add an alpm_db_get_valid() public function
This allows one to check if a database is valid or invalid.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 16:05:20 -05:00
Dan McGee
13235ba65a Make local_db_read() private to the local backend
There is little need to expose the guts of this function even within the
library. Make it static in be_local.c, and clean up a few other things
since we know exactly where it is being called from:

* Remove unnecessary origin checks in _cache_get_*() methods- if you are
  calling a cache method your package type will be correct.
* Remove sanity checks within local_db_read() itself- packages will
  always have a name and version if they get this far, and the package
  object will never be NULL either.

The one case calling this from outside the backend was in add.c, where
we forced a full load of a package before we duplicated it. Move this
concern elsewhere and have pkg_dup() always force a full package load
via a new force_load() function on the operations callback struct.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 11:51:49 -05:00
Dan McGee
b94e8ecd1f Fix a few warnings pointed out via clang scan-build
Some of these are legit (the backup hash NULL checks), while others are
either extemely unlikely or just impossible for the static code
analysis to prove, but are worth adding anyway because they have little
overhead.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 11:51:36 -05:00
Dan McGee
ad577b3cb4 Merge remote-tracking branch 'allan/breakshit' 2011-06-30 10:37:08 -05:00
Dave Reisner
0f4aaeee42 lib/util: modify entry_prefix, not prefix
Modifying prefix caused tmp directories to be left behind after
running scriptlets, and the path '/' to be passed to _alpm_rmrf. Broken
in f01c6f.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 10:34:32 -05:00
Dave Reisner
002d2fda7a lib/alpm: unlock the handle before freeing it
This avoids, probably among other things, leaving the lock file in place
after a SIGINT'd sync DB update.

Fixes regression introduced in 4f8ae2b.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 10:33:24 -05:00
Allan McRae
fed3e09c94 Use ignoregroup rather than ignoregrp in the handle
This matches the naming in pacman.conf.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-29 16:00:25 +10:00
Allan McRae
b1894ccf06 Rename internal functions with grp in their name
The following function renames take place for the same reasoning as
the previous commit:

  _alpm_grp_new -> _alpm_group_new
  _alpm_grp_free -> _alpm_group_free
  _alpm_db_free_grpcache -> _alpm_db_free_groupcache
  _alpm_db_get_grpfromcache -> _alpm_db_get_groupfromcache

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-29 15:52:33 +10:00
Allan McRae
f1bb56cebf Rename public functions with grp in their name
Using grp instead of group is a small saving at the cost of clarity.
Rename the following functions:

  alpm_option_get_ignoregrps -> alpm_option_get_ignoregroups
  alpm_option_add_ignoregrp -> alpm_option_add_ignoregroup
  alpm_option_set_ignoregrps -> alpm_option_set_ignoregroups
  alpm_option_remove_ignoregrp -> alpm_option_remove_ignoregroup
  alpm_db_readgrp -> alpm_db_readgroup
  alpm_db_get_grpcache -> alpm_db_get_groupcache
  alpm_find_grp_pkgs -> alpm_find_group_pkgs

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-29 15:46:49 +10:00
Allan McRae
7633c14bd5 Rename _pmdbstatus_t to _alpm_dbstatus_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
028b965e1a Rename pmdbinfrq_t to alpm_dbinfrq_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
925f42e460 Rename pmtransstate_t to alpm_transstate_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
71fa9f912d Rename pmpkghash_t to alpm_pkghash_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
57b9b19b10 Rename pmgraph_t to alpm_graph_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
08fc1db24c Rename pmpkgfrom_t to alpm_pkgfrom_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
ddad400900 Rename pmerrno_t to alpm_errno_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
1059df7486 Rename pmtransprog_t to alpm_transprog_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
565e167356 Rename pmtransconv_t to alpm_transconv_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
011ef6be0e Rename pmtransevt_t to alpm_transevt_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
590a8fcb1e Rename pmtransflag_t to alpm_transflag_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
0aef91bc4f Rename pmloglevel_t to alpm_loglevel_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae
cd1e39ba62 Rename pmbackup_t to alpm_backup_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae
bfe1771067 Rename pmdelta_t to alpm_delta_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae
1fdbe79022 Rename pmgrp_t to alpm_group_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae
37b6cceed4 Rename pmfileconflict_t to alpm_fileconflict_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae
220842b37b Rename pmconflict_t to alpm_conflict_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae
6d876f9b6b Rename pmdepmissing_t to alpm_depmissing_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae
9540dfc4d9 Rename pmdepend_t to alpm_depend_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae
6b62508c86 Rename pmtrans_t to alpm_trans_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:27:16 +10:00
Allan McRae
8a04bc25a1 Rename pmpkg_t to alpm_pkg_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:26:39 +10:00
Allan McRae
939d5a9511 Rename pmdb_t to alpm_db_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 14:16:12 +10:00
Allan McRae
64c1cf7921 Rename pmhandle_t to alpm_handle_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 14:04:00 +10:00
Allan McRae
1c5c7c907c Rename pmfileconflicttype_t to alpm_fileconflicttype_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 13:58:59 +10:00
Allan McRae
0a80cf31cf Rename pmdepmod_t to alpm_depmod_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 13:56:46 +10:00
Allan McRae
7ce674491b Rename pmpkgreason_t to alpm_pkgreason_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 13:54:04 +10:00
Dan McGee
865ac0f055 Remove setter for DB signature level
This should have been removed with commit db3b86e7f3 but was
erroniously left behind.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-27 11:57:43 -05:00
Dan McGee
f01c6f814a Fix several -Wshadow warnings
Only one of these looked like a real red flag, in find_requiredby(), but
it doesn't hurt to fix several of them up anyway.

Unfortunately, we can't turn this on universally due to things like the
sync(), remove(), etc. builtins which we often use as variable names.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-27 10:10:08 -05:00
Dan McGee
77a09c92c6 Merge branch 'maint'
Conflicts:
	lib/libalpm/conflict.c
2011-06-27 09:33:27 -05:00
Allan McRae
6a413fe72f Remove two alpm_list_count usages
We have just looped through the list of files, so might as well get
the count as we go.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-27 09:19:08 -05:00
Dan McGee
e378170c25 Ensure a file can be replaced by a directory
This addresses FS#24904. In a normal upgrade case, this replacement
seems to work just fine. However, when doing a sync "replace" type
upgrade, we weren't properly handling this edge case due to path
comparison not ignoring trailing slashes. Fix this by pruning any
trailing slashes past a certain point of file conflict resolution where
we no longer need them, which allows us to safely detect cases such as
now tested in the new pactest.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-27 09:15:31 -05:00
Dan McGee
f8f4c2a6f3 File conflict code cleanups
While researching the root cause of FS#24904, I couldn't help but clean
up some of the cruft in here. A few whitespace/line-wrapping issues, but
also fix shadowed variables and add some const where applicable.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-27 09:15:28 -05:00
Dan McGee
777bdc6c50 Make sync DB reading a bit more flexible
We can reorganize things a bit to not require reading a directory-only
entry first (or at all). This was noticed while working on some pactest
improvements, but should be a good step forward anyway.

Also make _alpm_splitname() a bit more generic in where it stores the
data it parses.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 14:04:39 -05:00
Dan McGee
719e0d3ddb archive_fgets(): ensure we return any trailing text with no newline
Discovered this when doing some pactest rewrite work to generate
archives in memory only. If a sync database file or PKGINFO file is
missing a newline on the final line, the text from that line gets tossed
aside and never read into the package struct. This is pretty critical
when that last line is a depend or something.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 14:03:51 -05:00
Dan McGee
4f8ae2bab6 Don't require a transaction for sync DB updates
Instead, just do the required locking directly in the backend in calls
to alpm_db_update().

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 04:11:38 -05:00
Dan McGee
7b8f8f69f1 Move locking functions to handle
These operate on the handle, and the state is stored on the handle, so
move them where they belong. Up until now only the transaction stuff
calls them, but this will soon change and alpm_db_update() will handle
locking all on its own.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 04:02:58 -05:00
Dan McGee
79e98316ea Add a 'valid' flag to the database object
Start by converting all of our flags to a 'status' bitmask (pkgcache
status, grpcache status). Add a new 'valid' flag as well. This will let
us keep track if the database itself has been marked valid in whatever
fashion.

For local databases at the moment we ensure there are no depends files;
for sync databases we ensure the PGP signature is valid if
required/requested. The loading of the pkgcache is prohibited if the
database is invalid.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 03:46:12 -05:00
Dan McGee
1150d9e15a Move database 'version' check to registration time
This is another step toward doing both local database validation
(ensuring we don't have depends files) and sync database validation (via
signatures if present) when the database is registered.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 03:31:32 -05:00
Dan McGee
db3b86e7f3 Do database signature checking at load time
This is the ideal place to do it as all clients should be checking the
return value and ensuring there are no errors. This is similar to
pkg_load().

We also add an additional step of validation after we download a new
database; a subsequent '-y' operation can potentially invalidate the
original check at registration time.

Note that this implementation is still a bit naive; if a signature is
invalid it is currently impossible to refresh and re-download the file
without manually deleting it first. Similarly, if one downloads a
database and the check fails, the database object is still there and can
be used. These shortcomings will be addressed in a future commit.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 02:34:50 -05:00
Dan McGee
f12ead2cf2 Remove three unnecessary usages of alpm_list_count()
For the files count when loading from a package, we can keep a counter.
The two in the frontend were completely useless due to the fact that if
sync_dbs is non-NULL, alpm_list_count() will always be greater than 0.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 01:36:47 -05:00
Dan McGee
d589a7b5db Prevent segfault when parsing unexpected sync database file
This doesn't fix the real (bigger) problem of failing to parse sync
databases without directory entries, but it does prevent the parser from
segfaulting when the first desc file encountered did not have a
directory entry, among other conditions.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 01:36:47 -05:00
Dan McGee
ac7d17f88e Merge branch 'po-split' 2011-06-23 23:44:35 -05:00
Dan McGee
a4a7006a13 po/: split into scripts/po/ and src/pacman/po/
This is the first step at separating the pacman message catalog and the
scripts message catalog. Makefiles, configure.ac, and other such files
are adjusted accordingly, as well as renaming files. The TEXTDOMAIN of
scripts is also adjusted.

Note that no actual pot or po files get changed here; these will get
pruned in a future commit so each catalog contains only the necessary
messages.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-23 22:50:01 -05:00
Dan McGee
78f297dabe Update all translation files
This is for the eventual 4.0.0 release, but more importantly to
logically separate new translations and strings from the PO split about
to happen between pacman and scripts.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-23 22:49:59 -05:00
Dan McGee
54ef162a1a Convert backup list to new pmbackup_t type
This allows us to separate the name and hash elements in one place and
not scatter different parsing code all over the place, including both
the frontend and backend.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-22 12:31:12 -05:00
Dave Reisner
3847446603 lib/util: call _alpm_log before setting handle->pm_errno
This is an unfortunate chain of events. RET_ERR and RET_ERR_VOID will
eventually call CHECK_HANDLE, which resets the handle's pm_errno member.
Dan probably had a reason for doing this, so we merely switch the order
of operations in the RET_ERR macros to avoid stomping on our pm_errno.

Signed-off-by: Dave Reisner <d@falconindy.com>
2011-06-20 10:43:54 -05:00
Dan McGee
36d98b3919 Improve cachedir removal and error handling
* Check the return value of canonicalize_path() for non-NULL
* Use ASSERT and RET_ERR as appropriate
* Make remove_cachedir() use same path munge logic as add_cachedir()

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-20 00:18:29 -05:00
Kerrick Staley
83071f579c Documented _alpm_download()
Documented the _alpm_download() function in dload.c

Signed-off-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-20 00:18:03 -05:00
Kerrick Staley
d980bd403d Documented purpose of be_*.c
Added a line to the top of each of be_local.c, be_package.c, and
be_sync.c indicating their purposes.

Signed-off-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-20 00:17:54 -05:00
Dan McGee
0f26e3aa5b Correctly duplicate delta objects
We were using copy_data before; this works for the struct itself but not
the strings contained within. Fix it up by duplicating all the data as
we do with our other structures.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-20 00:10:11 -05:00
Dan McGee
deb5601d8d Clean up util md5sum method
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-20 00:08:15 -05:00
Dan McGee
0ee9ced4cb Merge branch 'public-structs' 2011-06-20 00:07:10 -05:00
Dave Reisner
eb2d607899 lib/handle: use CALLOC macro instead of bare calloc
Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-20 00:05:03 -05:00
Dan McGee
36ae77dd49 Don't call public API in _alpm_log()
Calling get_logcb() here would reset any previous setting of
handle->pm_errno due to the CHECK_HANDLE() macro contained within. This
would make error setting a bit funny if one set pm_errno before calling
_alpm_log(), such as in the RET_ERR() macro.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-20 00:03:53 -05:00
Dan McGee
25b7df4dab Make pmgrp_t public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:58:04 -05:00
Dan McGee
51359e6d33 Make pmdelta_t public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:58:04 -05:00
Dan McGee
7f6c1a76c6 Make pmdepend_t and pmdepmissing_t public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:57:33 -05:00
Dan McGee
19fcc74016 Make struct pmconflict_t public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:57:30 -05:00
Dan McGee
bdf00d3dbd Make pmfileconflict_t type public
This removes the need to write accessor methods for every type we have,
and simplifies the API. Any type that doesn't need magic* can be
converted in this fashion to make it easier for frontend applications to
use, as well as make it less of a pain to introduce new such structs in
the future.

* "magic" meaning something like pmpkg_t where values can be lazy loaded.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:57:06 -05:00
Dan McGee
1cd6515af0 API: change 'signaturedir' to 'gpgdir'
This is more in line with reality and what we have our makepkg, etc.
options named anyway.

Original-patch-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-15 12:02:29 -05:00
Dan McGee
2f5f157274 Rename and rework signing helper methods
* Don't name static methods with a gpgme_ prefix to avoid confusion with
  methods provided by the library. These are static and local to our
  file so just give them sane non-prefixed names.
* Rework sigsum_test_bit() to not require assignment.
* Don't balk if there is more than one signature available (for now,
  only check the first).
* Fix error codes in publicly visible methods to return -1, not 0, if pkg
  or db are not provided.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14 10:18:43 -05:00
Dan McGee
71fd34e596 Alpm pkg accessors: ensure pkg argument is non-NULL
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14 10:09:35 -05:00
Dan McGee
ee015f086f Ensure handle is valid and pm_errno is reset when calling into API
We didn't do due diligence before and ensure prior pm_errno values
weren't influencing what happened in further ALPM calls. I observed one
case of early setup code setting pm_errno to PM_ERR_WRONG_ARGS and that
flag persisting the entire time we were calling library code.

Add a new CHECK_HANDLE() macro that does two things: 1) ensures the
handle variable passed to it is non-NULL and 2) clears any existing
pm_errno flag set on the handle. This macro can replace many places we
used the ASSERT(handle != NULL, ...) pattern before.

Several other other places only need a simple 'set to zero' of the
pm_errno field.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14 10:01:08 -05:00
Dan McGee
76a991c117 Conflict check and skip_remove code cleanups
* Move several variables into better scope
* const-ify a few variables
* Avoid duplicating filelists if it is unnecessary
* Better handling out out of memory condition when adding file conflicts
  to our list

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14 09:30:46 -05:00
Dan McGee
ba63e31cc7 Small handle related cleanups
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14 08:39:02 -05:00
Dan McGee
0074cadb3b Add handle argument to _alpm_pkg_should_ignore()
This allows callers to retrieve it from wherever is convenient, which
may or may not be on the package object itself.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14 08:38:51 -05:00
Dan McGee
00a1b1deeb Remove alpm_db_get_url()
This method is old, it doesn't adequately check for a NULL server list,
and can easily be done using better API method we provide these days.
All former users of this method can get similar results by calling
alpm_db_get_servers() and using the data from the returned server list.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14 08:26:58 -05:00
Dan McGee
8be4db8caf Add a helper method for retrieving the DB signature path
Note that is a bit different than the normal _alpm_db_path() method; the
caller is expected to free the result.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:41:37 -05:00
Dan McGee
f6700d5c98 alpm_db_update(): refactor out sync dir create/check
This was a lot of stuff that can stand by itself for the most part.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:41:37 -05:00
Dan McGee
4d9278f87f Remove global handle variable
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:41:16 -05:00
Dan McGee
52bffd2457 Switch all logging to use handle directly
This is the last user of our global handle object. Once again the diff
is large but the functional changes are not.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:41:16 -05:00
Dan McGee
e2aa952689 Move pm_errno onto the handle
This involves some serious changes and a very messy diff, unfortunately.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:38:38 -05:00
Dan McGee
8b62d9bc0a Add handle argument to two more alpm methods
This takes care of alpm_checkdeps() and alpm_find_dbs_satisfier().

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:35:22 -05:00
Dan McGee
70a86c14f4 Require handle for alpm_checkconflicts()
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:35:22 -05:00
Dan McGee
d76341297a Require handle for alpm_pkg_load()
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:35:22 -05:00
Dan McGee
fb3ad7f882 Add handle argument to alpm_(add|remove)_pkg()
This makes these functions consistent with the rest of the transaction
related API calls. We do an additional assert to ensure the handle
attached to the package is the same as the handle passed in.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:32:59 -05:00
Kerrick Staley
01ad3faee9 Added initialization code for database siglevel
The siglevel field of a newly created pmdb_t struct is now
initialized when it is created in _alpm_db_new().

Signed-off-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:32:59 -05:00
Dan McGee
bcd442761b Fix memory leak if package sig was invalid
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 17:44:49 -05:00
Dan McGee
c5761bfe41 Fix all current return(x) usages
A few of these snuck in as of late, some from the table display patches
that were using the previous format before we changed it after the 3.5.X
major release.

Noticed-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 17:43:11 -05:00
Dan McGee
ff7ad5fd73 commit_single_pkg(): Use handle object directly
Commit e68f5d9a30 did something a bit silly and changed the
scriptlet calls to use 'newpkg->handle' rather than the 'handle'
argument passed in. Use the handle directly.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 15:32:28 -05:00
Dan McGee
ff8e519d4b Require handle for alpm_sync_sysupgrade()
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:24:45 -05:00
Dan McGee
7d27cf8364 Require handle for alpm_db_register_sync()
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:24:45 -05:00
Dan McGee
24000b83c9 Require handle argument to all alpm_trans_*() methods
Begin enforcing the need to pass a handle. This allows us to remove one
more extern handle declaration from the backend.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:24:45 -05:00
Dan McGee
17a6ac5675 Require handle argument to all alpm_option_(get|set)_*() methods
This requires a lot of line changes, but not many functional changes as
more often than not our handle variable is already available in some
fashion.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:24:45 -05:00
Dan McGee
7968d30510 Require handle argument to alpm_logaction()
This is the first in a series of patches to update the API to remove the
implicit global handle variable.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:24:45 -05:00
Dan McGee
e826c143d3 Kill all remaining 'PATH_MAX + 1' usages
The few remaining instances were utilized for buffers in calls to
snprintf() and realpath(). Both of these functions will always ensure
the returned value is padded with '\0', so there is no need for the
extra byte.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:16:55 -05:00
Dan McGee
9d6568da0f _alpm_lstat: only duplicate string if necessary
The vast majority of the time we will just be passing the same string
value on to the lstat() call. The only time we need to duplicate it is
if the path ends in '/'. In one run using a profiler, only 400 of the
200,000 calls (0.2%) required the string to be copied first.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:14:55 -05:00
Dan McGee
11ba7a0e8a Fix graph free valgrind warnings
Due to the way we set up the graph structure, we don't always have good
parent information. The changes made in dd8cf0c12d assumed this, so
back them out and just live with the dead pointers being there in the
memory while we are cleaning up after ourselves.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-08 02:49:03 -05:00
Dan McGee
2668782db2 Plug a memory leak
Introduced by me in commit cc25576f8b.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-08 02:48:43 -05:00
Dan McGee
8c6a636cd9 Merge branch 'maint'
Conflicts:
	lib/libalpm/add.c
2011-06-07 11:43:12 -05:00
Dan McGee
fb4b422fc4 New signatures for alpm initialize and release
These new method signatures return and take handle objects to operate on
so we can move away from the idea of one global handle in the API. There
is also another important change and that deals with the setting of root
and dbpaths. These are now done at initialization time instead of using
setter methods. This allows the library to operate more safely knowing
that paths won't change underneath it.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-07 11:37:05 -05:00
Dan McGee
992fa50dfd Add cachedirs one-by-one in set_cachedirs()
This addresses the issue where calling set_cachedirs() didn't
canonicalize the passed-in paths.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-07 11:36:30 -05:00
Dan McGee
c1a5b11f11 Be consistent with memory treatment for plural option setters
In all cases we should duplicate the passed-in list so the caller is
free to do with it as it pleases.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-07 11:33:29 -05:00
Dan McGee
991b3ff7e6 Add helper methods for setting directory options
This keeps duplicate code to a minimum. This will come in more handy as
we refactor some of these option setters away.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-07 11:30:44 -05:00
Allan McRae
67c33fb8ff Remove incorrect output when downloading only
When only downloading a package, pacman can produce some incorrect
output.

> pacman -Sddw nvidia-utils
warning: nvidia-utils-270.41.19-1 is up to date -- reinstalling

This line is now now silenced when using -Sw.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-07 10:51:46 -05:00
Dan McGee
cc25576f8b Use standard errno codes in return from _alpm_archive_fgets
This allows us to not require the context (e.g. handle) when calling
this function. Also beef up the checks in the two callers of this
function to bail if the last return code is not ARCHIVE_EOF, which is
the expected value.

This requires a change to one of the pactest return codes and the
overall result of the test, but results in a much safer operating
condition whereby invalid database entries will stop the operation.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03 14:37:51 -05:00
Dan McGee
e68f5d9a30 Remove global handle dependencies from sync/upgrade paths
This kills a lot more global handle business off. sync.c still requires
the handle declaration for one reference that can't be changed yet; it
will be removed in a future patch which isolates all of the necesary API
changes.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03 13:18:36 -05:00
Dan McGee
d2f05f72f0 Remove global handle from remove.c
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03 12:53:53 -05:00
Dan McGee
307a6de17a Remove global handle from some package and db code
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03 12:44:01 -05:00
Dan McGee
4015b23e8e Remove global handle from diskspace.c
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03 12:36:13 -05:00
Dan McGee
7fc635fee0 Remove global handle from util.c
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03 12:33:18 -05:00
Dan McGee
de36c5fac4 Push down extern handle variable to files that need it
This will make the patching process less invasive as we start to remove
this variable from all source files.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03 12:23:32 -05:00
Dan McGee
7f98460e37 Add handle attribute to pmpkg_t struct
Similar to what we just did for the database; this will make it easy to
always know what handle a given package originated from.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03 12:13:22 -05:00