xbps-repo: if fetching info from remote repo for the 'show' and 'show-files'

targets and the binary package exists in cachedir, use it.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20091128022129-y6y2tr0vtvy2w745
This commit is contained in:
Juan RP 2009-11-28 03:21:29 +01:00
parent 21bea723f4
commit f3d2481c31
6 changed files with 35 additions and 13 deletions

View File

@ -121,7 +121,7 @@ download_package_list(prop_object_iterator_t iter)
"filename-sha256", &sha256)) "filename-sha256", &sha256))
return errno; return errno;
lbinfile = xbps_get_binpkg_local_path(obj); lbinfile = xbps_get_binpkg_local_path(obj, repoloc);
if (lbinfile == NULL) if (lbinfile == NULL)
return errno; return errno;

View File

@ -66,8 +66,8 @@ Please note that all targets are *case insensitive*.
Shows information about binary package 'pkgname'. This will print Shows information about binary package 'pkgname'. This will print
the size it takes in filesystem, description, maintainer, architecture the size it takes in filesystem, description, maintainer, architecture
and other information. The first repository in the pool wins. *NOTE: 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 if a remote repository is the winner and binary package is not available
from it.* in cachedir, it will fetch remotely and __on-the-fly__ the info*.
*show-deps 'pkgname'*:: *show-deps 'pkgname'*::
Shows run time dependencies for binary package 'pkgname'. The first 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'*:: *show-files 'pkgname'*::
Shows the file list for a binary package 'pkgname' by searching it 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 in repository pool. The first repository in the pool wins. *NOTE:
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*.
*sync*:: *sync*::
Syncs the package index file for all registered remote repositories. Syncs the package index file for all registered remote repositories.

View File

@ -238,7 +238,8 @@ int SYMEXPORT xbps_check_file_hash(const char *, const char *);
int SYMEXPORT xbps_check_is_installed_pkg(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_installed_pkgname(const char *);
bool SYMEXPORT xbps_check_is_repo_string_remote(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_index_plist(const char *);
char SYMEXPORT *xbps_get_pkg_name(const char *); char SYMEXPORT *xbps_get_pkg_name(const char *);
char SYMEXPORT *xbps_get_pkgdep_name(const char *); char SYMEXPORT *xbps_get_pkgdep_name(const char *);

View File

@ -136,10 +136,30 @@ open_archive(const char *url)
return a; 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 * char SYMEXPORT *
xbps_get_path_from_pkg_dict_repo(prop_dictionary_t d, const char *uri) xbps_get_path_from_pkg_dict_repo(prop_dictionary_t d, const char *uri)
{ {
const char *arch, *filen; 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)) if (!prop_dictionary_get_cstring_nocopy(d, "architecture", &arch))
return NULL; return NULL;

View File

@ -39,7 +39,7 @@ static void set_extract_flags(int *);
int SYMEXPORT int SYMEXPORT
xbps_unpack_binary_pkg(prop_dictionary_t pkg, bool essential) xbps_unpack_binary_pkg(prop_dictionary_t pkg, bool essential)
{ {
const char *pkgname; const char *pkgname, *repoloc;
struct archive *ar = NULL; struct archive *ar = NULL;
char *binfile = NULL; char *binfile = NULL;
int pkg_fd, rv = 0; 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)) if (!prop_dictionary_get_cstring_nocopy(pkg, "pkgname", &pkgname))
return errno; return errno;
if (!prop_dictionary_get_cstring_nocopy(pkg, "repository", &repoloc))
binfile = xbps_get_binpkg_local_path(pkg); return errno;
binfile = xbps_get_binpkg_local_path(pkg, repoloc);
if (binfile == NULL) if (binfile == NULL)
return EINVAL; return EINVAL;

View File

@ -305,12 +305,10 @@ xbps_get_pkg_index_plist(const char *uri)
} }
char SYMEXPORT * 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)) if (!prop_dictionary_get_cstring_nocopy(pkg, "filename", &filen))
return NULL; return NULL;
if (!prop_dictionary_get_cstring_nocopy(pkg, "architecture", &arch)) if (!prop_dictionary_get_cstring_nocopy(pkg, "architecture", &arch))