git: 79ebd9b2cddf - main - archivers/lz4json: add new port

From: Mikhail Teterin <mi_at_FreeBSD.org>
Date: Tue, 22 Aug 2023 06:11:13 UTC
The branch main has been updated by mi:

URL: https://cgit.FreeBSD.org/ports/commit/?id=79ebd9b2cddf24f710e378d28e7aa4d38c32d4ab

commit 79ebd9b2cddf24f710e378d28e7aa4d38c32d4ab
Author:     Mikhail Teterin <mi@FreeBSD.org>
AuthorDate: 2023-08-22 06:10:19 +0000
Commit:     Mikhail Teterin <mi@FreeBSD.org>
CommitDate: 2023-08-22 06:10:19 +0000

    archivers/lz4json: add new port
    
    OpenBSD has had it for years, and so have various Linux distributions.
---
 archivers/Makefile                     |  1 +
 archivers/lz4json/Makefile             | 18 ++++++++++++
 archivers/lz4json/distinfo             |  3 ++
 archivers/lz4json/files/BSDmakefile    | 11 ++++++++
 archivers/lz4json/files/patch-warnings | 50 ++++++++++++++++++++++++++++++++++
 archivers/lz4json/pkg-descr            |  6 ++++
 6 files changed, 89 insertions(+)

diff --git a/archivers/Makefile b/archivers/Makefile
index 22e73d5ae510..aa9aa1032174 100644
--- a/archivers/Makefile
+++ b/archivers/Makefile
@@ -78,6 +78,7 @@
     SUBDIR += lua-lzlib
     SUBDIR += lua-zlib
     SUBDIR += lxqt-archiver
+    SUBDIR += lz4json
     SUBDIR += lzfse
     SUBDIR += lzip
     SUBDIR += lziprecover
diff --git a/archivers/lz4json/Makefile b/archivers/lz4json/Makefile
new file mode 100644
index 000000000000..9792d938eb59
--- /dev/null
+++ b/archivers/lz4json/Makefile
@@ -0,0 +1,18 @@
+PORTNAME=	lz4json
+PORTVERSION=	20191229
+CATEGORIES=	archivers www
+
+MAINTAINER=	mi@aldan.algebra.com
+COMMENT=	Unpack Mozilla lz4json files, such as bookmarks and session restore
+WWW=		https://github.com/andikleen/lz4json
+
+USES=		uidfix
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	andikleen
+GH_TAGNAME=	c44c5100
+PLIST_FILES=	bin/lz4jsoncat man/man1/lz4jsoncat.1${COMPRESS_EXT}
+
+MAKEFILE=	${FILESDIR}/BSDmakefile
+
+.include <bsd.port.mk>
diff --git a/archivers/lz4json/distinfo b/archivers/lz4json/distinfo
new file mode 100644
index 000000000000..cd6261539be4
--- /dev/null
+++ b/archivers/lz4json/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1692684009
+SHA256 (andikleen-lz4json-20191229-c44c5100_GH0.tar.gz) = 0aabebdad1963c9f04c2692993e71bf3cadb7007474e617a4435d424e449eca3
+SIZE (andikleen-lz4json-20191229-c44c5100_GH0.tar.gz) = 2036
diff --git a/archivers/lz4json/files/BSDmakefile b/archivers/lz4json/files/BSDmakefile
new file mode 100644
index 000000000000..002b0e285465
--- /dev/null
+++ b/archivers/lz4json/files/BSDmakefile
@@ -0,0 +1,11 @@
+PROG=	lz4jsoncat
+
+BINDIR=	${LOCALBASE}/bin
+MANDIR=	${LOCALBASE}/man/man
+
+WARNS=	3
+
+CFLAGS+=-isystem ${PREFIX}/include
+LDADD=	-L${PREFIX}/lib -llz4
+
+.include <bsd.prog.mk>
diff --git a/archivers/lz4json/files/patch-warnings b/archivers/lz4json/files/patch-warnings
new file mode 100644
index 000000000000..13c4f68607a7
--- /dev/null
+++ b/archivers/lz4json/files/patch-warnings
@@ -0,0 +1,50 @@
+--- lz4jsoncat.c	2019-12-29 00:44:09.000000000 -0500
++++ lz4jsoncat.c	2023-08-22 01:48:00.646059000 -0400
+@@ -1,3 +1,3 @@
+-/* 
++/*
+  * Dump mozilla style lz4json files.
+  *
+@@ -30,15 +30,19 @@
+ #include <stdint.h>
+ #ifndef __APPLE__
++#	if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFlyBSD__)
++#include <sys/endian.h>
++#	else
+ #include <endian.h>
++#	endif
+ #else
+ #define htole32(x) x /* assume apple targets are little endian */
+ #endif
+ 
+-#include "lz4.h"
++#include <lz4.h>
+ 
+ int main(int ac, char **av)
+ {
+-	while (*++av) {
+-		int fd = open(*av, O_RDONLY);
++	while (--ac) {
++		int fd = open(*++av, O_RDONLY);
+ 		if (fd < 0) {
+ 			perror(*av);
+@@ -56,5 +60,5 @@
+ 
+ 		char *map = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+-		if (map == (char *)-1) {
++		if (map == MAP_FAILED) {
+ 			perror(*av);
+ 			exit(1);
+@@ -64,5 +68,5 @@
+ 			exit(1);
+ 		}
+-		size_t outsz = htole32(*(uint32_t *) (map + 8));
++		ssize_t outsz = htole32(*(uint32_t *) (map + 8));
+ 		char *out = malloc(outsz);
+ 		if (!out) {
+@@ -88,5 +92,2 @@
+ 	return 0;
+ }
+-
+-
+-
diff --git a/archivers/lz4json/pkg-descr b/archivers/lz4json/pkg-descr
new file mode 100644
index 000000000000..501d1483c774
--- /dev/null
+++ b/archivers/lz4json/pkg-descr
@@ -0,0 +1,6 @@
+A little utility to unpack lz4json files as generated by Firefox's
+bookmark backups and session restore.  This is a different format
+from what the normal lz4 utility expects.
+
+The input must be regular file(s) (accessible via mmap()). The
+output is dumped to stdout.