New pkgdb (0.21) and repo index (1.7) format, see NEWS for info.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2009-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,9 +33,9 @@
|
||||
#endif
|
||||
|
||||
/* from show-deps.c */
|
||||
int show_pkg_deps(struct xbps_handle *, const char *);
|
||||
int show_pkg_deps(struct xbps_handle *, const char *, bool);
|
||||
int show_pkg_revdeps(struct xbps_handle *, const char *);
|
||||
int repo_show_pkg_deps(struct xbps_handle *, const char *);
|
||||
int repo_show_pkg_deps(struct xbps_handle *, const char *, bool);
|
||||
int repo_show_pkg_revdeps(struct xbps_handle *, const char *);
|
||||
|
||||
/* from show-info-files.c */
|
||||
@@ -56,8 +56,6 @@ int repo_ownedby(struct xbps_handle *, int, char **);
|
||||
|
||||
/* From list.c */
|
||||
size_t get_maxcols(void);
|
||||
int list_strings_sep_in_array(struct xbps_handle *,
|
||||
prop_object_t, void *, bool *);
|
||||
size_t find_longest_pkgver(struct xbps_handle *, prop_object_t);
|
||||
|
||||
int list_pkgs_in_dict(struct xbps_handle *, prop_object_t, void *, bool *);
|
||||
|
@@ -241,19 +241,3 @@ find_longest_pkgver(struct xbps_handle *xhp, prop_object_t o)
|
||||
|
||||
return ffl.len;
|
||||
}
|
||||
|
||||
int
|
||||
list_strings_sep_in_array(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
{
|
||||
const char *sep = arg;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
|
||||
printf("%s%s\n", sep ? sep : "", prop_string_cstring_nocopy(obj));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ usage(bool fail)
|
||||
" -s --search PATTERN(s) Search for packages matching PATTERN(s)\n"
|
||||
" -f --files Show files for PKGNAME\n"
|
||||
" -p --property PROP,... Show properties for PKGNAME\n"
|
||||
" -x --deps Show dependencies for PKGNAME\n"
|
||||
" -x --deps Show dependencies for PKGNAME (set it twice for a full dependency tree)\n"
|
||||
" -X --revdeps Show reverse dependencies for PKGNAME\n");
|
||||
|
||||
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
@@ -90,16 +90,16 @@ main(int argc, char **argv)
|
||||
};
|
||||
struct xbps_handle xh;
|
||||
const char *rootdir, *cachedir, *conffile, *props, *defrepo;
|
||||
int c, flags, rv;
|
||||
int c, flags, rv, show_deps = 0;
|
||||
bool list_pkgs, list_repos, orphans, own;
|
||||
bool list_manual, show_prop, show_files, show_deps, show_rdeps;
|
||||
bool show, search, repo_mode, opmode;
|
||||
bool list_manual, show_prop, show_files, show_rdeps;
|
||||
bool show, search, repo_mode, opmode, fulldeptree;
|
||||
|
||||
rootdir = cachedir = conffile = defrepo = props = NULL;
|
||||
flags = rv = c = 0;
|
||||
list_pkgs = list_repos = orphans = search = own = false;
|
||||
list_manual = show_prop = show_files = false;
|
||||
show = show_deps = show_rdeps = false;
|
||||
show = show_rdeps = fulldeptree = false;
|
||||
repo_mode = opmode = false;
|
||||
|
||||
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
|
||||
@@ -157,7 +157,8 @@ main(int argc, char **argv)
|
||||
printf("%s\n", XBPS_RELVER);
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'x':
|
||||
show_deps = opmode = true;
|
||||
show_deps++;
|
||||
opmode = true;
|
||||
break;
|
||||
case 'X':
|
||||
show_rdeps = opmode = true;
|
||||
@@ -234,10 +235,13 @@ main(int argc, char **argv)
|
||||
|
||||
} else if (show_deps) {
|
||||
/* show-deps mode */
|
||||
if (show_deps > 1)
|
||||
fulldeptree = true;
|
||||
|
||||
if (repo_mode)
|
||||
rv = repo_show_pkg_deps(&xh, argv[optind]);
|
||||
rv = repo_show_pkg_deps(&xh, argv[optind], fulldeptree);
|
||||
else
|
||||
rv = show_pkg_deps(&xh, argv[optind]);
|
||||
rv = show_pkg_deps(&xh, argv[optind], fulldeptree);
|
||||
|
||||
} else if (show_rdeps) {
|
||||
/* show-rdeps mode */
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2009-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,22 +33,64 @@
|
||||
#include <xbps_api.h>
|
||||
#include "defs.h"
|
||||
|
||||
int
|
||||
show_pkg_deps(struct xbps_handle *xhp, const char *pkgname)
|
||||
static void
|
||||
print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps,
|
||||
bool full, bool repo, bool origin, int *indent)
|
||||
{
|
||||
prop_dictionary_t propsd;
|
||||
int rv = 0;
|
||||
prop_array_t currdeps;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *pkgdep;
|
||||
size_t i;
|
||||
int j;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
if (!origin)
|
||||
(*indent)++;
|
||||
|
||||
propsd = xbps_pkgdb_get_pkg_metadata(xhp, pkgname);
|
||||
if (propsd == NULL)
|
||||
for (i = 0; i < prop_array_count(rdeps); i++) {
|
||||
prop_array_get_cstring_nocopy(rdeps, i, &pkgdep);
|
||||
if (!origin || !full)
|
||||
for (j = 0; j < *indent; j++)
|
||||
putchar(' ');
|
||||
|
||||
printf("%s\n", pkgdep);
|
||||
if (!full)
|
||||
continue;
|
||||
|
||||
if (repo) {
|
||||
pkgd = xbps_rpool_get_pkg(xhp, pkgdep);
|
||||
if (pkgd == NULL)
|
||||
pkgd = xbps_rpool_get_virtualpkg(xhp, pkgdep);
|
||||
} else {
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkgdep);
|
||||
if (pkgd == NULL)
|
||||
pkgd = xbps_pkgdb_get_virtualpkg(xhp, pkgdep);
|
||||
}
|
||||
if (pkgd != NULL) {
|
||||
currdeps = prop_dictionary_get(pkgd, "run_depends");
|
||||
if (currdeps != NULL)
|
||||
print_rdeps(xhp, currdeps,
|
||||
full, repo, false, indent);
|
||||
}
|
||||
}
|
||||
(*indent)--;
|
||||
}
|
||||
|
||||
int
|
||||
show_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool full)
|
||||
{
|
||||
prop_array_t rdeps;
|
||||
prop_dictionary_t pkgd;
|
||||
int indent = 0;
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
|
||||
if (pkgd == NULL)
|
||||
return ENOENT;
|
||||
|
||||
rv = xbps_callback_array_iter_in_dict(xhp, propsd, "run_depends",
|
||||
list_strings_sep_in_array, NULL);
|
||||
rdeps = prop_dictionary_get(pkgd, "run_depends");
|
||||
if (rdeps != NULL)
|
||||
print_rdeps(xhp, rdeps, full, false, true, &indent);
|
||||
|
||||
return rv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -58,8 +100,7 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
|
||||
const char *pkgdep;
|
||||
size_t i;
|
||||
|
||||
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkg);
|
||||
if (reqby) {
|
||||
if ((reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkg)) != NULL) {
|
||||
for (i = 0; i < prop_array_count(reqby); i++) {
|
||||
prop_array_get_cstring_nocopy(reqby, i, &pkgdep);
|
||||
printf("%s\n", pkgdep);
|
||||
@@ -69,16 +110,19 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
|
||||
}
|
||||
|
||||
int
|
||||
repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern)
|
||||
repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern, bool full)
|
||||
{
|
||||
prop_array_t rdeps;
|
||||
prop_dictionary_t pkgd;
|
||||
int indent = 0;
|
||||
|
||||
if (((pkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) &&
|
||||
((pkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL))
|
||||
return errno;
|
||||
|
||||
(void)xbps_callback_array_iter_in_dict(xhp, pkgd,
|
||||
"run_depends", list_strings_sep_in_array, NULL);
|
||||
rdeps = prop_dictionary_get(pkgd, "run_depends");
|
||||
if (rdeps != NULL)
|
||||
print_rdeps(xhp, rdeps, full, true, true, &indent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -295,8 +295,7 @@ repo_show_pkg_info(struct xbps_handle *xhp,
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
if (((pkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) &&
|
||||
((pkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL))
|
||||
if ((pkgd = xbps_rpool_get_pkg_plist(xhp, pattern, "./props.plist")) == NULL)
|
||||
return errno;
|
||||
|
||||
if (option)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
.Dd February 20, 2013
|
||||
.Dd March 4, 2013
|
||||
.Os Void Linux
|
||||
.Dt xbps-query 8
|
||||
.Sh NAME
|
||||
@@ -139,6 +139,7 @@ Multiple properties can be specified by delimiting them with commas.
|
||||
.It Fl x, Fl -deps Ar PKG
|
||||
Show the required dependencies for
|
||||
.Ar PKG .
|
||||
Only direct dependencies are shown. To see a full dependency tree set it twice.
|
||||
.It Fl X, Fl -revdeps Ar PKG
|
||||
Show the reverse dependencies for
|
||||
.Ar PKG .
|
||||
@@ -152,13 +153,13 @@ architecture.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /var/db/xbps/.<pkgname>.plist
|
||||
.It Ar /etc/xbps/xbps.conf
|
||||
Default XBPS configuration file.
|
||||
Default configuration file.
|
||||
.It Ar /var/db/xbps/.<pkgname>.plist
|
||||
Package metadata properties.
|
||||
.It Ar /var/db/xbps/pkgdb.plist
|
||||
XBPS package database.
|
||||
.It Ar /var/db/xbps/pkgdb-0.21.plist
|
||||
Default package database (0.21 format). Keeps track of installed packages and properties.
|
||||
.It Ar /var/cache/xbps
|
||||
Default XBPS cache directory.
|
||||
Default cache directory to store downloaded binary packages.
|
||||
.Sh SEE ALSO
|
||||
.Xr xbps-create 8 ,
|
||||
.Xr xbps-dgraph 8 ,
|
||||
|
Reference in New Issue
Block a user