From 705a30c63cd0a15b0668db9afcd0ef528daaefd5 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Fri, 6 Jul 2018 08:07:58 +0200 Subject: [PATCH] Revert "bin/xbps-create: process_entry_file uses dictionary instead of linked list now." This reverts commit 61d23616467615bb029199d3f044b445e22eac7d. --- bin/xbps-create/main.c | 44 +++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c index 6ae5996b..94c4e0ac 100644 --- a/bin/xbps-create/main.c +++ b/bin/xbps-create/main.c @@ -615,7 +615,7 @@ write_entry(struct archive *ar, struct archive_entry *entry) static void process_entry_file(struct archive *ar, struct archive_entry_linkresolver *resolver, - const char *filename) + struct xentry *xe, const char *filematch) { struct archive_entry *entry, *sparse_entry; struct stat st; @@ -623,14 +623,18 @@ process_entry_file(struct archive *ar, ssize_t len; assert(ar); + assert(xe); - p = xbps_xasprintf("%s/%s", destdir, filename); + if (filematch && strcmp(xe->file, filematch)) + return; + + p = xbps_xasprintf("%s/%s", destdir, xe->file); if (lstat(p, &st) == -1) - die("failed to add entry (fstat) %s to archive:", filename); + die("failed to add entry (fstat) %s to archive:", xe->file); entry = archive_entry_new(); assert(entry); - archive_entry_set_pathname(entry, filename); + archive_entry_set_pathname(entry, xe->file); if (st.st_uid == geteuid()) st.st_uid = 0; if (st.st_gid == getegid()) @@ -649,7 +653,7 @@ process_entry_file(struct archive *ar, len = readlink(p, buf, st.st_size+1); if (len < 0 || len > st.st_size) die("failed to add entry %s (readlink) to archive:", - filename); + xe->file); buf[len] = '\0'; archive_entry_set_symlink(entry, buf); } @@ -670,17 +674,14 @@ process_archive(struct archive *ar, struct archive_entry_linkresolver *resolver, const char *pkgver, bool quiet) { + struct xentry *xe; char *xml; - const char *filepath, *p; - xbps_object_iterator_t iter; - xbps_object_t filepathk; - xbps_dictionary_t fileinfo; /* Add INSTALL/REMOVE metadata scripts first */ - if (xbps_dictionary_get(all_filesd, "./INSTALL")) - process_entry_file(ar, resolver, "./INSTALL"); - if (xbps_dictionary_get(all_filesd, "./REMOVE")) - process_entry_file(ar, resolver, "./REMOVE"); + TAILQ_FOREACH(xe, &xentry_list, entries) { + process_entry_file(ar, resolver, xe, "./INSTALL"); + process_entry_file(ar, resolver, xe, "./REMOVE"); + } /* * Add the installed-size object. */ @@ -702,23 +703,18 @@ process_archive(struct archive *ar, free(xml); /* Add all package data files and release resources */ - iter = xbps_dictionary_iterator(all_filesd); - assert(iter); - while ((filepathk = xbps_object_iterator_next(iter))) { - filepath = xbps_dictionary_keysym_cstring_nocopy(filepathk); - fileinfo = xbps_dictionary_get_keysym(all_filesd, filepathk); - if (xbps_string_equals_cstring(xbps_dictionary_get(fileinfo, "type"), "metadata") || - xbps_string_equals_cstring(xbps_dictionary_get(fileinfo, "type"), "dirs")) + while ((xe = TAILQ_FIRST(&xentry_list)) != NULL) { + TAILQ_REMOVE(&xentry_list, xe, entries); + if ((strcmp(xe->type, "metadata") == 0) || + (strcmp(xe->type, "dirs") == 0)) continue; if (!quiet) { - xbps_dictionary_get_cstring_nocopy(fileinfo, "file", &p); - printf("%s: adding `%s' ...\n", pkgver, p); + printf("%s: adding `%s' ...\n", pkgver, xe->file); fflush(stdout); } - process_entry_file(ar, resolver, filepath); + process_entry_file(ar, resolver, xe, NULL); } - xbps_object_iterator_release(iter); } int