Better metadata printing for the 'show' target.
All objects are sorted to be comparable to 'apt-cache show' output, like: $ ./xbps-bin show openssl Repository: /storage/xbps/binpkgs Package: openssl Installed size: 10265289 bytes Maintainer: Juan RP [xtraeme@gmail.com] Architecture: x86_64 Version: 0.9.8i Filename: openssl-0.9.8i.x86_64.xbps SHA256: 33204337e944bdcca285af5540cee39e60cdcbc4bc99cb5da32040793844eab5 Dependencies: glibc-2.8 zlib-1.2.3 Configuration files: /etc/ssl/openssl.cnf Permanent directories: /etc/ssl Description: Secure Socket Layer and cryptographic library The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a full-strength general purpose cryptography library. $ --HG-- extra : convert_revision : 77e59abbd586e495288c3e0805d7865269846bd8
This commit is contained in:
parent
017b192a85
commit
d534631f62
@ -321,53 +321,74 @@ xbps_unregister_repository(const char *uri)
|
|||||||
void
|
void
|
||||||
xbps_show_pkg_info(prop_dictionary_t dict)
|
xbps_show_pkg_info(prop_dictionary_t dict)
|
||||||
{
|
{
|
||||||
prop_object_iterator_t iter;
|
prop_object_t obj;
|
||||||
prop_object_t obj, obj2;
|
|
||||||
const char *sep = NULL;
|
const char *sep = NULL;
|
||||||
bool rundeps = false;
|
|
||||||
|
|
||||||
assert(dict != NULL);
|
assert(dict != NULL);
|
||||||
if (prop_dictionary_count(dict) == 0)
|
if (prop_dictionary_count(dict) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
iter = prop_dictionary_iterator(dict);
|
obj = prop_dictionary_get(dict, "pkgname");
|
||||||
if (iter == NULL)
|
if (obj && prop_object_type(obj) == PROP_TYPE_STRING)
|
||||||
return;
|
printf("Package: %s\n", prop_string_cstring_nocopy(obj));
|
||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter))) {
|
obj = prop_dictionary_get(dict, "installed_size");
|
||||||
/* Print the key */
|
if (obj && prop_object_type(obj) == PROP_TYPE_NUMBER)
|
||||||
printf("%s: ", prop_dictionary_keysym_cstring_nocopy(obj));
|
printf("Installed size: %zu bytes\n",
|
||||||
/* Get the obj for current keysym */
|
prop_number_unsigned_integer_value(obj));
|
||||||
obj2 = prop_dictionary_get_keysym(dict, obj);
|
|
||||||
|
|
||||||
if (prop_object_type(obj2) == PROP_TYPE_STRING) {
|
obj = prop_dictionary_get(dict, "maintainer");
|
||||||
printf("%s\n", prop_string_cstring_nocopy(obj2));
|
if (obj && prop_object_type(obj) == PROP_TYPE_STRING)
|
||||||
|
printf("Maintainer: %s\n", prop_string_cstring_nocopy(obj));
|
||||||
|
|
||||||
} else if (prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
obj = prop_dictionary_get(dict, "architecture");
|
||||||
printf("%zu\n",
|
if (obj && prop_object_type(obj) == PROP_TYPE_STRING)
|
||||||
prop_number_unsigned_integer_value(obj2));
|
printf("Architecture: %s\n", prop_string_cstring_nocopy(obj));
|
||||||
|
|
||||||
} else if (prop_object_type(obj2) == PROP_TYPE_ARRAY) {
|
obj = prop_dictionary_get(dict, "version");
|
||||||
/*
|
if (obj && prop_object_type(obj) == PROP_TYPE_STRING)
|
||||||
* Apply some indentation for array objs other than
|
printf("Version: %s\n", prop_string_cstring_nocopy(obj));
|
||||||
* "run_depends".
|
|
||||||
*/
|
obj = prop_dictionary_get(dict, "filename");
|
||||||
if (strcmp(prop_dictionary_keysym_cstring_nocopy(obj),
|
if (obj && prop_object_type(obj) == PROP_TYPE_STRING)
|
||||||
"run_depends") == 0) {
|
printf("Filename: %s\n", prop_string_cstring_nocopy(obj));
|
||||||
rundeps = true;
|
|
||||||
sep = " ";
|
obj = prop_dictionary_get(dict, "filename-sha256");
|
||||||
}
|
if (obj && prop_object_type(obj) == PROP_TYPE_STRING)
|
||||||
printf("\n\t");
|
printf("SHA256: %s\n", prop_string_cstring_nocopy(obj));
|
||||||
xbps_callback_array_iter_in_dict(dict,
|
|
||||||
prop_dictionary_keysym_cstring_nocopy(obj),
|
obj = prop_dictionary_get(dict, "run_depends");
|
||||||
xbps_list_strings_in_array2, (void *)sep);
|
if (obj && prop_object_type(obj) == PROP_TYPE_ARRAY) {
|
||||||
printf("\n");
|
printf("Dependencies:\n\t");
|
||||||
if (rundeps)
|
sep = " ";
|
||||||
printf("\n");
|
xbps_callback_array_iter_in_dict(dict, "run_depends",
|
||||||
}
|
xbps_list_strings_in_array2, (void *)sep);
|
||||||
|
printf("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_object_iterator_release(iter);
|
obj = prop_dictionary_get(dict, "conf_files");
|
||||||
|
if (obj && prop_object_type(obj) == PROP_TYPE_ARRAY) {
|
||||||
|
printf("Configuration files:\n\t");
|
||||||
|
xbps_callback_array_iter_in_dict(dict, "conf_files",
|
||||||
|
xbps_list_strings_in_array2, NULL);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = prop_dictionary_get(dict, "keep_dirs");
|
||||||
|
if (obj && prop_object_type(obj) == PROP_TYPE_ARRAY) {
|
||||||
|
printf("Permanent directories:\n\t");
|
||||||
|
xbps_callback_array_iter_in_dict(dict, "keep_dirs",
|
||||||
|
xbps_list_strings_in_array2, NULL);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = prop_dictionary_get(dict, "short_desc");
|
||||||
|
if (obj && prop_object_type(obj) == PROP_TYPE_STRING)
|
||||||
|
printf("Description: %s", prop_string_cstring_nocopy(obj));
|
||||||
|
|
||||||
|
obj = prop_dictionary_get(dict, "long_desc");
|
||||||
|
if (obj && prop_object_type(obj) == PROP_TYPE_STRING)
|
||||||
|
printf(" %s\n", prop_string_cstring_nocopy(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Loading…
x
Reference in New Issue
Block a user