diff options
Diffstat (limited to 'lib/libalpm')
-rw-r--r-- | lib/libalpm/alpm.h | 6 | ||||
-rw-r--r-- | lib/libalpm/be_local.c | 18 | ||||
-rw-r--r-- | lib/libalpm/be_package.c | 2 | ||||
-rw-r--r-- | lib/libalpm/package.c | 11 | ||||
-rw-r--r-- | lib/libalpm/package.h | 2 |
5 files changed, 39 insertions, 0 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index c2a069ad..6203f765 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -1358,6 +1358,12 @@ alpm_filelist_t *alpm_pkg_get_files(alpm_pkg_t *pkg); */ alpm_list_t *alpm_pkg_get_backup(alpm_pkg_t *pkg); +/** Returns the list of alternatives provided by the package + * @param pkg a pointer to package + * @return a reference to a list of char* objects + */ +alpm_list_t *alpm_pkg_get_alternatives(alpm_pkg_t *pkg); + /** Returns the database containing pkg. * Returns a pointer to the alpm_db_t structure the package is * originating from, or NULL if the package was loaded from a file. diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 9ebdfa40..2b9e2594 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -195,6 +195,12 @@ static alpm_list_t *_cache_get_backup(alpm_pkg_t *pkg) return pkg->backup; } +static alpm_list_t *_cache_get_alternatives(alpm_pkg_t *pkg) +{ + LAZY_LOAD(INFRQ_DESC); + return pkg->alternatives; +} + /** * Open a package changelog for reading. Similar to fopen in functionality, * except that the returned 'file stream' is from the database. @@ -351,6 +357,7 @@ static struct pkg_operations local_pkg_ops = { .get_replaces = _cache_get_replaces, .get_files = _cache_get_files, .get_backup = _cache_get_backup, + .get_alternatives = _cache_get_alternatives, .changelog_open = _cache_changelog_open, .changelog_read = _cache_changelog_read, @@ -806,6 +813,8 @@ static int local_db_read(alpm_pkg_t *info, int inforeq) READ_AND_SPLITDEP(info->conflicts); } else if(strcmp(line, "%PROVIDES%") == 0) { READ_AND_SPLITDEP(info->provides); + } else if(strcmp(line, "%ALTERNATIVES%") == 0) { + READ_AND_STORE_ALL(info->alternatives); } } fclose(fp); @@ -1047,6 +1056,15 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, int inforeq) write_deps(fp, "%CONFLICTS%", info->conflicts); write_deps(fp, "%PROVIDES%", info->provides); + if(info->alternatives) { + fputs("%ALTERNATIVES%\n", fp); + for(lp = info->alternatives; lp; lp = lp->next) { + fputs(lp->data, fp); + fputc('\n', fp); + } + fputc('\n', fp); + } + fclose(fp); fp = NULL; } diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 7a118d2a..3d8d15cd 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -241,6 +241,8 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t * CALLOC(backup, 1, sizeof(alpm_backup_t), return -1); STRDUP(backup->name, ptr, FREE(backup); return -1); newpkg->backup = alpm_list_add(newpkg->backup, backup); + } else if(strcmp(key, "alternative") == 0) { + newpkg->alternatives = alpm_list_add(newpkg->alternatives, strdup(ptr)); } else if(strcmp(key, "force") == 0) { /* deprecated, skip it */ } else if(strcmp(key, "makepkgopt") == 0) { diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 5c5fa073..8a9b64e6 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -98,6 +98,7 @@ static alpm_list_t *_pkg_get_provides(alpm_pkg_t *pkg) { return pkg->provides; static alpm_list_t *_pkg_get_replaces(alpm_pkg_t *pkg) { return pkg->replaces; } static alpm_filelist_t *_pkg_get_files(alpm_pkg_t *pkg) { return &(pkg->files); } static alpm_list_t *_pkg_get_backup(alpm_pkg_t *pkg) { return pkg->backup; } +static alpm_list_t *_pkg_get_alternatives(alpm_pkg_t *pkg) { return pkg->alternatives; } static void *_pkg_changelog_open(alpm_pkg_t UNUSED *pkg) { @@ -162,6 +163,7 @@ struct pkg_operations default_pkg_ops = { .get_replaces = _pkg_get_replaces, .get_files = _pkg_get_files, .get_backup = _pkg_get_backup, + .get_alternatives = _pkg_get_alternatives, .changelog_open = _pkg_changelog_open, .changelog_read = _pkg_changelog_read, @@ -380,6 +382,13 @@ alpm_list_t SYMEXPORT *alpm_pkg_get_backup(alpm_pkg_t *pkg) return pkg->ops->get_backup(pkg); } +alpm_list_t SYMEXPORT *alpm_pkg_get_alternatives(alpm_pkg_t *pkg) +{ + ASSERT(pkg != NULL, return NULL); + pkg->handle->pm_errno = ALPM_ERR_OK; + return pkg->ops->get_alternatives(pkg); +} + alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg) { /* Sanity checks */ @@ -594,6 +603,7 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr) newpkg->optdepends = list_depdup(pkg->optdepends); newpkg->conflicts = list_depdup(pkg->conflicts); newpkg->provides = list_depdup(pkg->provides); + newpkg->alternatives = alpm_list_strdup(pkg->alternatives); if(pkg->files.count) { size_t filenum; @@ -671,6 +681,7 @@ void _alpm_pkg_free(alpm_pkg_t *pkg) free_deplist(pkg->provides); alpm_list_free(pkg->removes); _alpm_pkg_free(pkg->oldpkg); + FREELIST(pkg->alternatives); if(pkg->origin == ALPM_PKG_FROM_FILE) { FREE(pkg->origin_data.file); diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index c37bd11e..26c605b8 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -66,6 +66,7 @@ struct pkg_operations { alpm_list_t *(*get_replaces) (alpm_pkg_t *); alpm_filelist_t *(*get_files) (alpm_pkg_t *); alpm_list_t *(*get_backup) (alpm_pkg_t *); + alpm_list_t *(*get_alternatives) (alpm_pkg_t *); void *(*changelog_open) (alpm_pkg_t *); size_t (*changelog_read) (void *, size_t, const alpm_pkg_t *, void *); @@ -120,6 +121,7 @@ struct __alpm_pkg_t { alpm_list_t *provides; alpm_list_t *removes; /* in transaction targets only */ alpm_pkg_t *oldpkg; /* in transaction targets only */ + alpm_list_t *alternatives; struct pkg_operations *ops; |