xbps-dgraph: make this work again; needs more changes yet.

This commit is contained in:
Juan RP 2013-06-12 10:34:01 +02:00
parent db1efb3aa6
commit f868dd7816

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2010-2012 Juan Romero Pardines. * Copyright (c) 2010-2013 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -49,7 +49,7 @@
*/ */
static const char *optional_objs[] = { static const char *optional_objs[] = {
"conflicts", "conf_files", "replaces", "run_depends", "preserve", "conflicts", "conf_files", "replaces", "run_depends", "preserve",
"requiredby", "provides", "homepage", "license" "files", "dirs", "links", "provides", "homepage", "license"
}; };
/* /*
@ -131,6 +131,8 @@ convert_proptype_to_string(prop_object_t obj)
return "integer"; return "integer";
case PROP_TYPE_STRING: case PROP_TYPE_STRING:
return "string"; return "string";
case PROP_TYPE_DATA:
return "data";
default: default:
return NULL; return NULL;
} }
@ -252,12 +254,14 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
/* /*
* While parsing package's dictionary from pkgdb, we are * While parsing package's dictionary from pkgdb, we are
* only interested in the "automatic-install" and "requiredby" * only interested in the "automatic-install" object.
* objects.
*/ */
if (parse_pkgdb && if (parse_pkgdb &&
(strcmp(tmpkeyname, "automatic-install")) && (strcmp(tmpkeyname, "automatic-install")))
(strcmp(tmpkeyname, "requiredby"))) continue;
/* Ignore these objects */
if (strcmp(tmpkeyname, "source-revisions") == 0)
continue; continue;
keyobj = prop_dictionary_get_keysym(plistd, dksym); keyobj = prop_dictionary_get_keysym(plistd, dksym);
@ -279,8 +283,7 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
optnodetmp = optnode; optnodetmp = optnode;
/* /*
* We can assume that all arrays only contain strings, so * Process array objects.
* this can be simplified.
*/ */
prop_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop); prop_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop);
if (prop_object_type(keyobj) == PROP_TYPE_ARRAY) { if (prop_object_type(keyobj) == PROP_TYPE_ARRAY) {
@ -289,7 +292,11 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
optnodetmp); optnodetmp);
for (x = 0; x < prop_array_count(keyobj); x++) { for (x = 0; x < prop_array_count(keyobj); x++) {
/*
* Process arrays of strings.
*/
sub_keyobj = prop_array_get(keyobj, x); sub_keyobj = prop_array_get(keyobj, x);
if (prop_object_type(sub_keyobj) == PROP_TYPE_STRING) {
fprintf(f, " %s -> %s_%zu_string " fprintf(f, " %s -> %s_%zu_string "
"[label=\"string\"];\n", "[label=\"string\"];\n",
keyname, keyname, x); keyname, keyname, x);
@ -303,6 +310,7 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
"label=\"%s\"];\n", cfprop, "label=\"%s\"];\n", cfprop,
prop_string_cstring_nocopy(sub_keyobj)); prop_string_cstring_nocopy(sub_keyobj));
} }
}
if (optnode) if (optnode)
free(optnode); free(optnode);
free(keyname); free(keyname);
@ -365,10 +373,9 @@ create_dot_graph(struct xbps_handle *xhp,
{ {
prop_dictionary_t sub_confd, regpkgd = NULL; prop_dictionary_t sub_confd, regpkgd = NULL;
prop_array_t allkeys; prop_array_t allkeys;
const char *pkgver, *pkgn, *cfprop; const char *pkgver, *cfprop;
prop_dictionary_get_cstring_nocopy(plistd, "pkgver", &pkgver); prop_dictionary_get_cstring_nocopy(plistd, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(plistd, "pkgname", &pkgn);
/* /*
* Start filling the output file... * Start filling the output file...
@ -423,10 +430,10 @@ create_dot_graph(struct xbps_handle *xhp,
* list file, aka XBPS_META_PATH/XBPS_PKGDB. * list file, aka XBPS_META_PATH/XBPS_PKGDB.
*/ */
if (revdeps) { if (revdeps) {
regpkgd = xbps_pkgdb_get_pkg(xhp, pkgn); regpkgd = xbps_pkgdb_get_pkg(xhp, pkgver);
if (regpkgd == NULL) if (regpkgd == NULL)
die("cannot find '%s' dictionary on %s!", die("cannot find '%s' dictionary on %s!",
pkgn, XBPS_PKGDB); pkgver, XBPS_PKGDB);
allkeys = prop_dictionary_all_keys(regpkgd); allkeys = prop_dictionary_all_keys(regpkgd);
parse_array_in_pkg_dictionary(f, regpkgd, sub_confd, parse_array_in_pkg_dictionary(f, regpkgd, sub_confd,