Get rid of libfetch and proplib external dependencies.

The list of required external deps is now confuse, libarchive and openssl.

libxbps now includes a wrapper for proplib prefixed with xbps_ rather than prop_.
This commit is contained in:
Juan RP
2013-06-20 10:26:12 +02:00
parent 31efece727
commit 42c0766c00
67 changed files with 3004 additions and 1487 deletions

View File

@@ -59,7 +59,7 @@ static TAILQ_HEAD(xentry_head, xentry) xentry_list =
TAILQ_HEAD_INITIALIZER(xentry_list);
static uint64_t instsize;
static prop_dictionary_t pkg_propsd, pkg_filesd;
static xbps_dictionary_t pkg_propsd, pkg_filesd;
static const char *destdir;
static void __attribute__((noreturn))
@@ -122,7 +122,7 @@ die(const char *fmt, ...)
static void
process_array(const char *key, const char *val)
{
prop_array_t array;
xbps_array_t array;
char *args, *p = NULL, *saveptr;
assert(key);
@@ -130,11 +130,11 @@ process_array(const char *key, const char *val)
if (val == NULL)
return;
array = prop_array_create();
array = xbps_array_create();
assert(array);
if (strchr(val, ' ') == NULL) {
prop_array_add_cstring_nocopy(array, val);
xbps_array_add_cstring_nocopy(array, val);
goto out;
}
@@ -145,29 +145,29 @@ process_array(const char *key, const char *val)
(p = strtok_r(NULL, " ", &saveptr))) {
if (p == NULL)
continue;
prop_array_add_cstring(array, p);
xbps_array_add_cstring(array, p);
}
free(args);
out:
prop_dictionary_set(pkg_propsd, key, array);
prop_object_release(array);
xbps_dictionary_set(pkg_propsd, key, array);
xbps_object_release(array);
}
static bool
entry_is_conf_file(const char *file)
{
prop_array_t a;
xbps_array_t a;
const char *curfile;
unsigned int i;
assert(file);
a = prop_dictionary_get(pkg_propsd, "conf_files");
if (a == NULL || prop_array_count(a) == 0)
a = xbps_dictionary_get(pkg_propsd, "conf_files");
if (a == NULL || xbps_array_count(a) == 0)
return false;
for (i = 0; i < prop_array_count(a); i++) {
prop_array_get_cstring_nocopy(a, i, &curfile);
for (i = 0; i < xbps_array_count(a); i++) {
xbps_array_get_cstring_nocopy(a, i, &curfile);
if (strcmp(file, curfile) == 0)
return true;
}
@@ -292,13 +292,13 @@ out:
static void
process_xentry(const char *key, const char *mutable_files)
{
prop_array_t a;
prop_dictionary_t d;
xbps_array_t a;
xbps_dictionary_t d;
struct xentry *xe;
char *p, *saveptr, *args, *tok;
bool found = false, mutable_found = false;
a = prop_array_create();
a = xbps_array_create();
assert(a);
TAILQ_FOREACH_REVERSE(xe, &xentry_list, xentry_head, entries) {
@@ -306,7 +306,7 @@ process_xentry(const char *key, const char *mutable_files)
continue;
found = true;
d = prop_dictionary_create();
d = xbps_dictionary_create();
assert(d);
/* sanitize file path */
p = strchr(xe->file, '.') + 1;
@@ -316,7 +316,7 @@ process_xentry(const char *key, const char *mutable_files)
if (mutable_files) {
if ((strchr(mutable_files, ' ') == NULL) &&
(strcmp(mutable_files, p) == 0))
prop_dictionary_set_bool(d, "mutable", true);
xbps_dictionary_set_bool(d, "mutable", true);
else {
args = strdup(mutable_files);
assert(args);
@@ -329,24 +329,24 @@ process_xentry(const char *key, const char *mutable_files)
}
free(args);
if (mutable_found) {
prop_dictionary_set_bool(d, "mutable",
xbps_dictionary_set_bool(d, "mutable",
true);
mutable_found = false;
}
}
}
prop_dictionary_set_cstring(d, "file", p);
xbps_dictionary_set_cstring(d, "file", p);
if (xe->target)
prop_dictionary_set_cstring(d, "target", xe->target);
xbps_dictionary_set_cstring(d, "target", xe->target);
else if (xe->hash)
prop_dictionary_set_cstring(d, "sha256", xe->hash);
prop_array_add(a, d);
prop_object_release(d);
xbps_dictionary_set_cstring(d, "sha256", xe->hash);
xbps_array_add(a, d);
xbps_object_release(d);
}
if (found)
prop_dictionary_set(pkg_filesd, key, a);
xbps_dictionary_set(pkg_filesd, key, a);
prop_object_release(a);
xbps_object_release(a);
}
static void
@@ -485,17 +485,17 @@ process_archive(struct archive *ar,
/*
* Add the installed-size object.
*/
prop_dictionary_set_uint64(pkg_propsd, "installed_size", instsize);
xbps_dictionary_set_uint64(pkg_propsd, "installed_size", instsize);
/* Add props.plist metadata file */
xml = prop_dictionary_externalize(pkg_propsd);
xml = xbps_dictionary_externalize(pkg_propsd);
assert(xml);
xbps_archive_append_buf(ar, xml, strlen(xml), "./props.plist",
0644, "root", "root");
free(xml);
/* Add files.plist metadata file */
xml = prop_dictionary_externalize(pkg_filesd);
xml = xbps_dictionary_externalize(pkg_filesd);
assert(xml);
xbps_archive_append_buf(ar, xml, strlen(xml), "./files.plist",
0644, "root", "root");
@@ -530,7 +530,7 @@ set_build_date(void)
if (strftime(outstr, sizeof(outstr)-1, "%F %R %Z", tmp) == 0)
die("failed to set build-date object (strftime):");
if (!prop_dictionary_set_cstring(pkg_propsd, "build-date", outstr))
if (!xbps_dictionary_set_cstring(pkg_propsd, "build-date", outstr))
die("failed to add build-date object:");
}
@@ -687,40 +687,40 @@ main(int argc, char **argv)
/*
* Process XBPS_PKGPROPS metadata file.
*/
pkg_propsd = prop_dictionary_create();
pkg_propsd = xbps_dictionary_create();
assert(pkg_propsd);
/* Required properties */
prop_dictionary_set_cstring_nocopy(pkg_propsd, "architecture", arch);
prop_dictionary_set_cstring_nocopy(pkg_propsd, "pkgname", pkgname);
prop_dictionary_set_cstring_nocopy(pkg_propsd, "version", version);
prop_dictionary_set_cstring_nocopy(pkg_propsd, "pkgver", pkgver);
prop_dictionary_set_cstring_nocopy(pkg_propsd, "short_desc", desc);
xbps_dictionary_set_cstring_nocopy(pkg_propsd, "architecture", arch);
xbps_dictionary_set_cstring_nocopy(pkg_propsd, "pkgname", pkgname);
xbps_dictionary_set_cstring_nocopy(pkg_propsd, "version", version);
xbps_dictionary_set_cstring_nocopy(pkg_propsd, "pkgver", pkgver);
xbps_dictionary_set_cstring_nocopy(pkg_propsd, "short_desc", desc);
set_build_date();
/* Optional properties */
if (homepage)
prop_dictionary_set_cstring_nocopy(pkg_propsd,
xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"homepage", homepage);
if (license)
prop_dictionary_set_cstring_nocopy(pkg_propsd,
xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"license", license);
if (maint)
prop_dictionary_set_cstring_nocopy(pkg_propsd,
xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"maintainer", maint);
if (ldesc)
prop_dictionary_set_cstring_nocopy(pkg_propsd,
xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"long_desc", ldesc);
if (bwith)
prop_dictionary_set_cstring_nocopy(pkg_propsd,
xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"packaged-with", bwith);
if (srcrevs)
prop_dictionary_set_cstring_nocopy(pkg_propsd,
xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"source-revisions", srcrevs);
if (preserve)
prop_dictionary_set_bool(pkg_propsd, "preserve", true);
xbps_dictionary_set_bool(pkg_propsd, "preserve", true);
if (buildopts)
prop_dictionary_set_cstring_nocopy(pkg_propsd,
xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"build-options", buildopts);
/* Optional arrays */
@@ -742,7 +742,7 @@ main(int argc, char **argv)
/*
* Process XBPS_PKGFILES metadata file.
*/
pkg_filesd = prop_dictionary_create();
pkg_filesd = xbps_dictionary_create();
assert(pkg_filesd);
process_destdir(mutable_files);

View File

@@ -117,22 +117,22 @@ usage(void)
}
static const char *
convert_proptype_to_string(prop_object_t obj)
convert_proptype_to_string(xbps_object_t obj)
{
switch (prop_object_type(obj)) {
case PROP_TYPE_ARRAY:
switch (xbps_object_type(obj)) {
case XBPS_TYPE_ARRAY:
return "array";
case PROP_TYPE_BOOL:
case XBPS_TYPE_BOOL:
return "bool";
case PROP_TYPE_DICTIONARY:
case XBPS_TYPE_DICTIONARY:
return "dictionary";
case PROP_TYPE_DICT_KEYSYM:
case XBPS_TYPE_DICT_KEYSYM:
return "dictionary key";
case PROP_TYPE_NUMBER:
case XBPS_TYPE_NUMBER:
return "integer";
case PROP_TYPE_STRING:
case XBPS_TYPE_STRING:
return "string";
case PROP_TYPE_DATA:
case XBPS_TYPE_DATA:
return "data";
default:
return NULL;
@@ -142,77 +142,77 @@ convert_proptype_to_string(prop_object_t obj)
static void
generate_conf_file(void)
{
prop_dictionary_t d, d2;
xbps_dictionary_t d, d2;
struct defprops *dfp;
size_t i;
const char *outfile = "xbps-dgraph.conf";
d = prop_dictionary_create();
d = xbps_dictionary_create();
d2 = prop_dictionary_create();
prop_dictionary_set(d, "graph", d2);
prop_object_release(d2);
d2 = xbps_dictionary_create();
xbps_dictionary_set(d, "graph", d2);
xbps_object_release(d2);
d2 = prop_dictionary_create();
prop_dictionary_set(d, "edge", d2);
prop_object_release(d2);
d2 = xbps_dictionary_create();
xbps_dictionary_set(d, "edge", d2);
xbps_object_release(d2);
d2 = prop_dictionary_create();
prop_dictionary_set(d, "node", d2);
prop_object_release(d2);
d2 = xbps_dictionary_create();
xbps_dictionary_set(d, "node", d2);
xbps_object_release(d2);
d2 = prop_dictionary_create();
prop_dictionary_set(d, "node-sub", d2);
prop_object_release(d2);
d2 = xbps_dictionary_create();
xbps_dictionary_set(d, "node-sub", d2);
xbps_object_release(d2);
for (i = 0; i < __arraycount(dfprops); i++) {
dfp = &dfprops[i];
d2 = prop_dictionary_get(d, dfp->sect);
prop_dictionary_set_cstring_nocopy(d2, dfp->prop, dfp->val);
d2 = xbps_dictionary_get(d, dfp->sect);
xbps_dictionary_set_cstring_nocopy(d2, dfp->prop, dfp->val);
}
if (prop_dictionary_externalize_to_file(d, outfile) == false) {
prop_object_release(d);
if (xbps_dictionary_externalize_to_file(d, outfile) == false) {
xbps_object_release(d);
die("couldn't write conf_file to %s", outfile);
}
prop_object_release(d);
xbps_object_release(d);
printf("Wrote configuration file: %s\n", _DGRAPH_CFFILE);
}
static void
write_conf_property_on_stream(FILE *f,
const char *section,
prop_dictionary_t confd)
xbps_dictionary_t confd)
{
prop_array_t allkeys, allkeys2;
prop_dictionary_keysym_t dksym, dksym2;
prop_object_t keyobj, keyobj2;
xbps_array_t allkeys, allkeys2;
xbps_dictionary_keysym_t dksym, dksym2;
xbps_object_t keyobj, keyobj2;
size_t i, x;
const char *cf_val, *keyname, *keyname2;
/*
* Iterate over the main dictionary.
*/
allkeys = prop_dictionary_all_keys(confd);
for (i = 0; i < prop_array_count(allkeys); i++) {
dksym = prop_array_get(allkeys, i);
keyname = prop_dictionary_keysym_cstring_nocopy(dksym);
keyobj = prop_dictionary_get_keysym(confd, dksym);
allkeys = xbps_dictionary_all_keys(confd);
for (i = 0; i < xbps_array_count(allkeys); i++) {
dksym = xbps_array_get(allkeys, i);
keyname = xbps_dictionary_keysym_cstring_nocopy(dksym);
keyobj = xbps_dictionary_get_keysym(confd, dksym);
if (strcmp(keyname, section))
continue;
/*
* Iterate over the dictionary sections [edge/graph/node].
*/
allkeys2 = prop_dictionary_all_keys(keyobj);
for (x = 0; x < prop_array_count(allkeys2); x++) {
dksym2 = prop_array_get(allkeys2, x);
keyname2 = prop_dictionary_keysym_cstring_nocopy(dksym2);
keyobj2 = prop_dictionary_get_keysym(keyobj, dksym2);
allkeys2 = xbps_dictionary_all_keys(keyobj);
for (x = 0; x < xbps_array_count(allkeys2); x++) {
dksym2 = xbps_array_get(allkeys2, x);
keyname2 = xbps_dictionary_keysym_cstring_nocopy(dksym2);
keyobj2 = xbps_dictionary_get_keysym(keyobj, dksym2);
cf_val = prop_string_cstring_nocopy(keyobj2);
cf_val = xbps_string_cstring_nocopy(keyobj2);
fprintf(f, "%s=\"%s\"", keyname2, cf_val);
if (x + 1 >= prop_array_count(allkeys2))
if (x + 1 >= xbps_array_count(allkeys2))
continue;
fprintf(f, ",");
@@ -238,19 +238,19 @@ strip_dashes_from_key(const char *str)
}
static void
parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
prop_dictionary_t sub_confd,
prop_array_t allkeys)
parse_array_in_pkg_dictionary(FILE *f, xbps_dictionary_t plistd,
xbps_dictionary_t sub_confd,
xbps_array_t allkeys)
{
prop_dictionary_keysym_t dksym;
prop_object_t keyobj, sub_keyobj;
xbps_dictionary_keysym_t dksym;
xbps_object_t keyobj, sub_keyobj;
unsigned int i, x;
const char *tmpkeyname, *cfprop, *optnodetmp;
char *optnode, *keyname;
for (i = 0; i < prop_array_count(allkeys); i++) {
dksym = prop_array_get(allkeys, i);
tmpkeyname = prop_dictionary_keysym_cstring_nocopy(dksym);
for (i = 0; i < xbps_array_count(allkeys); i++) {
dksym = xbps_array_get(allkeys, i);
tmpkeyname = xbps_dictionary_keysym_cstring_nocopy(dksym);
/* Ignore these objects */
if ((strcmp(tmpkeyname, "source-revisions") == 0) ||
(strcmp(tmpkeyname, "files") == 0) ||
@@ -259,14 +259,14 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
(strcmp(tmpkeyname, "links") == 0))
continue;
keyobj = prop_dictionary_get_keysym(plistd, dksym);
keyobj = xbps_dictionary_get_keysym(plistd, dksym);
keyname = strip_dashes_from_key(tmpkeyname);
optnode = NULL;
fprintf(f, " main -> %s [label=\"%s\"];\n",
keyname, convert_proptype_to_string(keyobj));
prop_dictionary_get_cstring_nocopy(sub_confd, "opt-style", &cfprop);
xbps_dictionary_get_cstring_nocopy(sub_confd, "opt-style", &cfprop);
/* Check if object is optional and fill it in */
for (x = 0; x < __arraycount(optional_objs); x++) {
if (strcmp(keyname, optional_objs[x]) == 0) {
@@ -280,30 +280,30 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
/*
* Process array objects.
*/
prop_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop);
if (prop_object_type(keyobj) == PROP_TYPE_ARRAY) {
xbps_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop);
if (xbps_object_type(keyobj) == XBPS_TYPE_ARRAY) {
if (optnodetmp)
fprintf(f, " %s %s];\n", keyname,
optnodetmp);
for (x = 0; x < prop_array_count(keyobj); x++) {
sub_keyobj = prop_array_get(keyobj, x);
if (prop_object_type(sub_keyobj) == PROP_TYPE_STRING) {
for (x = 0; x < xbps_array_count(keyobj); x++) {
sub_keyobj = xbps_array_get(keyobj, x);
if (xbps_object_type(sub_keyobj) == XBPS_TYPE_STRING) {
/*
* Process arrays of strings.
*/
fprintf(f, " %s -> %s_%u_string "
"[label=\"string\"];\n",
keyname, keyname, x);
prop_dictionary_get_cstring_nocopy(sub_confd,
xbps_dictionary_get_cstring_nocopy(sub_confd,
"style", &cfprop);
fprintf(f, " %s_%u_string [style=\"%s\",",
keyname, x, cfprop);
prop_dictionary_get_cstring_nocopy(sub_confd,
xbps_dictionary_get_cstring_nocopy(sub_confd,
"fillcolor", &cfprop);
fprintf(f, "fillcolor=\"%s\","
"label=\"%s\"];\n", cfprop,
prop_string_cstring_nocopy(sub_keyobj));
xbps_string_cstring_nocopy(sub_keyobj));
}
}
if (optnode)
@@ -319,28 +319,28 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
} else
fprintf(f, " %s -> %s_value;\n", keyname, keyname);
prop_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop);
xbps_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop);
fprintf(f, " %s_value [style=\"%s\",", keyname, cfprop);
prop_dictionary_get_cstring_nocopy(sub_confd,
xbps_dictionary_get_cstring_nocopy(sub_confd,
"fillcolor", &cfprop);
fprintf(f, "fillcolor=\"%s\"", cfprop);
/*
* Process all other object types...
*/
switch (prop_object_type(keyobj)) {
case PROP_TYPE_BOOL:
switch (xbps_object_type(keyobj)) {
case XBPS_TYPE_BOOL:
fprintf(f, ",label=\"%s\"",
prop_bool_true(keyobj) ? "true" : "false");
xbps_bool_true(keyobj) ? "true" : "false");
break;
case PROP_TYPE_DATA:
fprintf(f, ",label=\"%zu bytes\"", prop_data_size(keyobj));
case XBPS_TYPE_DATA:
fprintf(f, ",label=\"%zu bytes\"", xbps_data_size(keyobj));
break;
case PROP_TYPE_NUMBER:
case XBPS_TYPE_NUMBER:
fprintf(f, ",label=\"%"PRIu64" bytes\"",
prop_number_unsigned_integer_value(keyobj));
xbps_number_unsigned_integer_value(keyobj));
break;
case PROP_TYPE_STRING:
case XBPS_TYPE_STRING:
if (strcmp(keyname, "long_desc") == 0) {
/*
* Do not print this obj, too large!
@@ -348,7 +348,7 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
fprintf(f, ",label=\"...\"");
} else {
fprintf(f, ",label=\"%s\"",
prop_string_cstring_nocopy(keyobj));
xbps_string_cstring_nocopy(keyobj));
}
break;
default:
@@ -365,15 +365,15 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
static void
create_dot_graph(struct xbps_handle *xhp,
FILE *f,
prop_dictionary_t plistd,
prop_dictionary_t confd,
xbps_dictionary_t plistd,
xbps_dictionary_t confd,
bool revdeps)
{
prop_dictionary_t sub_confd;
prop_array_t allkeys, rdeps;
xbps_dictionary_t sub_confd;
xbps_array_t allkeys, rdeps;
const char *pkgver, *cfprop;
prop_dictionary_get_cstring_nocopy(plistd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(plistd, "pkgver", &pkgver);
/*
* Start filling the output file...
@@ -407,11 +407,11 @@ create_dot_graph(struct xbps_handle *xhp,
* Process the node-sub section in config file.
*/
fprintf(f, " main [");
sub_confd = prop_dictionary_get(confd, "node-sub");
prop_dictionary_get_cstring_nocopy(sub_confd, "main-style", &cfprop);
sub_confd = xbps_dictionary_get(confd, "node-sub");
xbps_dictionary_get_cstring_nocopy(sub_confd, "main-style", &cfprop);
if (cfprop)
fprintf(f, "style=%s,", cfprop);
prop_dictionary_get_cstring_nocopy(sub_confd, "main-fillcolor", &cfprop);
xbps_dictionary_get_cstring_nocopy(sub_confd, "main-fillcolor", &cfprop);
if (cfprop)
fprintf(f, "fillcolor=\"%s\",", cfprop);
fprintf(f, "label=\"Dictionary\"];\n");
@@ -422,10 +422,10 @@ create_dot_graph(struct xbps_handle *xhp,
*/
if (revdeps) {
rdeps = xbps_pkgdb_get_pkg_revdeps(xhp, pkgver);
if (prop_array_count(rdeps))
prop_dictionary_set(plistd, "requiredby", rdeps);
if (xbps_array_count(rdeps))
xbps_dictionary_set(plistd, "requiredby", rdeps);
}
allkeys = prop_dictionary_all_keys(plistd);
allkeys = xbps_dictionary_all_keys(plistd);
parse_array_in_pkg_dictionary(f, plistd, sub_confd, allkeys);
/*
* Terminate the stream...
@@ -438,7 +438,7 @@ create_dot_graph(struct xbps_handle *xhp,
int
main(int argc, char **argv)
{
prop_dictionary_t plistd, confd = NULL;
xbps_dictionary_t plistd, confd = NULL;
struct xbps_handle xh;
FILE *f = NULL;
char *outfile = NULL;
@@ -502,7 +502,7 @@ main(int argc, char **argv)
/*
* Internalize the configuration file.
*/
confd = prop_dictionary_internalize_from_zfile(conf_file);
confd = xbps_dictionary_internalize_from_zfile(conf_file);
if (confd == NULL)
die("cannot read conf file `%s'", conf_file);

View File

@@ -34,7 +34,7 @@
void
state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
const char *instver, *newver;
char *pkgname;
bool syslog_enabled = false;
@@ -90,7 +90,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
assert(pkgname);
newver = xbps_pkg_version(xscd->arg);
pkgd = xbps_pkgdb_get_pkg(xscd->xhp, pkgname);
prop_dictionary_get_cstring_nocopy(pkgd, "version", &instver);
xbps_dictionary_get_cstring_nocopy(pkgd, "version", &instver);
printf("%s-%s: updating to %s ...\n", pkgname, instver, newver);
free(pkgname);
break;

View File

@@ -37,8 +37,8 @@
#include "defs.h"
struct transaction {
prop_dictionary_t d;
prop_object_iterator_t iter;
xbps_dictionary_t d;
xbps_object_iterator_t iter;
uint32_t inst_pkgcnt;
uint32_t up_pkgcnt;
uint32_t cf_pkgcnt;
@@ -46,45 +46,45 @@ struct transaction {
};
static void
show_missing_deps(prop_array_t a)
show_missing_deps(xbps_array_t a)
{
unsigned int i;
const char *str;
fprintf(stderr, "Unable to locate some required packages:\n");
for (i = 0; i < prop_array_count(a); i++) {
prop_array_get_cstring_nocopy(a, i, &str);
for (i = 0; i < xbps_array_count(a); i++) {
xbps_array_get_cstring_nocopy(a, i, &str);
fprintf(stderr, " %s\n", str);
}
}
static void
show_conflicts(prop_array_t a)
show_conflicts(xbps_array_t a)
{
unsigned int i;
const char *str;
fprintf(stderr, "Conflicting packages were found:\n");
for (i = 0; i < prop_array_count(a); i++) {
prop_array_get_cstring_nocopy(a, i, &str);
for (i = 0; i < xbps_array_count(a); i++) {
xbps_array_get_cstring_nocopy(a, i, &str);
fprintf(stderr, " %s\n", str);
}
}
static void
show_actions(prop_object_iterator_t iter)
show_actions(xbps_object_iterator_t iter)
{
prop_object_t obj;
xbps_object_t obj;
const char *repoloc, *trans, *pkgver, *arch;
repoloc = trans = pkgver = arch = NULL;
while ((obj = prop_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
xbps_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s %s", pkgver, trans);
prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
xbps_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
if (repoloc && arch)
printf(" %s %s", arch, repoloc);
@@ -93,19 +93,19 @@ show_actions(prop_object_iterator_t iter)
}
static void
show_package_list(prop_object_iterator_t iter, const char *match, int cols)
show_package_list(xbps_object_iterator_t iter, const char *match, int cols)
{
prop_object_t obj;
xbps_object_t obj;
const char *pkgver, *tract;
while ((obj = prop_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
if (strcmp(match, tract))
continue;
print_package_line(pkgver, cols, false);
}
prop_object_iterator_reset(iter);
xbps_object_iterator_reset(iter);
print_package_line(NULL, cols, true);
}
@@ -118,28 +118,28 @@ show_transaction_sizes(struct transaction *trans, int cols)
/*
* Show the list of packages that will be installed.
*/
if (prop_dictionary_get_uint32(trans->d, "total-install-pkgs",
if (xbps_dictionary_get_uint32(trans->d, "total-install-pkgs",
&trans->inst_pkgcnt)) {
printf("%u package%s will be installed:\n",
trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s");
show_package_list(trans->iter, "install", cols);
printf("\n");
}
if (prop_dictionary_get_uint32(trans->d, "total-update-pkgs",
if (xbps_dictionary_get_uint32(trans->d, "total-update-pkgs",
&trans->up_pkgcnt)) {
printf("%u package%s will be updated:\n",
trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s");
show_package_list(trans->iter, "update", cols);
printf("\n");
}
if (prop_dictionary_get_uint32(trans->d, "total-configure-pkgs",
if (xbps_dictionary_get_uint32(trans->d, "total-configure-pkgs",
&trans->cf_pkgcnt)) {
printf("%u package%s will be configured:\n",
trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s");
show_package_list(trans->iter, "configure", cols);
printf("\n");
}
if (prop_dictionary_get_uint32(trans->d, "total-remove-pkgs",
if (xbps_dictionary_get_uint32(trans->d, "total-remove-pkgs",
&trans->rm_pkgcnt)) {
printf("%u package%s will be removed:\n",
trans->rm_pkgcnt, trans->rm_pkgcnt == 1 ? "" : "s");
@@ -149,10 +149,10 @@ show_transaction_sizes(struct transaction *trans, int cols)
/*
* Show total download/installed/removed size for all required packages.
*/
prop_dictionary_get_uint64(trans->d, "total-download-size", &dlsize);
prop_dictionary_get_uint64(trans->d, "total-installed-size",
xbps_dictionary_get_uint64(trans->d, "total-download-size", &dlsize);
xbps_dictionary_get_uint64(trans->d, "total-installed-size",
&instsize);
prop_dictionary_get_uint64(trans->d, "total-removed-size", &rmsize);
xbps_dictionary_get_uint64(trans->d, "total-removed-size", &rmsize);
if (dlsize || instsize || rmsize)
printf("\n");
@@ -258,7 +258,7 @@ update_pkg(struct xbps_handle *xhp, const char *pkgname)
int
exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
{
prop_array_t mdeps, cflicts;
xbps_array_t mdeps, cflicts;
struct transaction *trans;
int rv = 0;
@@ -269,13 +269,13 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
if ((rv = xbps_transaction_prepare(xhp)) != 0) {
if (rv == ENODEV) {
mdeps =
prop_dictionary_get(xhp->transd, "missing_deps");
xbps_dictionary_get(xhp->transd, "missing_deps");
/* missing packages */
show_missing_deps(mdeps);
goto out;
} else if (rv == EAGAIN) {
/* conflicts */
cflicts = prop_dictionary_get(xhp->transd, "conflicts");
cflicts = xbps_dictionary_get(xhp->transd, "conflicts");
show_conflicts(cflicts);
goto out;
}
@@ -285,7 +285,7 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
}
xbps_dbg_printf(xhp, "Dictionary before transaction happens:\n");
xbps_dbg_printf_append(xhp, "%s",
prop_dictionary_externalize(xhp->transd));
xbps_dictionary_externalize(xhp->transd));
trans->d = xhp->transd;
trans->iter = xbps_array_iter_from_dict(xhp->transd, "packages");
@@ -321,7 +321,7 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
}
out:
if (trans->iter)
prop_object_iterator_release(trans->iter);
xbps_object_iterator_release(trans->iter);
if (trans)
free(trans);

View File

@@ -47,23 +47,23 @@ struct thread_data {
static void *
pkgdb_thread_worker(void *arg)
{
prop_dictionary_t pkgd;
prop_array_t array;
prop_object_t obj;
xbps_dictionary_t pkgd;
xbps_array_t array;
xbps_object_t obj;
struct thread_data *thd = arg;
const char *pkgver;
char *pkgname;
unsigned int i;
int rv;
array = prop_dictionary_all_keys(thd->xhp->pkgdb);
array = xbps_dictionary_all_keys(thd->xhp->pkgdb);
assert(array);
/* process pkgs from start until end */
for (i = thd->start; i < thd->end; i++) {
obj = prop_array_get(array, i);
pkgd = prop_dictionary_get_keysym(thd->xhp->pkgdb, obj);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
obj = xbps_array_get(array, i);
pkgd = xbps_dictionary_get_keysym(thd->xhp->pkgdb, obj);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
if (thd->xhp->flags & XBPS_FLAG_VERBOSE)
printf("Checking %s ...\n", pkgver);
@@ -75,7 +75,7 @@ pkgdb_thread_worker(void *arg)
fprintf(stderr, "pkgdb[%d] failed for %s: %s\n",
thd->thread_num, pkgver, strerror(rv));
}
prop_object_release(array);
xbps_object_release(array);
return NULL;
}
@@ -94,7 +94,7 @@ check_pkg_integrity_all(struct xbps_handle *xhp)
thd = calloc(maxthreads, sizeof(*thd));
assert(thd);
slicecount = prop_dictionary_count(xhp->pkgdb) / maxthreads;
slicecount = xbps_dictionary_count(xhp->pkgdb) / maxthreads;
pkgcount = 0;
for (i = 0; i < maxthreads; i++) {
@@ -102,7 +102,7 @@ check_pkg_integrity_all(struct xbps_handle *xhp)
thd[i].xhp = xhp;
thd[i].start = pkgcount;
if (i + 1 >= maxthreads)
thd[i].end = prop_dictionary_count(xhp->pkgdb);
thd[i].end = xbps_dictionary_count(xhp->pkgdb);
else
thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL,
@@ -124,10 +124,10 @@ check_pkg_integrity_all(struct xbps_handle *xhp)
int
check_pkg_integrity(struct xbps_handle *xhp,
prop_dictionary_t pkgd,
xbps_dictionary_t pkgd,
const char *pkgname)
{
prop_dictionary_t opkgd, propsd;
xbps_dictionary_t opkgd, propsd;
const char *sha256;
char *buf;
int rv = 0;
@@ -147,27 +147,27 @@ check_pkg_integrity(struct xbps_handle *xhp,
* Check for props.plist metadata file.
*/
buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
propsd = prop_dictionary_internalize_from_file(buf);
propsd = xbps_dictionary_internalize_from_file(buf);
free(buf);
if (propsd == NULL) {
xbps_error_printf("%s: unexistent metafile!\n", pkgname);
return EINVAL;
} else if (prop_dictionary_count(propsd) == 0) {
} else if (xbps_dictionary_count(propsd) == 0) {
xbps_error_printf("%s: incomplete metadata file.\n", pkgname);
prop_object_release(propsd);
xbps_object_release(propsd);
return 1;
}
/*
* Check pkg metadata signature.
*/
prop_dictionary_get_cstring_nocopy(opkgd, "metafile-sha256", &sha256);
xbps_dictionary_get_cstring_nocopy(opkgd, "metafile-sha256", &sha256);
if (sha256 != NULL) {
buf = xbps_xasprintf("%s/.%s.plist",
xhp->metadir, pkgname);
rv = xbps_file_hash_check(buf, sha256);
free(buf);
if (rv == ERANGE) {
prop_object_release(propsd);
xbps_object_release(propsd);
fprintf(stderr, "%s: metadata file has been "
"modified!\n", pkgname);
return 1;
@@ -190,7 +190,7 @@ do { \
RUN_PKG_CHECK(xhp, rundeps, propsd);
RUN_PKG_CHECK(xhp, unneeded, opkgd);
prop_object_release(propsd);
xbps_object_release(propsd);
#undef RUN_PKG_CHECK

View File

@@ -48,25 +48,25 @@
int
check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
{
prop_array_t array;
prop_object_t obj;
prop_object_iterator_t iter;
prop_dictionary_t pkg_filesd = arg;
xbps_array_t array;
xbps_object_t obj;
xbps_object_iterator_t iter;
xbps_dictionary_t pkg_filesd = arg;
const char *file, *sha256;
char *path;
bool mutable, broken = false, test_broken = false;
int rv;
array = prop_dictionary_get(pkg_filesd, "files");
if (array != NULL && prop_array_count(array) > 0) {
array = xbps_dictionary_get(pkg_filesd, "files");
if (array != NULL && xbps_array_count(array) > 0) {
iter = xbps_array_iter_from_dict(pkg_filesd, "files");
if (iter == NULL)
return -1;
while ((obj = prop_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
while ((obj = xbps_object_iterator_next(iter))) {
xbps_dictionary_get_cstring_nocopy(obj, "file", &file);
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj,
"sha256", &sha256);
rv = xbps_file_hash_check(path, sha256);
free(path);
@@ -80,7 +80,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
break;
case ERANGE:
mutable = false;
prop_dictionary_get_bool(obj,
xbps_dictionary_get_bool(obj,
"mutable", &mutable);
if (!mutable) {
xbps_error_printf("%s: hash mismatch "
@@ -95,7 +95,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
break;
}
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
}
if (test_broken) {
xbps_error_printf("%s: files check FAILED.\n", pkgname);
@@ -106,14 +106,14 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
/*
* Check for missing configuration files.
*/
array = prop_dictionary_get(pkg_filesd, "conf_files");
if (array != NULL && prop_array_count(array) > 0) {
array = xbps_dictionary_get(pkg_filesd, "conf_files");
if (array != NULL && xbps_array_count(array) > 0) {
iter = xbps_array_iter_from_dict(pkg_filesd, "conf_files");
if (iter == NULL)
return -1;
while ((obj = prop_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
while ((obj = xbps_object_iterator_next(iter))) {
xbps_dictionary_get_cstring_nocopy(obj, "file", &file);
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
if (access(path, R_OK) == -1) {
if (errno == ENOENT) {
@@ -129,7 +129,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
}
free(path);
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
}
if (test_broken) {
xbps_error_printf("%s: conf files check FAILED.\n", pkgname);

View File

@@ -47,8 +47,8 @@
int
check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, void *arg)
{
prop_dictionary_t pkg_propsd = arg;
prop_array_t array;
xbps_dictionary_t pkg_propsd = arg;
xbps_array_t array;
unsigned int i;
const char *reqpkg;
bool test_broken = false;
@@ -56,9 +56,9 @@ check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, void *arg)
if (!xbps_pkg_has_rundeps(pkg_propsd))
return 0;
array = prop_dictionary_get(pkg_propsd, "run_depends");
for (i = 0; i < prop_array_count(array); i++) {
prop_array_get_cstring_nocopy(array, i, &reqpkg);
array = xbps_dictionary_get(pkg_propsd, "run_depends");
for (i = 0; i < xbps_array_count(array); i++) {
xbps_array_get_cstring_nocopy(array, i, &reqpkg);
if (xbps_pkg_is_installed(xhp, reqpkg) <= 0) {
xbps_error_printf("%s: dependency not satisfied: %s\n",
pkgname, reqpkg);

View File

@@ -74,27 +74,27 @@ symlink_target(const char *pkgname, const char *path)
int
check_pkg_symlinks(struct xbps_handle *xhp, const char *pkgname, void *arg)
{
prop_array_t array;
prop_object_t obj;
prop_dictionary_t filesd = arg;
xbps_array_t array;
xbps_object_t obj;
xbps_dictionary_t filesd = arg;
unsigned int i;
const char *file, *tgt = NULL;
char *path, *p, *buf, *buf2, *lnk, *dname, *tgt_path;
int rv;
bool broken = false;
array = prop_dictionary_get(filesd, "links");
array = xbps_dictionary_get(filesd, "links");
if (array == NULL)
return false;
for (i = 0; i < prop_array_count(array); i++) {
obj = prop_array_get(array, i);
if (!prop_dictionary_get_cstring_nocopy(obj, "target", &tgt)) {
for (i = 0; i < xbps_array_count(array); i++) {
obj = xbps_array_get(array, i);
if (!xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt)) {
xbps_warn_printf("%s: `%s' symlink with "
"empty target object!\n", pkgname, file);
continue;
}
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
xbps_dictionary_get_cstring_nocopy(obj, "file", &file);
if (strcmp(tgt, "") == 0) {
xbps_warn_printf("%s: `%s' symlink with "
"empty target object!\n", pkgname, file);

View File

@@ -45,19 +45,19 @@
int
check_pkg_unneeded(struct xbps_handle *xhp, const char *pkgname, void *arg)
{
prop_dictionary_t pkgd = arg;
xbps_dictionary_t pkgd = arg;
(void)xhp;
(void)pkgname;
if (prop_dictionary_get(pkgd, "remove-and-update"))
prop_dictionary_remove(pkgd, "remove-and-update");
if (xbps_dictionary_get(pkgd, "remove-and-update"))
xbps_dictionary_remove(pkgd, "remove-and-update");
if (prop_dictionary_get(pkgd, "transaction"))
prop_dictionary_remove(pkgd, "transaction");
if (xbps_dictionary_get(pkgd, "transaction"))
xbps_dictionary_remove(pkgd, "transaction");
if (prop_dictionary_get(pkgd, "skip-obsoletes"))
prop_dictionary_remove(pkgd, "skip-obsoletes");
if (xbps_dictionary_get(pkgd, "skip-obsoletes"))
xbps_dictionary_remove(pkgd, "skip-obsoletes");
return 0;
}

View File

@@ -44,8 +44,8 @@
static void
pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new)
{
prop_array_t array, rdeps;
prop_dictionary_t pkgdb, pkgd;
xbps_array_t array, rdeps;
xbps_dictionary_t pkgdb, pkgd;
unsigned int i;
char *pkgname, *plist;
@@ -61,45 +61,45 @@ pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new)
exit(EXIT_FAILURE);
}
array = prop_array_internalize_from_zfile(plist);
if (prop_object_type(array) != PROP_TYPE_ARRAY) {
array = xbps_array_internalize_from_zfile(plist);
if (xbps_object_type(array) != XBPS_TYPE_ARRAY) {
xbps_error_printf("unknown object type for %s\n",
plist, strerror(errno));
exit(EXIT_FAILURE);
}
pkgdb = prop_dictionary_create();
pkgdb = xbps_dictionary_create();
assert(pkgdb);
for (i = 0; i < prop_array_count(array); i++) {
pkgd = prop_array_get(array, i);
prop_dictionary_get_cstring(pkgd, "pkgname", &pkgname);
rdeps = prop_dictionary_get(pkgd, "run_depends");
for (i = 0; i < xbps_array_count(array); i++) {
pkgd = xbps_array_get(array, i);
xbps_dictionary_get_cstring(pkgd, "pkgname", &pkgname);
rdeps = xbps_dictionary_get(pkgd, "run_depends");
/* remove unneeded objs */
prop_dictionary_remove(pkgd, "pkgname");
prop_dictionary_remove(pkgd, "version");
if (prop_array_count(rdeps) == 0)
prop_dictionary_remove(pkgd, "run_depends");
xbps_dictionary_remove(pkgd, "pkgname");
xbps_dictionary_remove(pkgd, "version");
if (xbps_array_count(rdeps) == 0)
xbps_dictionary_remove(pkgd, "run_depends");
prop_dictionary_set(pkgdb, pkgname, pkgd);
xbps_dictionary_set(pkgdb, pkgname, pkgd);
free(pkgname);
}
if (prop_array_count(array) != prop_dictionary_count(pkgdb)) {
if (xbps_array_count(array) != xbps_dictionary_count(pkgdb)) {
xbps_error_printf("failed conversion! unmatched obj count "
"(got %zu, need %zu)\n", prop_dictionary_count(pkgdb),
prop_array_count(array));
"(got %zu, need %zu)\n", xbps_dictionary_count(pkgdb),
xbps_array_count(array));
exit(EXIT_FAILURE);
}
if (!prop_dictionary_externalize_to_file(pkgdb, plist_new)) {
if (!xbps_dictionary_externalize_to_file(pkgdb, plist_new)) {
xbps_error_printf("failed to write %s: %s\n",
plist_new, strerror(errno));
exit(EXIT_FAILURE);
}
prop_object_release(array);
prop_object_release(pkgdb);
xbps_object_release(array);
xbps_object_release(pkgdb);
free(plist);
printf("Conversion to 0.21 pkgdb format successfully\n");

View File

@@ -30,7 +30,7 @@
#include <xbps_api.h>
/* from check.c */
int check_pkg_integrity(struct xbps_handle *, prop_dictionary_t, const char *);
int check_pkg_integrity(struct xbps_handle *, xbps_dictionary_t, const char *);
int check_pkg_integrity_all(struct xbps_handle *);
#define CHECK_PKG_DECL(type) \

View File

@@ -57,7 +57,7 @@ change_pkg_instmode(struct xbps_handle *xhp,
const char *pkgname,
const char *modestr)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
bool mode = false;
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
@@ -67,7 +67,7 @@ change_pkg_instmode(struct xbps_handle *xhp,
if (strcmp(modestr, "auto") == 0)
mode = true;
prop_dictionary_set_bool(pkgd, "automatic-install", mode);
xbps_dictionary_set_bool(pkgd, "automatic-install", mode);
return xbps_pkgdb_update(xhp, true);
}

View File

@@ -41,15 +41,15 @@ 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 */
void show_pkg_info(prop_dictionary_t);
void show_pkg_info_one(prop_dictionary_t, const char *);
void show_pkg_info(xbps_dictionary_t);
void show_pkg_info_one(xbps_dictionary_t, const char *);
int show_pkg_info_from_metadir(struct xbps_handle *, const char *,
const char *);
int show_pkg_files(prop_dictionary_t);
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 repo_show_pkg_info(struct xbps_handle *, const char *, const char *);
int repo_show_pkg_namedesc(struct xbps_handle *, prop_object_t, void *,
int repo_show_pkg_namedesc(struct xbps_handle *, xbps_object_t, void *,
bool *);
/* from ownedby.c */
@@ -57,10 +57,10 @@ int ownedby(struct xbps_handle *, int, char **);
int repo_ownedby(struct xbps_handle *, int, char **);
/* From list.c */
unsigned int find_longest_pkgver(struct xbps_handle *, prop_object_t);
unsigned int find_longest_pkgver(struct xbps_handle *, xbps_object_t);
int list_pkgs_in_dict(struct xbps_handle *, prop_object_t, void *, bool *);
int list_manual_pkgs(struct xbps_handle *, prop_object_t, void *, bool *);
int list_pkgs_in_dict(struct xbps_handle *, xbps_object_t, void *, bool *);
int list_manual_pkgs(struct xbps_handle *, xbps_object_t, void *, bool *);
int list_orphans(struct xbps_handle *);
int list_pkgs_pkgdb(struct xbps_handle *);

View File

@@ -40,7 +40,7 @@ struct list_pkgver_cb {
int
list_pkgs_in_dict(struct xbps_handle *xhp,
prop_object_t obj,
xbps_object_t obj,
void *arg,
bool *loop_done)
{
@@ -53,8 +53,8 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
(void)xhp;
(void)loop_done;
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj, "short_desc", &short_desc);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "short_desc", &short_desc);
if (!pkgver || !short_desc)
return EINVAL;
@@ -92,7 +92,7 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
int
list_manual_pkgs(struct xbps_handle *xhp,
prop_object_t obj,
xbps_object_t obj,
void *arg,
bool *loop_done)
{
@@ -103,9 +103,9 @@ list_manual_pkgs(struct xbps_handle *xhp,
(void)arg;
(void)loop_done;
prop_dictionary_get_bool(obj, "automatic-install", &automatic);
xbps_dictionary_get_bool(obj, "automatic-install", &automatic);
if (automatic == false) {
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s\n", pkgver);
}
@@ -115,24 +115,24 @@ list_manual_pkgs(struct xbps_handle *xhp,
int
list_orphans(struct xbps_handle *xhp)
{
prop_array_t orphans;
prop_object_iterator_t iter;
prop_object_t obj;
xbps_array_t orphans;
xbps_object_iterator_t iter;
xbps_object_t obj;
const char *pkgver;
orphans = xbps_find_pkg_orphans(xhp, NULL);
if (orphans == NULL)
return EINVAL;
if (prop_array_count(orphans) == 0)
if (xbps_array_count(orphans) == 0)
return 0;
iter = prop_array_iterator(orphans);
iter = xbps_array_iterator(orphans);
if (iter == NULL)
return ENOMEM;
while ((obj = prop_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s\n", pkgver);
}
@@ -157,7 +157,7 @@ repo_list_uri_cb(struct xbps_repo *repo, void *arg, bool *done)
(void)done;
printf("%s (%u packages)\n", repo->uri,
prop_dictionary_count(repo->idx));
xbps_dictionary_count(repo->idx));
return 0;
}
@@ -177,30 +177,30 @@ repo_list(struct xbps_handle *xhp)
}
struct fflongest {
prop_dictionary_t d;
xbps_dictionary_t d;
unsigned int len;
};
static int
_find_longest_pkgver_cb(struct xbps_handle *xhp,
prop_object_t obj,
xbps_object_t obj,
void *arg,
bool *loop_done)
{
struct fflongest *ffl = arg;
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
const char *pkgver;
unsigned int len;
(void)xhp;
(void)loop_done;
if (prop_object_type(obj) == PROP_TYPE_DICT_KEYSYM)
pkgd = prop_dictionary_get_keysym(ffl->d, obj);
if (xbps_object_type(obj) == XBPS_TYPE_DICT_KEYSYM)
pkgd = xbps_dictionary_get_keysym(ffl->d, obj);
else
pkgd = obj;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
len = strlen(pkgver);
if (ffl->len == 0 || len > ffl->len)
ffl->len = len;
@@ -209,20 +209,20 @@ _find_longest_pkgver_cb(struct xbps_handle *xhp,
}
unsigned int
find_longest_pkgver(struct xbps_handle *xhp, prop_object_t o)
find_longest_pkgver(struct xbps_handle *xhp, xbps_object_t o)
{
struct fflongest ffl;
ffl.d = o;
ffl.len = 0;
if (prop_object_type(o) == PROP_TYPE_DICTIONARY) {
prop_array_t array;
if (xbps_object_type(o) == XBPS_TYPE_DICTIONARY) {
xbps_array_t array;
array = prop_dictionary_all_keys(o);
array = xbps_dictionary_all_keys(o);
(void)xbps_callback_array_iter(xhp, array,
_find_longest_pkgver_cb, &ffl);
prop_object_release(array);
xbps_object_release(array);
} else {
(void)xbps_pkgdb_foreach_cb(xhp,
_find_longest_pkgver_cb, &ffl);

View File

@@ -42,18 +42,18 @@ struct ffdata {
};
static void
match_files_by_pattern(prop_dictionary_t pkg_filesd,
prop_dictionary_keysym_t key,
match_files_by_pattern(xbps_dictionary_t pkg_filesd,
xbps_dictionary_keysym_t key,
struct ffdata *ffd,
const char *pkgver)
{
prop_array_t array;
prop_object_t obj;
xbps_array_t array;
xbps_object_t obj;
const char *keyname, *filestr, *typestr;
unsigned int i;
int x;
keyname = prop_dictionary_keysym_cstring_nocopy(key);
keyname = xbps_dictionary_keysym_cstring_nocopy(key);
if (strcmp(keyname, "files") == 0)
typestr = "regular file";
@@ -66,10 +66,10 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd,
else
return;
array = prop_dictionary_get_keysym(pkg_filesd, key);
for (i = 0; i < prop_array_count(array); i++) {
obj = prop_array_get(array, i);
prop_dictionary_get_cstring_nocopy(obj, "file", &filestr);
array = xbps_dictionary_get_keysym(pkg_filesd, key);
for (i = 0; i < xbps_array_count(array); i++) {
obj = xbps_array_get(array, i);
xbps_dictionary_get_cstring_nocopy(obj, "file", &filestr);
if (filestr == NULL)
continue;
for (x = 0; x < ffd->npatterns; x++) {
@@ -82,24 +82,24 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd,
}
static int
ownedby_pkgdb_cb(struct xbps_handle *xhp, prop_object_t obj, void *arg, bool *done)
ownedby_pkgdb_cb(struct xbps_handle *xhp, xbps_object_t obj, void *arg, bool *done)
{
prop_dictionary_t pkgmetad;
prop_array_t files_keys;
xbps_dictionary_t pkgmetad;
xbps_array_t files_keys;
struct ffdata *ffd = arg;
unsigned int i;
const char *pkgver;
(void)done;
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
pkgmetad = xbps_pkgdb_get_pkg_metadata(xhp, pkgver);
assert(pkgmetad);
files_keys = prop_dictionary_all_keys(pkgmetad);
for (i = 0; i < prop_array_count(files_keys); i++) {
files_keys = xbps_dictionary_all_keys(pkgmetad);
for (i = 0; i < xbps_array_count(files_keys); i++) {
match_files_by_pattern(pkgmetad,
prop_array_get(files_keys, i), ffd, pkgver);
xbps_array_get(files_keys, i), ffd, pkgver);
}
return 0;
}
@@ -123,7 +123,7 @@ ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
}
static void
repo_match_files_by_pattern(prop_array_t files,
repo_match_files_by_pattern(xbps_array_t files,
const char *pkgver,
struct ffdata *ffd)
{
@@ -131,8 +131,8 @@ repo_match_files_by_pattern(prop_array_t files,
unsigned int i;
int x;
for (i = 0; i < prop_array_count(files); i++) {
prop_array_get_cstring_nocopy(files, i, &filestr);
for (i = 0; i < xbps_array_count(files); i++) {
xbps_array_get_cstring_nocopy(files, i, &filestr);
for (x = 0; x < ffd->npatterns; x++) {
if ((fnmatch(ffd->patterns[x], filestr, FNM_PERIOD)) == 0) {
printf("%s: %s (%s)\n",
@@ -145,9 +145,9 @@ repo_match_files_by_pattern(prop_array_t files,
static int
repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done)
{
prop_array_t allkeys, pkgar;
prop_dictionary_t filesd;
prop_dictionary_keysym_t ksym;
xbps_array_t allkeys, pkgar;
xbps_dictionary_t filesd;
xbps_dictionary_keysym_t ksym;
struct ffdata *ffd = arg;
const char *pkgver;
unsigned int i;
@@ -156,12 +156,12 @@ repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done)
filesd = xbps_repo_get_plist(repo, XBPS_PKGINDEX_FILES);
ffd->repouri = repo->uri;
allkeys = prop_dictionary_all_keys(filesd);
allkeys = xbps_dictionary_all_keys(filesd);
for (i = 0; i < prop_array_count(allkeys); i++) {
ksym = prop_array_get(allkeys, i);
pkgar = prop_dictionary_get_keysym(filesd, ksym);
pkgver = prop_dictionary_keysym_cstring_nocopy(ksym);
for (i = 0; i < xbps_array_count(allkeys); i++) {
ksym = xbps_array_get(allkeys, i);
pkgar = xbps_dictionary_get_keysym(filesd, ksym);
pkgver = xbps_dictionary_keysym_cstring_nocopy(ksym);
repo_match_files_by_pattern(pkgar, pkgver, ffd);
}

View File

@@ -48,7 +48,7 @@ struct search_data {
int npatterns;
char **patterns;
int maxcols;
prop_array_t results;
xbps_array_t results;
};
static void
@@ -59,16 +59,16 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
unsigned int i, j, tlen = 0, len = 0;
/* Iterate over results array and find out largest pkgver string */
for (i = 0; i < prop_array_count(sd->results); i++) {
prop_array_get_cstring_nocopy(sd->results, i, &pkgver);
for (i = 0; i < xbps_array_count(sd->results); i++) {
xbps_array_get_cstring_nocopy(sd->results, i, &pkgver);
len = strlen(pkgver);
if (tlen == 0 || len > tlen)
tlen = len;
i++;
}
for (i = 0; i < prop_array_count(sd->results); i++) {
prop_array_get_cstring_nocopy(sd->results, i, &pkgver);
prop_array_get_cstring_nocopy(sd->results, i+1, &desc);
for (i = 0; i < xbps_array_count(sd->results); i++) {
xbps_array_get_cstring_nocopy(sd->results, i, &pkgver);
xbps_array_get_cstring_nocopy(sd->results, i+1, &desc);
strncpy(tmp, pkgver, sizeof(tmp));
for (j = strlen(tmp); j < tlen; j++)
tmp[j] = ' ';
@@ -98,9 +98,9 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
static int
search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done)
{
prop_array_t allkeys;
prop_dictionary_t pkgd;
prop_dictionary_keysym_t ksym;
xbps_array_t allkeys;
xbps_dictionary_t pkgd;
xbps_dictionary_keysym_t ksym;
struct search_data *sd = arg;
const char *pkgver, *desc;
unsigned int i;
@@ -108,13 +108,13 @@ search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done)
(void)done;
allkeys = prop_dictionary_all_keys(repo->idx);
for (i = 0; i < prop_array_count(allkeys); i++) {
ksym = prop_array_get(allkeys, i);
pkgd = prop_dictionary_get_keysym(repo->idx, ksym);
allkeys = xbps_dictionary_all_keys(repo->idx);
for (i = 0; i < xbps_array_count(allkeys); i++) {
ksym = xbps_array_get(allkeys, i);
pkgd = xbps_dictionary_get_keysym(repo->idx, ksym);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc);
for (x = 0; x < sd->npatterns; x++) {
bool vpkgfound = false;
@@ -125,12 +125,12 @@ search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done)
if ((xbps_pkgpattern_match(pkgver, sd->patterns[x])) ||
(strcasestr(pkgver, sd->patterns[x])) ||
(strcasestr(desc, sd->patterns[x])) || vpkgfound) {
prop_array_add_cstring_nocopy(sd->results, pkgver);
prop_array_add_cstring_nocopy(sd->results, desc);
xbps_array_add_cstring_nocopy(sd->results, pkgver);
xbps_array_add_cstring_nocopy(sd->results, desc);
}
}
}
prop_object_release(allkeys);
xbps_object_release(allkeys);
return 0;
}
@@ -144,7 +144,7 @@ repo_search(struct xbps_handle *xhp, int npatterns, char **patterns)
sd.npatterns = npatterns;
sd.patterns = patterns;
sd.maxcols = get_maxcols();
sd.results = prop_array_create();
sd.results = xbps_array_create();
rv = xbps_rpool_foreach(xhp, search_pkgs_cb, &sd);
if (rv != 0 && rv != ENOTSUP)

View File

@@ -34,11 +34,11 @@
#include "defs.h"
static void
print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps,
print_rdeps(struct xbps_handle *xhp, xbps_array_t rdeps,
bool full, bool repo, bool origin, int *indent)
{
prop_array_t currdeps;
prop_dictionary_t pkgd;
xbps_array_t currdeps;
xbps_dictionary_t pkgd;
const char *pkgdep;
unsigned int i;
int j;
@@ -46,8 +46,8 @@ print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps,
if (!origin)
(*indent)++;
for (i = 0; i < prop_array_count(rdeps); i++) {
prop_array_get_cstring_nocopy(rdeps, i, &pkgdep);
for (i = 0; i < xbps_array_count(rdeps); i++) {
xbps_array_get_cstring_nocopy(rdeps, i, &pkgdep);
if (!origin || !full)
for (j = 0; j < *indent; j++)
putchar(' ');
@@ -66,7 +66,7 @@ print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps,
pkgd = xbps_pkgdb_get_virtualpkg(xhp, pkgdep);
}
if (pkgd != NULL) {
currdeps = prop_dictionary_get(pkgd, "run_depends");
currdeps = xbps_dictionary_get(pkgd, "run_depends");
if (currdeps != NULL)
print_rdeps(xhp, currdeps,
full, repo, false, indent);
@@ -78,15 +78,15 @@ print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps,
int
show_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool full)
{
prop_array_t rdeps;
prop_dictionary_t pkgd;
xbps_array_t rdeps;
xbps_dictionary_t pkgd;
int indent = 0;
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
if (pkgd == NULL)
return ENOENT;
rdeps = prop_dictionary_get(pkgd, "run_depends");
rdeps = xbps_dictionary_get(pkgd, "run_depends");
if (rdeps != NULL)
print_rdeps(xhp, rdeps, full, false, true, &indent);
@@ -96,13 +96,13 @@ show_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool full)
int
show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{
prop_array_t reqby;
xbps_array_t reqby;
const char *pkgdep;
unsigned int i;
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);
for (i = 0; i < xbps_array_count(reqby); i++) {
xbps_array_get_cstring_nocopy(reqby, i, &pkgdep);
printf("%s\n", pkgdep);
}
}
@@ -112,15 +112,15 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
int
repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern, bool full)
{
prop_array_t rdeps;
prop_dictionary_t pkgd;
xbps_array_t rdeps;
xbps_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;
rdeps = prop_dictionary_get(pkgd, "run_depends");
rdeps = xbps_dictionary_get(pkgd, "run_depends");
if (rdeps != NULL)
print_rdeps(xhp, rdeps, full, true, true, &indent);
@@ -130,7 +130,7 @@ repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern, bool full)
int
repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{
prop_array_t revdeps;
xbps_array_t revdeps;
const char *pkgver;
unsigned int i;
int rv;
@@ -138,8 +138,8 @@ repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
revdeps = xbps_rpool_get_pkg_revdeps(xhp, pkg);
rv = errno;
for (i = 0; i < prop_array_count(revdeps); i++) {
prop_array_get_cstring_nocopy(revdeps, i, &pkgver);
for (i = 0; i < xbps_array_count(revdeps); i++) {
xbps_array_get_cstring_nocopy(revdeps, i, &pkgver);
printf("%s\n", pkgver);
}

View File

@@ -37,11 +37,11 @@
#include "defs.h"
static void
print_value_obj(const char *keyname, prop_object_t obj,
print_value_obj(const char *keyname, xbps_object_t obj,
const char *indent, bool raw)
{
prop_array_t allkeys;
prop_object_t obj2, keysym;
xbps_array_t allkeys;
xbps_object_t obj2, keysym;
const char *ksymname, *value;
unsigned int i;
char size[8];
@@ -49,34 +49,34 @@ print_value_obj(const char *keyname, prop_object_t obj,
if (indent == NULL)
indent = "";
switch (prop_object_type(obj)) {
case PROP_TYPE_STRING:
switch (xbps_object_type(obj)) {
case XBPS_TYPE_STRING:
if (!raw)
printf("%s%s: ", indent, keyname);
printf("%s\n", prop_string_cstring_nocopy(obj));
printf("%s\n", xbps_string_cstring_nocopy(obj));
break;
case PROP_TYPE_NUMBER:
case XBPS_TYPE_NUMBER:
if (!raw)
printf("%s%s: ", indent, keyname);
if (xbps_humanize_number(size,
(int64_t)prop_number_unsigned_integer_value(obj)) == -1)
(int64_t)xbps_number_unsigned_integer_value(obj)) == -1)
printf("%ju\n",
prop_number_unsigned_integer_value(obj));
xbps_number_unsigned_integer_value(obj));
else
printf("%s\n", size);
break;
case PROP_TYPE_BOOL:
case XBPS_TYPE_BOOL:
if (!raw)
printf("%s%s: ", indent, keyname);
printf("%s\n", prop_bool_true(obj) ? "yes" : "no");
printf("%s\n", xbps_bool_true(obj) ? "yes" : "no");
break;
case PROP_TYPE_ARRAY:
case XBPS_TYPE_ARRAY:
if (!raw)
printf("%s%s:\n", indent, keyname);
for (i = 0; i < prop_array_count(obj); i++) {
obj2 = prop_array_get(obj, i);
if (prop_object_type(obj2) == PROP_TYPE_STRING) {
value = prop_string_cstring_nocopy(obj2);
for (i = 0; i < xbps_array_count(obj); i++) {
obj2 = xbps_array_get(obj, i);
if (xbps_object_type(obj2) == XBPS_TYPE_STRING) {
value = xbps_string_cstring_nocopy(obj2);
printf("%s%s%s\n", indent, !raw ? "\t" : "",
value);
} else {
@@ -84,29 +84,29 @@ print_value_obj(const char *keyname, prop_object_t obj,
}
}
break;
case PROP_TYPE_DICTIONARY:
allkeys = prop_dictionary_all_keys(obj);
for (i = 0; i < prop_array_count(allkeys); i++) {
keysym = prop_array_get(allkeys, i);
ksymname = prop_dictionary_keysym_cstring_nocopy(keysym);
obj2 = prop_dictionary_get_keysym(obj, keysym);
case XBPS_TYPE_DICTIONARY:
allkeys = xbps_dictionary_all_keys(obj);
for (i = 0; i < xbps_array_count(allkeys); i++) {
keysym = xbps_array_get(allkeys, i);
ksymname = xbps_dictionary_keysym_cstring_nocopy(keysym);
obj2 = xbps_dictionary_get_keysym(obj, keysym);
print_value_obj(ksymname, obj2, " ", raw);
}
prop_object_release(allkeys);
xbps_object_release(allkeys);
if (raw)
printf("\n");
break;
case PROP_TYPE_DATA:
case XBPS_TYPE_DATA:
if (!raw) {
xbps_humanize_number(size, (int64_t)prop_data_size(obj));
xbps_humanize_number(size, (int64_t)xbps_data_size(obj));
printf("%s%s: %s\n", indent, keyname, size);
} else {
FILE *f;
char buf[BUFSIZ-1];
void *data;
data = prop_data_data(obj);
f = fmemopen(data, prop_data_size(obj), "r");
data = xbps_data_data(obj);
f = fmemopen(data, xbps_data_size(obj), "r");
assert(f);
while (fgets(buf, BUFSIZ-1, f))
printf("%s", buf);
@@ -122,13 +122,13 @@ print_value_obj(const char *keyname, prop_object_t obj,
}
void
show_pkg_info_one(prop_dictionary_t d, const char *keys)
show_pkg_info_one(xbps_dictionary_t d, const char *keys)
{
prop_object_t obj;
xbps_object_t obj;
char *key, *p, *saveptr;
if (strchr(keys, ',') == NULL) {
obj = prop_dictionary_get(d, keys);
obj = xbps_dictionary_get(d, keys);
if (obj == NULL)
return;
print_value_obj(keys, obj, NULL, true);
@@ -139,7 +139,7 @@ show_pkg_info_one(prop_dictionary_t d, const char *keys)
abort();
for ((p = strtok_r(key, ",", &saveptr)); p;
(p = strtok_r(NULL, ",", &saveptr))) {
obj = prop_dictionary_get(d, p);
obj = xbps_dictionary_get(d, p);
if (obj == NULL)
continue;
print_value_obj(p, obj, NULL, true);
@@ -148,9 +148,9 @@ show_pkg_info_one(prop_dictionary_t d, const char *keys)
}
static void
print_srcrevs(const char *keyname, prop_string_t obj)
print_srcrevs(const char *keyname, xbps_string_t obj)
{
const char *str = prop_string_cstring_nocopy(obj);
const char *str = xbps_string_cstring_nocopy(obj);
unsigned int i;
/* parse string appending a \t after EOL */
@@ -165,18 +165,18 @@ print_srcrevs(const char *keyname, prop_string_t obj)
}
void
show_pkg_info(prop_dictionary_t dict)
show_pkg_info(xbps_dictionary_t dict)
{
prop_array_t all_keys;
prop_object_t obj, keysym;
xbps_array_t all_keys;
xbps_object_t obj, keysym;
const char *keyname;
unsigned int i;
all_keys = prop_dictionary_all_keys(dict);
for (i = 0; i < prop_array_count(all_keys); i++) {
keysym = prop_array_get(all_keys, i);
keyname = prop_dictionary_keysym_cstring_nocopy(keysym);
obj = prop_dictionary_get_keysym(dict, keysym);
all_keys = xbps_dictionary_all_keys(dict);
for (i = 0; i < xbps_array_count(all_keys); i++) {
keysym = xbps_array_get(all_keys, i);
keyname = xbps_dictionary_keysym_cstring_nocopy(keysym);
obj = xbps_dictionary_get_keysym(dict, keysym);
/* ignore objs shown by other targets */
if ((strcmp(keyname, "run_depends") == 0) ||
(strcmp(keyname, "files") == 0) ||
@@ -195,37 +195,37 @@ show_pkg_info(prop_dictionary_t dict)
}
int
show_pkg_files(prop_dictionary_t filesd)
show_pkg_files(xbps_dictionary_t filesd)
{
prop_array_t array, allkeys;
prop_object_t obj;
prop_dictionary_keysym_t ksym;
xbps_array_t array, allkeys;
xbps_object_t obj;
xbps_dictionary_keysym_t ksym;
const char *keyname, *file;
unsigned int i, x;
if (prop_object_type(filesd) != PROP_TYPE_DICTIONARY)
if (xbps_object_type(filesd) != XBPS_TYPE_DICTIONARY)
return EINVAL;
allkeys = prop_dictionary_all_keys(filesd);
for (i = 0; i < prop_array_count(allkeys); i++) {
ksym = prop_array_get(allkeys, i);
keyname = prop_dictionary_keysym_cstring_nocopy(ksym);
allkeys = xbps_dictionary_all_keys(filesd);
for (i = 0; i < xbps_array_count(allkeys); i++) {
ksym = xbps_array_get(allkeys, i);
keyname = xbps_dictionary_keysym_cstring_nocopy(ksym);
if ((strcmp(keyname, "files") &&
(strcmp(keyname, "conf_files") &&
(strcmp(keyname, "links")))))
continue;
array = prop_dictionary_get(filesd, keyname);
if (array == NULL || prop_array_count(array) == 0)
array = xbps_dictionary_get(filesd, keyname);
if (array == NULL || xbps_array_count(array) == 0)
continue;
for (x = 0; x < prop_array_count(array); x++) {
obj = prop_array_get(array, x);
if (prop_object_type(obj) != PROP_TYPE_DICTIONARY)
for (x = 0; x < xbps_array_count(array); x++) {
obj = xbps_array_get(array, x);
if (xbps_object_type(obj) != XBPS_TYPE_DICTIONARY)
continue;
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
xbps_dictionary_get_cstring_nocopy(obj, "file", &file);
printf("%s", file);
if (prop_dictionary_get_cstring_nocopy(obj,
if (xbps_dictionary_get_cstring_nocopy(obj,
"target", &file))
printf(" -> %s", file);
@@ -241,7 +241,7 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp,
const char *pkg,
const char *option)
{
prop_dictionary_t d, pkgdb_d;
xbps_dictionary_t d, pkgdb_d;
const char *instdate;
bool autoinst;
pkg_state_t state;
@@ -254,13 +254,13 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp,
if (d == NULL)
return ENOENT;
if (prop_dictionary_get_cstring_nocopy(pkgdb_d,
if (xbps_dictionary_get_cstring_nocopy(pkgdb_d,
"install-date", &instdate))
prop_dictionary_set_cstring_nocopy(d, "install-date",
xbps_dictionary_set_cstring_nocopy(d, "install-date",
instdate);
if (prop_dictionary_get_bool(pkgdb_d, "automatic-install", &autoinst))
prop_dictionary_set_bool(d, "automatic-install", autoinst);
if (xbps_dictionary_get_bool(pkgdb_d, "automatic-install", &autoinst))
xbps_dictionary_set_bool(d, "automatic-install", autoinst);
xbps_pkg_state_dictionary(pkgdb_d, &state);
xbps_set_pkg_state_dictionary(d, state);
@@ -276,7 +276,7 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp,
int
show_pkg_files_from_metadir(struct xbps_handle *xhp, const char *pkg)
{
prop_dictionary_t d;
xbps_dictionary_t d;
int rv = 0;
d = xbps_pkgdb_get_pkg_metadata(xhp, pkg);
@@ -293,7 +293,7 @@ repo_show_pkg_info(struct xbps_handle *xhp,
const char *pattern,
const char *option)
{
prop_dictionary_t ipkgd, bpkgd;
xbps_dictionary_t ipkgd, bpkgd;
if (((ipkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) &&
((ipkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL))
@@ -302,10 +302,10 @@ repo_show_pkg_info(struct xbps_handle *xhp,
if ((bpkgd = xbps_repo_get_pkg_plist(xhp, ipkgd, "./props.plist")) == NULL)
return errno;
prop_dictionary_set(bpkgd, "filename-sha256",
prop_dictionary_get(ipkgd, "filename-sha256"));
prop_dictionary_set(bpkgd, "filename-size",
prop_dictionary_get(ipkgd, "filename-size"));
xbps_dictionary_set(bpkgd, "filename-sha256",
xbps_dictionary_get(ipkgd, "filename-sha256"));
xbps_dictionary_set(bpkgd, "filename-size",
xbps_dictionary_get(ipkgd, "filename-size"));
if (option)
show_pkg_info_one(bpkgd, option);
@@ -318,7 +318,7 @@ repo_show_pkg_info(struct xbps_handle *xhp,
int
repo_show_pkg_files(struct xbps_handle *xhp, const char *pkg)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
pkgd = xbps_rpool_get_pkg_plist(xhp, pkg, "./files.plist");
if (pkgd == NULL) {

View File

@@ -119,7 +119,7 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata)
static int
cachedir_clean(struct xbps_handle *xhp)
{
prop_dictionary_t pkg_propsd, repo_pkgd;
xbps_dictionary_t pkg_propsd, repo_pkgd;
DIR *dirp;
struct dirent *dp;
const char *pkgver, *rsha256;
@@ -152,14 +152,14 @@ cachedir_clean(struct xbps_handle *xhp)
rv = errno;
break;
}
prop_dictionary_get_cstring_nocopy(pkg_propsd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkg_propsd, "pkgver", &pkgver);
/*
* Remove binary pkg if it's not registered in any repository
* or if hash doesn't match.
*/
repo_pkgd = xbps_rpool_get_pkg(xhp, pkgver);
if (repo_pkgd) {
prop_dictionary_get_cstring_nocopy(repo_pkgd,
xbps_dictionary_get_cstring_nocopy(repo_pkgd,
"filename-sha256", &rsha256);
if (xbps_file_hash_check(binpkg, rsha256) == ERANGE) {
printf("Removed %s from cachedir (sha256 mismatch)\n",
@@ -186,7 +186,7 @@ static int
remove_pkg(struct xbps_handle *xhp, const char *pkgname, int cols,
bool recursive)
{
prop_array_t reqby;
xbps_array_t reqby;
const char *pkgver;
unsigned int x;
int rv;
@@ -196,10 +196,10 @@ remove_pkg(struct xbps_handle *xhp, const char *pkgname, int cols,
/* pkg has revdeps */
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgname);
printf("WARNING: %s IS REQUIRED BY %u PACKAGE%s:\n\n",
pkgname, prop_array_count(reqby),
prop_array_count(reqby) > 1 ? "S" : "");
for (x = 0; x < prop_array_count(reqby); x++) {
prop_array_get_cstring_nocopy(reqby, x, &pkgver);
pkgname, xbps_array_count(reqby),
xbps_array_count(reqby) > 1 ? "S" : "");
for (x = 0; x < xbps_array_count(reqby); x++) {
xbps_array_get_cstring_nocopy(reqby, x, &pkgver);
print_package_line(pkgver, cols, false);
}
printf("\n\n");

View File

@@ -43,6 +43,6 @@ int remove_obsoletes(struct xbps_handle *, const char *);
/* From repoflush.c */
int repodata_flush(struct xbps_handle *, const char *,
prop_dictionary_t, prop_dictionary_t);
xbps_dictionary_t, xbps_dictionary_t);
#endif /* !_XBPS_RINDEX_DEFS_H_ */

View File

@@ -44,9 +44,9 @@
int
index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
{
prop_array_t filespkgar, pkg_files, pkg_links, pkg_cffiles;
prop_dictionary_t idx, idxfiles, newpkgd, newpkgfilesd, curpkgd;
prop_object_t obj, fileobj;
xbps_array_t filespkgar, pkg_files, pkg_links, pkg_cffiles;
xbps_dictionary_t idx, idxfiles, newpkgd, newpkgfilesd, curpkgd;
xbps_object_t obj, fileobj;
struct xbps_repo *repo;
struct stat st;
const char *oldpkgver, *arch, *oldarch;
@@ -72,9 +72,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
idxfiles = xbps_repo_get_plist(repo, XBPS_PKGINDEX_FILES);
}
if (idx == NULL)
idx = prop_dictionary_create();
idx = xbps_dictionary_create();
if (idxfiles == NULL)
idxfiles = prop_dictionary_create();
idxfiles = xbps_dictionary_create();
if (repo != NULL)
xbps_repo_close(repo);
@@ -92,13 +92,13 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
" skipping!\n", XBPS_PKGPROPS, argv[i]);
continue;
}
prop_dictionary_get_cstring_nocopy(newpkgd, "architecture",
xbps_dictionary_get_cstring_nocopy(newpkgd, "architecture",
&arch);
prop_dictionary_get_cstring(newpkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring(newpkgd, "pkgver", &pkgver);
if (!xbps_pkg_arch_match(xhp, arch, NULL)) {
fprintf(stderr, "index: ignoring %s, unmatched "
"arch (%s)\n", pkgver, arch);
prop_object_release(newpkgd);
xbps_object_release(newpkgd);
continue;
}
pkgname = xbps_pkg_name(pkgver);
@@ -109,7 +109,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
* than current registered package, update the index; otherwise
* pass to the next one.
*/
curpkgd = prop_dictionary_get(idx, pkgname);
curpkgd = xbps_dictionary_get(idx, pkgname);
if (curpkgd == NULL) {
if (errno && errno != ENOENT) {
free(pkgver);
@@ -118,9 +118,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
}
} else if (!force) {
/* Only check version if !force */
prop_dictionary_get_cstring_nocopy(curpkgd,
xbps_dictionary_get_cstring_nocopy(curpkgd,
"pkgver", &oldpkgver);
prop_dictionary_get_cstring_nocopy(curpkgd,
xbps_dictionary_get_cstring_nocopy(curpkgd,
"architecture", &oldarch);
ret = xbps_cmpver(pkgver, oldpkgver);
if (ret <= 0) {
@@ -128,7 +128,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
fprintf(stderr, "index: skipping `%s' "
"(%s), already registered.\n",
pkgver, arch);
prop_object_release(newpkgd);
xbps_object_release(newpkgd);
free(pkgver);
free(pkgname);
continue;
@@ -138,7 +138,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
* index version.
*/
buf = xbps_xasprintf("`%s' (%s)", oldpkgver, oldarch);
prop_dictionary_remove(idx, pkgname);
xbps_dictionary_remove(idx, pkgname);
printf("index: removed obsolete entry %s.\n", buf);
free(buf);
}
@@ -151,7 +151,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
free(pkgname);
return errno;
}
if (!prop_dictionary_set_cstring(newpkgd, "filename-sha256",
if (!xbps_dictionary_set_cstring(newpkgd, "filename-sha256",
sha256)) {
free(pkgver);
free(pkgname);
@@ -165,7 +165,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
return errno;
}
if (!prop_dictionary_set_uint64(newpkgd, "filename-size",
if (!xbps_dictionary_set_uint64(newpkgd, "filename-size",
(uint64_t)st.st_size)) {
free(pkgver);
free(pkgname);
@@ -174,23 +174,23 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
/*
* Remove obsolete package objects.
*/
prop_dictionary_remove(newpkgd, "archive-compression-type");
prop_dictionary_remove(newpkgd, "build-date");
prop_dictionary_remove(newpkgd, "build_date");
prop_dictionary_remove(newpkgd, "conf_files");
prop_dictionary_remove(newpkgd, "filename");
prop_dictionary_remove(newpkgd, "homepage");
prop_dictionary_remove(newpkgd, "license");
prop_dictionary_remove(newpkgd, "maintainer");
prop_dictionary_remove(newpkgd, "packaged-with");
prop_dictionary_remove(newpkgd, "source-revisions");
prop_dictionary_remove(newpkgd, "long_desc");
prop_dictionary_remove(newpkgd, "pkgname");
prop_dictionary_remove(newpkgd, "version");
xbps_dictionary_remove(newpkgd, "archive-compression-type");
xbps_dictionary_remove(newpkgd, "build-date");
xbps_dictionary_remove(newpkgd, "build_date");
xbps_dictionary_remove(newpkgd, "conf_files");
xbps_dictionary_remove(newpkgd, "filename");
xbps_dictionary_remove(newpkgd, "homepage");
xbps_dictionary_remove(newpkgd, "license");
xbps_dictionary_remove(newpkgd, "maintainer");
xbps_dictionary_remove(newpkgd, "packaged-with");
xbps_dictionary_remove(newpkgd, "source-revisions");
xbps_dictionary_remove(newpkgd, "long_desc");
xbps_dictionary_remove(newpkgd, "pkgname");
xbps_dictionary_remove(newpkgd, "version");
/*
* Add new pkg dictionary into the index.
*/
if (!prop_dictionary_set(idx, pkgname, newpkgd)) {
if (!xbps_dictionary_set(idx, pkgname, newpkgd)) {
free(pkgname);
return EINVAL;
}
@@ -209,68 +209,68 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
}
/* Find out if binary pkg stored in index contain any file */
pkg_cffiles = prop_dictionary_get(newpkgfilesd, "conf_files");
if (prop_array_count(pkg_cffiles))
pkg_cffiles = xbps_dictionary_get(newpkgfilesd, "conf_files");
if (xbps_array_count(pkg_cffiles))
found = true;
else
pkg_cffiles = NULL;
pkg_files = prop_dictionary_get(newpkgfilesd, "files");
if (prop_array_count(pkg_files))
pkg_files = xbps_dictionary_get(newpkgfilesd, "files");
if (xbps_array_count(pkg_files))
found = true;
else
pkg_files = NULL;
pkg_links = prop_dictionary_get(newpkgfilesd, "links");
if (prop_array_count(pkg_links))
pkg_links = xbps_dictionary_get(newpkgfilesd, "links");
if (xbps_array_count(pkg_links))
found = true;
else
pkg_links = NULL;
/* If pkg does not contain any file, ignore it */
if (!found) {
prop_object_release(newpkgfilesd);
prop_object_release(newpkgd);
xbps_object_release(newpkgfilesd);
xbps_object_release(newpkgd);
free(pkgver);
free(pkgname);
continue;
}
/* create pkg files array */
filespkgar = prop_array_create();
filespkgar = xbps_array_create();
assert(filespkgar);
/* add conf_files in pkg files array */
if (pkg_cffiles != NULL) {
for (x = 0; x < prop_array_count(pkg_cffiles); x++) {
obj = prop_array_get(pkg_cffiles, x);
fileobj = prop_dictionary_get(obj, "file");
prop_array_add(filespkgar, fileobj);
for (x = 0; x < xbps_array_count(pkg_cffiles); x++) {
obj = xbps_array_get(pkg_cffiles, x);
fileobj = xbps_dictionary_get(obj, "file");
xbps_array_add(filespkgar, fileobj);
}
}
/* add files array in pkg array */
if (pkg_files != NULL) {
for (x = 0; x < prop_array_count(pkg_files); x++) {
obj = prop_array_get(pkg_files, x);
fileobj = prop_dictionary_get(obj, "file");
prop_array_add(filespkgar, fileobj);
for (x = 0; x < xbps_array_count(pkg_files); x++) {
obj = xbps_array_get(pkg_files, x);
fileobj = xbps_dictionary_get(obj, "file");
xbps_array_add(filespkgar, fileobj);
}
}
/* add links array in pkgd */
if (pkg_links != NULL) {
for (x = 0; x < prop_array_count(pkg_links); x++) {
obj = prop_array_get(pkg_links, x);
fileobj = prop_dictionary_get(obj, "file");
prop_array_add(filespkgar, fileobj);
for (x = 0; x < xbps_array_count(pkg_links); x++) {
obj = xbps_array_get(pkg_links, x);
fileobj = xbps_dictionary_get(obj, "file");
xbps_array_add(filespkgar, fileobj);
}
}
prop_object_release(newpkgfilesd);
xbps_object_release(newpkgfilesd);
/* add pkg files array into index-files */
prop_dictionary_set(idxfiles, pkgver, filespkgar);
prop_object_release(filespkgar);
xbps_dictionary_set(idxfiles, pkgver, filespkgar);
xbps_object_release(filespkgar);
printf("index-files: added `%s' (%s)\n", pkgver, arch);
prop_object_release(newpkgd);
xbps_object_release(newpkgd);
free(pkgver);
free(pkgname);
}
@@ -283,12 +283,12 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
return rv;
}
printf("index: %u packages registered.\n",
prop_dictionary_count(idx));
xbps_dictionary_count(idx));
printf("index-files: %u packages registered.\n",
prop_dictionary_count(idxfiles));
xbps_dictionary_count(idxfiles));
prop_object_release(idx);
prop_object_release(idxfiles);
xbps_object_release(idx);
xbps_object_release(idxfiles);
return 0;
}

View File

@@ -40,10 +40,10 @@
struct thread_data {
pthread_t thread;
prop_dictionary_t idx;
prop_dictionary_t idxfiles;
prop_array_t result;
prop_array_t result_files;
xbps_dictionary_t idx;
xbps_dictionary_t idxfiles;
xbps_array_t result;
xbps_array_t result_files;
struct xbps_handle *xhp;
unsigned int start;
unsigned int end;
@@ -53,22 +53,22 @@ struct thread_data {
static void *
cleaner_thread(void *arg)
{
prop_object_t obj;
prop_dictionary_t pkgd;
prop_array_t array;
xbps_object_t obj;
xbps_dictionary_t pkgd;
xbps_array_t array;
struct thread_data *thd = arg;
char *filen;
const char *pkgver, *arch, *sha256;
unsigned int i;
/* process pkgs from start until end */
array = prop_dictionary_all_keys(thd->idx);
array = xbps_dictionary_all_keys(thd->idx);
for (i = thd->start; i < thd->end; i++) {
obj = prop_array_get(array, i);
pkgd = prop_dictionary_get_keysym(thd->idx, obj);
prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
obj = xbps_array_get(array, i);
pkgd = xbps_dictionary_get_keysym(thd->idx, obj);
xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
filen = xbps_xasprintf("%s.%s.xbps", pkgver, arch);
xbps_dbg_printf(thd->xhp, "thread[%d] checking %s\n",
thd->thread_num, pkgver);
@@ -77,20 +77,20 @@ cleaner_thread(void *arg)
* File cannot be read, might be permissions,
* broken or simply unexistent; either way, remove it.
*/
prop_array_add_cstring_nocopy(thd->result, pkgver);
xbps_array_add_cstring_nocopy(thd->result, pkgver);
free(filen);
continue;
}
/*
* File can be read; check its hash.
*/
prop_dictionary_get_cstring_nocopy(pkgd,
xbps_dictionary_get_cstring_nocopy(pkgd,
"filename-sha256", &sha256);
if (xbps_file_hash_check(filen, sha256) != 0)
prop_array_add_cstring_nocopy(thd->result, pkgver);
xbps_array_add_cstring_nocopy(thd->result, pkgver);
free(filen);
}
prop_object_release(array);
xbps_object_release(array);
return NULL;
}
@@ -98,35 +98,35 @@ cleaner_thread(void *arg)
static void *
cleaner_files_thread(void *arg)
{
prop_object_t obj;
prop_array_t array;
prop_dictionary_t ipkgd;
xbps_object_t obj;
xbps_array_t array;
xbps_dictionary_t ipkgd;
struct thread_data *thd = arg;
const char *pkgver, *ipkgver;
char *pkgname;
unsigned int i;
/* process pkgs from start until end */
array = prop_dictionary_all_keys(thd->idxfiles);
array = xbps_dictionary_all_keys(thd->idxfiles);
for (i = thd->start; i < thd->end; i++) {
obj = prop_array_get(array, i);
pkgver = prop_dictionary_keysym_cstring_nocopy(obj);
obj = xbps_array_get(array, i);
pkgver = xbps_dictionary_keysym_cstring_nocopy(obj);
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
ipkgd = prop_dictionary_get(thd->idx, pkgname);
ipkgd = xbps_dictionary_get(thd->idx, pkgname);
/* If pkg is not registered in index, remove it */
if (ipkgd == NULL)
prop_array_add_cstring_nocopy(thd->result_files, pkgver);
xbps_array_add_cstring_nocopy(thd->result_files, pkgver);
/* if another version is registered in index, remove it */
else {
prop_dictionary_get_cstring_nocopy(ipkgd, "pkgver", &ipkgver);
xbps_dictionary_get_cstring_nocopy(ipkgd, "pkgver", &ipkgver);
if (strcmp(ipkgver, pkgver))
prop_array_add_cstring_nocopy(thd->result_files, pkgver);
xbps_array_add_cstring_nocopy(thd->result_files, pkgver);
}
free(pkgname);
}
prop_object_release(array);
xbps_object_release(array);
return NULL;
}
@@ -140,7 +140,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
{
struct xbps_repo *repo;
struct thread_data *thd;
prop_dictionary_t idx, idxfiles;
xbps_dictionary_t idx, idxfiles;
const char *keyname;
char *pkgname;
unsigned int x, pkgcount, slicecount;
@@ -171,18 +171,18 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN);
thd = calloc(maxthreads, sizeof(*thd));
slicecount = prop_dictionary_count(idx) / maxthreads;
slicecount = xbps_dictionary_count(idx) / maxthreads;
pkgcount = 0;
/* Setup threads to cleanup index and index-files */
for (i = 0; i < maxthreads; i++) {
thd[i].thread_num = i;
thd[i].idx = idx;
thd[i].result = prop_array_create();
thd[i].result = xbps_array_create();
thd[i].xhp = xhp;
thd[i].start = pkgcount;
if (i + 1 >= maxthreads)
thd[i].end = prop_dictionary_count(idx);
thd[i].end = xbps_dictionary_count(idx);
else
thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL, cleaner_thread, &thd[i]);
@@ -193,18 +193,18 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
pthread_join(thd[i].thread, NULL);
/* Setup threads to cleanup index-files */
slicecount = prop_dictionary_count(idxfiles) / maxthreads;
slicecount = xbps_dictionary_count(idxfiles) / maxthreads;
pkgcount = 0;
for (i = 0; i < maxthreads; i++) {
thd[i].thread_num = i;
thd[i].idx = idx;
thd[i].idxfiles = idxfiles;
thd[i].result_files = prop_array_create();
thd[i].result_files = xbps_array_create();
thd[i].xhp = xhp;
thd[i].start = pkgcount;
if (i + 1 >= maxthreads)
thd[i].end = prop_dictionary_count(idxfiles);
thd[i].end = xbps_dictionary_count(idxfiles);
else
thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL, cleaner_files_thread, &thd[i]);
@@ -215,21 +215,21 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
pthread_join(thd[i].thread, NULL);
for (i = 0; i < maxthreads; i++) {
for (x = 0; x < prop_array_count(thd[i].result); x++) {
prop_array_get_cstring_nocopy(thd[i].result,
for (x = 0; x < xbps_array_count(thd[i].result); x++) {
xbps_array_get_cstring_nocopy(thd[i].result,
x, &keyname);
printf("index: removed entry %s\n", keyname);
pkgname = xbps_pkg_name(keyname);
prop_dictionary_remove(idx, pkgname);
prop_dictionary_remove(idxfiles, keyname);
xbps_dictionary_remove(idx, pkgname);
xbps_dictionary_remove(idxfiles, keyname);
free(pkgname);
flush = true;
}
for (x = 0; x < prop_array_count(thd[i].result_files); x++) {
prop_array_get_cstring_nocopy(thd[i].result_files,
for (x = 0; x < xbps_array_count(thd[i].result_files); x++) {
xbps_array_get_cstring_nocopy(thd[i].result_files,
x, &keyname);
printf("index-files: removed entry %s\n", keyname);
prop_dictionary_remove(idxfiles, keyname);
xbps_dictionary_remove(idxfiles, keyname);
flush = true;
}
}
@@ -239,11 +239,11 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
return rv;
}
printf("index: %u packages registered.\n",
prop_dictionary_count(idx));
xbps_dictionary_count(idx));
printf("index-files: %u packages registered.\n",
prop_dictionary_count(idxfiles));
prop_object_release(idx);
prop_object_release(idxfiles);
xbps_dictionary_count(idxfiles));
xbps_object_release(idx);
xbps_object_release(idxfiles);
return rv;
}

View File

@@ -39,7 +39,7 @@
struct thread_data {
pthread_t thread;
prop_array_t array;
xbps_array_t array;
struct xbps_repo *repo;
unsigned int start;
unsigned int end;
@@ -84,7 +84,7 @@ remove_pkg(const char *repodir, const char *arch, const char *file)
static void *
cleaner_thread(void *arg)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
struct thread_data *thd = arg;
const char *binpkg, *pkgver, *arch;
unsigned int i;
@@ -92,21 +92,21 @@ cleaner_thread(void *arg)
/* process pkgs from start until end */
for (i = thd->start; i < thd->end; i++) {
prop_array_get_cstring_nocopy(thd->array, i, &binpkg);
xbps_array_get_cstring_nocopy(thd->array, i, &binpkg);
pkgd = xbps_get_pkg_plist_from_binpkg(binpkg, "./props.plist");
if (pkgd == NULL) {
rv = remove_pkg(thd->repo->uri, arch, binpkg);
if (rv != 0) {
prop_object_release(pkgd);
xbps_object_release(pkgd);
continue;
}
printf("Removed broken package `%s'.\n", binpkg);
}
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
/* ignore pkgs from other archs */
if (!xbps_pkg_arch_match(thd->repo->xhp, arch, NULL)) {
prop_object_release(pkgd);
xbps_object_release(pkgd);
continue;
}
xbps_dbg_printf(thd->repo->xhp, "thread[%d] checking %s (%s)\n",
@@ -117,12 +117,12 @@ cleaner_thread(void *arg)
if (!xbps_repo_get_pkg(thd->repo, pkgver)) {
rv = remove_pkg(thd->repo->uri, arch, binpkg);
if (rv != 0) {
prop_object_release(pkgd);
xbps_object_release(pkgd);
continue;
}
printf("Removed obsolete package `%s'.\n", binpkg);
}
prop_object_release(pkgd);
xbps_object_release(pkgd);
}
return NULL;
@@ -131,7 +131,7 @@ cleaner_thread(void *arg)
int
remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
{
prop_array_t array = NULL;
xbps_array_t array = NULL;
struct xbps_repo *repo;
struct thread_data *thd;
DIR *dirp;
@@ -171,16 +171,16 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
if (strcmp(ext, ".xbps"))
continue;
if (array == NULL)
array = prop_array_create();
array = xbps_array_create();
prop_array_add_cstring(array, dp->d_name);
xbps_array_add_cstring(array, dp->d_name);
}
(void)closedir(dirp);
maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN);
thd = calloc(maxthreads, sizeof(*thd));
slicecount = prop_array_count(array) / maxthreads;
slicecount = xbps_array_count(array) / maxthreads;
pkgcount = 0;
for (i = 0; i < maxthreads; i++) {
@@ -189,7 +189,7 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
thd[i].repo = repo;
thd[i].start = pkgcount;
if (i + 1 >= maxthreads)
thd[i].end = prop_array_count(array);
thd[i].end = xbps_array_count(array);
else
thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL, cleaner_thread, &thd[i]);

View File

@@ -39,7 +39,7 @@
int
repodata_flush(struct xbps_handle *xhp, const char *repodir,
prop_dictionary_t idx, prop_dictionary_t idxfiles)
xbps_dictionary_t idx, xbps_dictionary_t idxfiles)
{
struct archive *ar;
mode_t myumask;
@@ -60,7 +60,7 @@ repodata_flush(struct xbps_handle *xhp, const char *repodir,
archive_write_set_options(ar, "compression-level=9");
archive_write_open_fd(ar, repofd);
xml = prop_dictionary_externalize(idx);
xml = xbps_dictionary_externalize(idx);
assert(xml);
if (xbps_archive_append_buf(ar, xml, strlen(xml),
XBPS_PKGINDEX, 0644, "root", "root") != 0) {
@@ -69,7 +69,7 @@ repodata_flush(struct xbps_handle *xhp, const char *repodir,
}
free(xml);
xml = prop_dictionary_externalize(idxfiles);
xml = xbps_dictionary_externalize(idxfiles);
assert(xml);
if (xbps_archive_append_buf(ar, xml, strlen(xml),
XBPS_PKGINDEX_FILES, 0644, "root", "root") != 0) {

View File

@@ -37,12 +37,12 @@
#include "../xbps-install/defs.h"
static void
write_plist_file(prop_dictionary_t dict, const char *file)
write_plist_file(xbps_dictionary_t dict, const char *file)
{
assert(dict != NULL || file != NULL);
if (!prop_dictionary_externalize_to_zfile(dict, file)) {
prop_object_release(dict);
if (!xbps_dictionary_externalize_to_zfile(dict, file)) {
xbps_object_release(dict);
xbps_error_printf("xbps-uhelper: couldn't write to %s: %s\n",
file, strerror(errno));
exit(EXIT_FAILURE);
@@ -97,7 +97,7 @@ usage(void)
int
main(int argc, char **argv)
{
prop_dictionary_t dict;
xbps_dictionary_t dict;
struct xbps_handle xh;
struct xferstat xfer;
const char *version, *rootdir = NULL, *confdir = NULL;
@@ -159,14 +159,14 @@ main(int argc, char **argv)
(((dict = xbps_pkgdb_get_virtualpkg(&xh, argv[1])) == NULL)))
exit(EXIT_FAILURE);
prop_dictionary_get_cstring_nocopy(dict, "pkgver", &version);
xbps_dictionary_get_cstring_nocopy(dict, "pkgver", &version);
printf("%s\n", xbps_pkg_version(version));
} else if (strcasecmp(argv[0], "sanitize-plist") == 0) {
/* Sanitize a plist file (properly indent the file) */
if (argc != 2)
usage();
dict = prop_dictionary_internalize_from_zfile(argv[1]);
dict = xbps_dictionary_internalize_from_zfile(argv[1]);
if (dict == NULL) {
fprintf(stderr,
"=> ERROR: couldn't sanitize %s plist file "