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

Mark Weiman mark.weiman at markzz.com
Tue Jan 3 22:32:27 UTC 2017


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    | 18 ++++++++++++++++++
 lib/libalpm/package.h    |  4 ++++
 4 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 2d2491d8..3ef24262 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 b7c54fa1..93af9696 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 05becf01..629cf015 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; }
@@ -161,6 +163,8 @@ struct pkg_operations default_pkg_ops = {
 	.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,
@@ -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 0822a8d0..1f029bdc 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.11.0


More information about the pacman-dev mailing list