Bug 5324 - dpkg creates empty .list files
Summary: dpkg creates empty .list files
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.19.x
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-20 11:42 UTC by Sergei
Modified: 2012-06-22 14:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei 2012-06-20 11:42:10 UTC
This bug was introduced in commit 
b768aeb164d361d1ca2c8f6c091e93442f072656
tar: make typical extraction less memory-hungry

My workaround (this patch also implements proprly sorting of filenames):

diff --git a/archival/dpkg.c b/archival/dpkg.c
index 2a6a7b3..0604637 100644
@@ -1666,6 +1666,7 @@ static void unpack_package(deb_file_t *deb_file)
 	init_archive_deb_data(archive_handle);
 	archive_handle->dpkg__sub_archive->accept = conffile_list;
 	archive_handle->dpkg__sub_archive->filter = filter_rename_config;
+	archive_handle->dpkg__sub_archive->reject = (void *) 1; /* dirty hack */
 	archive_handle->dpkg__sub_archive->action_data = data_extract_all_prefix;
 	archive_handle->dpkg__sub_archive->dpkg__buffer = (char*)"/"; /* huh? */
 	archive_handle->dpkg__sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD;
@@ -1674,11 +1675,14 @@ static void unpack_package(deb_file_t *deb_file)
 	/* Create the list file */
 	list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
 	out_stream = xfopen_for_write(list_filename);
+	archive_handle->dpkg__sub_archive->passed =
+		llist_rev(archive_handle->dpkg__sub_archive->passed);
 	while (archive_handle->dpkg__sub_archive->passed) {
+		char *filename = llist_pop(&archive_handle->dpkg__sub_archive->passed);
 		/* the leading . has been stripped by data_extract_all_prefix already */
-		fputs(archive_handle->dpkg__sub_archive->passed->data, out_stream);
+		fputs(filename, out_stream);
 		fputc('\n', out_stream);
-		archive_handle->dpkg__sub_archive->passed = archive_handle->dpkg__sub_archive->passed->link;
+		free(filename);
 	}
 	fclose(out_stream);
Comment 1 Denys Vlasenko 2012-06-22 14:29:18 UTC
Thanks!

Fixed in git:

commit 440a509849391f2dc8ec720a136577ede3306fa8
Author: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Fri Jun 22 16:27:21 2012 +0200

    dpkg: fix creation of .list files (were empty since b768aeb)