bin/xbps-create: process_entry_file uses dictionary instead of linked list now.

This commit is contained in:
Enno Boland
2016-03-27 11:15:07 +02:00
parent 25fa00ea46
commit 61d2361646

View File

@ -608,7 +608,7 @@ write_entry(struct archive *ar, struct archive_entry *entry)
static void static void
process_entry_file(struct archive *ar, process_entry_file(struct archive *ar,
struct archive_entry_linkresolver *resolver, struct archive_entry_linkresolver *resolver,
struct xentry *xe, const char *filematch) const char *filename)
{ {
struct archive_entry *entry, *sparse_entry; struct archive_entry *entry, *sparse_entry;
struct stat st; struct stat st;
@ -616,18 +616,14 @@ process_entry_file(struct archive *ar,
ssize_t len; ssize_t len;
assert(ar); assert(ar);
assert(xe);
if (filematch && strcmp(xe->file, filematch)) p = xbps_xasprintf("%s/%s", destdir, filename);
return;
p = xbps_xasprintf("%s/%s", destdir, xe->file);
if (lstat(p, &st) == -1) if (lstat(p, &st) == -1)
die("failed to add entry (fstat) %s to archive:", xe->file); die("failed to add entry (fstat) %s to archive:", filename);
entry = archive_entry_new(); entry = archive_entry_new();
assert(entry); assert(entry);
archive_entry_set_pathname(entry, xe->file); archive_entry_set_pathname(entry, filename);
if (st.st_uid == geteuid()) if (st.st_uid == geteuid())
st.st_uid = 0; st.st_uid = 0;
if (st.st_gid == getegid()) if (st.st_gid == getegid())
@ -646,7 +642,7 @@ process_entry_file(struct archive *ar,
len = readlink(p, buf, st.st_size+1); len = readlink(p, buf, st.st_size+1);
if (len < 0 || len > st.st_size) if (len < 0 || len > st.st_size)
die("failed to add entry %s (readlink) to archive:", die("failed to add entry %s (readlink) to archive:",
xe->file); filename);
buf[len] = '\0'; buf[len] = '\0';
archive_entry_set_symlink(entry, buf); archive_entry_set_symlink(entry, buf);
} }
@ -667,14 +663,17 @@ process_archive(struct archive *ar,
struct archive_entry_linkresolver *resolver, struct archive_entry_linkresolver *resolver,
const char *pkgver, bool quiet) const char *pkgver, bool quiet)
{ {
struct xentry *xe;
char *xml; 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 */ /* Add INSTALL/REMOVE metadata scripts first */
TAILQ_FOREACH(xe, &xentry_list, entries) { if (xbps_dictionary_get(all_filesd, "./INSTALL"))
process_entry_file(ar, resolver, xe, "./INSTALL"); process_entry_file(ar, resolver, "./INSTALL");
process_entry_file(ar, resolver, xe, "./REMOVE"); if (xbps_dictionary_get(all_filesd, "./REMOVE"))
} process_entry_file(ar, resolver, "./REMOVE");
/* /*
* Add the installed-size object. * Add the installed-size object.
*/ */
@ -696,18 +695,23 @@ process_archive(struct archive *ar,
free(xml); free(xml);
/* Add all package data files and release resources */ /* Add all package data files and release resources */
while ((xe = TAILQ_FIRST(&xentry_list)) != NULL) { iter = xbps_dictionary_iterator(all_filesd);
TAILQ_REMOVE(&xentry_list, xe, entries); assert(iter);
if ((strcmp(xe->type, "metadata") == 0) || while ((filepathk = xbps_object_iterator_next(iter))) {
(strcmp(xe->type, "dirs") == 0)) 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"))
continue; continue;
if (!quiet) { if (!quiet) {
printf("%s: adding `%s' ...\n", pkgver, xe->file); xbps_dictionary_get_cstring_nocopy(fileinfo, "file", &p);
printf("%s: adding `%s' ...\n", pkgver, p);
fflush(stdout); fflush(stdout);
} }
process_entry_file(ar, resolver, xe, NULL); process_entry_file(ar, resolver, filepath);
} }
xbps_object_iterator_release(iter);
} }
int int