Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/handle.c
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-07-04 23:12:01 +0200
committerAllan McRae <allan@archlinux.org>2014-09-30 22:33:26 +1000
commit04e8048725441465788a6c76a326ff252c2fd815 (patch)
tree22ce157e65f1eae5e1f11357adee781b10fb1246 /lib/libalpm/handle.c
parent4e263f24c6ed1cc710b7873b9ea37534117247ea (diff)
Add --assume-installed option
This allows to ignore specific dependencies. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/libalpm/handle.c')
-rw-r--r--lib/libalpm/handle.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 0d8ea34a..dd284ac5 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -37,6 +37,7 @@
#include "delta.h"
#include "trans.h"
#include "alpm.h"
+#include "deps.h"
alpm_handle_t *_alpm_handle_new(void)
{
@@ -85,6 +86,10 @@ void _alpm_handle_free(alpm_handle_t *handle)
FREELIST(handle->noextract);
FREELIST(handle->ignorepkg);
FREELIST(handle->ignoregroup);
+
+ alpm_list_free_inner(handle->assumeinstalled, (alpm_list_fn_free)alpm_dep_free);
+ alpm_list_free(handle->assumeinstalled);
+
FREE(handle);
}
@@ -251,6 +256,12 @@ alpm_list_t SYMEXPORT *alpm_option_get_ignoregroups(alpm_handle_t *handle)
return handle->ignoregroup;
}
+alpm_list_t SYMEXPORT *alpm_option_get_assumeinstalled(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->assumeinstalled;
+}
+
const char SYMEXPORT *alpm_option_get_arch(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
@@ -557,6 +568,51 @@ int SYMEXPORT alpm_option_remove_ignoregroup(alpm_handle_t *handle, const char *
return _alpm_option_strlist_rem(handle, &(handle->ignoregroup), grp);
}
+int SYMEXPORT alpm_option_add_assumeinstalled(alpm_handle_t *handle, const alpm_depend_t *dep)
+{
+ CHECK_HANDLE(handle, return -1);
+
+ handle->assumeinstalled = alpm_list_add(handle->assumeinstalled, (void *)dep);
+ return 0;
+}
+
+int SYMEXPORT alpm_option_set_assumeinstalled(alpm_handle_t *handle, alpm_list_t *deps)
+{
+ CHECK_HANDLE(handle, return -1);
+ if(handle->assumeinstalled) {
+ alpm_list_free_inner(handle->assumeinstalled, (alpm_list_fn_free)alpm_dep_free);
+ alpm_list_free(handle->assumeinstalled);
+ }
+ handle->assumeinstalled = deps;
+ return 0;
+}
+
+static int assumeinstalled_cmp(const void *d1, const void *d2)
+{
+ const alpm_depend_t *dep1 = d1;
+ const alpm_depend_t *dep2 = d2;
+
+ if(strcmp(dep1->name, dep2->name) == 0 && strcmp(dep1->version, dep2->version) == 0) {
+ return 0;
+ }
+
+ return -1;
+}
+
+int SYMEXPORT alpm_option_remove_assumeinstalled(alpm_handle_t *handle, const alpm_depend_t *dep)
+{
+ alpm_depend_t *vdata = NULL;
+ CHECK_HANDLE(handle, return -1);
+
+ handle->assumeinstalled = alpm_list_remove(handle->assumeinstalled, dep, &assumeinstalled_cmp, (void **)&vdata);
+ if(vdata != NULL) {
+ alpm_dep_free(vdata);
+ return 1;
+ }
+
+ return 0;
+}
+
int SYMEXPORT alpm_option_set_arch(alpm_handle_t *handle, const char *arch)
{
CHECK_HANDLE(handle, return -1);