bin/xbps-create: process dictionary instead of linked list.
This commit is contained in:
parent
b2c7fa8846
commit
25fa00ea46
@ -492,31 +492,34 @@ out:
|
|||||||
static void
|
static void
|
||||||
process_xentry(const char *key, const char *mutable_files)
|
process_xentry(const char *key, const char *mutable_files)
|
||||||
{
|
{
|
||||||
|
xbps_object_iterator_t iter;
|
||||||
|
xbps_object_t filepathk;
|
||||||
xbps_array_t a;
|
xbps_array_t a;
|
||||||
xbps_dictionary_t d;
|
xbps_dictionary_t fileinfo;
|
||||||
struct xentry *xe;
|
char *saveptr, *args, *tok;
|
||||||
char *p, *saveptr, *args, *tok;
|
const char *p;
|
||||||
bool found = false, mutable_found = false;
|
bool found = false, mutable_found = false;
|
||||||
|
|
||||||
a = xbps_array_create();
|
a = xbps_array_create();
|
||||||
assert(a);
|
assert(a);
|
||||||
|
|
||||||
TAILQ_FOREACH_REVERSE(xe, &xentry_list, xentry_head, entries) {
|
iter = xbps_dictionary_iterator(all_filesd);
|
||||||
if (strcmp(xe->type, key))
|
assert(iter);
|
||||||
|
while ((filepathk = xbps_object_iterator_next(iter))) {
|
||||||
|
fileinfo = xbps_dictionary_get_keysym(all_filesd, filepathk);
|
||||||
|
|
||||||
|
if (!xbps_string_equals_cstring(xbps_dictionary_get(fileinfo, "type"), key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
d = xbps_dictionary_create();
|
xbps_dictionary_get_cstring_nocopy(fileinfo, "file", &p);
|
||||||
assert(d);
|
|
||||||
/* sanitize file path */
|
|
||||||
p = strchr(xe->file, '.') + 1;
|
|
||||||
/*
|
/*
|
||||||
* Find out if this file is mutable.
|
* Find out if this file is mutable.
|
||||||
*/
|
*/
|
||||||
if (mutable_files) {
|
if (mutable_files) {
|
||||||
if ((strchr(mutable_files, ' ') == NULL) &&
|
if ((strchr(mutable_files, ' ') == NULL) &&
|
||||||
(strcmp(mutable_files, p) == 0))
|
(strcmp(mutable_files, p) == 0))
|
||||||
xbps_dictionary_set_bool(d, "mutable", true);
|
xbps_dictionary_set_bool(fileinfo, "mutable", true);
|
||||||
else {
|
else {
|
||||||
args = strdup(mutable_files);
|
args = strdup(mutable_files);
|
||||||
assert(args);
|
assert(args);
|
||||||
@ -529,23 +532,21 @@ process_xentry(const char *key, const char *mutable_files)
|
|||||||
}
|
}
|
||||||
free(args);
|
free(args);
|
||||||
if (mutable_found) {
|
if (mutable_found) {
|
||||||
xbps_dictionary_set_bool(d, "mutable",
|
xbps_dictionary_set_bool(fileinfo, "mutable",
|
||||||
true);
|
true);
|
||||||
mutable_found = false;
|
mutable_found = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xbps_dictionary_set_cstring(d, "file", p);
|
/*
|
||||||
if (xe->target)
|
* Clean up dictionary
|
||||||
xbps_dictionary_set_cstring(d, "target", xe->target);
|
*/
|
||||||
if (xe->hash)
|
xbps_dictionary_remove(fileinfo, "inode");
|
||||||
xbps_dictionary_set_cstring(d, "sha256", xe->hash);
|
|
||||||
if (xe->mtime)
|
|
||||||
xbps_dictionary_set_uint64(d, "mtime", xe->mtime);
|
|
||||||
|
|
||||||
xbps_array_add(a, d);
|
xbps_array_add(a, fileinfo);
|
||||||
xbps_object_release(d);
|
xbps_object_release(fileinfo);
|
||||||
}
|
}
|
||||||
|
xbps_object_iterator_release(iter);
|
||||||
if (found)
|
if (found)
|
||||||
xbps_dictionary_set(pkg_filesd, key, a);
|
xbps_dictionary_set(pkg_filesd, key, a);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user