xbps-{bin,repo}: new -o flag for the 'show' target, to print specific objs value.
This commit is contained in:
13
NEWS
13
NEWS
@ -1,4 +1,15 @@
|
|||||||
xbps-0.10.2 (???):
|
xbps-0.11.0 (???):
|
||||||
|
|
||||||
|
* xbps-bin(8)/xbps-repo(8): new flag '-o' (option). This can be used
|
||||||
|
in the 'show' target to print only a set of objects stored in package's
|
||||||
|
properties dictionary, example:
|
||||||
|
|
||||||
|
$ xbps-bin -olicense show xbps
|
||||||
|
Simplified BSD
|
||||||
|
$ xbps-bin -oversion,build_date show xbps
|
||||||
|
0.10.1
|
||||||
|
Wednesday 26 October, 2011, 14:37:31 UTC
|
||||||
|
$
|
||||||
|
|
||||||
* libxbpps: when fetching new pkg-index.plist from a repository,
|
* libxbpps: when fetching new pkg-index.plist from a repository,
|
||||||
make sure that it's a plist file and can be internalized; otherwise
|
make sure that it's a plist file and can be internalized; otherwise
|
||||||
|
@ -66,7 +66,7 @@ int show_pkg_deps(const char *);
|
|||||||
int show_pkg_reverse_deps(const char *);
|
int show_pkg_reverse_deps(const char *);
|
||||||
|
|
||||||
/* from show-info-files.c */
|
/* from show-info-files.c */
|
||||||
int show_pkg_info_from_metadir(const char *);
|
int show_pkg_info_from_metadir(const char *, const char *);
|
||||||
int show_pkg_files_from_metadir(const char *);
|
int show_pkg_files_from_metadir(const char *);
|
||||||
|
|
||||||
/* from find-files.c */
|
/* from find-files.c */
|
||||||
@ -86,6 +86,7 @@ void transaction_err_cb(struct xbps_transaction_cb_data *);
|
|||||||
/* From util.c */
|
/* From util.c */
|
||||||
int show_pkg_files(prop_dictionary_t);
|
int show_pkg_files(prop_dictionary_t);
|
||||||
void show_pkg_info(prop_dictionary_t);
|
void show_pkg_info(prop_dictionary_t);
|
||||||
|
void show_pkg_info_one(prop_dictionary_t, const char *);
|
||||||
int show_pkg_namedesc(prop_object_t, void *, bool *);
|
int show_pkg_namedesc(prop_object_t, void *, bool *);
|
||||||
int list_strings_in_array(prop_object_t, void *, bool *);
|
int list_strings_in_array(prop_object_t, void *, bool *);
|
||||||
int list_strings_sep_in_array(prop_object_t, void *, bool *);
|
int list_strings_sep_in_array(prop_object_t, void *, bool *);
|
||||||
|
@ -185,17 +185,17 @@ main(int argc, char **argv)
|
|||||||
struct xferstat xfer;
|
struct xferstat xfer;
|
||||||
struct list_pkgver_cb lpc;
|
struct list_pkgver_cb lpc;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
const char *rootdir, *cachedir, *confdir;
|
const char *rootdir, *cachedir, *confdir, *option;
|
||||||
int i , c, flags, rv;
|
int i , c, flags, rv;
|
||||||
bool yes, purge, debug, force_rm_with_deps, recursive_rm;
|
bool yes, purge, debug, force_rm_with_deps, recursive_rm;
|
||||||
bool install_auto, install_manual, show_download_pkglist_url;
|
bool install_auto, install_manual, show_download_pkglist_url;
|
||||||
|
|
||||||
rootdir = cachedir = confdir = NULL;
|
rootdir = cachedir = confdir = option = NULL;
|
||||||
flags = rv = 0;
|
flags = rv = 0;
|
||||||
yes = purge = force_rm_with_deps = recursive_rm = debug = false;
|
yes = purge = force_rm_with_deps = recursive_rm = debug = false;
|
||||||
install_auto = install_manual = show_download_pkglist_url = false;
|
install_auto = install_manual = show_download_pkglist_url = false;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "AC:c:dDFfMpRr:Vvy")) != -1) {
|
while ((c = getopt(argc, argv, "AC:c:dDFfMo:pRr:Vvy")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'A':
|
case 'A':
|
||||||
install_auto = true;
|
install_auto = true;
|
||||||
@ -221,6 +221,9 @@ main(int argc, char **argv)
|
|||||||
case 'M':
|
case 'M':
|
||||||
install_manual = true;
|
install_manual = true;
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
option = optarg;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
purge = true;
|
purge = true;
|
||||||
break;
|
break;
|
||||||
@ -375,7 +378,7 @@ main(int argc, char **argv)
|
|||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
usage(xhp);
|
usage(xhp);
|
||||||
|
|
||||||
rv = show_pkg_info_from_metadir(argv[1]);
|
rv = show_pkg_info_from_metadir(argv[1], option);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
printf("Package %s not installed.\n", argv[1]);
|
printf("Package %s not installed.\n", argv[1]);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
show_pkg_info_from_metadir(const char *pkgname)
|
show_pkg_info_from_metadir(const char *pkgname, const char *option)
|
||||||
{
|
{
|
||||||
prop_dictionary_t d;
|
prop_dictionary_t d;
|
||||||
|
|
||||||
@ -43,7 +43,11 @@ show_pkg_info_from_metadir(const char *pkgname)
|
|||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
|
if (option == NULL)
|
||||||
show_pkg_info(d);
|
show_pkg_info(d);
|
||||||
|
else
|
||||||
|
show_pkg_info_one(d, option);
|
||||||
|
|
||||||
prop_object_release(d);
|
prop_object_release(d);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,86 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "../xbps-repo/defs.h"
|
#include "../xbps-repo/defs.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_value_obj(const char *keyname, prop_object_t obj, bool raw)
|
||||||
|
{
|
||||||
|
const char *value;
|
||||||
|
size_t i;
|
||||||
|
char size[8];
|
||||||
|
|
||||||
|
switch (prop_object_type(obj)) {
|
||||||
|
case PROP_TYPE_STRING:
|
||||||
|
if (!raw)
|
||||||
|
printf("%s: ", keyname);
|
||||||
|
printf("%s\n", prop_string_cstring_nocopy(obj));
|
||||||
|
break;
|
||||||
|
case PROP_TYPE_NUMBER:
|
||||||
|
if (!raw)
|
||||||
|
printf("%s: ", keyname);
|
||||||
|
if (xbps_humanize_number(size,
|
||||||
|
(int64_t)prop_number_unsigned_integer_value(obj)) == -1)
|
||||||
|
printf("%ju\n",
|
||||||
|
prop_number_unsigned_integer_value(obj));
|
||||||
|
else
|
||||||
|
printf("%s\n", size);
|
||||||
|
break;
|
||||||
|
case PROP_TYPE_BOOL:
|
||||||
|
if (!raw)
|
||||||
|
printf("%s: ", keyname);
|
||||||
|
printf("%s\n", prop_bool_true(obj) ? "yes" : "no");
|
||||||
|
break;
|
||||||
|
case PROP_TYPE_ARRAY:
|
||||||
|
if (!raw)
|
||||||
|
printf("%s:\n", keyname);
|
||||||
|
for (i = 0; i < prop_array_count(obj); i++) {
|
||||||
|
prop_array_get_cstring_nocopy(obj, i, &value);
|
||||||
|
printf("%s%s%s", !raw ? "\t" : "", value,
|
||||||
|
!raw ? "\n" : " ");
|
||||||
|
}
|
||||||
|
if (raw)
|
||||||
|
printf("\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
xbps_warn_printf("unknown obj type (key %s)\n",
|
||||||
|
keyname);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
show_pkg_info_one(prop_dictionary_t d, const char *keys)
|
||||||
|
{
|
||||||
|
prop_object_t obj;
|
||||||
|
char *key, *p, *saveptr;
|
||||||
|
|
||||||
|
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY);
|
||||||
|
assert(keys != NULL);
|
||||||
|
|
||||||
|
if (strchr(keys, ',') == NULL) {
|
||||||
|
obj = prop_dictionary_get(d, keys);
|
||||||
|
if (obj == NULL)
|
||||||
|
return;
|
||||||
|
print_value_obj(keys, obj, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
key = strdup(keys);
|
||||||
|
assert(key != NULL);
|
||||||
|
for ((p = strtok_r(key, ",", &saveptr)); p;
|
||||||
|
(p = strtok_r(NULL, ",", &saveptr))) {
|
||||||
|
obj = prop_dictionary_get(d, p);
|
||||||
|
if (obj == NULL)
|
||||||
|
continue;
|
||||||
|
print_value_obj(p, obj, true);
|
||||||
|
}
|
||||||
|
free(key);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
show_pkg_info(prop_dictionary_t dict)
|
show_pkg_info(prop_dictionary_t dict)
|
||||||
{
|
{
|
||||||
prop_array_t all_keys;
|
prop_array_t all_keys;
|
||||||
prop_object_t obj, keysym;
|
prop_object_t obj, keysym;
|
||||||
const char *keyname;
|
const char *keyname;
|
||||||
char size[8];
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
|
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
|
||||||
@ -57,38 +130,11 @@ show_pkg_info(prop_dictionary_t dict)
|
|||||||
keysym = prop_array_get(all_keys, i);
|
keysym = prop_array_get(all_keys, i);
|
||||||
keyname = prop_dictionary_keysym_cstring_nocopy(keysym);
|
keyname = prop_dictionary_keysym_cstring_nocopy(keysym);
|
||||||
obj = prop_dictionary_get_keysym(dict, keysym);
|
obj = prop_dictionary_get_keysym(dict, keysym);
|
||||||
|
|
||||||
switch (prop_object_type(obj)) {
|
|
||||||
case PROP_TYPE_STRING:
|
|
||||||
printf("%s: %s\n", keyname,
|
|
||||||
prop_string_cstring_nocopy(obj));
|
|
||||||
break;
|
|
||||||
case PROP_TYPE_NUMBER:
|
|
||||||
printf("%s: ", keyname);
|
|
||||||
if (xbps_humanize_number(size,
|
|
||||||
(int64_t)prop_number_unsigned_integer_value(obj)) == -1)
|
|
||||||
printf("%ju\n",
|
|
||||||
prop_number_unsigned_integer_value(obj));
|
|
||||||
else
|
|
||||||
printf("%s\n", size);
|
|
||||||
break;
|
|
||||||
case PROP_TYPE_BOOL:
|
|
||||||
printf("%s: %s\n", keyname,
|
|
||||||
prop_bool_true(obj) ? "yes" : "no");
|
|
||||||
break;
|
|
||||||
case PROP_TYPE_ARRAY:
|
|
||||||
/* ignore run_depends, it's shown via 'show-deps' */
|
/* ignore run_depends, it's shown via 'show-deps' */
|
||||||
if (strcmp(keyname, "run_depends") == 0)
|
if (strcmp(keyname, "run_depends") == 0)
|
||||||
break;
|
break;
|
||||||
printf("%s:\n", keyname);
|
|
||||||
(void)xbps_callback_array_iter_in_dict(dict, keyname,
|
print_value_obj(keyname, obj, false);
|
||||||
list_strings_sep_in_array, __UNCONST("\t"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
xbps_warn_printf("unknown obj type (key %s)\n",
|
|
||||||
keyname);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.TH "XBPS\-BIN" "8" "17/10/2011" "\ \&" "\ \&"
|
.TH "XBPS\-BIN" "8" "29/10/2011" "\ \&" "\ \&"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * set default formatting
|
.\" * set default formatting
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
@ -88,6 +88,14 @@ option takes effect in the \fIautoupdate\fR, \fIinstall\fR and \fIupdate\fR targ
|
|||||||
and target packages and its required dependencies will be matched.
|
and target packages and its required dependencies will be matched.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
|
\fB-o\fR \fIkey[,key2...]\fR
|
||||||
|
.RS 4
|
||||||
|
Used currently in the
|
||||||
|
\fIshow\fR
|
||||||
|
target\&. Prints the value of specified key(s) from package's properties dictionary.
|
||||||
|
Multiple keys can be specified delimited by the comma character.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
\fB\-p\fR
|
\fB\-p\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
Used currently in the
|
Used currently in the
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
int repo_genindex(const char *);
|
int repo_genindex(const char *);
|
||||||
|
|
||||||
/* From repository.c */
|
/* From repository.c */
|
||||||
int show_pkg_info_from_repolist(const char *);
|
int show_pkg_info_from_repolist(const char *, const char *);
|
||||||
int show_pkg_deps_from_repolist(const char *);
|
int show_pkg_deps_from_repolist(const char *);
|
||||||
int repository_sync(void);
|
int repository_sync(void);
|
||||||
|
|
||||||
|
@ -90,13 +90,13 @@ main(int argc, char **argv)
|
|||||||
struct xbps_handle *xhp;
|
struct xbps_handle *xhp;
|
||||||
struct xferstat xfer;
|
struct xferstat xfer;
|
||||||
prop_dictionary_t pkgd;
|
prop_dictionary_t pkgd;
|
||||||
const char *rootdir, *cachedir, *confdir;
|
const char *rootdir, *cachedir, *confdir, *option;
|
||||||
int c, rv = 0;
|
int c, rv = 0;
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
|
|
||||||
rootdir = cachedir = confdir = NULL;
|
rootdir = cachedir = confdir = option = NULL;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "C:c:dr:V")) != -1) {
|
while ((c = getopt(argc, argv, "C:c:do:r:V")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'C':
|
case 'C':
|
||||||
confdir = optarg;
|
confdir = optarg;
|
||||||
@ -107,6 +107,9 @@ main(int argc, char **argv)
|
|||||||
case 'd':
|
case 'd':
|
||||||
debug = true;
|
debug = true;
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
option = optarg;
|
||||||
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
/* To specify the root directory */
|
/* To specify the root directory */
|
||||||
rootdir = optarg;
|
rootdir = optarg;
|
||||||
@ -186,7 +189,7 @@ main(int argc, char **argv)
|
|||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
usage(xhp);
|
usage(xhp);
|
||||||
|
|
||||||
rv = show_pkg_info_from_repolist(argv[1]);
|
rv = show_pkg_info_from_repolist(argv[1], option);
|
||||||
if (rv == ENOENT) {
|
if (rv == ENOENT) {
|
||||||
xbps_printf("Unable to locate package "
|
xbps_printf("Unable to locate package "
|
||||||
"`%s' in repository pool.\n", argv[1]);
|
"`%s' in repository pool.\n", argv[1]);
|
||||||
|
@ -100,7 +100,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
show_pkg_info_from_repolist(const char *pkgname)
|
show_pkg_info_from_repolist(const char *pkgname, const char *option)
|
||||||
{
|
{
|
||||||
prop_dictionary_t pkgd;
|
prop_dictionary_t pkgd;
|
||||||
|
|
||||||
@ -111,7 +111,11 @@ show_pkg_info_from_repolist(const char *pkgname)
|
|||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (option)
|
||||||
|
show_pkg_info_one(pkgd, option);
|
||||||
|
else
|
||||||
show_pkg_info(pkgd);
|
show_pkg_info(pkgd);
|
||||||
|
|
||||||
prop_object_release(pkgd);
|
prop_object_release(pkgd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.TH "XBPS\-REPO" "8" "17/10/2011" "\ \&" "\ \&"
|
.TH "XBPS\-REPO" "8" "28/10/2011" "\ \&" "\ \&"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * set default formatting
|
.\" * set default formatting
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
@ -38,6 +38,14 @@ directory to store downloaded binary packages from remote repositories\&. By def
|
|||||||
Enables extra debugging output to be shown to stderr.
|
Enables extra debugging output to be shown to stderr.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
|
\fB-o\fR \fIkey[,key2...]\fR
|
||||||
|
.RS 4
|
||||||
|
Used currently in the
|
||||||
|
\fIshow\fR
|
||||||
|
target\&. Prints the value of specified key(s) from package's properties dictionary.
|
||||||
|
Multiple keys can be specified delimited by the comma character.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
\fB\-r\fR \fIrootdir\fR
|
\fB\-r\fR \fIrootdir\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
Sets the
|
Sets the
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
#define XBPS_PKGINDEX_VERSION "1.2"
|
#define XBPS_PKGINDEX_VERSION "1.2"
|
||||||
|
|
||||||
#define XBPS_API_VERSION "20111027-1"
|
#define XBPS_API_VERSION "20111027-1"
|
||||||
#define XBPS_VERSION "0.10.2"
|
#define XBPS_VERSION "0.11.0"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def XBPS_RELVER
|
* @def XBPS_RELVER
|
||||||
|
Reference in New Issue
Block a user