Commit Graph

1756 Commits

Author SHA1 Message Date
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