xbps-query: add repo and pkgdb mode to --cat

This commit is contained in:
Duncan Overbruck
2021-12-19 16:07:25 +01:00
parent 3939d9aeb5
commit f5355e53cd
7 changed files with 75 additions and 3 deletions

View File

@ -281,6 +281,27 @@ repo_show_pkg_info(struct xbps_handle *xhp,
return 0;
}
int
cat_file(struct xbps_handle *xhp, const char *pkg, const char *file)
{
xbps_dictionary_t pkgd;
char *url;
int rv;
pkgd = xbps_pkgdb_get_pkg(xhp, pkg);
if (pkgd == NULL)
return errno;
url = xbps_repository_pkg_path(xhp, pkgd);
if (url == NULL)
return EINVAL;
xbps_dbg_printf(xhp, "matched pkg at %s\n", url);
rv = xbps_archive_fetch_file_into_fd(url, file, STDOUT_FILENO);
free(url);
return rv;
}
int
repo_cat_file(struct xbps_handle *xhp, const char *pkg, const char *file)
{