From cc791a45d2fbbba691daf2217c48d5c3e73659cc Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 11 Oct 2023 01:19:28 +0200 Subject: [PATCH] Add mtools port. --- ports/mtools/mtools.patch | 136 ++++++++++++++++++++++++++++++++++++ ports/mtools/mtools.port | 11 +++ ports/mtools/mtools.rmpatch | 3 + 3 files changed, 150 insertions(+) create mode 100644 ports/mtools/mtools.patch create mode 100644 ports/mtools/mtools.port create mode 100644 ports/mtools/mtools.rmpatch diff --git a/ports/mtools/mtools.patch b/ports/mtools/mtools.patch new file mode 100644 index 00000000..69a9469f --- /dev/null +++ b/ports/mtools/mtools.patch @@ -0,0 +1,136 @@ +diff -Paur --no-dereference -- mtools.upstream/configure mtools/configure +--- mtools.upstream/configure ++++ mtools/configure +@@ -3964,17 +3964,11 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +-/* Override any GCC internal prototype to avoid an error. +- Use char because int might match the return type of a GCC +- builtin and then its argument prototype would still apply. */ +-#ifdef __cplusplus +-extern "C" +-#endif +-char iconv (); ++#include + int + main () + { +-return iconv (); ++return (int) iconv; + ; + return 0; + } +diff -Paur --no-dereference -- mtools.upstream/file.c mtools/file.c +--- mtools.upstream/file.c ++++ mtools/file.c +@@ -522,7 +522,7 @@ + extern long timezone; + #endif + tzset(); +- tzone = (long) timezone; ++ tzone = (long) 0; + } + #else + tzone = 0; +diff -Paur --no-dereference -- mtools.upstream/mainloop.h mtools/mainloop.h +--- mtools.upstream/mainloop.h ++++ mtools/mainloop.h +@@ -18,7 +18,6 @@ + * along with Mtools. If not, see . + */ + +-#include + #include "mtoolsDirentry.h" + + typedef struct bounded_string { +diff -Paur --no-dereference -- mtools.upstream/mcopy.c mtools/mcopy.c +--- mtools.upstream/mcopy.c ++++ mtools/mcopy.c +@@ -39,28 +39,12 @@ + static void set_mtime(const char *target, time_t mtime) + { + if (target && strcmp(target, "-") && mtime != 0L) { +-#ifdef HAVE_UTIMES +- struct timeval tv[2]; +- tv[0].tv_sec = mtime; +- tv[0].tv_usec = 0; +- tv[1].tv_sec = mtime; +- tv[1].tv_usec = 0; +- utimes(target, tv); +-#else +-#ifdef HAVE_UTIME +-#ifndef HAVE_UTIMBUF +- struct utimbuf { +- time_t actime; /* access time */ +- time_t modtime; /* modification time */ +- }; +-#endif +- struct utimbuf utbuf; +- +- utbuf.actime = mtime; +- utbuf.modtime = mtime; +- utime(target, &utbuf); +-#endif +-#endif ++ struct timespec ts[2]; ++ ts[0].tv_sec = mtime; ++ ts[0].tv_nsec = 0; ++ ts[1].tv_sec = mtime; ++ ts[1].tv_nsec = 0; ++ utimens(target, ts); + } + return; + } +diff -Paur --no-dereference -- mtools.upstream/plain_io.c mtools/plain_io.c +--- mtools.upstream/plain_io.c ++++ mtools/plain_io.c +@@ -145,7 +145,10 @@ + static int init_geom_with_reg(int fd, struct device *dev, + struct device *orig_dev, + struct MT_STAT *statbuf) { ++ // TODO: Actually use the geometry but the partition has to report it. ++#ifndef __sortix__ + if(S_ISREG(statbuf->st_mode)) { ++#endif + /* Regular file (image file) */ + mt_off_t sectors; + if(statbuf->st_size == 0) { +@@ -161,10 +164,12 @@ + ? UINT32_MAX + : (uint32_t) sectors; + return 0; ++#ifndef __sortix__ + } else { + /* All the rest (devices, etc.) */ + return init_geom(fd, dev, orig_dev, statbuf); + } ++#endif + } + + static int file_geom(Stream_t *Stream, struct device *dev, +diff -Paur --no-dereference -- mtools.upstream/sysincludes.h mtools/sysincludes.h +--- mtools.upstream/sysincludes.h ++++ mtools/sysincludes.h +@@ -397,19 +397,11 @@ + + /* missing functions */ + #ifndef HAVE_SRANDOM +-# ifdef OS_mingw32msvc +-# define srandom srand +-# else +-# define srandom srand48 +-# endif ++# define srandom + #endif + + #ifndef HAVE_RANDOM +-# ifdef OS_mingw32msvc +-# define random (long)rand +-# else +-# define random (long)lrand48 +-# endif ++# define random (long)arc4random + #endif + + #ifndef HAVE_STRCHR diff --git a/ports/mtools/mtools.port b/ports/mtools/mtools.port new file mode 100644 index 00000000..70aaa011 --- /dev/null +++ b/ports/mtools/mtools.port @@ -0,0 +1,11 @@ +NAME=mtools +BUILD_LIBRARIES='libiconv' +VERSION=4.0.43 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.bz2 +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=541e179665dc4e272b9602f2074243591a157da89cc47064da8c5829dbd2b339 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/mtools +UPSTREAM_ARCHIVE=$ARCHIVE +LICENSE=GPL-3.0-or-later +BUILD_SYSTEM=configure diff --git a/ports/mtools/mtools.rmpatch b/ports/mtools/mtools.rmpatch new file mode 100644 index 00000000..5a33d9b0 --- /dev/null +++ b/ports/mtools/mtools.rmpatch @@ -0,0 +1,3 @@ +rm -rf -- 'mtools.info' +rm -rf -- 'mtools.1' +rm -rf -- 'mtools.5'