git: f5858d0bce93 - main - sysutils/genimage: New port: Tool to generate multiple filesystem and flash images from a tree

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Fri, 06 Jan 2023 18:17:50 UTC
The branch main has been updated by yuri:

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

commit f5858d0bce93eaa9bc455da3382a34b778939cd6
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2023-01-06 15:31:22 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2023-01-06 18:17:45 +0000

    sysutils/genimage: New port: Tool to generate multiple filesystem and flash images from a tree
---
 sysutils/Makefile                                  |  1 +
 sysutils/genimage/Makefile                         | 26 ++++++++++++++++++++++
 sysutils/genimage/distinfo                         |  3 +++
 sysutils/genimage/files/patch-config.c             | 19 ++++++++++++++++
 .../genimage/files/patch-image-android-sparse.c    | 11 +++++++++
 sysutils/genimage/files/patch-image-hd.c           | 11 +++++++++
 sysutils/genimage/files/patch-image-rauc.c         | 11 +++++++++
 sysutils/genimage/files/patch-image-vfat.c         | 11 +++++++++
 sysutils/genimage/pkg-descr                        |  8 +++++++
 9 files changed, 101 insertions(+)

diff --git a/sysutils/Makefile b/sysutils/Makefile
index 5ad5cf480cea..64f22e349622 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -472,6 +472,7 @@
     SUBDIR += gdisk
     SUBDIR += gdmap
     SUBDIR += gdu
+    SUBDIR += genimage
     SUBDIR += genisoimage
     SUBDIR += geomWatch
     SUBDIR += getdelta
diff --git a/sysutils/genimage/Makefile b/sysutils/genimage/Makefile
new file mode 100644
index 000000000000..89037b7f0c86
--- /dev/null
+++ b/sysutils/genimage/Makefile
@@ -0,0 +1,26 @@
+PORTNAME=	genimage
+DISTVERSIONPREFIX=	v
+DISTVERSION=	16-10
+DISTVERSIONSUFFIX=	-g2b9d870
+#MASTER_SITES=	https://github.com/pengutronix/genimage/releases/download/v${DISTVERSION}/
+CATEGORIES=	sysutils
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Tool to generate multiple filesystem and flash images from a tree
+WWW=		https://github.com/pengutronix/genimage
+
+LICENSE=	GPLv2
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+LIB_DEPENDS=	libconfuse.so:devel/libconfuse
+
+USES=		autoreconf gettext-runtime pkgconfig #tar:xz
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	pengutronix
+
+GNU_CONFIGURE=	yes
+
+PLIST_FILES=	bin/genimage
+
+.include <bsd.port.mk>
diff --git a/sysutils/genimage/distinfo b/sysutils/genimage/distinfo
new file mode 100644
index 000000000000..266fd2f092b7
--- /dev/null
+++ b/sysutils/genimage/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1673027507
+SHA256 (pengutronix-genimage-v16-10-g2b9d870_GH0.tar.gz) = b6de4e7e14216e1a79a5ea4ee2703c1f5ffa84ec4cfa5b72dc63905bc31fcaed
+SIZE (pengutronix-genimage-v16-10-g2b9d870_GH0.tar.gz) = 87753
diff --git a/sysutils/genimage/files/patch-config.c b/sysutils/genimage/files/patch-config.c
new file mode 100644
index 000000000000..1a1663c75946
--- /dev/null
+++ b/sysutils/genimage/files/patch-config.c
@@ -0,0 +1,19 @@
+--- config.c.orig	2023-01-06 17:56:22 UTC
++++ config.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <getopt.h>
+ #include <unistd.h>
++#include <sys/syslimits.h>
+ 
+ #include "genimage.h"
+ 
+@@ -259,7 +260,7 @@ static char *abspath(const char *path)
+ 	if (*path == '/')
+ 		return strdup(path);
+ 
+-	xasprintf(&p, "%s/%s", get_current_dir_name(), path);
++	xasprintf(&p, "%s/%s", getcwd(NULL, PATH_MAX), path);
+ 
+ 	return p;
+ }
diff --git a/sysutils/genimage/files/patch-image-android-sparse.c b/sysutils/genimage/files/patch-image-android-sparse.c
new file mode 100644
index 000000000000..62644b0a8fd1
--- /dev/null
+++ b/sysutils/genimage/files/patch-image-android-sparse.c
@@ -0,0 +1,11 @@
+--- image-android-sparse.c.orig	2023-01-06 17:52:40 UTC
++++ image-android-sparse.c
+@@ -15,7 +15,7 @@
+  */
+ 
+ #include <confuse.h>
+-#include <endian.h>
++#include <sys/endian.h>
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <stdlib.h>
diff --git a/sysutils/genimage/files/patch-image-hd.c b/sysutils/genimage/files/patch-image-hd.c
new file mode 100644
index 000000000000..0b3465c91655
--- /dev/null
+++ b/sysutils/genimage/files/patch-image-hd.c
@@ -0,0 +1,11 @@
+--- image-hd.c.orig	2023-01-06 17:53:09 UTC
++++ image-hd.c
+@@ -22,7 +22,7 @@
+ #include <stdlib.h>
+ #include <errno.h>
+ #include <inttypes.h>
+-#include <endian.h>
++#include <sys/endian.h>
+ #include <stdbool.h>
+ #include <unistd.h>
+ #include <sys/types.h>
diff --git a/sysutils/genimage/files/patch-image-rauc.c b/sysutils/genimage/files/patch-image-rauc.c
new file mode 100644
index 000000000000..225db5c40bd0
--- /dev/null
+++ b/sysutils/genimage/files/patch-image-rauc.c
@@ -0,0 +1,11 @@
+--- image-rauc.c.orig	2023-01-06 17:59:29 UTC
++++ image-rauc.c
+@@ -95,7 +95,7 @@ static int rauc_generate(struct image *image)
+ 		}
+ 
+ 		/* create parent directories if target needs it */
+-		path = strdupa(target);
++		path = strdup(target); // XXX causes memory leak
+ 		tmp = strrchr(path, '/');
+ 		if (tmp) {
+ 			*tmp = '\0';
diff --git a/sysutils/genimage/files/patch-image-vfat.c b/sysutils/genimage/files/patch-image-vfat.c
new file mode 100644
index 000000000000..e3d524cd9e24
--- /dev/null
+++ b/sysutils/genimage/files/patch-image-vfat.c
@@ -0,0 +1,11 @@
+--- image-vfat.c.orig	2023-01-06 18:01:33 UTC
++++ image-vfat.c
+@@ -47,7 +47,7 @@ static int vfat_generate(struct image *image)
+ 		struct image *child = image_get(part->image);
+ 		const char *file = imageoutfile(child);
+ 		const char *target = part->name;
+-		char *path = strdupa(target);
++		char *path = strdup(target); // XXX causes memory leak
+ 		char *next = path;
+ 
+ 		while ((next = strchr(next, '/')) != NULL) {
diff --git a/sysutils/genimage/pkg-descr b/sysutils/genimage/pkg-descr
new file mode 100644
index 000000000000..2198193a3014
--- /dev/null
+++ b/sysutils/genimage/pkg-descr
@@ -0,0 +1,8 @@
+genimage is a tool to generate multiple filesystem and flash/disk images
+from a given root filesystem tree. genimage is intended to be run in a
+fakeroot environment. It also supports creating flash/disk images out of
+different file-system images and files.
+
+Configuration is done in a config file parsed by libconfuse. Options like the
+path to tools can be given via environment variables, the config file or from
+commandline switches.