diff --git a/bin/xbps-bin/install.c b/bin/xbps-bin/install.c index 66ea558f..0464bc3a 100644 --- a/bin/xbps-bin/install.c +++ b/bin/xbps-bin/install.c @@ -121,7 +121,7 @@ download_package_list(prop_object_iterator_t iter) "filename-sha256", &sha256)) return errno; - lbinfile = xbps_get_binpkg_local_path(obj); + lbinfile = xbps_get_binpkg_local_path(obj, repoloc); if (lbinfile == NULL) return errno; diff --git a/bin/xbps-repo/xbps-repo.8.txt b/bin/xbps-repo/xbps-repo.8.txt index 621ef8dd..64d208c7 100644 --- a/bin/xbps-repo/xbps-repo.8.txt +++ b/bin/xbps-repo/xbps-repo.8.txt @@ -66,8 +66,8 @@ Please note that all targets are *case insensitive*. Shows information about binary package 'pkgname'. This will print the size it takes in filesystem, description, maintainer, architecture and other information. The first repository in the pool wins. *NOTE: - if a remote repository is the winner it will have to fetch some info - from it.* + if a remote repository is the winner and binary package is not available + in cachedir, it will fetch remotely and __on-the-fly__ the info*. *show-deps 'pkgname'*:: Shows run time dependencies for binary package 'pkgname'. The first @@ -75,8 +75,10 @@ Please note that all targets are *case insensitive*. *show-files 'pkgname'*:: Shows the file list for a binary package 'pkgname' by searching it - in repository pool. *NOTE: if a remote repository is the winner it will - have to fetch some info from it.* + in repository pool. The first repository in the pool wins. *NOTE: + if a remote repository is the winner and binary package is not + available in `cachedir`, it will fetch remotely and __on-the-fly__ + the info*. *sync*:: Syncs the package index file for all registered remote repositories. diff --git a/include/xbps_api.h b/include/xbps_api.h index 96f759a2..5f1e8528 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -238,7 +238,8 @@ int SYMEXPORT xbps_check_file_hash(const char *, const char *); int SYMEXPORT xbps_check_is_installed_pkg(const char *); bool SYMEXPORT xbps_check_is_installed_pkgname(const char *); bool SYMEXPORT xbps_check_is_repo_string_remote(const char *); -char SYMEXPORT *xbps_get_binpkg_local_path(prop_dictionary_t); +char SYMEXPORT + *xbps_get_binpkg_local_path(prop_dictionary_t, const char *); char SYMEXPORT *xbps_get_pkg_index_plist(const char *); char SYMEXPORT *xbps_get_pkg_name(const char *); char SYMEXPORT *xbps_get_pkgdep_name(const char *); diff --git a/lib/repository_plist.c b/lib/repository_plist.c index e78fda23..198043e4 100644 --- a/lib/repository_plist.c +++ b/lib/repository_plist.c @@ -136,10 +136,30 @@ open_archive(const char *url) return a; } +static char * +binpkg_in_cachedir(prop_dictionary_t d, const char *uri) +{ + char *lbinfile; + + lbinfile = xbps_get_binpkg_local_path(d, uri); + if (lbinfile == NULL) + return NULL; + + if (access(lbinfile, R_OK) == 0) + return lbinfile; + + return NULL; +} + char SYMEXPORT * xbps_get_path_from_pkg_dict_repo(prop_dictionary_t d, const char *uri) { const char *arch, *filen; + char *path = NULL; + + path = binpkg_in_cachedir(d, uri); + if (path) + return path; if (!prop_dictionary_get_cstring_nocopy(d, "architecture", &arch)) return NULL; diff --git a/lib/unpack.c b/lib/unpack.c index fe328ec5..d6296c7b 100644 --- a/lib/unpack.c +++ b/lib/unpack.c @@ -39,7 +39,7 @@ static void set_extract_flags(int *); int SYMEXPORT xbps_unpack_binary_pkg(prop_dictionary_t pkg, bool essential) { - const char *pkgname; + const char *pkgname, *repoloc; struct archive *ar = NULL; char *binfile = NULL; int pkg_fd, rv = 0; @@ -48,8 +48,9 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg, bool essential) if (!prop_dictionary_get_cstring_nocopy(pkg, "pkgname", &pkgname)) return errno; - - binfile = xbps_get_binpkg_local_path(pkg); + if (!prop_dictionary_get_cstring_nocopy(pkg, "repository", &repoloc)) + return errno; + binfile = xbps_get_binpkg_local_path(pkg, repoloc); if (binfile == NULL) return EINVAL; diff --git a/lib/util.c b/lib/util.c index e0b4ecc6..6af2f17e 100644 --- a/lib/util.c +++ b/lib/util.c @@ -305,12 +305,10 @@ xbps_get_pkg_index_plist(const char *uri) } char SYMEXPORT * -xbps_get_binpkg_local_path(prop_dictionary_t pkg) +xbps_get_binpkg_local_path(prop_dictionary_t pkg, const char *repoloc) { - const char *repoloc, *filen, *arch, *cdir; + const char *filen, *arch, *cdir; - if (!prop_dictionary_get_cstring_nocopy(pkg, "repository", &repoloc)) - return NULL; if (!prop_dictionary_get_cstring_nocopy(pkg, "filename", &filen)) return NULL; if (!prop_dictionary_get_cstring_nocopy(pkg, "architecture", &arch))