diff --git a/packages/squashfs-tools/build.sh b/packages/squashfs-tools/build.sh new file mode 100644 index 000000000000000..019156ff340123e --- /dev/null +++ b/packages/squashfs-tools/build.sh @@ -0,0 +1,23 @@ +TERMUX_PKG_HOMEPAGE=https://github.com/plougher/squashfs-tools +TERMUX_PKG_DESCRIPTION="Tools for squashfs, a highly compressed read-only filesystem for Linux" +TERMUX_PKG_LICENSE="GPL-2.0" +TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_VERSION="4.6.1" +TERMUX_PKG_SRCURL="https://github.com/plougher/squashfs-tools/archive/refs/tags/${TERMUX_PKG_VERSION}.tar.gz" +TERMUX_PKG_SHA256=94201754b36121a9f022a190c75f718441df15402df32c2b520ca331a107511c +TERMUX_PKG_DEPENDS="liblz4, liblzma, liblzo, zlib, zstd" +TERMUX_PKG_AUTO_UPDATE=true +TERMUX_PKG_BUILD_IN_SRC=true +TERMUX_PKG_EXTRA_MAKE_ARGS=" +INSTALL_PREFIX=${TERMUX_PREFIX} +INSTALL_MANPAGES_DIR=${TERMUX_PREFIX}/share/man/man1 +GZIP_SUPPORT=1 +LZ4_SUPPORT=1 +LZMA_XZ_SUPPORT=1 +LZO_SUPPORT=1 +USE_PREBUILT_MANPAGES=1 +XATTR_SUPPORT=1 +XZ_SUPPORT=1 +ZSTD_SUPPORT=1 +-C squashfs-tools +" diff --git a/packages/squashfs-tools/squashfs-tools-mksquashfs.c.patch b/packages/squashfs-tools/squashfs-tools-mksquashfs.c.patch new file mode 100644 index 000000000000000..c2ac038cf83d949 --- /dev/null +++ b/packages/squashfs-tools/squashfs-tools-mksquashfs.c.patch @@ -0,0 +1,39 @@ +diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c +index ba28d65..1e9011e 100644 +--- a/squashfs-tools/mksquashfs.c ++++ b/squashfs-tools/mksquashfs.c +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -76,6 +77,8 @@ + #include "tar.h" + #include "merge_sort.h" + ++static atomic_flag event_thread_cancel; ++ + /* Compression options */ + int noF = FALSE; + int noI = FALSE; +@@ -7592,7 +7595,7 @@ print_sqfstar_compressor_options: + pthread_mutex_lock(&fragment_mutex); + while(fragments_outstanding) { + pthread_mutex_unlock(&fragment_mutex); +- pthread_testcancel(); ++ if (!atomic_flag_test_and_set(&event_thread_cancel)) pthread_exit(NULL); + sched_yield(); + pthread_mutex_lock(&fragment_mutex); + } +@@ -8865,7 +8868,7 @@ print_compressor_options: + pthread_mutex_lock(&fragment_mutex); + while(fragments_outstanding) { + pthread_mutex_unlock(&fragment_mutex); +- pthread_testcancel(); ++ if (!atomic_flag_test_and_set(&event_thread_cancel)) pthread_exit(NULL); + sched_yield(); + pthread_mutex_lock(&fragment_mutex); + } diff --git a/packages/squashfs-tools/squashfs-tools-restore.c.patch b/packages/squashfs-tools/squashfs-tools-restore.c.patch new file mode 100644 index 000000000000000..4f34574bb66156f --- /dev/null +++ b/packages/squashfs-tools/squashfs-tools-restore.c.patch @@ -0,0 +1,114 @@ +diff --git a/squashfs-tools/restore.c b/squashfs-tools/restore.c +index cec5ce9..3ea007f 100644 +--- a/squashfs-tools/restore.c ++++ b/squashfs-tools/restore.c +@@ -57,8 +57,25 @@ extern int reproducible; + static int interrupted = 0; + static pthread_t restore_thread; + ++#ifdef __ANDROID__ ++#include ++static void threadSignalHandler(int signum) ++{ ++ pthread_exit(0); ++} ++#endif ++ + void *restore_thrd(void *arg) + { ++#ifdef __ANDROID__ ++ struct sigaction actions; ++ memset(&actions, 0, sizeof(actions)); ++ sigemptyset(&actions.sa_mask); ++ actions.sa_flags = 0; ++ actions.sa_handler = threadSignalHandler; ++ sigaction(SIGUSR2, &actions, NULL); ++#endif ++ + sigset_t sigmask, old_mask; + int i, sig; + +@@ -84,7 +101,11 @@ void *restore_thrd(void *arg) + disable_info(); + + /* first kill the reader thread */ ++#ifdef __ANDROID__ ++ pthread_kill(reader_thread, SIGUSR2); ++#else + pthread_cancel(reader_thread); ++#endif + pthread_join(reader_thread, NULL); + + /* +@@ -95,7 +116,11 @@ void *restore_thrd(void *arg) + + /* now kill the deflator thread(s) */ + for(i = 0; i < processors; i++) ++#ifdef __ANDROID__ ++ pthread_kill(deflator_thread[i], SIGUSR2); ++#else + pthread_cancel(deflator_thread[i]); ++#endif + for(i = 0; i < processors; i++) + pthread_join(deflator_thread[i], NULL); + +@@ -107,7 +132,11 @@ void *restore_thrd(void *arg) + + /* now kill the process fragment thread(s) */ + for(i = 0; i < processors; i++) ++#ifdef __ANDROID__ ++ pthread_kill(frag_thread[i], SIGUSR2); ++#else + pthread_cancel(frag_thread[i]); ++#endif + for(i = 0; i < processors; i++) + pthread_join(frag_thread[i], NULL); + +@@ -118,7 +147,11 @@ void *restore_thrd(void *arg) + seq_queue_flush(to_main); + + /* now kill the main thread */ ++#ifdef __ANDROID__ ++ pthread_kill(main_thread, SIGUSR2); ++#else + pthread_cancel(main_thread); ++#endif + pthread_join(main_thread, NULL); + + /* then flush the main thread to fragment deflator thread(s) +@@ -128,7 +161,11 @@ void *restore_thrd(void *arg) + + /* now kill the fragment deflator thread(s) */ + for(i = 0; i < processors; i++) ++#ifdef __ANDROID__ ++ pthread_kill(frag_deflator_thread[i], SIGUSR2); ++#else + pthread_cancel(frag_deflator_thread[i]); ++#endif + for(i = 0; i < processors; i++) + pthread_join(frag_deflator_thread[i], NULL); + +@@ -140,7 +177,11 @@ void *restore_thrd(void *arg) + seq_queue_flush(to_order); + + /* now kill the frag orderer thread */ ++#ifdef __ANDROID__ ++ pthread_kill(order_thread, SIGUSR2); ++#else + pthread_cancel(order_thread); ++#endif + pthread_join(order_thread, NULL); + } + +@@ -151,7 +192,11 @@ void *restore_thrd(void *arg) + queue_flush(to_writer); + + /* now kill the writer thread */ ++#ifdef __ANDROID__ ++ pthread_kill(writer_thread, SIGUSR2); ++#else + pthread_cancel(writer_thread); ++#endif + pthread_join(writer_thread, NULL); + + TRACE("All threads cancelled\n"); diff --git a/packages/squashfs-tools/squashfs-tools-unsquashfs.c.patch b/packages/squashfs-tools/squashfs-tools-unsquashfs.c.patch new file mode 100644 index 000000000000000..b360766451b5b1d --- /dev/null +++ b/packages/squashfs-tools/squashfs-tools-unsquashfs.c.patch @@ -0,0 +1,23 @@ +diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c +index 0ac6356..2b548be 100644 +--- a/squashfs-tools/unsquashfs.c ++++ b/squashfs-tools/unsquashfs.c +@@ -1040,6 +1040,18 @@ void queue_dir(char *pathname, struct dir *dir) + queue_put(to_writer, file); + } + ++// https://git.musl-libc.org/cgit/musl/tree/src/legacy/lutimes.c ++int lutimes(const char *filename, const struct timeval tv[2]) ++{ ++ struct timespec times[2]; ++ if (tv) { ++ times[0].tv_sec = tv[0].tv_sec; ++ times[0].tv_nsec = tv[0].tv_usec * 1000; ++ times[1].tv_sec = tv[1].tv_sec; ++ times[1].tv_nsec = tv[1].tv_usec * 1000; ++ } ++ return utimensat(AT_FDCWD, filename, tv ? times : 0, AT_SYMLINK_NOFOLLOW); ++} + + int write_file(struct inode *inode, char *pathname) + {