From 040083b97fab61c8afc16a1c49a8384d097c272a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 28 Aug 2011 23:41:17 -0500 Subject: Allow access to package origin data Add new alpm_pkg_get_origin() method, use it in the front end now that the enum constants are publicly available. Signed-off-by: Dan McGee --- README | 2 +- lib/libalpm/alpm.h | 5 +++++ lib/libalpm/package.c | 7 +++++++ src/pacman/package.c | 7 +++---- src/pacman/package.h | 2 +- src/pacman/query.c | 4 ++-- src/pacman/sync.c | 4 ++-- 7 files changed, 21 insertions(+), 10 deletions(-) diff --git a/README b/README index fbd40d2f..c14fd3c7 100644 --- a/README +++ b/README @@ -429,7 +429,7 @@ API CHANGES BETWEEN 3.5 AND 4.0 alpm_option_get_default_siglevel(), alpm_option_set_default_siglevel(), alpm_option_get_gpgdir(), alpm_option_set_gpgdir(), alpm_db_get_siglevel(), alpm_sigresult_cleanup(), alpm_db_check_pgp_signature(), alpm_pkg_check_pgp_signature(), - alpm_pkg_get_sha256sum(), alpm_pkg_get_base64_sig() + alpm_pkg_get_origin(), alpm_pkg_get_sha256sum(), alpm_pkg_get_base64_sig() - list functions: alpm_list_to_array(), alpm_list_previous() - structs: diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 2f625658..42e60385 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -598,6 +598,11 @@ const char *alpm_pkg_get_name(alpm_pkg_t *pkg); */ const char *alpm_pkg_get_version(alpm_pkg_t *pkg); +/** Returns the origin of the package. + * @return a #alpm_pkgfrom_t constant, -1 on error + */ +alpm_pkgfrom_t alpm_pkg_get_origin(alpm_pkg_t *pkg); + /** Returns the package description. * @param pkg a pointer to package * @return a reference to an internal string diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 3d73a433..487b56d9 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -185,6 +185,13 @@ const char SYMEXPORT *alpm_pkg_get_version(alpm_pkg_t *pkg) return pkg->version; } +alpm_pkgfrom_t SYMEXPORT alpm_pkg_get_origin(alpm_pkg_t *pkg) +{ + ASSERT(pkg != NULL, return -1); + pkg->handle->pm_errno = 0; + return pkg->origin; +} + const char SYMEXPORT *alpm_pkg_get_desc(alpm_pkg_t *pkg) { ASSERT(pkg != NULL, return NULL); diff --git a/src/pacman/package.c b/src/pacman/package.c index f7065d54..5654944c 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -61,7 +61,7 @@ static void deplist_display(const char *title, * @param from the type of package we are dealing with * @param extra should we show extra information */ -void dump_pkg_full(alpm_pkg_t *pkg, alpm_pkgfrom_t from, int extra) +void dump_pkg_full(alpm_pkg_t *pkg, int extra) { const char *reason; time_t bdate, idate; @@ -69,10 +69,9 @@ void dump_pkg_full(alpm_pkg_t *pkg, alpm_pkgfrom_t from, int extra) const char *label; double size; alpm_list_t *requiredby = NULL; + alpm_pkgfrom_t from; - if(pkg == NULL) { - return; - } + from = alpm_pkg_get_origin(pkg); /* set variables here, do all output below */ bdate = alpm_pkg_get_builddate(pkg); diff --git a/src/pacman/package.h b/src/pacman/package.h index 4bbc2ba0..890b4fe1 100644 --- a/src/pacman/package.h +++ b/src/pacman/package.h @@ -22,7 +22,7 @@ #include -void dump_pkg_full(alpm_pkg_t *pkg, alpm_pkgfrom_t from, int extra); +void dump_pkg_full(alpm_pkg_t *pkg, int extra); void dump_pkg_backups(alpm_pkg_t *pkg); void dump_pkg_files(alpm_pkg_t *pkg, int quiet); diff --git a/src/pacman/query.c b/src/pacman/query.c index ec98c999..5f2b37eb 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -460,9 +460,9 @@ static int display(alpm_pkg_t *pkg) if(config->op_q_info) { if(config->op_q_isfile) { - dump_pkg_full(pkg, PKG_FROM_FILE, 0); + dump_pkg_full(pkg, 0); } else { - dump_pkg_full(pkg, PKG_FROM_LOCALDB, config->op_q_info > 1); + dump_pkg_full(pkg, config->op_q_info > 1); } } if(config->op_q_list) { diff --git a/src/pacman/sync.c b/src/pacman/sync.c index a7fe5be9..e97da37a 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -469,7 +469,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) alpm_pkg_t *pkg = alpm_list_getdata(k); if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) { - dump_pkg_full(pkg, PKG_FROM_SYNCDB, config->op_s_info > 1); + dump_pkg_full(pkg, config->op_s_info > 1); foundpkg = 1; break; } @@ -494,7 +494,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) { alpm_pkg_t *pkg = alpm_list_getdata(j); - dump_pkg_full(pkg, PKG_FROM_SYNCDB, config->op_s_info > 1); + dump_pkg_full(pkg, config->op_s_info > 1); } } } -- cgit v1.2.3-70-g09d2