Skip to content

Commit

Permalink
addpkg(main/squashfs-tools): 4.2-p20130326
Browse files Browse the repository at this point in the history
  • Loading branch information
robertkirkman committed Jan 29, 2025
1 parent e3f57ed commit 0f21335
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 0 deletions.
61 changes: 61 additions & 0 deletions packages/squashfs-tools/0001-forward-port.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
minor selective cherry-picks:
https://github.com/plougher/squashfs-tools/commit/968aa53dd6d2c0831a9af01873441767c06b88d0
https://github.com/plougher/squashfs-tools/commit/4a33df67a4ec67d32a6a58745517c8fbaa47d602

--- a/squashfs-tools/action.c
+++ b/squashfs-tools/action.c
@@ -39,6 +39,10 @@
#include <limits.h>
#include <errno.h>

+#ifndef FNM_EXTMATCH /* glibc extension */
+ #define FNM_EXTMATCH 0
+#endif
+
#include "squashfs_fs.h"
#include "mksquashfs.h"
#include "action.h"
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -35,6 +35,7 @@
#include <stddef.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
@@ -51,6 +52,10 @@
#include <limits.h>
#include <ctype.h>

+#ifndef FNM_EXTMATCH /* glibc extension */
+ #define FNM_EXTMATCH 0
+#endif
+
#ifndef linux
#define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -32,6 +32,7 @@
#include "stdarg.h"

#include <sys/sysinfo.h>
+#include <sys/sysmacros.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
--- a/squashfs-tools/unsquashfs.h
+++ b/squashfs-tools/unsquashfs.h
@@ -45,6 +45,10 @@
#include <sys/ioctl.h>
#include <sys/time.h>

+#ifndef FNM_EXTMATCH /* glibc extension */
+ #define FNM_EXTMATCH 0
+#endif
+
#ifndef linux
#define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN
18 changes: 18 additions & 0 deletions packages/squashfs-tools/0002-strdupa.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copied and pasted from FreeBSD
https://github.com/freebsd/freebsd-ports/blob/8a36c580e223f80151c857f53288df13e215b92c/filesystems/squashfs-tools/files/patch-action.c

--- a/squashfs-tools/action.c
+++ b/squashfs-tools/action.c
@@ -44,6 +44,12 @@
#include "action.h"
#include "error.h"

+#ifndef strdupa
+#include <string.h> // required for str*()
+#include <stdlib.h> // required for alloca
+#define strdupa(foo) (strncpy( alloca( strlen(foo) + 1 ), foo, strlen( foo ) + 1 ))
+#endif
+
/*
* code to parse actions
*/
80 changes: 80 additions & 0 deletions packages/squashfs-tools/0003-force-little-endian.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
For an unknown reason, endianness detection is not working correctly.
For the record, Android cannot be Big Endian: https://developer.android.com/ndk/guides/abis

--- a/squashfs-tools/mksquashfs.h
+++ b/squashfs-tools/mksquashfs.h
@@ -25,7 +25,7 @@
*
*/

-#if __BYTE_ORDER == __BIG_ENDIAN
+#if 0
#define SQUASHFS_SWAP_SHORTS(s, d, n) swap_le16_num(s, d, n)
#define SQUASHFS_SWAP_INTS(s, d, n) swap_le32_num(s, d, n)
#define SQUASHFS_SWAP_LONG_LONGS(s, d, n) swap_le64_num(s, d, n)
--- a/squashfs-tools/read_fs.h
+++ b/squashfs-tools/read_fs.h
@@ -24,7 +24,7 @@
*
*/

-#if __BYTE_ORDER == __BIG_ENDIAN
+#if 0
#define SQUASHFS_SWAP_SHORTS(d, s, n) swap_le16_num(s, d, n)
#define SQUASHFS_SWAP_INTS(d, s, n) swap_le32_num(s, d, n)
#define SQUASHFS_SWAP_LONG_LONGS(d, s, n) swap_le64_num(s, d, n)
--- a/squashfs-tools/squashfs_compat.h
+++ b/squashfs-tools/squashfs_compat.h
@@ -765,7 +765,7 @@ typedef struct squashfs_fragment_entry_2 squashfs_fragment_entry_2;
* macros used to swap each structure entry, taking into account
* bitfields and different bitfield placing conventions on differing architectures
*/
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if 0
/* convert from big endian to little endian */
#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, b_pos)
#else
--- a/squashfs-tools/squashfs_swap.h
+++ b/squashfs-tools/squashfs_swap.h
@@ -27,7 +27,7 @@
* macros to convert each stucture from big endian to little endian
*/

-#if __BYTE_ORDER == __BIG_ENDIAN
+#if 0
#include <stddef.h>
extern void swap_le16(void *, void *);
extern void swap_le32(void *, void *);
--- a/squashfs-tools/swap.c
+++ b/squashfs-tools/swap.c
@@ -27,7 +27,7 @@
#include <endian.h>
#endif

-#if __BYTE_ORDER == __BIG_ENDIAN
+#if 0
void swap_le16(void *src, void *dest)
{
unsigned char *s = src;
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -1590,7 +1590,7 @@ void squashfs_stat(char *source)
time_t mkfs_time = (time_t) sBlk.s.mkfs_time;
char *mkfs_str = ctime(&mkfs_time);

-#if __BYTE_ORDER == __BIG_ENDIAN
+#if 0
printf("Found a valid %sSQUASHFS %d:%d superblock on %s.\n",
sBlk.s.s_major == 4 ? "" : swap ? "little endian " :
"big endian ", sBlk.s.s_major, sBlk.s.s_minor, source);
--- a/squashfs-tools/xz_wrapper.h
+++ b/squashfs-tools/xz_wrapper.h
@@ -32,7 +32,7 @@
#include <endian.h>
#endif

-#if __BYTE_ORDER == __BIG_ENDIAN
+#if 0
extern unsigned int inswap_le32(unsigned int);

#define SQUASHFS_INSWAP_COMP_OPTS(s) { \
78 changes: 78 additions & 0 deletions packages/squashfs-tools/0004-set-inline-functions-static.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
If these functions are not set as static,
they result in these errors at link-time
ld.lld: error: undefined symbol: waitforthread
This problem is reproducible in a milder form when
building squashfs-tools 4.2 on modern GNU/Linux when using Clang version 19.1.4,
but is not reproducible when building it using GCC 14.2.1.

--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -707,7 +707,7 @@ void cache_block_put(struct file_buffer *entry)
+ (((char *)A) - data_cache)))


-inline void waitforthread(int i)
+static inline void waitforthread(int i)
{
TRACE("Waiting for thread %d\n", i);
while(thread[i] != 0)
@@ -2323,7 +2323,7 @@ struct file_info *duplicate(long long file_size, long long bytes,
}


-inline int is_fragment(struct inode_info *inode)
+static inline int is_fragment(struct inode_info *inode)
{
int file_size = inode->buf.st_size;

@@ -3389,20 +3389,20 @@ struct inode_info *lookup_inode2(struct stat *buf, int pseudo, int id)
}


-inline struct inode_info *lookup_inode(struct stat *buf)
+static inline struct inode_info *lookup_inode(struct stat *buf)
{
return lookup_inode2(buf, 0, 0);
}


-inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
+static inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
{
if (inode->inode_number == 0)
inode->inode_number = use_this ? : inode_no ++;
}


-inline struct dir_ent *create_dir_entry(char *name, char *source_name,
+static inline struct dir_ent *create_dir_entry(char *name, char *source_name,
char *nonstandard_pathname, struct dir_info *dir)
{
struct dir_ent *dir_ent = malloc(sizeof(struct dir_ent));
@@ -3419,7 +3419,7 @@ inline struct dir_ent *create_dir_entry(char *name, char *source_name,
}


-inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
+static inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
struct inode_info *inode_info)
{
struct dir_info *dir = dir_ent->our_dir;
@@ -3435,7 +3435,7 @@ inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
}


-inline void add_dir_entry2(char *name, char *source_name,
+static inline void add_dir_entry2(char *name, char *source_name,
char *nonstandard_pathname, struct dir_info *sub_dir,
struct inode_info *inode_info, struct dir_info *dir)
{
@@ -3447,7 +3447,7 @@ inline void add_dir_entry2(char *name, char *source_name,
}


-inline void free_dir_entry(struct dir_ent *dir_ent)
+static inline void free_dir_entry(struct dir_ent *dir_ent)
{
if(dir_ent->name)
free(dir_ent->name);
45 changes: 45 additions & 0 deletions packages/squashfs-tools/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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"
# last commit made before pthread_cancel() introduced to codebase
_COMMIT=1a26745235e776cd47264b2d96c703676b89cc70
_COMMIT_DATE=20130326
TERMUX_PKG_VERSION="4.2-p${_COMMIT_DATE}"
TERMUX_PKG_SRCURL=git+https://github.com/plougher/squashfs-tools.git
TERMUX_PKG_GIT_BRANCH=master
TERMUX_PKG_SHA256=6cd4a91a2db99c9b041a3b9077da9860758d44320c1461b4d06513f9a2a6ad70
TERMUX_PKG_DEPENDS="liblz4, liblzma, liblzo, zlib, zstd"
TERMUX_PKG_AUTO_UPDATE=false
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_MAKE_PROCESSES=1
TERMUX_PKG_EXTRA_MAKE_ARGS="
INSTALL_DIR=$TERMUX_PREFIX/bin
LZO_DIR=$TERMUX_PREFIX
GZIP_SUPPORT=1
LZ4_SUPPORT=1
LZMA_XZ_SUPPORT=1
LZO_SUPPORT=1
XATTR_SUPPORT=1
XZ_SUPPORT=1
ZSTD_SUPPORT=1
-C squashfs-tools
"

termux_step_post_get_source() {
git fetch --unshallow
git checkout $_COMMIT

local pdate="p$(git log -1 --format=%cs | sed 's/-//g')"
if [[ "$TERMUX_PKG_VERSION" != *"${pdate}" ]]; then
echo -n "ERROR: The version string \"$TERMUX_PKG_VERSION\" is"
echo -n " different from what is expected to be; should end"
echo " with \"${pdate}\"."
return 1
fi

local s=$(find . -type f ! -path '*/.git/*' -print0 | xargs -0 sha256sum | LC_ALL=C sort | sha256sum)
if [[ "${s}" != "${TERMUX_PKG_SHA256} "* ]]; then
termux_error_exit "Checksum mismatch for source files."
fi
}

0 comments on commit 0f21335

Please sign in to comment.