From 9a0c175c18869fe975c3e2f0fef34b420e480dcd Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 24 Dec 2008 12:34:04 +0100 Subject: [PATCH] Use the repo list to find binary packages. --HG-- extra : convert_revision : c35e25604d0e417115cd1c30d77d23fee3c39f92 --- bin/xbps-bin.c | 12 ------------ include/plist.h | 1 + lib/install.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/bin/xbps-bin.c b/bin/xbps-bin.c index 172d6bac23a..38550e80a11 100644 --- a/bin/xbps-bin.c +++ b/bin/xbps-bin.c @@ -163,7 +163,6 @@ main(int argc, char **argv) prop_dictionary_t dict; repo_info_t *rinfo = NULL; char dpkgidx[PATH_MAX], repolist[PATH_MAX]; - int rv = 0; if (argc < 2) usage(); @@ -273,7 +272,6 @@ main(int argc, char **argv) if (argc != 3) usage(); -#if 0 dict = getrepolist_dict(); if (!xbps_callback_array_iter_in_dict(dict, "repository-list", xbps_install_binary_pkg_from_repolist, argv[2])) { @@ -282,16 +280,6 @@ main(int argc, char **argv) "for %s.\n", argv[2]); exit(EINVAL); } -#endif - - dict = prop_dictionary_internalize_from_file("/storage/xbps/binpkgs/pkg-index.plist"); - if (dict == NULL) - exit(EINVAL); - - rv = xbps_install_binary_pkg(dict, argv[2], - "/home/juan/root_xbps"); - if (rv) - exit(rv); prop_object_release(dict); } else { diff --git a/include/plist.h b/include/plist.h index fe92f05c06d..b4aed480ebf 100644 --- a/include/plist.h +++ b/include/plist.h @@ -161,6 +161,7 @@ char * xbps_get_pkg_name(const char *); int xbps_install_pkg_deps(prop_dictionary_t, prop_dictionary_t); int xbps_install_binary_pkg(prop_dictionary_t, const char *, const char *); +bool xbps_install_binary_pkg_from_repolist(prop_object_t, void *, bool *); int xbps_unpack_binary_pkg(prop_dictionary_t, int (*cb)(struct archive *)); int xbps_unpack_archive_cb(struct archive *); diff --git a/lib/install.c b/lib/install.c index d5f37a801b6..8be1b870509 100644 --- a/lib/install.c +++ b/lib/install.c @@ -32,6 +32,50 @@ #include +bool +xbps_install_binary_pkg_from_repolist(prop_object_t obj, void *arg, bool *done) +{ + prop_dictionary_t dict; + prop_string_t oloc; + const char *repofile, *repoloc; + char plist[PATH_MAX]; + int rv = 0; + + assert(prop_object_type(obj) == PROP_TYPE_STRING); + + /* Get the location */ + repofile = prop_string_cstring_nocopy(obj); + + /* Get string for pkg-index.plist with full path. */ + if (!xbps_append_full_path(plist, repofile, XBPS_PKGINDEX)) + return false; + + dict = prop_dictionary_internalize_from_file(plist); + if (dict == NULL || prop_dictionary_count(dict) == 0) + return false; + + oloc = prop_dictionary_get(dict, "location-remote"); + if (oloc == NULL) + oloc = prop_dictionary_get(dict, "location-local"); + + if (oloc && prop_object_type(oloc) == PROP_TYPE_STRING) + repoloc = prop_string_cstring_nocopy(oloc); + else { + prop_object_release(dict); + return false; + } + + printf("Searching in repository: %s\n", repoloc); + rv = xbps_install_binary_pkg(dict, arg, "/home/juan/root_xbps"); + *done = true; + prop_object_release(dict); + + if (rv != 0) + return false; + + return true; +} + int xbps_install_binary_pkg(prop_dictionary_t repo, const char *pkgname, const char *dest)