Commit Graph

287 Commits

Author SHA1 Message Date
Allan McRae 4742f5929d Update copyright years for 2016
make update-copyright OLD=2015 NEW=2016

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Rikard Falkeborn 0c5dbdbfec Alpm, check for NULL in free-functions
Also, use FREE() instead of free() in _alpm_backup_free()
to set the pointers to NULL.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-27 14:22:30 +10:00
Andrew Gregory 75fe6ef104 sortbydeps: skip local packages being updated
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-19 15:12:35 +10:00
Allan McRae 2e48101999 Update copyright notices for 2015
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:19:04 +10:00
Andrew Gregory 8da9be0955 initialize pointers passed to _alpm_pkg_dup
_alpm_pkg_dup leaves the destination pointer unaltered in case of fatal
errors, so when commits 2f0ca00e and be4198b3 freed the pointer, they
fixed a memory leak on non-fatal errors by replacing it with
a segmentation fault on fatal errors.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:48:59 +10:00
Allan McRae 60d958c78b Initialize memory to prevent issues when freeing on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:32 +10:00
Allan McRae be4198b34e _alpm_recursedeps: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:32 +10:00
Allan McRae c6dd581ec5 alpm_dep_from_string: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae e892234207 _alpm_dep_dup: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae 32ebd7ad5d depmiss_new: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Florian Pritz 04e8048725 Add --assume-installed option
This allows to ignore specific dependencies.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2014-09-30 22:33:26 +10:00
Florian Pritz 4e263f24c6 libalpm: export alpm_splitdep as alpm_dep_from_depstring and alpm_dep_free
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2014-09-30 22:20:53 +10:00
Florian Pritz 13c9745302 deps.c: split _alpm_depcmp into _alpm_depcmp_provides
This allows to reuse the provision checker for a simple list of
provisions without a package.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2014-09-30 22:07:11 +10:00
Andrew Gregory f4992960ad deps.c: use alpm_list_find_ptr
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-08-04 14:23:58 +10:00
Andrew Gregory 0c43198ee0 dep_graph_init: filter ignored packages by name
Ignored packages are from the transaction remove list which consists of
duplicated packages so a direct pointer comparison is not appropriate.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-08-04 14:23:58 +10:00
Olivier Brunel f1fadecfb3 Update the question callback
Much like with events, instead of using a bunch of void* arguments for
all questions, we now send one pointer to an alpm_question_t union.
This contains the type of question that was triggered.

With this information, a question-specific struct can be accessed in
order to get additional arguments.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-06-24 13:52:15 +10:00
Andrew Gregory b9601b1e59 alpm: export *_free functions
Front-ends should be able to free memory that alpm hands them.

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

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

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

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06 14:38:49 +10:00
Jason St. John 230bd5c2fd Fix whitespace and other formatting issues
This commit:
-- replaces space-based indents with tabs per the coding standards
-- removes extraneous whitespace (e.g. extra spaces between function args)
-- adds missing braces for a one-line if statement

Signed-off-by: Jason St. John <jstjohn@purdue.edu>
2013-11-15 11:02:27 +10:00
Andrew Gregory c3493360af deps.c: pass alpm_list** to _alpm_recursedeps
Improves consistency and makes it clear that targs will be modified by
_alpm_recursedeps.

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

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

Fixes FS#37380

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

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

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

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

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

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

Fixes FS#32764.

Partially fixes FS#23011.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-26 15:32:15 +10:00
Allan McRae 1ed881fed3 Fix comment typo
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-18 22:43:12 +10:00
Anatol Pomozov 769facca22 Fix spelling errors using 'codespell' tool
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-18 13:20:13 +10:00
Allan McRae 1dd3405813 Update copyright year for 2013
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-03 12:03:09 +10:00
Allan McRae 62f1c590fc Make alpm_pkg_find public
This function is particularly useful, so make it public.

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

[Allan: Remove expected failure from fixed pactests]
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14 12:35:34 +10:00
Dave Reisner e533478e02 fix -Wshadow warnings as reported by gcc 4.4.3
Apparently gcc 4.7 has decided that -Wshadow warnings aren't worth
reporting anymore even with the flag enabled. These were found on
an Ubuntu 10.04 install.

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

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-08 22:28:45 -04:00
Dan McGee 00f29cbc14 Allow alpm_depend_t to have a description
This is the first step in parsing and handling optdepends. There is no
behavior change introduced in this commit; however, depends that contain
a ": " string will now be parsed as having a description and it will be
stored in the depend structure. Later patches will utilize this new
field as appropriate.

This is heavily based on the work of Benedikt, who did something similar
but introduced a new type for this rather than only a new field to the
existing type.

Heavily-influenced-by: Benedikt Morbach <benedikt.morbach@googlemail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-08 17:26:41 -06:00
Dan McGee 3849c3aec1 Merge branch 'maint'
Conflicts:
	contrib/pacsysclean.in
	src/pacman/conf.h
2012-02-20 17:00:26 -06:00
Allan McRae 326c6a8eed Update copyright years
Add 2012 to the copyright range for all libalpm and pacman source files.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-20 16:54:34 -06:00
Dan McGee 85712814cd Revert "Add -S --recursive operation"
This reverts commit f3fa77bcf1 along with
making other necessary changes to fully back this (mis)feature out until
we can do it correctly.

The quick summary here is this was not implemented correctly; provides
are not fully taken into account in this logic, and making that happen
exposes a lot of other flaws in this code that are covered up later on
in the dependency resolving process by several other pieces of
convoluted and conditional logic.

Tests have been adjusted accordingly. Some test EXISTS conditions have
been removed as we already know the package is installed locally, and we
also are checking the VERSION condition anyway.

With these two related revert commits, we do have some changes in test
pass/fail results:

* upgrade078.py: does not pass, this is due to --recursive getting
  removed for -U/-S operations after this commit.
* sync302.py: the version checks have been disabled, so this test
  continues to pass but has been scaled back in scope.
* sync303.py: now passes, was failing before.
* sync304.py: still failing, was failing before.
* sync305.py: now passes, was failing before.
* sync306.py: still passes, was passing before.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-15 15:58:07 -06:00
Dan McGee ac239c54d0 libalpm/deps.c: access trans flags directly
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-23 12:21:05 -06:00
Dave Reisner d6ccd44390 include config.h via Makefiles
Ensures that config.h is always ordered correctly (first) in the
includes. Also means that new source files get this for free without
having to remember to add it.

We opt for -imacros over -include as its more portable, and the
added constraint by -imacros doesn't bother us for config.h.

This also touches the HACKING file to remove the explicit mention of
config.h as part of the includes.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-21 18:13:17 -06:00
Dave Reisner 3d4656c020 code syntax cleanup
As per HACKING file, we use 'CTRL(' rather than 'CTRL ('

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12 12:51:59 -06:00
Dan McGee 9363e7dc22 Allow sync_prepare to work in certain cases without sync databases
When doing a bare -U operation on a local package that doesn't pull in
any dependencies from the sync databases, we can get away with missing
database files. This makes the check conditional on no sync targets
found in the target list. This is not the prettiest code here so we have
a bit of hackish behavior required to straighten both the behavior and
the nonsensical error message out.

Addresses FS#26899.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-15 09:12:18 -06:00
Dan McGee 69962184bb _alpm_splitdep: use malloc instead of calloc
There was only one simple to handle case where we left a field
uninitialized; set it to NULL and use malloc() instead.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-27 17:52:38 -05:00
Dan McGee 2517ba3303 Update Doxyfile and fix some documentation errors caught by Doxygen
A few parameters were outdated or wrongly named, and a few things were
explicitly linked that Doxygen wasn't able to resolve.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 16:37:36 -05:00
Dan McGee 79cbce60ac Remove all usages of alpm_list_getdata() from the library
No need for the indirection; just access ->data instead.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:10 -05:00
Dan McGee 98fdfa1968 Former transaction callback rename refactor
Put all the callback stuff in alpm.h in one spot, and make the following
renames for clarity with the new structure:

ALPM_TRANS_EVT_* --> ALPM_EVENT_*
ALPM_TRANS_CONV_* --> ALPM_QUESTION_*
ALPM_TRANS_PROGRESS_* --> ALPM_PROGRESS_*
alpm_option_get_convcb() --> alpm_option_get_questioncb()
alpm_option_set_convcb() --> alpm_option_set_questioncb()

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02 21:45:08 -05:00
Dan McGee 37da18aee8 Move all callbacks up to the handle level
This was just disgusting before, unnecessary to limit these to only
usage in a transaction. Still a lot of more room for cleanup but we'll
start by attaching them to the handle rather than the transaction we may
or may not even want to use these callbacks.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02 21:45:03 -05:00
Dan McGee 499e09734b Streamline alpm_splitdep() comparisons
This reduces from 5 to 3 the number of searches needed on the string
looking for a comparison operator, since we can so a second quick
comparison looking for '=' if we find '<' or '>'. It also makes every
search doable with strchr() or memchr() rather than the slower strstr()
method.

In testing, only 10% of splitdep calls (~1600 / 16000) during an -Ss
database load found a version comparison operator, so optimizing the not
found path to be require less work makes sense.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-29 19:54:18 -05:00
Dan McGee 8973875a1f _alpm_splitdep(): don't pass bogus length value to strndup
If we fell through to the ALPM_DEP_MOD_ANY case, ptr would be NULL, and
we would pass (0 - <str>), which is a rather large negative number or
bogus positive number, depending on signed/unsigned. Just use strdup in
the case where we don't have a ptr available.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28 23:50:28 -05:00
Dan McGee 6d544984f2 Be more robust when copying package data
This changes the signature of _alpm_pkg_dup() to return an integer error
code and provide the new package in a passed pointer argument. All
callers are now more robust with checking the return value of this
function to ensure a fatal error did not occur.

We allow load failures to proceed as otherwise we have a chicken and egg
problem- if a 'desc' local database entry is missing, the best way of
restoring said file is `pacman -Sf --dbonly packagename`. This patch
fixes a segfault that was occurring in this case.

Fixes the segfault reported in FS#25667.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-19 11:09:57 -05:00