summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-09-25 23:02:30 -0500
committerDan McGee <dan@archlinux.org>2007-09-25 23:02:30 -0500
commitfc0e83f05b29f57accb49544dabe856968349b3a (patch)
tree8a417de5ee3e2a522d6c13b1198a62b4c7a44155
parent012f7939784358b02726c169543aa99436439335 (diff)
Preliminary support for optdepends
Add some alpm functions for getting optdepends, have makepkg include them in the PKGINFO file, and have a pacman -Qi operation display the raw string as stored by libalpm. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/alpm.h1
-rw-r--r--lib/libalpm/be_files.c11
-rw-r--r--lib/libalpm/package.c19
-rw-r--r--lib/libalpm/package.h1
-rw-r--r--scripts/makepkg.sh.in5
-rw-r--r--src/pacman/package.c1
6 files changed, 36 insertions, 2 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;
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index d5b41144..747484f4 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -815,6 +815,9 @@ create_package() {
for it in "${depends[@]}"; do
echo "depend = $it" >>.PKGINFO
done
+ for it in "${optdepends[@]}"; do
+ echo "optdepend = $it" >>.PKGINFO
+ done
for it in "${conflicts[@]}"; do
echo "conflict = $it" >>.PKGINFO
done
@@ -1177,7 +1180,7 @@ fi
unset pkgname pkgver pkgrel pkgdesc url license groups provides md5sums force
unset replaces depends conflicts backup source install build makedepends
-unset options noextract
+unset optdepends options noextract
if [ ! -f "$BUILDSCRIPT" ]; then
error "$(gettext "%s does not exist.")" "$BUILDSCRIPT"
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 86d91ecb..01f4e973 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -75,6 +75,7 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
list_display(_("Groups :"), alpm_pkg_get_groups(pkg));
list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
list_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
+ list_display(_("Optional Deps :"), alpm_pkg_get_optdepends(pkg));
/* Only applicable if installed */
if(level > 0) {
list_display(_("Required By :"), alpm_pkg_get_requiredby(pkg));