[pacman-dev] [PATCH] Add alpm_pkg_get_makedepends and alpm_pkg_get_checkdepends

Mark Weiman mark.weiman at markzz.com
Fri Dec 9 02:17:24 UTC 2016


makepkg adds makedepends and checkdepends to a package's .PKGINFO file.
Add functions that allow use of these from libalpm.

Signed-off-by: Mark Weiman <mark.weiman at markzz.com>
---
 lib/libalpm/alpm.h       | 12 ++++++++
 lib/libalpm/be_package.c |  6 ++--
 lib/libalpm/package.c    | 80 +++++++++++++++++++++++++++++-------------------
 lib/libalpm/package.h    |  4 +++
 4 files changed, 69 insertions(+), 33 deletions(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 2d2491d..3ef2426 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -1261,6 +1261,18 @@ alpm_list_t *alpm_pkg_get_depends(alpm_pkg_t *pkg);
  */
 alpm_list_t *alpm_pkg_get_optdepends(alpm_pkg_t *pkg);
 
+/** Returns a list of package check dependencies
+ * @param pkg a pointer to package
+ * @return a reference to an internal list of alpm_depend_t structures.
+ */
+alpm_list_t *alpm_pkg_get_checkdepends(alpm_pkg_t *pkg);
+
+/** Returns a list of package make dependencies
+ * @param pkg a pointer to package
+ * @return a reference to an internal list of alpm_depend_t structures.
+ */
+alpm_list_t *alpm_pkg_get_makedepends(alpm_pkg_t *pkg);
+
 /** Returns the list of packages conflicting with pkg.
  * @param pkg a pointer to package
  * @return a reference to an internal list of alpm_depend_t structures.
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index b7c54fa..93af969 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -223,9 +223,11 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
 				alpm_depend_t *optdep = alpm_dep_from_string(ptr);
 				newpkg->optdepends = alpm_list_add(newpkg->optdepends, optdep);
 			} else if(strcmp(key, "makedepend") == 0) {
-				/* not used atm */
+				alpm_depend_t *makedep = alpm_dep_from_string(ptr);
+				newpkg->makedepends = alpm_list_add(newpkg->makedepends, makedep);
 			} else if(strcmp(key, "checkdepend") == 0) {
-				/* not used atm */
+				alpm_depend_t *checkdep = alpm_dep_from_string(ptr);
+				newpkg->checkdepends = alpm_list_add(newpkg->checkdepends, checkdep);
 			} else if(strcmp(key, "conflict") == 0) {
 				alpm_depend_t *conflict = alpm_dep_from_string(ptr);
 				newpkg->conflicts = alpm_list_add(newpkg->conflicts, conflict);
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 05becf0..6bc9936 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -99,6 +99,8 @@ static alpm_list_t *_pkg_get_licenses(alpm_pkg_t *pkg)   { return pkg->licenses;
 static alpm_list_t *_pkg_get_groups(alpm_pkg_t *pkg)     { return pkg->groups; }
 static alpm_list_t *_pkg_get_depends(alpm_pkg_t *pkg)    { return pkg->depends; }
 static alpm_list_t *_pkg_get_optdepends(alpm_pkg_t *pkg) { return pkg->optdepends; }
+static alpm_list_t *_pkg_get_checkdepends(alpm_pkg_t *pkg) { return pkg->checkdepends; }
+static alpm_list_t *_pkg_get_makedepends(alpm_pkg_t *pkg)  { return pkg->makedepends; }
 static alpm_list_t *_pkg_get_conflicts(alpm_pkg_t *pkg)  { return pkg->conflicts; }
 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; }
@@ -145,37 +147,39 @@ static int _pkg_force_load(alpm_pkg_t UNUSED *pkg) { return 0; }
  * struct itself with no abstraction layer or any type of lazy loading.
  */
 struct pkg_operations default_pkg_ops = {
-	.get_base        = _pkg_get_base,
-	.get_desc        = _pkg_get_desc,
-	.get_url         = _pkg_get_url,
-	.get_builddate   = _pkg_get_builddate,
-	.get_installdate = _pkg_get_installdate,
-	.get_packager    = _pkg_get_packager,
-	.get_arch        = _pkg_get_arch,
-	.get_isize       = _pkg_get_isize,
-	.get_reason      = _pkg_get_reason,
-	.get_validation  = _pkg_get_validation,
-	.has_scriptlet   = _pkg_has_scriptlet,
-
-	.get_licenses    = _pkg_get_licenses,
-	.get_groups      = _pkg_get_groups,
-	.get_depends     = _pkg_get_depends,
-	.get_optdepends  = _pkg_get_optdepends,
-	.get_conflicts   = _pkg_get_conflicts,
-	.get_provides    = _pkg_get_provides,
-	.get_replaces    = _pkg_get_replaces,
-	.get_files       = _pkg_get_files,
-	.get_backup      = _pkg_get_backup,
-
-	.changelog_open  = _pkg_changelog_open,
-	.changelog_read  = _pkg_changelog_read,
-	.changelog_close = _pkg_changelog_close,
-
-	.mtree_open      = _pkg_mtree_open,
-	.mtree_next      = _pkg_mtree_next,
-	.mtree_close     = _pkg_mtree_close,
-
-	.force_load      = _pkg_force_load,
+	.get_base         = _pkg_get_base,
+	.get_desc         = _pkg_get_desc,
+	.get_url          = _pkg_get_url,
+	.get_builddate    = _pkg_get_builddate,
+	.get_installdate  = _pkg_get_installdate,
+	.get_packager     = _pkg_get_packager,
+	.get_arch         = _pkg_get_arch,
+	.get_isize        = _pkg_get_isize,
+	.get_reason       = _pkg_get_reason,
+	.get_validation   = _pkg_get_validation,
+	.has_scriptlet    = _pkg_has_scriptlet,
+
+	.get_licenses     = _pkg_get_licenses,
+	.get_groups       = _pkg_get_groups,
+	.get_depends      = _pkg_get_depends,
+	.get_optdepends   = _pkg_get_optdepends,
+	.get_checkdepends = _pkg_get_checkdepends,
+	.get_makedepends  = _pkg_get_makedepends,
+	.get_conflicts    = _pkg_get_conflicts,
+	.get_provides     = _pkg_get_provides,
+	.get_replaces     = _pkg_get_replaces,
+	.get_files        = _pkg_get_files,
+	.get_backup       = _pkg_get_backup,
+
+	.changelog_open   = _pkg_changelog_open,
+	.changelog_read   = _pkg_changelog_read,
+	.changelog_close  = _pkg_changelog_close,
+
+	.mtree_open       = _pkg_mtree_open,
+	.mtree_next       = _pkg_mtree_next,
+	.mtree_close      = _pkg_mtree_close,
+
+	.force_load       = _pkg_force_load,
 };
 
 /* Public functions for getting package information. These functions
@@ -335,6 +339,20 @@ alpm_list_t SYMEXPORT *alpm_pkg_get_optdepends(alpm_pkg_t *pkg)
 	return pkg->ops->get_optdepends(pkg);
 }
 
+alpm_list_t SYMEXPORT *alpm_pkg_get_checkdepends(alpm_pkg_t *pkg)
+{
+	ASSERT(pkg != NULL, return NULL);
+	pkg->handle->pm_errno = ALPM_ERR_OK;
+	return pkg->ops->get_checkdepends(pkg);
+}
+
+alpm_list_t SYMEXPORT *alpm_pkg_get_makedepends(alpm_pkg_t *pkg)
+{
+	ASSERT(pkg != NULL, return NULL);
+	pkg->handle->pm_errno = ALPM_ERR_OK;
+	return pkg->ops->get_makedepends(pkg);
+}
+
 alpm_list_t SYMEXPORT *alpm_pkg_get_conflicts(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 0822a8d..1f029bd 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -59,6 +59,8 @@ struct pkg_operations {
 	alpm_list_t *(*get_groups) (alpm_pkg_t *);
 	alpm_list_t *(*get_depends) (alpm_pkg_t *);
 	alpm_list_t *(*get_optdepends) (alpm_pkg_t *);
+	alpm_list_t *(*get_checkdepends) (alpm_pkg_t *);
+	alpm_list_t *(*get_makedepends) (alpm_pkg_t *);
 	alpm_list_t *(*get_conflicts) (alpm_pkg_t *);
 	alpm_list_t *(*get_provides) (alpm_pkg_t *);
 	alpm_list_t *(*get_replaces) (alpm_pkg_t *);
@@ -112,6 +114,8 @@ struct __alpm_pkg_t {
 	alpm_list_t *backup;
 	alpm_list_t *depends;
 	alpm_list_t *optdepends;
+	alpm_list_t *checkdepends;
+	alpm_list_t *makedepends;
 	alpm_list_t *conflicts;
 	alpm_list_t *provides;
 	alpm_list_t *deltas;
-- 
2.10.2


More information about the pacman-dev mailing list