From aa21cb08fd1714496c307823239ac19d381c4913 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Fri, 6 Jul 2018 08:07:59 +0200 Subject: [PATCH] Revert "bin/xbps-create: process dictionary instead of linked list." This reverts commit 25fa00ea461d85e3387be372c2dd77acc6685ca7. --- bin/xbps-create/main.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c index 94c4e0ac..59c67e8e 100644 --- a/bin/xbps-create/main.c +++ b/bin/xbps-create/main.c @@ -493,34 +493,31 @@ out: static void process_xentry(const char *key, const char *mutable_files) { - xbps_object_iterator_t iter; - xbps_object_t filepathk; xbps_array_t a; - xbps_dictionary_t fileinfo; - char *saveptr, *args, *tok; - const char *p; + xbps_dictionary_t d; + struct xentry *xe; + char *p, *saveptr, *args, *tok; bool found = false, mutable_found = false; a = xbps_array_create(); assert(a); - iter = xbps_dictionary_iterator(all_filesd); - 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)) + TAILQ_FOREACH_REVERSE(xe, &xentry_list, xentry_head, entries) { + if (strcmp(xe->type, key)) continue; found = true; - xbps_dictionary_get_cstring_nocopy(fileinfo, "file", &p); + d = xbps_dictionary_create(); + assert(d); + /* sanitize file path */ + p = strchr(xe->file, '.') + 1; /* * Find out if this file is mutable. */ if (mutable_files) { if ((strchr(mutable_files, ' ') == NULL) && (strcmp(mutable_files, p) == 0)) - xbps_dictionary_set_bool(fileinfo, "mutable", true); + xbps_dictionary_set_bool(d, "mutable", true); else { args = strdup(mutable_files); assert(args); @@ -533,21 +530,23 @@ process_xentry(const char *key, const char *mutable_files) } free(args); if (mutable_found) { - xbps_dictionary_set_bool(fileinfo, "mutable", + xbps_dictionary_set_bool(d, "mutable", true); mutable_found = false; } } } - /* - * Clean up dictionary - */ - xbps_dictionary_remove(fileinfo, "inode"); + xbps_dictionary_set_cstring(d, "file", p); + if (xe->target) + xbps_dictionary_set_cstring(d, "target", xe->target); + if (xe->hash) + xbps_dictionary_set_cstring(d, "sha256", xe->hash); + if (xe->mtime) + xbps_dictionary_set_uint64(d, "mtime", xe->mtime); - xbps_array_add(a, fileinfo); - xbps_object_release(fileinfo); + xbps_array_add(a, d); + xbps_object_release(d); } - xbps_object_iterator_release(iter); if (found) xbps_dictionary_set(pkg_filesd, key, a);