git.iko.soy/typeable/nixpkgs
on master help sign in
squashfsTools: 4.4dev_20180612 -> 4.4 (#68275)

squashfsTools: 4.4dev_20180612 -> 4.4

commit27994da3185d3112d490b56798beee2a76ba8551 authorJörg Thalheim <Mic92@users.noreply.github.com> dateFri 20 Sep 2019, 09:57 (7 years ago) parent6c3bf80f6e8ee7
6 files changed+120−582
pkgs/tools/filesystems/squashfs/0001-If-SOURCE_DATE_EPOCH-is-set-override-timestamps-with.patch−90 pkgs/tools/filesystems/squashfs/0002-If-SOURCE_DATE_EPOCH-is-set-also-clamp-content-times.patch−83 pkgs/tools/filesystems/squashfs/0003-remove-frag-deflator-thread.patch−220 pkgs/tools/filesystems/squashfs/squashfs-tools-4.4-4k-align.patch → pkgs/tools/filesystems/squashfs/4k-align.patch+31−20 pkgs/tools/filesystems/squashfs/darwin.patch+84−158 pkgs/tools/filesystems/squashfs/default.nix+5−11
pkgs/tools/filesystems/squashfs/0001-If-SOURCE_DATE_EPOCH-is-set-override-timestamps-with.patchdeleted−90
@@ -1,90 +0,0 @@
1−From 0ab12a8585373be2de5129e14d979c62e7a90d82 Mon Sep 17 00:00:00 2001
2−From: Chris Lamb <lamby@debian.org>
3−Date: Mon, 21 Nov 2016 09:33:05 +0100
4−Subject: [PATCH] If SOURCE_DATE_EPOCH is set, override timestamps with that
5− value.
6−
7−See https://reproducible-builds.org/specs/source-date-epoch/ for more
8−information about this environment variable.
9−
10−Based on a patch by Alexander Couzens <lynxis@fe...> posted on
11−https://sourceforge.net/p/squashfs/mailman/message/34673610/
12−
13−Signed-off-by: Chris Lamb <lamby@debian.org>
14−---
15− squashfs-tools/mksquashfs.c | 38 ++++++++++++++++++++++++++++++++++++-
16− 1 file changed, 37 insertions(+), 1 deletion(-)
17−
18−diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
19−index c2098bd..b49e956 100644
20−--- a/squashfs-tools/mksquashfs.c
21−+++ b/squashfs-tools/mksquashfs.c
22−@@ -137,6 +137,9 @@ unsigned int cache_bytes = 0, cache_size = 0, inode_count = 0;
23− /* inode lookup table */
24− squashfs_inode *inode_lookup_table = NULL;
25−
26−+/* override filesystem creation time */
27−+time_t mkfs_fixed_time = -1;
28−+
29− /* in memory directory data */
30− #define I_COUNT_SIZE 128
31− #define DIR_ENTRIES 32
32−@@ -5104,6 +5107,9 @@ int main(int argc, char *argv[])
33− int total_mem = get_default_phys_mem();
34− int progress = TRUE;
35− int force_progress = FALSE;
36−+ char *source_date_epoch, *endptr;
37−+ unsigned long long epoch;
38−+
39− struct file_buffer **fragment = NULL;
40−
41− if(argc > 1 && strcmp(argv[1], "-version") == 0) {
42−@@ -5641,6 +5647,36 @@ printOptions:
43− }
44− }
45−
46−+ /* if SOURCE_DATE_EPOCH is set, use that timestamp for the mkfs time */
47−+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
48−+ if(source_date_epoch) {
49−+ errno = 0;
50−+ epoch = strtoull(source_date_epoch, &endptr, 10);
51−+ if((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
52−+ || (errno != 0 && epoch == 0)) {
53−+ ERROR("Environment variable $SOURCE_DATE_EPOCH: "
54−+ "strtoull: %s\n", strerror(errno));
55−+ EXIT_MKSQUASHFS();
56−+ }
57−+ if(endptr == source_date_epoch) {
58−+ ERROR("Environment variable $SOURCE_DATE_EPOCH: "
59−+ "No digits were found: %s\n", endptr);
60−+ EXIT_MKSQUASHFS();
61−+ }
62−+ if(*endptr != '\0') {
63−+ ERROR("Environment variable $SOURCE_DATE_EPOCH: "
64−+ "Trailing garbage: %s\n", endptr);
65−+ EXIT_MKSQUASHFS();
66−+ }
67−+ if(epoch > ULONG_MAX) {
68−+ ERROR("Environment variable $SOURCE_DATE_EPOCH: "
69−+ "value must be smaller than or equal to "
70−+ "%lu but was found to be: %llu \n", ULONG_MAX, epoch);
71−+ EXIT_MKSQUASHFS();
72−+ }
73−+ mkfs_fixed_time = (time_t)epoch;
74−+ }
75−+
76− /*
77− * Some compressors may need the options to be checked for validity
78− * once all the options have been processed
79−@@ -5993,7 +6029,7 @@ printOptions:
80− sBlk.flags = SQUASHFS_MKFLAGS(noI, noD, noF, noX, no_fragments,
81− always_use_fragments, duplicate_checking, exportable,
82− no_xattrs, comp_opts);
83−- sBlk.mkfs_time = time(NULL);
84−+ sBlk.mkfs_time = mkfs_fixed_time != -1 ? mkfs_fixed_time : time(NULL);
85−
86− disable_info();
87−
88−--
89−2.17.0
90−
pkgs/tools/filesystems/squashfs/0002-If-SOURCE_DATE_EPOCH-is-set-also-clamp-content-times.patchdeleted−83
@@ -1,83 +0,0 @@
1−From 32a07d4156a281084c90a4b78affc8b0b32a26fc Mon Sep 17 00:00:00 2001
2−From: intrigeri <intrigeri@boum.org>
3−Date: Mon, 21 Nov 2016 11:41:28 +0000
4−Subject: [PATCH] If SOURCE_DATE_EPOCH is set, also clamp content timestamps
5− with that value.
6−
7−Based on a patch by Alexander Couzens <lynxis@fe...> posted on
8−https://sourceforge.net/p/squashfs/mailman/message/34673610/
9−---
10− squashfs-tools/mksquashfs.c | 15 ++++++++++++---
11− 1 file changed, 12 insertions(+), 3 deletions(-)
12−
13−diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
14−index b49e956..9f020bf 100644
15−--- a/squashfs-tools/mksquashfs.c
16−+++ b/squashfs-tools/mksquashfs.c
17−@@ -137,6 +137,9 @@ unsigned int cache_bytes = 0, cache_size = 0, inode_count = 0;
18− /* inode lookup table */
19− squashfs_inode *inode_lookup_table = NULL;
20−
21−+/* clamp all timestamps to SOURCE_DATE_EPOCH */
22−+time_t content_clamp_time = -1;
23−+
24− /* override filesystem creation time */
25− time_t mkfs_fixed_time = -1;
26−
27−@@ -2246,6 +2249,8 @@ restat:
28− pathname_reader(dir_ent), strerror(errno));
29− goto read_err;
30− }
31−+ if(content_clamp_time != -1 && buf2.st_mtime >= content_clamp_time)
32−+ buf2.st_mtime = content_clamp_time;
33−
34− if(read_size != buf2.st_size) {
35− close(file);
36−@@ -3101,7 +3106,7 @@ void dir_scan(squashfs_inode *inode, char *pathname,
37− buf.st_mode = S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR;
38− buf.st_uid = getuid();
39− buf.st_gid = getgid();
40−- buf.st_mtime = time(NULL);
41−+ buf.st_mtime = content_clamp_time != -1 ? content_clamp_time : time(NULL);
42− buf.st_dev = 0;
43− buf.st_ino = 0;
44− dir_ent->inode = lookup_inode2(&buf, PSEUDO_FILE_OTHER, 0);
45−@@ -3127,6 +3115,8 @@ void dir_scan(squashfs_inode *inode, char *pathname,
46− /* source directory has disappeared? */
47− BAD_ERROR("Cannot stat source directory %s because %s\n",
48− pathname, strerror(errno));
49−+ if(content_clamp_time != -1 && buf.st_mtime >= content_clamp_time)
50−+ buf.st_mtime = content_clamp_time;
51− dir_ent->inode = lookup_inode(&buf);
52− }
53−
54−@@ -3365,6 +3372,8 @@ struct dir_info *dir_scan1(char *filename, char *subpath,
55− free_dir_entry(dir_ent);
56− continue;
57− }
58−+ if(content_clamp_time != -1 && buf.st_mtime >= content_clamp_time)
59−+ buf.st_mtime = content_clamp_time;
60−
61− if((buf.st_mode & S_IFMT) != S_IFREG &&
62− (buf.st_mode & S_IFMT) != S_IFDIR &&
63−@@ -3544,7 +3553,7 @@ void dir_scan2(struct dir_info *dir, struct pseudo *pseudo)
64− buf.st_gid = pseudo_ent->dev->gid;
65− buf.st_rdev = makedev(pseudo_ent->dev->major,
66− pseudo_ent->dev->minor);
67−- buf.st_mtime = time(NULL);
68−+ buf.st_mtime = content_clamp_time != -1 ? content_clamp_time : time(NULL);
69− buf.st_ino = pseudo_ino ++;
70−
71− if(pseudo_ent->dev->type == 'd') {
72−@@ -5674,7 +5683,7 @@ printOptions:
73− "%lu but was found to be: %llu \n", ULONG_MAX, epoch);
74− EXIT_MKSQUASHFS();
75− }
76−- mkfs_fixed_time = (time_t)epoch;
77−+ mkfs_fixed_time = content_clamp_time = (time_t)epoch;
78− }
79−
80− /*
81−--
82−2.17.0
83−
pkgs/tools/filesystems/squashfs/0003-remove-frag-deflator-thread.patchdeleted−220
@@ -1,220 +0,0 @@
1−From afc0c76a170bd17cbd29bbec6ae6d2227e398570 Mon Sep 17 00:00:00 2001
2−From: Alexander Couzens <lynxis@fe80.eu>
3−Date: Fri, 13 Jan 2017 22:00:37 +0100
4−Subject: [PATCH] remove frag_deflator_thread
5−
6−frag_deflator_thread compress fragments.
7−Replace the deflator_thread with a function and
8−use the function instead of the to_frag queue.
9−---
10− squashfs-tools/info.c | 5 ---
11− squashfs-tools/mksquashfs.c | 76 +++++++++++++------------------------
12− squashfs-tools/mksquashfs.h | 2 +-
13− squashfs-tools/restore.c | 15 +-------
14− 4 files changed, 30 insertions(+), 68 deletions(-)
15−
16−diff --git a/squashfs-tools/info.c b/squashfs-tools/info.c
17−index 7968c77..028d578 100644
18−--- a/squashfs-tools/info.c
19−+++ b/squashfs-tools/info.c
20−@@ -96,11 +96,6 @@ void dump_state()
21− printf("compressed block queue (deflate thread(s) -> main thread)\n");
22− dump_seq_queue(to_main, 0);
23−
24−- printf("uncompressed packed fragment queue (main thread -> fragment"
25−- " deflate thread(s))\n");
26−- dump_queue(to_frag);
27−-
28−-
29− printf("locked frag queue (compressed frags waiting while multi-block"
30− " file is written)\n");
31− dump_queue(locked_fragment);
32−diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
33−index cf48e40..cacf14c 100644
34−--- a/squashfs-tools/mksquashfs.c
35−+++ b/squashfs-tools/mksquashfs.c
36−@@ -270,10 +270,10 @@ unsigned int sid_count = 0, suid_count = 0, sguid_count = 0;
37− struct cache *reader_buffer, *fragment_buffer, *reserve_cache;
38− struct cache *bwriter_buffer, *fwriter_buffer;
39− struct queue *to_reader, *to_deflate, *to_writer, *from_writer,
40−- *to_frag, *locked_fragment, *to_process_frag;
41−+ *locked_fragment, *to_process_frag;
42− struct seq_queue *to_main;
43− pthread_t reader_thread, writer_thread, main_thread;
44−-pthread_t *deflator_thread, *frag_deflator_thread, *frag_thread;
45−+pthread_t *deflator_thread, *frag_thread;
46− pthread_t *restore_thread = NULL;
47− pthread_mutex_t fragment_mutex = PTHREAD_MUTEX_INITIALIZER;
48− pthread_mutex_t pos_mutex = PTHREAD_MUTEX_INITIALIZER;
49−@@ -323,7 +323,7 @@ struct dir_info *scan1_opendir(char *pathname, char *subpath, int depth);
50− void write_filesystem_tables(struct squashfs_super_block *sBlk, int nopad);
51− unsigned short get_checksum_mem(char *buff, int bytes);
52− void check_usable_phys_mem(int total_mem);
53−-
54−+void frag_deflator(struct file_buffer *file_buffer);
55−
56− void prep_exit()
57− {
58−@@ -1540,7 +1540,7 @@ void write_fragment(struct file_buffer *fragment)
59− pthread_mutex_lock(&fragment_mutex);
60− fragment_table[fragment->block].unused = 0;
61− fragments_outstanding ++;
62−- queue_put(to_frag, fragment);
63−+ frag_deflator(fragment);
64− pthread_cleanup_pop(1);
65− }
66−
67−@@ -2412,51 +2412,34 @@ void *deflator(void *arg)
68− }
69−
70−
71−-void *frag_deflator(void *arg)
72−+void frag_deflator(struct file_buffer *file_buffer)
73− {
74−- void *stream = NULL;
75−- int res;
76−
77−- res = compressor_init(comp, &stream, block_size, 1);
78−- if(res)
79−- BAD_ERROR("frag_deflator:: compressor_init failed\n");
80−-
81−- pthread_cleanup_push((void *) pthread_mutex_unlock, &fragment_mutex);
82−-
83−- while(1) {
84−- int c_byte, compressed_size;
85−- struct file_buffer *file_buffer = queue_get(to_frag);
86−- struct file_buffer *write_buffer =
87−+ int c_byte, compressed_size;
88−+ struct file_buffer *write_buffer =
89− cache_get(fwriter_buffer, file_buffer->block);
90−
91−- c_byte = mangle2(stream, write_buffer->data, file_buffer->data,
92−- file_buffer->size, block_size, noF, 1);
93−- compressed_size = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
94−- write_buffer->size = compressed_size;
95−- pthread_mutex_lock(&fragment_mutex);
96−- if(fragments_locked == FALSE) {
97−- fragment_table[file_buffer->block].size = c_byte;
98−- fragment_table[file_buffer->block].start_block = bytes;
99−- write_buffer->block = bytes;
100−- bytes += compressed_size;
101−- fragments_outstanding --;
102−- queue_put(to_writer, write_buffer);
103−- pthread_mutex_unlock(&fragment_mutex);
104−- TRACE("Writing fragment %lld, uncompressed size %d, "
105−- "compressed size %d\n", file_buffer->block,
106−- file_buffer->size, compressed_size);
107−- } else {
108−- add_pending_fragment(write_buffer, c_byte,
109−- file_buffer->block);
110−- pthread_mutex_unlock(&fragment_mutex);
111−- }
112−- cache_block_put(file_buffer);
113−+ c_byte = mangle2(stream, write_buffer->data, file_buffer->data,
114−+ file_buffer->size, block_size, noF, 1);
115−+ compressed_size = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
116−+ write_buffer->size = compressed_size;
117−+ if(fragments_locked == FALSE) {
118−+ fragment_table[file_buffer->block].size = c_byte;
119−+ fragment_table[file_buffer->block].start_block = bytes;
120−+ write_buffer->block = bytes;
121−+ bytes += compressed_size;
122−+ fragments_outstanding --;
123−+ queue_put(to_writer, write_buffer);
124−+ TRACE("Writing fragment %lld, uncompressed size %d, "
125−+ "compressed size %d\n", file_buffer->block,
126−+ file_buffer->size, compressed_size);
127−+ } else {
128−+ add_pending_fragment(write_buffer, c_byte,
129−+ file_buffer->block);
130− }
131−-
132−- pthread_cleanup_pop(0);
133−+ cache_block_put(file_buffer);
134− }
135−
136−-
137− struct file_buffer *get_file_buffer()
138− {
139− struct file_buffer *file_buffer = seq_queue_get(to_main);
140−@@ -4257,19 +4240,17 @@ void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
141− multiply_overflow(processors * 3, sizeof(pthread_t)))
142− BAD_ERROR("Processors too large\n");
143−
144−- deflator_thread = malloc(processors * 3 * sizeof(pthread_t));
145−+ deflator_thread = malloc(processors * 2 * sizeof(pthread_t));
146− if(deflator_thread == NULL)
147− MEM_ERROR();
148−
149−- frag_deflator_thread = &deflator_thread[processors];
150−- frag_thread = &frag_deflator_thread[processors];
151−+ frag_thread = &deflator_thread[processors];
152−
153− to_reader = queue_init(1);
154− to_deflate = queue_init(reader_size);
155− to_process_frag = queue_init(reader_size);
156− to_writer = queue_init(bwriter_size + fwriter_size);
157− from_writer = queue_init(1);
158−- to_frag = queue_init(fragment_size);
159− locked_fragment = queue_init(fragment_size);
160− to_main = seq_queue_init();
161− reader_buffer = cache_init(block_size, reader_size, 0, 0);
162−@@ -4285,9 +4266,6 @@ void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
163− for(i = 0; i < processors; i++) {
164− if(pthread_create(&deflator_thread[i], NULL, deflator, NULL))
165− BAD_ERROR("Failed to create thread\n");
166−- if(pthread_create(&frag_deflator_thread[i], NULL, frag_deflator,
167−- NULL) != 0)
168−- BAD_ERROR("Failed to create thread\n");
169− if(pthread_create(&frag_thread[i], NULL, frag_thrd,
170− (void *) destination_file) != 0)
171− BAD_ERROR("Failed to create thread\n");
172−diff --git a/squashfs-tools/mksquashfs.h b/squashfs-tools/mksquashfs.h
173−index 55708a3..dc5bde4 100644
174−--- a/squashfs-tools/mksquashfs.h
175−+++ b/squashfs-tools/mksquashfs.h
176−@@ -135,7 +135,7 @@ struct append_file {
177− extern struct cache *reader_buffer, *fragment_buffer, *reserve_cache;
178− struct cache *bwriter_buffer, *fwriter_buffer;
179− extern struct queue *to_reader, *to_deflate, *to_writer, *from_writer,
180−- *to_frag, *locked_fragment, *to_process_frag;
181−+ *locked_fragment, *to_process_frag;
182− extern struct append_file **file_mapping;
183− extern struct seq_queue *to_main;
184− extern pthread_mutex_t fragment_mutex, dup_mutex;
185−diff --git a/squashfs-tools/restore.c b/squashfs-tools/restore.c
186−index 5e336b3..a7aaf2e 100644
187−--- a/squashfs-tools/restore.c
188−+++ b/squashfs-tools/restore.c
189−@@ -47,8 +47,8 @@
190− #define TRUE 1
191−
192− extern pthread_t reader_thread, writer_thread, main_thread;
193−-extern pthread_t *deflator_thread, *frag_deflator_thread, *frag_thread;
194−-extern struct queue *to_deflate, *to_writer, *to_frag, *to_process_frag;
195−+extern pthread_t *deflator_thread, *frag_thread;
196−+extern struct queue *to_deflate, *to_writer, *to_process_frag;
197− extern struct seq_queue *to_main;
198− extern void restorefs();
199− extern int processors;
200−@@ -120,17 +120,6 @@ void *restore_thrd(void *arg)
201− pthread_cancel(main_thread);
202− pthread_join(main_thread, NULL);
203−
204−- /* then flush the main thread to fragment deflator thread(s)
205−- * queue. The fragment deflator thread(s) will idle
206−- */
207−- queue_flush(to_frag);
208−-
209−- /* now kill the fragment deflator thread(s) */
210−- for(i = 0; i < processors; i++)
211−- pthread_cancel(frag_deflator_thread[i]);
212−- for(i = 0; i < processors; i++)
213−- pthread_join(frag_deflator_thread[i], NULL);
214−-
215− /*
216− * then flush the main thread/fragment deflator thread(s)
217− * to writer thread queue. The writer thread will idle
218−--
219−2.17.0
220−
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/darwin.patch+84−158
@@ -1,5 +1,11 @@
1+Patch based on commits by Dave Vasilevsky <dave@vasilevsky.ca> and
2+Blake Riley <blake.riley@gmail.com>, squashed into a single patch,
3+with BSD-specific changes omitted.
4+
5+See also https://github.com/plougher/squashfs-tools/pull/69.
6+
17diff --git a/squashfs-tools/action.c b/squashfs-tools/action.c
2−index 4b06ccb..26365e7 100644
8+index 4b06ccb..3cad2ab 100644
39--- a/squashfs-tools/action.c
410+++ b/squashfs-tools/action.c
511@@ -38,6 +38,10 @@
@@ -7,7 +13,7 @@ index 4b06ccb..26365e7 100644
713 #include <errno.h>
814
915+#ifndef FNM_EXTMATCH /* glibc extension */
10−+ #define FNM_EXTMATCH 0
16++ #define FNM_EXTMATCH 0
1117+#endif
1218+
1319 #include "squashfs_fs.h"
@@ -28,21 +34,21 @@ index 4b06ccb..26365e7 100644
2834
2935 /*
3036diff --git a/squashfs-tools/info.c b/squashfs-tools/info.c
31−index 7968c77..c8e4c52 100644
37+index fe23d78..5c2f835 100644
3238--- a/squashfs-tools/info.c
3339+++ b/squashfs-tools/info.c
34−@@ -134,31 +134,22 @@ void dump_state()
40+@@ -144,31 +144,22 @@ void dump_state()
3541 void *info_thrd(void *arg)
3642 {
3743 sigset_t sigmask;
3844- struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
3945- int sig, waiting = 0;
40−+ int sig, err, waiting = 0;
46++ int sig, err, waiting = 0;
4147
4248 sigemptyset(&sigmask);
4349 sigaddset(&sigmask, SIGQUIT);
4450 sigaddset(&sigmask, SIGHUP);
45−+ sigaddset(&sigmask, SIGALRM);
51++ sigaddset(&sigmask, SIGALRM);
4652
4753 while(1) {
4854- if(waiting)
@@ -64,11 +70,11 @@ index 7968c77..c8e4c52 100644
6470 continue;
6571 default:
6672- BAD_ERROR("sigtimedwait/sigwaitinfo failed "
67−+ BAD_ERROR("sigwaitfailed "
73++ BAD_ERROR("sigwait failed "
6874 "because %s\n", strerror(errno));
6975 }
7076 }
71−@@ -169,8 +160,12 @@ void *info_thrd(void *arg)
77+@@ -179,8 +170,12 @@ void *info_thrd(void *arg)
7278 /* set one second interval period, if ^\ received
7379 within then, dump queue and cache status */
7480 waiting = 1;
@@ -83,119 +89,46 @@ index 7968c77..c8e4c52 100644
8389 }
8490
8591diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
86−index d696a51..c86d1b3 100644
92+index a45b77f..3607448 100644
8793--- a/squashfs-tools/mksquashfs.c
8894+++ b/squashfs-tools/mksquashfs.c
89−@@ -50,6 +50,10 @@
95+@@ -35,7 +35,12 @@
96+ #include <stddef.h>
97+ #include <sys/types.h>
98+ #include <sys/stat.h>
99++#ifndef linux
100++#include <sys/sysctl.h>
101++#else
102++#include <sys/sysinfo.h>
103+ #include <sys/sysmacros.h>
104++#endif
105+ #include <fcntl.h>
106+ #include <errno.h>
107+ #include <dirent.h>
108+@@ -50,7 +55,10 @@
109+ #include <sys/wait.h>
90110 #include <limits.h>
91111 #include <ctype.h>
92−
112+-#include <sys/sysinfo.h>
113++
93114+#ifndef FNM_EXTMATCH /* glibc extension */
94−+ #define FNM_EXTMATCH 0
115++ #define FNM_EXTMATCH 0
95116+#endif
96−+
117+
97118 #ifndef linux
98119 #define __BYTE_ORDER BYTE_ORDER
99− #define __BIG_ENDIAN BIG_ENDIAN
100−@@ -831,13 +835,13 @@ char *subpathname(struct dir_ent *dir_ent)
101− }
102−
103−
104−-inline unsigned int get_inode_no(struct inode_info *inode)
105−+static inline unsigned int get_inode_no(struct inode_info *inode)
106− {
107− return inode->inode_number;
108− }
109−
110−
111−-inline unsigned int get_parent_no(struct dir_info *dir)
112−+static inline unsigned int get_parent_no(struct dir_info *dir)
113− {
114− return dir->depth ? get_inode_no(dir->dir_ent->inode) : inode_no;
115− }
116−@@ -2030,7 +2034,7 @@ struct file_info *duplicate(long long file_size, long long bytes,
117− }
118−
119−
120−-inline int is_fragment(struct inode_info *inode)
121−+static inline int is_fragment(struct inode_info *inode)
122− {
123− off_t file_size = inode->buf.st_size;
124−
125−@@ -2999,13 +3003,13 @@ struct inode_info *lookup_inode2(struct stat *buf, int pseudo, int id)
126− }
127−
128−
129−-inline struct inode_info *lookup_inode(struct stat *buf)
130−+static inline struct inode_info *lookup_inode(struct stat *buf)
131− {
132− return lookup_inode2(buf, 0, 0);
133− }
134−
135−
136−-inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
137−+static inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
138− {
139− if (inode->inode_number == 0) {
140− inode->inode_number = use_this ? : inode_no ++;
141−@@ -3016,7 +3020,7 @@ inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
142− }
143−
144−
145−-inline struct dir_ent *create_dir_entry(char *name, char *source_name,
146−+static inline struct dir_ent *create_dir_entry(char *name, char *source_name,
147− char *nonstandard_pathname, struct dir_info *dir)
148− {
149− struct dir_ent *dir_ent = malloc(sizeof(struct dir_ent));
150−@@ -3034,7 +3038,7 @@ inline struct dir_ent *create_dir_entry(char *name, char *source_name,
151− }
152−
153−
154−-inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
155−+static inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
156− struct inode_info *inode_info)
157− {
158− struct dir_info *dir = dir_ent->our_dir;
159−@@ -3050,7 +3054,7 @@ inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
160− }
161−
162−
163−-inline void add_dir_entry2(char *name, char *source_name,
164−+static inline void add_dir_entry2(char *name, char *source_name,
165− char *nonstandard_pathname, struct dir_info *sub_dir,
166− struct inode_info *inode_info, struct dir_info *dir)
167− {
168−@@ -3062,7 +3066,7 @@ inline void add_dir_entry2(char *name, char *source_name,
169− }
170−
171−
172−-inline void free_dir_entry(struct dir_ent *dir_ent)
173−+static inline void free_dir_entry(struct dir_ent *dir_ent)
174− {
175− if(dir_ent->name)
176− free(dir_ent->name);
177−@@ -3083,7 +3087,7 @@ inline void free_dir_entry(struct dir_ent *dir_ent)
178− }
179−
180−
181−-inline void add_excluded(struct dir_info *dir)
182−+static inline void add_excluded(struct dir_info *dir)
183− {
184− dir->excluded ++;
185− }
186−@@ -4200,6 +4204,7 @@ void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
120+@@ -4348,6 +4356,7 @@ void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
187121 sigemptyset(&sigmask);
188122 sigaddset(&sigmask, SIGQUIT);
189123 sigaddset(&sigmask, SIGHUP);
190124+ sigaddset(&sigmask, SIGALRM);
191− if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == -1)
125+ if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) != 0)
192126 BAD_ERROR("Failed to set signal mask in intialise_threads\n");
193127
194−@@ -4987,6 +4992,36 @@ int parse_num(char *arg, int *res)
128+@@ -5195,6 +5204,35 @@ int get_physical_memory()
129+ long long page_size = sysconf(_SC_PAGESIZE);
130+ int phys_mem;
195131
196− int get_physical_memory()
197− {
198−+ int phys_mem;
199132+#ifndef linux
200133+ #ifdef HW_MEMSIZE
201134+ #define SYSCTL_PHYSMEM HW_MEMSIZE
@@ -223,50 +156,21 @@ index d696a51..c86d1b3 100644
223156+ ERROR_EXIT(" Defaulting to least viable amount\n");
224157+ phys_mem = SQUASHFS_LOWMEM;
225158+ }
226−+ #undef SYSCTL_PHYSMEM
159++ #undef SYSCTL_PHYSMEM
227160+#else
228− /*
229− * Long longs are used here because with PAE, a 32-bit
230− * machine can have more than 4GB of physical memory
231−@@ -4996,10 +5031,11 @@ int get_physical_memory()
232− */
233− long long num_pages = sysconf(_SC_PHYS_PAGES);
234− long long page_size = sysconf(_SC_PAGESIZE);
235−- int phys_mem = num_pages * page_size >> 20;
236−+ phys_mem = num_pages * page_size >> 20;
161+ if(num_pages == -1 || page_size == -1) {
162+ struct sysinfo sys;
163+ int res = sysinfo(&sys);
164+@@ -5207,6 +5245,7 @@ int get_physical_memory()
165+ }
237166
238− if(num_pages == -1 || page_size == -1)
239− return 0;
167+ phys_mem = num_pages * page_size >> 20;
240168+#endif
241169
242170 if(phys_mem < SQUASHFS_LOWMEM)
243171 BAD_ERROR("Mksquashfs requires more physical memory than is "
244−diff --git a/squashfs-tools/mksquashfs.h b/squashfs-tools/mksquashfs.h
245−index 55708a3..d44d1fd 100644
246−--- a/squashfs-tools/mksquashfs.h
247−+++ b/squashfs-tools/mksquashfs.h
248−@@ -24,6 +24,7 @@
249− * mksquashfs.h
250− *
251− */
252−+#include <pthread.h>
253−
254− struct dir_info {
255− char *pathname;
256−diff --git a/squashfs-tools/pseudo.c b/squashfs-tools/pseudo.c
257−index cb74cf6..fe2b4bc 100644
258−--- a/squashfs-tools/pseudo.c
259−+++ b/squashfs-tools/pseudo.c
260−@@ -30,6 +30,7 @@
261− #include <errno.h>
262− #include <string.h>
263− #include <stdlib.h>
264−+#include <sys/stat.h>
265− #include <sys/types.h>
266− #include <sys/wait.h>
267− #include <sys/stat.h>
268172diff --git a/squashfs-tools/read_xattrs.c b/squashfs-tools/read_xattrs.c
269−index 42106f5..837d3fb 100644
173+index 4debedf..3257c30 100644
270174--- a/squashfs-tools/read_xattrs.c
271175+++ b/squashfs-tools/read_xattrs.c
272176@@ -39,13 +39,13 @@
@@ -286,10 +190,10 @@ index 42106f5..837d3fb 100644
286190 extern int read_block(int, long long, long long *, int, void *);
287191
288192diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
289−index f190e96..927e441 100644
193+index 727f1d5..c1a6183 100644
290194--- a/squashfs-tools/unsquashfs.c
291195+++ b/squashfs-tools/unsquashfs.c
292−@@ -32,7 +32,12 @@
196+@@ -32,8 +32,12 @@
293197 #include "stdarg.h"
294198 #include "fnmatch_compat.h"
295199
@@ -297,21 +201,40 @@ index f190e96..927e441 100644
297201+#include <sys/sysctl.h>
298202+#else
299203 #include <sys/sysinfo.h>
204+ #include <sys/sysmacros.h>
300205+#endif
301−+
302206 #include <sys/types.h>
303207 #include <sys/time.h>
304208 #include <sys/resource.h>
305−@@ -2185,6 +2190,7 @@ void initialise_threads(int fragment_buffer_size, int data_buffer_size)
209+@@ -1080,7 +1084,7 @@ int create_inode(char *pathname, struct inode *i)
210+ break;
211+ case SQUASHFS_SYMLINK_TYPE:
212+ case SQUASHFS_LSYMLINK_TYPE: {
213+- struct timespec times[2] = {
214++ struct timeval times[2] = {
215+ { i->time, 0 },
216+ { i->time, 0 }
217+ };
218+@@ -1099,8 +1103,7 @@ int create_inode(char *pathname, struct inode *i)
219+ goto failed;
220+ }
221+
222+- res = utimensat(AT_FDCWD, pathname, times,
223+- AT_SYMLINK_NOFOLLOW);
224++ res = lutimes(pathname, times);
225+ if(res == -1) {
226+ EXIT_UNSQUASH_STRICT("create_inode: failed to set time on "
227+ "%s, because %s\n", pathname,
228+@@ -2235,6 +2238,7 @@ void initialise_threads(int fragment_buffer_size, int data_buffer_size)
306229 sigemptyset(&sigmask);
307230 sigaddset(&sigmask, SIGQUIT);
308231 sigaddset(&sigmask, SIGHUP);
309232+ sigaddset(&sigmask, SIGALRM);
310− if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == -1)
233+ if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) != 0)
311234 EXIT_UNSQUASH("Failed to set signal mask in initialise_threads"
312235 "\n");
313236diff --git a/squashfs-tools/unsquashfs.h b/squashfs-tools/unsquashfs.h
314−index 0edbd25..cea9caa 100644
237+index 934618b..0e680ab 100644
315238--- a/squashfs-tools/unsquashfs.h
316239+++ b/squashfs-tools/unsquashfs.h
317240@@ -46,6 +46,10 @@
@@ -319,7 +242,7 @@ index 0edbd25..cea9caa 100644
319242 #include <sys/time.h>
320243
321244+#ifndef FNM_EXTMATCH /* glibc extension */
322−+ #define FNM_EXTMATCH 0
245++ #define FNM_EXTMATCH 0
323246+#endif
324247+
325248 #ifndef linux
@@ -381,7 +304,7 @@ index c8e2b9b..7d4f7af 100644
381304 }
382305
383306diff --git a/squashfs-tools/unsquashfs_xattr.c b/squashfs-tools/unsquashfs_xattr.c
384−index 59f4aae..13f0e35 100644
307+index 7742dfe..f8cd3b6 100644
385308--- a/squashfs-tools/unsquashfs_xattr.c
386309+++ b/squashfs-tools/unsquashfs_xattr.c
387310@@ -27,6 +27,11 @@
@@ -389,15 +312,15 @@ index 59f4aae..13f0e35 100644
389312 #include <sys/xattr.h>
390313
391314+#ifdef XATTR_NOFOLLOW /* Apple's xattrs */
392−+ #define lsetxattr(path_, name_, val_, sz_, flags_) \
393−+ setxattr(path_, name_, val_, sz_, 0, flags_ | XATTR_NOFOLLOW)
315++ #define lsetxattr(path_, name_, val_, sz_, flags_) \
316++ setxattr(path_, name_, val_, sz_, 0, flags_ | XATTR_NOFOLLOW)
394317+#endif
395318+
396319 #define NOSPACE_MAX 10
397320
398321 extern int root_process;
399322diff --git a/squashfs-tools/xattr.c b/squashfs-tools/xattr.c
400−index b46550c..5b32eca 100644
323+index 64dfd82..d82d186 100644
401324--- a/squashfs-tools/xattr.c
402325+++ b/squashfs-tools/xattr.c
403326@@ -22,6 +22,14 @@
@@ -420,12 +343,15 @@ index b46550c..5b32eca 100644
420343 #include <sys/xattr.h>
421344
422345+#ifdef XATTR_NOFOLLOW /* Apple's xattrs */
423−+ #define llistxattr(path_, buf_, sz_) \
424−+ listxattr(path_, buf_, sz_, XATTR_NOFOLLOW)
425−+ #define lgetxattr(path_, name_, val_, sz_) \
426−+ getxattr(path_, name_, val_, sz_, 0, XATTR_NOFOLLOW)
346++ #define llistxattr(path_, buf_, sz_) \
347++ listxattr(path_, buf_, sz_, XATTR_NOFOLLOW)
348++ #define lgetxattr(path_, name_, val_, sz_) \
349++ getxattr(path_, name_, val_, sz_, 0, XATTR_NOFOLLOW)
427350+#endif
428351+
429352 #include "squashfs_fs.h"
430353 #include "squashfs_swap.h"
431354 #include "mksquashfs.h"
355+--
356+2.23.0
357+
pkgs/tools/filesystems/squashfs/default.nix+5−11
@@ -8,26 +8,20 @@ assert lz4Support -> (lz4 != null);
88
99stdenv.mkDerivation {
1010 pname = "squashfs";
11− version = "4.4dev_20180612";
11+ version = "4.4";
1212
1313 src = fetchFromGitHub {
1414 owner = "plougher";
1515 repo = "squashfs-tools";
16− sha256 = "1y53z8dkph3khdyhkmkmy0sg9p1n8czv3vj4l324nj8kxyih3l2c";
17− rev = "6e242dc95485ada8d1d0b3dd9346c5243d4a517f";
16+ sha256 = "0697fv8n6739mcyn57jclzwwbbqwpvjdfkv1qh9s56lvyqnplwaw";
17+ # Tag "4.4" points to this commit.
18+ rev = "52eb4c279cd283ed9802dd1ceb686560b22ffb67";
1819 };
1920
2021 patches = [
21− # These patches ensures that mksquashfs output is reproducible.
22− # See also https://reproducible-builds.org/docs/system-images/
23− # and https://github.com/NixOS/nixpkgs/issues/40144.
24− ./0001-If-SOURCE_DATE_EPOCH-is-set-override-timestamps-with.patch
25− ./0002-If-SOURCE_DATE_EPOCH-is-set-also-clamp-content-times.patch
26− ./0003-remove-frag-deflator-thread.patch
27−
2822 # This patch adds an option to pad filesystems (increasing size) in
2923 # exchange for better chunking / binary diff calculation.
30− ./squashfs-tools-4.4-4k-align.patch
24+ ./4k-align.patch
3125 ] ++ stdenv.lib.optional stdenv.isDarwin ./darwin.patch;
3226
3327 buildInputs = [ zlib xz zstd ]