archivers/lz4json: add new port

OpenBSD has had it for years, and so have various Linux distributions.
This commit is contained in:
Mikhail Teterin 2023-08-22 02:10:19 -04:00
parent 01c420e177
commit 79ebd9b2cd
6 changed files with 89 additions and 0 deletions

View file

@ -78,6 +78,7 @@
SUBDIR += lua-lzlib
SUBDIR += lua-zlib
SUBDIR += lxqt-archiver
SUBDIR += lz4json
SUBDIR += lzfse
SUBDIR += lzip
SUBDIR += lziprecover

View file

@ -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>

View file

@ -0,0 +1,3 @@
TIMESTAMP = 1692684009
SHA256 (andikleen-lz4json-20191229-c44c5100_GH0.tar.gz) = 0aabebdad1963c9f04c2692993e71bf3cadb7007474e617a4435d424e449eca3
SIZE (andikleen-lz4json-20191229-c44c5100_GH0.tar.gz) = 2036

View file

@ -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>

View file

@ -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;
}
-
-
-

View file

@ -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.