From 3117c8b4ee2cadf20b21b049bb8d3c24bf3507bb Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 25 Nov 2009 02:15:56 +0000 Subject: [PATCH] xbps-repo(8): added 'show-files' target. It will search for 'pkgname' and will print its list of files, by searching it in repository pool. The first repo wins. Bump XBPS_RELVER to 20091125. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091125021556-n8p6atfbkuvb4doi --- bin/xbps-bin/show-info-files.c | 57 ++-------------------------------- bin/xbps-repo/defs.h | 1 + bin/xbps-repo/main.c | 20 +++++++++++- bin/xbps-repo/util.c | 57 ++++++++++++++++++++++++++++++++++ bin/xbps-repo/xbps-repo.8.txt | 4 +++ include/xbps_api.h | 2 +- 6 files changed, 85 insertions(+), 56 deletions(-) diff --git a/bin/xbps-bin/show-info-files.c b/bin/xbps-bin/show-info-files.c index 7bc42fcc..76a166f4 100644 --- a/bin/xbps-bin/show-info-files.c +++ b/bin/xbps-bin/show-info-files.c @@ -62,12 +62,8 @@ int show_pkg_files_from_metadir(const char *pkgname) { prop_dictionary_t pkgd; - prop_array_t array; - prop_object_iterator_t iter = NULL; - prop_object_t obj; - const char *file; - char *plist, *array_str = "files"; - int i, rv = 0; + char *plist; + int rv = 0; plist = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, pkgname, XBPS_PKGFILES); @@ -81,54 +77,7 @@ show_pkg_files_from_metadir(const char *pkgname) } free(plist); - /* Links. */ - array = prop_dictionary_get(pkgd, "links"); - if (array && prop_array_count(array) > 0) { - iter = xbps_get_array_iter_from_dict(pkgd, "links"); - if (iter == NULL) { - rv = EINVAL; - goto out; - } - while ((obj = prop_object_iterator_next(iter))) { - if (!prop_dictionary_get_cstring_nocopy(obj, - "file", &file)) { - prop_object_iterator_release(iter); - rv = errno; - goto out; - } - printf("%s\n", file); - } - prop_object_iterator_release(iter); - } - - /* Files and configuration files. */ - for (i = 0; i < 2; i++) { - if (i == 0) - array_str = "conf_files"; - else - array_str = "files"; - - array = prop_dictionary_get(pkgd, array_str); - if (array == NULL || prop_array_count(array) == 0) - continue; - - iter = xbps_get_array_iter_from_dict(pkgd, array_str); - if (iter == NULL) { - rv = EINVAL; - goto out; - } - while ((obj = prop_object_iterator_next(iter))) { - if (!prop_dictionary_get_cstring_nocopy(obj, - "file", &file)) { - prop_object_iterator_release(iter); - rv = errno; - goto out; - } - printf("%s\n", file); - } - prop_object_iterator_release(iter); - } -out: + rv = show_pkg_files(pkgd); prop_object_release(pkgd); return rv; diff --git a/bin/xbps-repo/defs.h b/bin/xbps-repo/defs.h index a2321077..062674c0 100644 --- a/bin/xbps-repo/defs.h +++ b/bin/xbps-repo/defs.h @@ -29,6 +29,7 @@ /* From index.c */ int xbps_repo_genindex(const char *); /* From util.c */ +int show_pkg_files(prop_dictionary_t); void show_pkg_info(prop_dictionary_t); int show_pkg_namedesc(prop_object_t, void *, bool *); int list_strings_in_array(prop_object_t, void *, bool *); diff --git a/bin/xbps-repo/main.c b/bin/xbps-repo/main.c index 29cd7e48..85fb3623 100644 --- a/bin/xbps-repo/main.c +++ b/bin/xbps-repo/main.c @@ -43,7 +43,8 @@ usage(void) { printf("Usage: xbps-repo [options] [action] [arguments]\n\n" " Available actions:\n" - " add, genindex, list, remove, search, show, show-deps, sync\n" + " add, genindex, list, remove, search, show, show-deps,\n" + " show-files, sync\n" " Actions with arguments:\n" " add\t\t\n" " genindex\t\n" @@ -51,6 +52,7 @@ usage(void) " search\t\n" " show\t\n" " show-deps\t\n" + " show-files\t\n" " Options shared by all actions:\n" " -r\t\t\n" " -V\t\tPrints xbps release version\n" @@ -346,6 +348,22 @@ main(int argc, char **argv) goto out; } + } else if (strcasecmp(argv[0], "show-files") == 0) { + /* Shows the package files in a binary package */ + if (argc != 2) + usage(); + + pkgd = xbps_get_pkg_plist_dict_from_repo(argv[1], + "./files.plist"); + if (pkgd == NULL) { + printf("E: couldn't read files.plist: %s.\n", + strerror(errno)); + rv = errno; + goto out; + } + rv = show_pkg_files(pkgd); + prop_object_release(pkgd); + } else if (strcasecmp(argv[0], "genindex") == 0) { /* Generates a package repository index plist file. */ if (argc != 2) diff --git a/bin/xbps-repo/util.c b/bin/xbps-repo/util.c index ce718636..7c240fcb 100644 --- a/bin/xbps-repo/util.c +++ b/bin/xbps-repo/util.c @@ -112,6 +112,63 @@ show_pkg_info(prop_dictionary_t dict) printf(" %s\n", prop_string_cstring_nocopy(obj)); } +int +show_pkg_files(prop_dictionary_t filesd) +{ + prop_array_t array; + prop_object_iterator_t iter = NULL; + prop_object_t obj; + const char *file; + char *array_str = "files"; + int i = 0; + + /* Links. */ + array = prop_dictionary_get(filesd, "links"); + if (array && prop_array_count(array) > 0) { + iter = xbps_get_array_iter_from_dict(filesd, "links"); + if (iter == NULL) + return EINVAL; + + while ((obj = prop_object_iterator_next(iter))) { + if (!prop_dictionary_get_cstring_nocopy(obj, + "file", &file)) { + prop_object_iterator_release(iter); + return errno; + } + printf("%s\n", file); + } + prop_object_iterator_release(iter); + } + + /* Files and configuration files. */ + for (i = 0; i < 2; i++) { + if (i == 0) + array_str = "conf_files"; + else + array_str = "files"; + + array = prop_dictionary_get(filesd, array_str); + if (array == NULL || prop_array_count(array) == 0) + continue; + + iter = xbps_get_array_iter_from_dict(filesd, array_str); + if (iter == NULL) + return EINVAL; + + while ((obj = prop_object_iterator_next(iter))) { + if (!prop_dictionary_get_cstring_nocopy(obj, + "file", &file)) { + prop_object_iterator_release(iter); + return errno; + } + printf("%s\n", file); + } + prop_object_iterator_release(iter); + } + + return 0; +} + int show_pkg_namedesc(prop_object_t obj, void *arg, bool *loop_done) { diff --git a/bin/xbps-repo/xbps-repo.8.txt b/bin/xbps-repo/xbps-repo.8.txt index f8fc40fc..10f2506e 100644 --- a/bin/xbps-repo/xbps-repo.8.txt +++ b/bin/xbps-repo/xbps-repo.8.txt @@ -73,6 +73,10 @@ Please note that all targets are *case insensitive*. Shows run time dependencies for binary package 'pkgname'. The first repository in the pool wins. +*show-files 'pkgname'*:: + Shows the file list for a binary package 'pkgname' by searching it + in repository pool. Local and remote repositories are supported. + *sync*:: Syncs the package index file for all registered remote repositories. The new file will be fetched if local and remote size/mtime do not match. diff --git a/include/xbps_api.h b/include/xbps_api.h index f6de26c9..681e6240 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -38,7 +38,7 @@ #include /* Current release version */ -#define XBPS_RELVER "20091124-1" +#define XBPS_RELVER "20091125" /* Default root PATH for xbps to store metadata info. */ #define XBPS_META_PATH "/var/db/xbps"