diff --git a/archivers/lrzip/Makefile b/archivers/lrzip/Makefile new file mode 100644 index 00000000000..fa10c739ca6 --- /dev/null +++ b/archivers/lrzip/Makefile @@ -0,0 +1,36 @@ +COMMENT = compression utility for large files + +GH_ACCOUNT = ckolivas +GH_PROJECT = lrzip +GH_TAGNAME = v0.651 + +CATEGORIES = archivers + +MAINTAINER = Ruben Llorente + +# GPLv2+ +PERMIT_PACKAGE = Yes + +WANTLIB += ${COMPILER_LIBCXX} bz2 c lz4 lzo2 m z + +COMPILER = base-clang ports-gcc + +LIB_DEPENDS = archivers/bzip2 \ + archivers/lz4 \ + archivers/lzo2 + +RUN_DEPENDS = shells/bash + +CONFIGURE_STYLE = autoreconf +CONFIGURE_ARGS = --disable-doc +CONFIGURE_ENV = CPPFLAGS="-I${LOCALBASE}/include" \ + LDFLAGS="-L${LOCALBASE}/lib" + +AUTOCONF_VERSION = 2.69 +AUTOMAKE_VERSION = 1.16 + +post-install: + ${INSTALL_DATA_DIR} ${PREFIX}/share/examples/lrzip + ${INSTALL_DATA} ${WRKSRC}/doc/*.example ${PREFIX}/share/examples/lrzip + +.include diff --git a/archivers/lrzip/distinfo b/archivers/lrzip/distinfo new file mode 100644 index 00000000000..48130635619 --- /dev/null +++ b/archivers/lrzip/distinfo @@ -0,0 +1,2 @@ +SHA256 (lrzip-0.651.tar.gz) = 9MhN53igWRIwQGgf1HwXVl/MT+wMzGj88y2X+tFs2JI= +SIZE (lrzip-0.651.tar.gz) = 238854 diff --git a/archivers/lrzip/patches/patch-Lrzip_h b/archivers/lrzip/patches/patch-Lrzip_h new file mode 100644 index 00000000000..e8c811642db --- /dev/null +++ b/archivers/lrzip/patches/patch-Lrzip_h @@ -0,0 +1,14 @@ +Index: Lrzip.h +--- Lrzip.h.orig ++++ Lrzip.h +@@ -29,6 +29,10 @@ + # include + #endif + ++#if defined (__OpenBSD__) || (__NetBSD__) ++# include ++#endif ++ + #ifdef __cplusplus + extern "C" { + #endif diff --git a/archivers/lrzip/patches/patch-lrzip_c b/archivers/lrzip/patches/patch-lrzip_c new file mode 100644 index 00000000000..e2ae7474681 --- /dev/null +++ b/archivers/lrzip/patches/patch-lrzip_c @@ -0,0 +1,50 @@ +- Use datasize-max instead of all available physical memory for + determining the decompression window. + +- Fix for CVE-2018-5786 + +Index: lrzip.c +--- lrzip.c.orig ++++ lrzip.c +@@ -90,6 +90,32 @@ i64 get_ram(rzip_control *control) + + return ramsize; + } ++#elif defined(__OpenBSD__) ++# include ++i64 get_ram(rzip_control *control) ++{ ++ struct rlimit rl; ++ i64 ramsize = (i64)sysconf(_SC_PHYS_PAGES) * PAGE_SIZE; ++ ++ /* Raise limits all the way to the max */ ++ ++ if (getrlimit(RLIMIT_DATA, &rl) == -1) ++ fatal_return(("Failed to get limits in get_ram\n"), -1); ++ ++ rl.rlim_cur = rl.rlim_max; ++ if (setrlimit(RLIMIT_DATA, &rl) == -1) ++ fatal_return(("Failed to set limits in get_ram\n"), -1); ++ ++ /* Declare detected RAM to be either the max RAM available from ++ physical memory or the max RAM allowed by RLIMIT_DATA, whatever ++ is smaller, to prevent the heuristics from selecting ++ compression windows which cause lrzip to go into deep swap */ ++ ++ if (rl.rlim_max < ramsize) ++ return rl.rlim_max; ++ ++ return ramsize; ++} + #else /* __APPLE__ */ + i64 get_ram(rzip_control *control) + { +@@ -1093,7 +1119,7 @@ next_chunk: + do { + i64 head_off; + +- if (unlikely(last_head && last_head < second_last)) ++ if (unlikely(last_head && last_head <= second_last)) + failure_goto(("Invalid earlier last_head position, corrupt archive.\n"), error); + second_last = last_head; + if (unlikely(last_head + ofs > infile_size)) diff --git a/archivers/lrzip/patches/patch-lrzip_private_h b/archivers/lrzip/patches/patch-lrzip_private_h new file mode 100644 index 00000000000..9fe72e5dfaf --- /dev/null +++ b/archivers/lrzip/patches/patch-lrzip_private_h @@ -0,0 +1,21 @@ +Index: lrzip_private.h +--- lrzip_private.h.orig ++++ lrzip_private.h +@@ -46,8 +46,6 @@ + + #ifdef HAVE_ALLOCA_H + # include +-#elif defined __GNUC__ +-# define alloca __builtin_alloca + #elif defined _AIX + # define alloca __alloca + #elif defined _MSC_VER +@@ -144,7 +142,7 @@ extern int errno; + #define unlikely(x) __builtin_expect(!!(x), 0) + #define __maybe_unused __attribute__((unused)) + +-#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__ANDROID__) || defined(__APPLE__) ++#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__OpenBSD__) + # define ffsll __builtin_ffsll + #endif + diff --git a/archivers/lrzip/pkg/DESCR b/archivers/lrzip/pkg/DESCR new file mode 100644 index 00000000000..c098528e9f6 --- /dev/null +++ b/archivers/lrzip/pkg/DESCR @@ -0,0 +1,5 @@ +LRZIP (Long Range ZIP) is a file compression program designed to +do particularly well on very large files containing long distance +redundancy. The larger the file and the more memory you have, the better +the compression advantage this will provide. A variety of compression +options allow optimizing for size and speed. diff --git a/archivers/lrzip/pkg/PLIST b/archivers/lrzip/pkg/PLIST new file mode 100644 index 00000000000..e87f73c53bc --- /dev/null +++ b/archivers/lrzip/pkg/PLIST @@ -0,0 +1,40 @@ +bin/lrunzip +bin/lrz +bin/lrzcat +@bin bin/lrzip +bin/lrztar +bin/lrzuntar +@man man/man1/lrunzip.1 +@man man/man1/lrz.1 +@man man/man1/lrzcat.1 +@man man/man1/lrzip.1 +@man man/man1/lrztar.1 +@man man/man1/lrzuntar.1 +@man man/man5/lrzip.conf.5 +share/doc/lrzip/ +share/doc/lrzip/AUTHORS +share/doc/lrzip/BUGS +share/doc/lrzip/COPYING +share/doc/lrzip/ChangeLog +share/doc/lrzip/README-NOT-BACKWARD-COMPATIBLE +share/doc/lrzip/README.Assembler +share/doc/lrzip/README.benchmarks +share/doc/lrzip/README.lzo_compresses.test.txt +share/doc/lrzip/README.md +share/doc/lrzip/TODO +share/doc/lrzip/WHATS-NEW +share/doc/lrzip/lrzip.conf.example +share/doc/lrzip/lzma/ +share/doc/lrzip/lzma/7zC.txt +share/doc/lrzip/lzma/7zFormat.txt +share/doc/lrzip/lzma/Methods.txt +share/doc/lrzip/lzma/README +share/doc/lrzip/lzma/README-Alloc +share/doc/lrzip/lzma/history.txt +share/doc/lrzip/lzma/lzma.txt +share/doc/lrzip/magic.header.txt +share/doc/pkg-readmes/${PKGSTEM} +share/examples/lrzip/ +@sample ${SYSCONFDIR}/lrzip/ +share/examples/lrzip/lrzip.conf.example +@sample ${SYSCONFDIR}/lrzip/lrzip.conf diff --git a/archivers/lrzip/pkg/README b/archivers/lrzip/pkg/README new file mode 100644 index 00000000000..4bf87f82365 --- /dev/null +++ b/archivers/lrzip/pkg/README @@ -0,0 +1,7 @@ ++----------------------------------------------------------------------- +| Running ${FULLPKGNAME} on OpenBSD ++----------------------------------------------------------------------- + +Lrzip might require an abusive amount of memory for compression and +decompression. The default limits for datasize may need to be bumped to +use this software.