squashfs tool is finally reborn and correctly maintained.
Bump it to latest version and add new patch to add missing feature from
squashfskit4 to use it as an universal tool.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
tools-y += e2fsprogs expat fakeroot findutils firmware-utils flex gengetopt
tools-y += libressl libtool lzma m4 make-ext4fs meson missing-macros mkimage
tools-y += mklibs mtd-utils mtools ninja padjffs2 patch-image
-tools-y += patchelf pkgconf quilt squashfskit4 sstrip zip zlib zstd
+tools-y += patchelf pkgconf quilt squashfskit4 squashfs sstrip zip zlib zstd
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_B43_TOOLS),y) += b43-tools
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_ISL),y) += isl
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_TOOLCHAIN),y) += gmp mpc mpfr
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_apm821xx)$(CONFIG_TARGET_gemini),y) += genext2fs
-tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_ath79),y) += lzma-old squashfs
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_mxs),y) += elftosb sdimage
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_realtek),y) += 7z
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_tegra),y) += cbootimage cbootimage-configs
$(curdir)/isl/compile := $(curdir)/gmp/compile
$(curdir)/libressl/compile := $(curdir)/pkgconf/compile
$(curdir)/libtool/compile := $(curdir)/m4/compile $(curdir)/autoconf/compile $(curdir)/automake/compile $(curdir)/missing-macros/compile
-$(curdir)/lzma-old/compile := $(curdir)/zlib/compile
$(curdir)/llvm-bpf/compile := $(curdir)/cmake/compile
$(curdir)/make-ext4fs/compile := $(curdir)/zlib/compile
$(curdir)/meson/compile := $(curdir)/ninja/compile
$(curdir)/pkgconf/compile := $(curdir)/meson/compile
$(curdir)/quilt/compile := $(curdir)/autoconf/compile $(curdir)/findutils/compile
$(curdir)/sdcc/compile := $(curdir)/bison/compile
-$(curdir)/squashfs/compile := $(curdir)/lzma-old/compile
+$(curdir)/squashfs/compile := $(curdir)/xz/compile $(curdir)/zlib/compile
$(curdir)/squashfskit4/compile := $(curdir)/xz/compile $(curdir)/zlib/compile
$(curdir)/zstd/compile := $(curdir)/meson/compile
ifneq ($(HOST_OS),Linux)
+ $(curdir)/squashfs/compile += $(curdir)/coreutils/compile
$(curdir)/squashfskit4/compile += $(curdir)/coreutils/compile
tools-y += coreutils
endif
PKG_NAME:=squashfs
PKG_CPE_ID:=cpe:/a:phillip_lougher:squashfs
-PKG_VERSION:=3.0
+PKG_VERSION:=4.5.1
+PKG_RELEASE=$(AUTORELEASE)
-PKG_SOURCE:=$(PKG_NAME)$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=@SF/squashfs
-PKG_HASH:=39dbda43cf118536deb746c7730b468702d514a19f4cfab73b710e32908ddf20
-PKG_CAT:=zcat
-
-HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)$(PKG_VERSION)
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/plougher/squashfs-tools
+PKG_SOURCE_DATE:=2022-17-03
+PKG_SOURCE_VERSION:=afdd63fc386919b4aa40d573b0a6069414d14317
+PKG_MIRROR_HASH:=caedb66cf6dcbdcee0d1525923e203d003ef15f34a13a328686794666f16171f
include $(INCLUDE_DIR)/host-build.mk
define Host/Compile
+ +$(HOST_MAKE_VARS) \
$(MAKE) -C $(HOST_BUILD_DIR)/squashfs-tools \
- CC="$(HOSTCC)" \
- CFLAGS="$(HOST_CFLAGS) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I." \
- CXX="$(CXX)" \
- LZMAPATH=$(STAGING_DIR_HOST)/lib \
- mksquashfs-lzma unsquashfs-lzma
+ XZ_SUPPORT=1 \
+ LZMA_XZ_SUPPORT=1 \
+ EXTRA_CFLAGS="-I$(STAGING_DIR_HOST)/include" \
+ mksquashfs unsquashfs
endef
define Host/Install
- $(INSTALL_BIN) $(HOST_BUILD_DIR)/squashfs-tools/mksquashfs-lzma $(STAGING_DIR_HOST)/bin/
- $(INSTALL_BIN) $(HOST_BUILD_DIR)/squashfs-tools/unsquashfs-lzma $(STAGING_DIR_HOST)/bin/
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/squashfs-tools/mksquashfs $(STAGING_DIR_HOST)/bin/mksquashfs
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/squashfs-tools/unsquashfs $(STAGING_DIR_HOST)/bin/unsquashfs
endef
define Host/Clean
- rm -f $(STAGING_DIR_HOST)/bin/mksquashfs-lzma
- rm -f $(STAGING_DIR_HOST)/bin/unsquashfs-lzma
+ rm -f $(STAGING_DIR_HOST)/bin/mksquashfs
+ rm -f $(STAGING_DIR_HOST)/bin/unsquashfs
endef
$(eval $(call HostBuild))
--- /dev/null
+From f49793cfbd72fdc40ab75dbffef42dca774701d1 Mon Sep 17 00:00:00 2001
+From: Christian Marangi <ansuelsmth@gmail.com>
+Date: Fri, 14 Oct 2022 15:59:16 +0200
+Subject: [PATCH] xz_wrapper: support multiple lzma configuration options
+
+Add option to configure preset, lc, lp and pb lzma parameters.
+-Xpreset can be both a level or set to 'extreme' to use the lzma extreme
+compression options.
+
+New option added:
+ -Xpreset
+ -Xlc
+ -Xlp
+ -Xpb
+
+Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
+---
+ squashfs-tools/xz_wrapper.c | 112 +++++++++++++++++++++++++++++++++++-
+ 1 file changed, 109 insertions(+), 3 deletions(-)
+
+diff --git a/squashfs-tools/xz_wrapper.c b/squashfs-tools/xz_wrapper.c
+index 0d650e0..211ebec 100644
+--- a/squashfs-tools/xz_wrapper.c
++++ b/squashfs-tools/xz_wrapper.c
+@@ -44,7 +44,10 @@ static struct bcj bcj[] = {
+ static int filter_count = 1;
+ static int dictionary_size = 0;
+ static float dictionary_percent = 0;
+-
++static int preset = LZMA_PRESET_DEFAULT;
++static int lc = -1;
++static int lp = -1;
++static int pb = -1;
+
+ /*
+ * This function is called by the options parsing code in mksquashfs.c
+@@ -53,6 +56,11 @@ static float dictionary_percent = 0;
+ * Two specific options are supported:
+ * -Xbcj
+ * -Xdict-size
++ * -Xpreset
++ * -Xe
++ * -Xlc
++ * -Xlp
++ * -Xpb
+ *
+ * This function returns:
+ * >=0 (number of additional args parsed) on success
+@@ -140,6 +148,85 @@ static int xz_options(char *argv[], int argc)
+ }
+ }
+
++ return 1;
++ } else if(strcmp(argv[0], "-Xpreset") == 0) {
++ char *b;
++ long val;
++
++ if(argc < 2) {
++ fprintf(stderr, "xz: -Xpreset missing preset-level\n");
++ goto failed;
++ }
++
++ if (strcmp(argv[1], "extreme") == 0) {
++ preset = LZMA_PRESET_EXTREME;
++
++ return 1;
++ }
++
++ val = strtol(argv[1], &b, 10);
++ if ((int) val < 0 || (int) val & ~LZMA_PRESET_LEVEL_MASK) {
++ fprintf(stderr, "xz: -Xpreset can't be "
++ "negative or more than the max preset\n");
++ goto failed;
++ }
++
++ preset = (int) val;
++
++ return 1;
++ } else if(strcmp(argv[0], "-Xlc") == 0) {
++ char *b;
++ long val;
++
++ if(argc < 2) {
++ fprintf(stderr, "xz: -Xlc missing value\n");
++ goto failed;
++ }
++
++ val = strtol(argv[1], &b, 10);
++ if ((int) val < LZMA_LCLP_MIN || (int) val > LZMA_LCLP_MAX) {
++ fprintf(stderr, "xz: -Xlc invalid value\n");
++ goto failed;
++ }
++
++ lc = (int) val;
++
++ return 1;
++ } else if(strcmp(argv[0], "-Xlp") == 0) {
++ char *b;
++ long val;
++
++ if(argc < 2) {
++ fprintf(stderr, "xz: -Xlp missing value\n");
++ goto failed;
++ }
++
++ val = strtol(argv[1], &b, 10);
++ if ((int) val < LZMA_LCLP_MIN || (int) val > LZMA_LCLP_MAX) {
++ fprintf(stderr, "xz: -Xlc invalid value\n");
++ goto failed;
++ }
++
++ lp = (int) val;
++
++ return 1;
++ } else if(strcmp(argv[0], "-Xpb") == 0) {
++ char *b;
++ long val;
++
++ if(argc < 2) {
++ fprintf(stderr, "xz: -Xpb missing value\n");
++ goto failed;
++ }
++
++ val = strtol(argv[1], &b, 10);
++ if ((int) val < LZMA_PB_MIN || (int) val > LZMA_PB_MAX) {
++ fprintf(stderr, "xz: -Xlc invalid value\n");
++ goto failed;
++ }
++
++ pb = (int) val;
++
+ return 1;
+ }
+
+@@ -446,11 +533,20 @@ static int xz_compress(void *strm, void *dest, void *src, int size,
+ for(i = 0; i < stream->filters; i++) {
+ struct filter *filter = &stream->filter[i];
+
+- if(lzma_lzma_preset(&stream->opt, LZMA_PRESET_DEFAULT))
++ if(lzma_lzma_preset(&stream->opt, preset))
+ goto failed;
+
+ stream->opt.dict_size = stream->dictionary_size;
+
++ if (lc >= 0)
++ stream->opt.lc = lc;
++
++ if (lp >= 0)
++ stream->opt.lp = lp;
++
++ if (pb >= 0)
++ stream->opt.pb = pb;
++
+ filter->length = 0;
+ res = lzma_stream_buffer_encode(filter->filter,
+ LZMA_CHECK_CRC32, NULL, src, size, filter->buffer,
+@@ -521,6 +602,12 @@ static void xz_usage(FILE *stream)
+ fprintf(stream, " header as either 2^n or as 2^n+2^(n+1).\n\t\t");
+ fprintf(stream, "Example dict-sizes are 75%%, 50%%, 37.5%%, 25%%, or");
+ fprintf(stream, " 32K, 16K, 8K\n\t\tetc.\n");
++ fprintf(stream, "\t -Xpreset <preset-level or extreme>\n");
++ fprintf(stream, "\t\tUse <preset-value> as the custom preset to use");
++ fprintf(stream, " on compress. Can be a level number or extreme.\n");
++ fprintf(stream, "\t -Xlc <value>\n");
++ fprintf(stream, "\t -Xlp <value>\n");
++ fprintf(stream, "\t -Xpb <value>\n");
+ }
+
+
+# {
+# if(strcmp(option, "-Xbcj") == 0 ||
+# - strcmp(option, "-Xdict-size") == 0)
+# + strcmp(option, "-Xdict-size") == 0 ||
+# + strcmp(option, "-Xpreset") == 0 ||
+# + strcmp(option, "-Xlc") == 0 ||
+# + strcmp(option, "-Xlp") == 0 ||
+# + strcmp(option, "-Xpb") == 0)
+# return 1;
+
+# return 0;
+--
+2.37.2
+
--- /dev/null
+From a9119c969af0a5aa961d56978d5dd4f3eb952667 Mon Sep 17 00:00:00 2001
+From: Phillip Lougher <phillip@squashfs.org.uk>
+Date: Mon, 15 Aug 2022 17:04:43 +0100
+Subject: [PATCH 1/1] Unsquashfs: Add and make some header includes conditional
+
+Fixes https://github.com/plougher/squashfs-tools/issues/122
+
+Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
+---
+ squashfs-tools/reader.c | 1 +
+ squashfs-tools/unsquashfs.c | 5 +++++
+ 2 files changed, 6 insertions(+)
+
+diff --git a/squashfs-tools/reader.c b/squashfs-tools/reader.c
+index 11cc2f3..d6cadd3 100644
+--- a/squashfs-tools/reader.c
++++ b/squashfs-tools/reader.c
+@@ -38,6 +38,7 @@
+ #include <errno.h>
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <signal.h>
+ #include "squashfs_fs.h"
+ #include "mksquashfs.h"
+ #include "caches-queues-lists.h"
+diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
+index dbfb06e..c4a2040 100644
+--- a/squashfs-tools/unsquashfs.c
++++ b/squashfs-tools/unsquashfs.c
+@@ -32,8 +32,13 @@
+ #include "stdarg.h"
+ #include "fnmatch_compat.h"
+
++#ifdef linux
+ #include <sys/sysinfo.h>
+ #include <sys/sysmacros.h>
++#else
++#include <sys/sysctl.h>
++#endif
++
+ #include <sys/types.h>
+ #include <sys/time.h>
+ #include <sys/resource.h>
+--
+2.37.2
+
--- /dev/null
+From 5443af020352b2f8678fd8c1d505a66f27aa6777 Mon Sep 17 00:00:00 2001
+From: Christian Marangi <ansuelsmth@gmail.com>
+Date: Fri, 14 Oct 2022 19:37:52 +0200
+Subject: [PATCH] Mksquashfs: fix sysinfo.h missing on macos system
+
+sysinfo.h and sysmacros.h is missing on MacOS. Exclude it from non
+linux systems.
+
+Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
+---
+ squashfs-tools/mksquashfs.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
+index 714ed35..da78ca7 100644
+--- a/squashfs-tools/mksquashfs.c
++++ b/squashfs-tools/mksquashfs.c
+@@ -49,9 +49,11 @@
+ #include <sys/wait.h>
+ #include <limits.h>
+ #include <ctype.h>
+-#include <sys/sysinfo.h>
+
+-#ifndef linux
++#ifdef linux
++#include <sys/sysinfo.h>
++#include <sys/sysmacros.h>
++#else
+ #include <sys/sysctl.h>
+ #endif
+
+--
+2.37.2
+
--- /dev/null
+From 374e39a786a5acda841056bec26fd0e0c4d40dac Mon Sep 17 00:00:00 2001
+From: Phillip Lougher <phillip@squashfs.org.uk>
+Date: Mon, 15 Aug 2022 17:09:05 +0100
+Subject: [PATCH 1/1] Mksquashfs: Make sysinfo() conditional
+
+Fixes https://github.com/plougher/squashfs-tools/issues/123
+
+Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
+---
+ squashfs-tools/mksquashfs.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
+index 46ab740..e822441 100644
+--- a/squashfs-tools/mksquashfs.c
++++ b/squashfs-tools/mksquashfs.c
+@@ -5818,6 +5818,7 @@ static int get_physical_memory()
+ long long page_size = sysconf(_SC_PAGESIZE);
+ int phys_mem;
+
++#ifdef __linux__
+ if(num_pages == -1 || page_size == -1) {
+ struct sysinfo sys;
+ int res = sysinfo(&sys);
+@@ -5828,6 +5829,7 @@ static int get_physical_memory()
+ num_pages = sys.totalram;
+ page_size = sys.mem_unit;
+ }
++#endif
+
+ phys_mem = num_pages * page_size >> 20;
+
+--
+2.37.2
+
--- /dev/null
+From 6e28ae53f6146d32d09b99d2041c66765c899bf9 Mon Sep 17 00:00:00 2001
+From: Christian Marangi <ansuelsmth@gmail.com>
+Date: Sat, 15 Oct 2022 00:11:20 +0200
+Subject: [PATCH] action: rework strdupa with POSIX strdup and free
+
+strdupa is not POSIX and cause compilation error on macos.
+Fix this by using strdup and free.
+
+Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
+---
+ squashfs-tools/action.c | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/squashfs-tools/action.c b/squashfs-tools/action.c
+index 3e8c7c7..279ea55 100644
+--- a/squashfs-tools/action.c
++++ b/squashfs-tools/action.c
+@@ -2596,9 +2596,17 @@ static char *get_start(char *s, int n)
+
+ static int subpathname_fn(struct atom *atom, struct action_data *action_data)
+ {
+- return fnmatch(atom->argv[0], get_start(strdupa(action_data->subpath),
+- count_components(atom->argv[0])),
+- FNM_PATHNAME|FNM_EXTMATCH) == 0;
++ char *s, *tmp;
++ int ret;
++
++ s = tmp = strdup(action_data->subpath);
++ tmp = get_start(tmp, count_components(atom->argv[0]));
++
++ ret = fnmatch(atom->argv[0], tmp, FNM_PATHNAME|FNM_EXTMATCH);
++
++ free(s);
++
++ return ret == 0;
+ }
+
+ /*
+--
+2.37.2
+
--- /dev/null
+From b9e89a1437a02e76fc02426eb85a3f1950678b65 Mon Sep 17 00:00:00 2001
+From: Christian Marangi <ansuelsmth@gmail.com>
+Date: Sat, 15 Oct 2022 09:54:11 +0200
+Subject: [PATCH] info: rework info_thrd to POSIX variant
+
+sigtimedwait and sigwaitinfo is not POSIX and is not present on macos.
+
+Rework the logic with gettimeofday to get the second interval and revert
+to POSIX sigwait.
+
+Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
+---
+ squashfs-tools/info.c | 27 ++++++++-------------------
+ squashfs-tools/unsquashfs_info.c | 27 ++++++++-------------------
+ 2 files changed, 16 insertions(+), 38 deletions(-)
+
+diff --git a/squashfs-tools/info.c b/squashfs-tools/info.c
+index a34dcca..563bf63 100644
+--- a/squashfs-tools/info.c
++++ b/squashfs-tools/info.c
+@@ -144,7 +144,7 @@ static void dump_state()
+ static void *info_thrd(void *arg)
+ {
+ sigset_t sigmask;
+- struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
++ struct timeval old_time = {0}, cur_time = {0};
+ int sig, waiting = 0;
+
+ sigemptyset(&sigmask);
+@@ -152,25 +152,12 @@ static void *info_thrd(void *arg)
+ sigaddset(&sigmask, SIGHUP);
+
+ while(1) {
+- if(waiting)
+- sig = sigtimedwait(&sigmask, NULL, ×pec);
+- else
+- sig = sigwaitinfo(&sigmask, NULL);
+-
+- if(sig == -1) {
+- switch(errno) {
+- case EAGAIN:
+- /* interval timed out */
++ sigwait(&sigmask, &sig);
++
++ if(waiting) {
++ gettimeofday(&cur_time, NULL);
++ if (cur_time.tv_sec > old_time.tv_sec )
+ waiting = 0;
+- /* FALLTHROUGH */
+- case EINTR:
+- /* if waiting, the wait will be longer, but
+- that's OK */
+- continue;
+- default:
+- BAD_ERROR("sigtimedwait/sigwaitinfo failed "
+- "because %s\n", strerror(errno));
+- }
+ }
+
+ if(sig == SIGQUIT && !waiting) {
+@@ -181,6 +168,8 @@ static void *info_thrd(void *arg)
+ waiting = 1;
+ } else
+ dump_state();
++
++ gettimeofday(&old_time, NULL);
+ }
+ }
+
+diff --git a/squashfs-tools/unsquashfs_info.c b/squashfs-tools/unsquashfs_info.c
+index e906eaf..6015634 100644
+--- a/squashfs-tools/unsquashfs_info.c
++++ b/squashfs-tools/unsquashfs_info.c
+@@ -96,7 +96,7 @@ void dump_state()
+ void *info_thrd(void *arg)
+ {
+ sigset_t sigmask;
+- struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
++ struct timeval old_time = {0}, cur_time = {0};
+ int sig, waiting = 0;
+
+ sigemptyset(&sigmask);
+@@ -104,25 +104,12 @@ void *info_thrd(void *arg)
+ sigaddset(&sigmask, SIGHUP);
+
+ while(1) {
+- if(waiting)
+- sig = sigtimedwait(&sigmask, NULL, ×pec);
+- else
+- sig = sigwaitinfo(&sigmask, NULL);
+-
+- if(sig == -1) {
+- switch(errno) {
+- case EAGAIN:
+- /* interval timed out */
++ sigwait(&sigmask, &sig);
++
++ if(waiting) {
++ gettimeofday(&cur_time, NULL);
++ if (cur_time.tv_sec > old_time.tv_sec )
+ waiting = 0;
+- /* FALLTHROUGH */
+- case EINTR:
+- /* if waiting, the wait will be longer, but
+- that's OK */
+- continue;
+- default:
+- BAD_ERROR("sigtimedwait/sigwaitinfo failed "
+- "because %s\n", strerror(errno));
+- }
+ }
+
+ if(sig == SIGQUIT && !waiting) {
+@@ -134,6 +121,8 @@ void *info_thrd(void *arg)
+ waiting = 1;
+ } else
+ dump_state();
++
++ gettimeofday(&old_time, NULL);
+ }
+ }
+
+--
+2.37.2
+
--- /dev/null
+--- a/squashfs-tools/xattr.c
++++ b/squashfs-tools/xattr.c
+@@ -113,6 +113,7 @@ static int get_prefix(struct xattr_list
+
+ static int read_xattrs_from_system(char *filename, struct xattr_list **xattrs)
+ {
++#if defined(linux)
+ ssize_t size, vsize;
+ char *xattr_names, *p;
+ int i;
+@@ -222,6 +223,10 @@ failed:
+ free(xattr_list);
+ free(xattr_names);
+ return 0;
++#else
++ *xattrs = NULL;
++ return 0;
++#endif
+ }
+
+
+--- a/squashfs-tools/unsquashfs_xattr.c
++++ b/squashfs-tools/unsquashfs_xattr.c
+@@ -34,6 +34,7 @@ extern int user_xattrs;
+
+ void write_xattr(char *pathname, unsigned int xattr)
+ {
++#if defined(linux)
+ unsigned int count;
+ struct xattr_list *xattr_list;
+ int i;
+@@ -136,6 +137,7 @@ void write_xattr(char *pathname, unsigne
+ free_xattr(xattr_list, count);
+
+ return !failed;
++#endif
+ }
+
+
+++ /dev/null
---- a/squashfs-tools/Makefile
-+++ b/squashfs-tools/Makefile
-@@ -7,6 +7,9 @@ all: mksquashfs unsquashfs
- mksquashfs: mksquashfs.o read_fs.o sort.o
- $(CC) mksquashfs.o read_fs.o sort.o -lz -o $@
-
-+mksquashfs-lzma: mksquashfs.o read_fs.o sort.o
-+ $(CXX) mksquashfs.o read_fs.o sort.o -L$(LZMAPATH) -llzma-old -o $@
-+
- mksquashfs.o: mksquashfs.c squashfs_fs.h mksquashfs.h global.h sort.h
-
- read_fs.o: read_fs.c squashfs_fs.h read_fs.h global.h
-@@ -16,4 +19,9 @@ sort.o: sort.c squashfs_fs.h global.h so
- unsquashfs: unsquashfs.o
- $(CC) unsquashfs.o -lz -o $@
-
-+unsquashfs-lzma: unsquashfs.o
-+ $(CXX) unsquashfs.o -L$(LZMAPATH) -llzma-old -o $@
-+
- unsquashfs.o: unsquashfs.c squashfs_fs.h read_fs.h global.h
-+
-+clean:
+++ /dev/null
---- a/squashfs-tools/mksquashfs.c
-+++ b/squashfs-tools/mksquashfs.c
-@@ -1347,7 +1347,7 @@ struct inode_info *lookup_inode(struct s
- }
-
-
--inline void add_dir_entry(char *name, char *pathname, struct dir_info *sub_dir, struct inode_info *inode_info, void *data, struct dir_info *dir)
-+static inline void add_dir_entry(char *name, char *pathname, struct dir_info *sub_dir, struct inode_info *inode_info, void *data, struct dir_info *dir)
- {
- if((dir->count % DIR_ENTRIES) == 0)
- if((dir->list = realloc(dir->list, (dir->count + DIR_ENTRIES) * sizeof(struct dir_ent *))) == NULL)
+++ /dev/null
---- a/squashfs-tools/mksquashfs.c
-+++ b/squashfs-tools/mksquashfs.c
-@@ -117,6 +117,9 @@ unsigned int inode_bytes = 0, inode_size
- char *data_cache = NULL;
- unsigned int cache_bytes = 0, cache_size = 0, inode_count = 0;
-
-+/* override all timestamps */
-+time_t fixed_time = -1;
-+
- /* in memory directory data */
- #define I_COUNT_SIZE 128
- #define DIR_ENTRIES 32
-@@ -1554,6 +1557,11 @@ void dir_scan(squashfs_inode *inode, cha
- perror(buffer);
- return;
- }
-+
-+ /* override timestamp of lstat if fixed_time is given */
-+ if(fixed_time != -1)
-+ inode_info->buf.st_mtime = fixed_time;
-+
- if(sorted)
- sort_files_and_write(dir_info);
- dir_scan2(inode, dir_info);
-@@ -1582,6 +1590,10 @@ struct dir_info *dir_scan1(char *pathnam
- perror(buffer);
- continue;
- }
-+
-+ if(fixed_time != -1)
-+ buf.st_mtime = fixed_time;
-+
- if(excluded(filename, &buf))
- continue;
-
-@@ -1621,6 +1633,9 @@ int dir_scan2(squashfs_inode *inode, str
- char *dir_name = dir_ent->name;
- unsigned int inode_number = ((buf->st_mode & S_IFMT) == S_IFDIR) ? dir_ent->inode->inode_number : dir_ent->inode->inode_number + dir_inode_no;
-
-+ if(fixed_time != -1)
-+ buf->st_mtime = fixed_time;
-+
- if(dir_ent->inode->inode == SQUASHFS_INVALID_BLK) {
- switch(buf->st_mode & S_IFMT) {
- case S_IFREG:
-@@ -1898,6 +1913,16 @@ int main(int argc, char *argv[])
- exit(1);
- }
- }
-+ } else if(strcmp(argv[i], "-fixed-time") == 0) {
-+ if(++i == argc) {
-+ ERROR("%s: -fixed-time missing a timestamp\n", argv[0]);
-+ exit(1);
-+ }
-+ fixed_time = strtoll(argv[i], &b, 10);
-+ if(*b != '\0') {
-+ ERROR("%s: -fixed-time has an invalid number\n", argv[0]);
-+ exit(1);
-+ }
- } else if(strcmp(argv[i], "-noI") == 0 ||
- strcmp(argv[i], "-noInodeCompression") == 0)
- noI = TRUE;
-@@ -1967,6 +1992,7 @@ printOptions:
- ERROR("-all-root\t\tmake all files owned by root\n");
- ERROR("-force-uid uid\t\tset all file uids to uid\n");
- ERROR("-force-gid gid\t\tset all file gids to gid\n");
-+ ERROR("-fixed-time timestamp\tset all timestamps to timestamp\n");
- ERROR("-le\t\t\tcreate a little endian filesystem\n");
- ERROR("-be\t\t\tcreate a big endian filesystem\n");
- ERROR("-nopad\t\t\tdo not pad filesystem to a multiple of 4K\n");
-@@ -2190,7 +2216,7 @@ printOptions:
- sBlk.block_size = block_size;
- sBlk.block_log = block_log;
- sBlk.flags = SQUASHFS_MKFLAGS(noI, noD, check_data, noF, no_fragments, always_use_fragments, duplicate_checking);
-- sBlk.mkfs_time = time(NULL);
-+ sBlk.mkfs_time = fixed_time != -1 ? fixed_time : time(NULL);
-
- restore_filesystem:
- write_fragment();
+++ /dev/null
---- a/squashfs-tools/mksquashfs.c
-+++ b/squashfs-tools/mksquashfs.c
-@@ -30,6 +30,7 @@
- #include <unistd.h>
- #include <stdio.h>
- #include <sys/types.h>
-+#include <sys/sysmacros.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <errno.h>
---- a/squashfs-tools/unsquashfs.c
-+++ b/squashfs-tools/unsquashfs.c
-@@ -25,6 +25,7 @@
- #define FALSE 0
- #include <stdio.h>
- #include <sys/types.h>
-+#include <sys/sysmacros.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <errno.h>
+++ /dev/null
-Fixes the following build error with GCC 10:
- /usr/bin/ld: read_fs.o:(.bss+0x0): multiple definition of `swap'; mksquashfs.o:(.bss+0x1b2a88): first defined here
-And a compile warning.
-
---- a/squashfs-tools/read_fs.c
-+++ b/squashfs-tools/read_fs.c
-@@ -61,7 +61,7 @@ extern int add_file(long long, long long
- fprintf(stderr, s, ## args); \
- } while(0)
-
--int swap;
-+static int swap;
-
- int read_block(int fd, long long start, long long *next, unsigned char *block, squashfs_super_block *sBlk)
- {
---- a/squashfs-tools/mksquashfs.c
-+++ b/squashfs-tools/mksquashfs.c
-@@ -258,6 +258,7 @@ int read_sort_file(char *filename, int s
- void sort_files_and_write(struct dir_info *dir);
- struct file_info *duplicate(char *(get_next_file_block)(struct duplicate_buffer_handle *, unsigned int), struct duplicate_buffer_handle *file_start, long long bytes, unsigned int **block_list, long long *start, int blocks, struct fragment **fragment, char *frag_data, int frag_bytes);
- struct dir_info *dir_scan1(char *, int (_readdir)(char *, char *, struct dir_info *));
-+int dir_scan2(squashfs_inode *inode, struct dir_info *dir_info);
-
- #define MKINODE(A) ((squashfs_inode)(((squashfs_inode) inode_bytes << 16) + (((char *)A) - data_cache)))
-