xbps-query: add repo and pkgdb mode to --cat
This commit is contained in:
parent
3939d9aeb5
commit
f5355e53cd
2
NEWS
2
NEWS
@ -45,6 +45,8 @@ xbps-X.XX.X (2020-XX-XX):
|
||||
|
||||
* xbps-remove(1): fix dry run cache cleaning inconsistencies. [duncaen]
|
||||
|
||||
* xbps-query(1): --cat now works in either repo or pkgdb mode. [duncaen]
|
||||
|
||||
* xbps.d(5): describe ignorepkg more precisely. [chocimier]
|
||||
|
||||
xbps-0.59.1 (2020-04-01):
|
||||
|
@ -42,6 +42,7 @@ int show_pkg_info_from_metadir(struct xbps_handle *, const char *,
|
||||
int show_pkg_files(xbps_dictionary_t);
|
||||
int show_pkg_files_from_metadir(struct xbps_handle *, const char *);
|
||||
int repo_show_pkg_files(struct xbps_handle *, const char *);
|
||||
int cat_file(struct xbps_handle *, const char *, const char *);
|
||||
int repo_cat_file(struct xbps_handle *, const char *, const char *);
|
||||
int repo_show_pkg_info(struct xbps_handle *, const char *, const char *);
|
||||
int repo_show_pkg_namedesc(struct xbps_handle *, xbps_object_t, void *,
|
||||
|
@ -288,8 +288,10 @@ main(int argc, char **argv)
|
||||
|
||||
} else if (catfile) {
|
||||
/* repo cat file mode */
|
||||
rv = repo_cat_file(&xh, pkg, catfile);
|
||||
|
||||
if (repo_mode)
|
||||
rv = repo_cat_file(&xh, pkg, catfile);
|
||||
else
|
||||
rv = cat_file(&xh, pkg, catfile);
|
||||
} else if (show || show_prop) {
|
||||
/* show mode */
|
||||
if (repo_mode)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -3,3 +3,4 @@ syntax("kyuafile", 1)
|
||||
test_suite("xbps-query")
|
||||
atf_test_program{name="ignore_repos_test"}
|
||||
atf_test_program{name="remote_test"}
|
||||
atf_test_program{name="query_test"}
|
||||
|
@ -1,7 +1,7 @@
|
||||
TOPDIR = ../../..
|
||||
-include $(TOPDIR)/config.mk
|
||||
|
||||
TESTSHELL = ignore_repos_test remote_test
|
||||
TESTSHELL = ignore_repos_test remote_test query_test
|
||||
TESTSSUBDIR = xbps/xbps-query
|
||||
EXTRA_FILES = Kyuafile
|
||||
|
||||
|
45
tests/xbps/xbps-query/query_test.sh
Normal file
45
tests/xbps/xbps-query/query_test.sh
Normal file
@ -0,0 +1,45 @@
|
||||
#! /usr/bin/env atf-sh
|
||||
|
||||
cat_file_head() {
|
||||
atf_set "descr" "xbps-query(1) --cat: cat pkgdb file"
|
||||
}
|
||||
|
||||
cat_file_body() {
|
||||
mkdir -p repo pkg_A/bin
|
||||
echo "hello world!" > pkg_A/bin/file
|
||||
cd repo
|
||||
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
|
||||
atf_check_equal $? 0
|
||||
xbps-rindex -d -a *.xbps
|
||||
atf_check_equal $? 0
|
||||
cd ..
|
||||
mkdir root
|
||||
xbps-install -r root --repository=repo -dvy foo
|
||||
atf_check_equal $? 0
|
||||
res=$(xbps-query -r root -dv -C empty.conf --cat /bin/file foo)
|
||||
atf_check_equal $? 0
|
||||
atf_check_equal "$res" "hello world!"
|
||||
}
|
||||
|
||||
repo_cat_file_head() {
|
||||
atf_set "descr" "xbps-query(1) -R --cat: cat repo file"
|
||||
}
|
||||
|
||||
repo_cat_file_body() {
|
||||
mkdir -p repo pkg_A/bin
|
||||
echo "hello world!" > pkg_A/bin/file
|
||||
cd repo
|
||||
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
|
||||
atf_check_equal $? 0
|
||||
xbps-rindex -d -a *.xbps
|
||||
atf_check_equal $? 0
|
||||
cd ..
|
||||
res=$(xbps-query -r root -dv --repository=repo -C empty.conf --cat /bin/file foo)
|
||||
atf_check_equal $? 0
|
||||
atf_check_equal "$res" "hello world!"
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case cat_file
|
||||
atf_add_test_case repo_cat_file
|
||||
}
|
Loading…
Reference in New Issue
Block a user