git.iko.soy/typeable/nixpkgs
on master help sign in
squashfsTools: make alignment patch apply to 4.4

I took the patch, and applied it on top of the previous squashfs-tools commit that we packaged (which required editing one line in the patch, as it assumed to be applied on top of the reproducibility patches). Then I rebased that on top of master, resolved one conflict, and I formatted a new patch for this.

commita60ee9a74c8f9305469e2b8962aef05f33f64afc authorRuud van Asseldonk <dev@veniogames.com> dateSat 7 Sep 2019, 18:58 (7 years ago) parent442cf4f
2 files changed+32−22
pkgs/tools/filesystems/squashfs/squashfs-tools-4.4-4k-align.patch → pkgs/tools/filesystems/squashfs/4k-align.patch+31−20 pkgs/tools/filesystems/squashfs/default.nix+1−2
pkgs/tools/filesystems/squashfs/squashfs-tools-4.4-4k-align.patch → pkgs/tools/filesystems/squashfs/4k-align.patchrenamed+31−20
@@ -1,3 +1,7 @@
1+This patch has been edited to apply to squashfs 4.4, commit
2+52eb4c279cd283ed9802dd1ceb686560b22ffb67. Below is the original
3+message body of the patch.
4+
15From 7bda7c75748f36b0a50f93e46144d5a4de4974ad Mon Sep 17 00:00:00 2001
26From: Amin Hassani <ahassani@google.com>
37Date: Thu, 15 Dec 2016 10:43:15 -0800
@@ -16,20 +20,24 @@ increased_size = (number_of_unfragmented_files_in_image + number of fragments) *
1620
1721The 4k alignment can be enabled by flag '-4k-align'
1822---
19−diff -u a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
20−--- a/squashfs-tools/mksquashfs.c 2019-07-06 15:50:22.214873176 +0000
21−+++ b/squashfs-tools/mksquashfs.c 2019-07-06 15:51:22.244802582 +0000
22−@@ -100,7 +100,9 @@
23+ squashfs-tools/mksquashfs.c | 16 ++++++++++++++++
24+ 1 file changed, 16 insertions(+)
25+
26+diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
27+index a45b77f..07b1c06 100644
28+--- a/squashfs-tools/mksquashfs.c
29++++ b/squashfs-tools/mksquashfs.c
30+@@ -102,7 +102,9 @@ int old_exclude = TRUE;
2331 int use_regex = FALSE;
2432 int nopad = FALSE;
2533 int exit_on_error = FALSE;
2634+int do_4k_align = FALSE;
27− static off_t squashfs_start_offset = 0;
35+ long long start_offset = 0;
2836+#define ALIGN_UP(bytes, size) (bytes = (bytes + size - 1) & ~(size - 1))
2937
3038 long long global_uid = -1, global_gid = -1;
3139
32−@@ -1495,6 +1497,9 @@
40+@@ -1546,6 +1548,9 @@ void unlock_fragments()
3341 * queue at this time.
3442 */
3543 while(!queue_empty(locked_fragment)) {
@@ -39,17 +47,17 @@ diff -u a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
3947 write_buffer = queue_get(locked_fragment);
4048 frg = write_buffer->block;
4149 size = SQUASHFS_COMPRESSED_SIZE_BLOCK(fragment_table[frg].size);
42−@@ -2414,6 +2419,9 @@
43− compressed_size = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
44− write_buffer->size = compressed_size;
45− if(fragments_locked == FALSE) {
46−+ // 4k align the start of each fragment.
47−+ if(do_4k_align)
48−+ ALIGN_UP(bytes, 4096);
49− fragment_table[file_buffer->block].size = c_byte;
50− fragment_table[file_buffer->block].start_block = bytes;
51− write_buffer->block = bytes;
52−@@ -2728,6 +2736,10 @@
50+@@ -2478,6 +2483,9 @@ void *frag_deflator(void *arg)
51+ write_buffer->size = compressed_size;
52+ pthread_mutex_lock(&fragment_mutex);
53+ if(fragments_locked == FALSE) {
54++ // 4k align the start of each fragment.
55++ if(do_4k_align)
56++ ALIGN_UP(bytes, 4096);
57+ fragment_table[file_buffer->block].size = c_byte;
58+ fragment_table[file_buffer->block].start_block = bytes;
59+ write_buffer->block = bytes;
60+@@ -2877,6 +2885,10 @@ int write_file_blocks(squashfs_inode *inode, struct dir_ent *dir_ent,
5361 long long sparse = 0;
5462 struct file_buffer *fragment_buffer = NULL;
5563
@@ -60,7 +68,7 @@ diff -u a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
6068 if(pre_duplicate(read_size))
6169 return write_file_blocks_dup(inode, dir_ent, read_buffer, dup);
6270
63−@@ -4808,6 +4820,7 @@
71+@@ -4972,6 +4984,7 @@ void write_filesystem_tables(struct squashfs_super_block *sBlk, int nopad)
6472 "compressed", no_fragments ? "no" : noF ? "uncompressed" :
6573 "compressed", no_xattrs ? "no" : noX ? "uncompressed" :
6674 "compressed", noI || noId ? "uncompressed" : "compressed");
@@ -68,7 +76,7 @@ diff -u a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
6876 printf("\tduplicates are %sremoved\n", duplicate_checking ? "" :
6977 "not ");
7078 printf("Filesystem size %.2f Kbytes (%.2f Mbytes)\n", bytes / 1024.0,
71−@@ -5570,6 +5583,8 @@
79+@@ -5853,6 +5866,8 @@ print_compressor_options:
7280 root_name = argv[i];
7381 } else if(strcmp(argv[i], "-version") == 0) {
7482 VERSION();
@@ -77,7 +85,7 @@ diff -u a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
7785 } else {
7886 ERROR("%s: invalid option\n\n", argv[0]);
7987 printOptions:
80−@@ -5613,6 +5628,7 @@
88+@@ -5904,6 +5919,7 @@ printOptions:
8189 ERROR("\t\t\tdirectory containing that directory, "
8290 "rather than the\n");
8391 ERROR("\t\t\tcontents of the directory\n");
@@ -85,3 +93,6 @@ diff -u a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
8593 ERROR("\nFilesystem filter options:\n");
8694 ERROR("-p <pseudo-definition>\tAdd pseudo file "
8795 "definition\n");
96+--
97+2.23.0
98+
pkgs/tools/filesystems/squashfs/default.nix+1−2
@@ -21,8 +21,7 @@ stdenv.mkDerivation {
2121 patches = [
2222 # This patch adds an option to pad filesystems (increasing size) in
2323 # exchange for better chunking / binary diff calculation.
24− # TODO(ruuda): make this patch apply to the proper 4.4 release.
25− # ./squashfs-tools-4.4-4k-align.patch
24+ ./4k-align.patch
2625 ] ++ stdenv.lib.optional stdenv.isDarwin ./darwin.patch;
2726
2827 buildInputs = [ zlib xz zstd ]