diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/alpm.h | 1 | ||||
-rw-r--r-- | lib/libalpm/be_files.c | 11 | ||||
-rw-r--r-- | lib/libalpm/package.c | 19 | ||||
-rw-r--r-- | lib/libalpm/package.h | 1 |
4 files changed, 31 insertions, 1 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 4a44cc76..852b5c15 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -213,6 +213,7 @@ pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg); alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg); alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg); alpm_list_t *alpm_pkg_get_depends(pmpkg_t *pkg); +alpm_list_t *alpm_pkg_get_optdepends(pmpkg_t *pkg); alpm_list_t *alpm_pkg_get_requiredby(pmpkg_t *pkg); alpm_list_t *alpm_pkg_get_conflicts(pmpkg_t *pkg); alpm_list_t *alpm_pkg_get_provides(pmpkg_t *pkg); diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index 8998f678..af222136 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -388,6 +388,10 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) { info->depends = alpm_list_add(info->depends, strdup(line)); } + } else if(!strcmp(line, "%OPTDEPENDS%")) { + while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) { + info->optdepends = alpm_list_add(info->optdepends, strdup(line)); + } } else if(!strcmp(line, "%REQUIREDBY%")) { while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) { info->requiredby = alpm_list_add(info->requiredby, strdup(line)); @@ -587,6 +591,13 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) } fprintf(fp, "\n"); } + if(info->optdepends) { + fputs("%OPTDEPENDS%\n", fp); + for(lp = info->optdepends; lp; lp = lp->next) { + fprintf(fp, "%s\n", (char *)lp->data); + } + fprintf(fp, "\n"); + } if(local && info->requiredby) { fputs("%REQUIREDBY%\n", fp); for(lp = info->requiredby; lp; lp = lp->next) { diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 64a63b96..4a6e62b9 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -417,7 +417,6 @@ alpm_list_t SYMEXPORT *alpm_pkg_get_groups(pmpkg_t *pkg) return pkg->groups; } -/* depends */ alpm_list_t SYMEXPORT *alpm_pkg_get_depends(pmpkg_t *pkg) { ALPM_LOG_FUNC; @@ -432,6 +431,20 @@ alpm_list_t SYMEXPORT *alpm_pkg_get_depends(pmpkg_t *pkg) return pkg->depends; } +alpm_list_t SYMEXPORT *alpm_pkg_get_optdepends(pmpkg_t *pkg) +{ + ALPM_LOG_FUNC; + + /* Sanity checks */ + ASSERT(handle != NULL, return(NULL)); + ASSERT(pkg != NULL, return(NULL)); + + if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) { + _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DEPENDS); + } + return pkg->optdepends; +} + alpm_list_t SYMEXPORT *alpm_pkg_get_requiredby(pmpkg_t *pkg) { ALPM_LOG_FUNC; @@ -721,6 +734,7 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg) newpkg->files = alpm_list_strdup(alpm_pkg_get_files(pkg)); newpkg->backup = alpm_list_strdup(alpm_pkg_get_backup(pkg)); newpkg->depends = alpm_list_strdup(alpm_pkg_get_depends(pkg)); + newpkg->optdepends = alpm_list_strdup(alpm_pkg_get_optdepends(pkg)); newpkg->groups = alpm_list_strdup(alpm_pkg_get_groups(pkg)); newpkg->provides = alpm_list_strdup(alpm_pkg_get_provides(pkg)); newpkg->replaces = alpm_list_strdup(alpm_pkg_get_replaces(pkg)); @@ -746,6 +760,7 @@ void _alpm_pkg_free(pmpkg_t *pkg) FREELIST(pkg->files); FREELIST(pkg->backup); FREELIST(pkg->depends); + FREELIST(pkg->optdepends); FREELIST(pkg->conflicts); FREELIST(pkg->requiredby); FREELIST(pkg->groups); @@ -876,6 +891,8 @@ static int parse_descfile(const char *descfile, pmpkg_t *info) info->isize = atol(ptr); } else if(!strcmp(key, "depend")) { info->depends = alpm_list_add(info->depends, strdup(ptr)); + } else if(!strcmp(key, "optdepend")) { + info->optdepends = alpm_list_add(info->optdepends, strdup(ptr)); } else if(!strcmp(key, "conflict")) { info->conflicts = alpm_list_add(info->conflicts, strdup(ptr)); } else if(!strcmp(key, "replaces")) { diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index 9a877ffd..460a38c8 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -71,6 +71,7 @@ struct __pmpkg_t { alpm_list_t *files; alpm_list_t *backup; alpm_list_t *depends; + alpm_list_t *optdepends; alpm_list_t *requiredby; alpm_list_t *conflicts; alpm_list_t *provides; |