lib/util.c: xbps_remote_binpkg_exists to check if signature and binpkg are cached

This commit is contained in:
Duncaen
2019-07-07 14:08:55 +02:00
committed by Juan RP
parent d2bdd9574e
commit 62c1102cc4
2 changed files with 40 additions and 0 deletions

View File

@ -378,6 +378,35 @@ xbps_binpkg_exists(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
return access(path, R_OK) == 0;
}
bool
xbps_remote_binpkg_exists(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
{
char path[PATH_MAX];
const char *pkgver, *arch;
assert(xhp);
assert(xbps_object_type(pkgd) == XBPS_TYPE_DICTIONARY);
if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver))
return NULL;
if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"architecture", &arch))
return NULL;
snprintf(path, sizeof(path), "%s/%s.%s.xbps.sig", xhp->cachedir,
pkgver, arch);
/* check if the signature file exists */
if (access(path, R_OK) != 0)
return false;
/* strip the .sig suffix and check if binpkg file exists */
path[strlen(path)-sizeof (".sig")+1] = '\0';
return access(path, R_OK) == 0;
}
bool
xbps_pkg_has_rundeps(xbps_dictionary_t pkgd)
{