Introduce xbps_binpkg_get_file_into_fd() and use it for xbps-query(8) --cat.

This allows you to print to stdout any file stored in a binary package,
locally or remotely!

$ xbps-query -R --cat=/usr/bin/ls coreutils > ls
$ file ls
ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=7a195fc46d1d5cdca32bfccd3b30f81784e342ed, stripped
$
This commit is contained in:
Juan RP
2014-11-17 18:43:08 +01:00
parent db14524cf3
commit 77c6c3e504
3 changed files with 52 additions and 9 deletions

View File

@@ -311,7 +311,8 @@ int
repo_cat_file(struct xbps_handle *xhp, const char *pkg, const char *file)
{
xbps_dictionary_t pkgd;
char *url, *buf;
char *url;
int rv;
pkgd = xbps_rpool_get_pkg(xhp, pkg);
if (pkgd == NULL)
@@ -322,14 +323,9 @@ repo_cat_file(struct xbps_handle *xhp, const char *pkg, const char *file)
return EINVAL;
xbps_dbg_printf(xhp, "matched pkg at %s\n", url);
buf = xbps_binpkg_get_file(url, file);
rv = xbps_binpkg_get_file_into_fd(url, file, STDOUT_FILENO);
free(url);
if (buf == NULL)
return ENOENT;
printf("%s", buf);
free(buf);
return 0;
return rv;
}
int