diff mbox series

[1/1] package/open-iscsi: new package

Message ID 20220926154320.35494-1-tianyuanhao3@163.com
State Changes Requested
Headers show
Series [1/1] package/open-iscsi: new package | expand

Commit Message

TIAN Yuanhao Sept. 26, 2022, 3:43 p.m. UTC
Signed-off-by: TIAN Yuanhao <tianyuanhao3@163.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 DEVELOPERS                         |  1 +
 package/Config.in                  |  1 +
 package/open-iscsi/Config.in       | 38 +++++++++++++++++
 package/open-iscsi/open-iscsi.hash |  3 ++
 package/open-iscsi/open-iscsi.mk   | 68 ++++++++++++++++++++++++++++++
 5 files changed, 111 insertions(+)
 create mode 100644 package/open-iscsi/Config.in
 create mode 100644 package/open-iscsi/open-iscsi.hash
 create mode 100644 package/open-iscsi/open-iscsi.mk

Comments

Thomas Petazzoni Sept. 26, 2022, 4:27 p.m. UTC | #1
Hello,

On Mon, 26 Sep 2022 08:43:20 -0700
TIAN Yuanhao <tianyuanhao3@163.com> wrote:

> Signed-off-by: TIAN Yuanhao <tianyuanhao3@163.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Thanks for this new patch! See comments below.


> +OPEN_ISCSI_CONF_OPTS = -Ddbroot=/var/lib/iscsi
> +
> +ifeq ($(BR2_PACKAGE_SYSTEMD),y)
> +OPEN_ISCSI_DEPENDENCIES += systemd
> +OPEN_ISCSI_CONF_OPTS += -Dno_systemd=false
> +else
> +OPEN_ISCSI_CONF_OPTS += -Dno_systemd=true
> +endif

Weird option "no_systemd". Why didn't they make that positive logic?

> +
> +ifeq ($(BR2_PACKAGE_OPEN_ISNS),)
> +define OPEN_ISCSI_DISABLE_ISNS
> +	$(SED) "/'isns'/s/^/#/" $(@D)/meson.build
> +	$(SED) "/'iscsid'/s/^/#/" $(@D)/usr/meson.build
> +	$(SED) "/'iscsiadm'/s/^/#/" $(@D)/usr/meson.build
> +endef

Isn't a bit annoying to have this kind of mess. Could you instead add
an option in meson.build to enable/disable isns support, and contribute
this improvement upstream?

> +OPEN_ISCSI_PRE_CONFIGURE_HOOKS += OPEN_ISCSI_DISABLE_ISNS
> +else
> +OPEN_ISCSI_DEPENDENCIES += open-isns
> +endif
> +
> +define OPEN_ISCSI_INSTALL_TARGET_CMDS
> +	$(INSTALL) -d -m 755 $(TARGET_DIR)/usr/lib
> +	cp -dpf $(@D)/build/libopeniscsiusr.so{,.0,.0.2.0} \
> +		$(TARGET_DIR)/usr/lib/
> +	$(OPEN_ISCSI_INSTALL_ISCSID)
> +	$(OPEN_ISCSI_INSTALL_ISCSISTART)
> +endef
> +
> +ifeq ($(BR2_PACKAGE_OPEN_ISCSI_ISCSID),y)
> +define OPEN_ISCSI_INSTALL_ISCSID
> +	$(INSTALL) -d -m 755 $(TARGET_DIR)/usr/sbin
> +	$(INSTALL) -m 755 -t $(TARGET_DIR)/usr/sbin \
> +		$(@D)/build/{iscsi-iname,iscsiadm,iscsid}
> +	$(INSTALL) -D -m 644 {$(@D)/etc,$(TARGET_DIR)/etc/iscsi}/iscsid.conf
> +endef
> +
> +define OPEN_ISCSI_INSTALL_INIT_SYSTEMD
> +	$(INSTALL) -d -m 755 $(TARGET_DIR)/usr/lib/systemd/system
> +	$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/systemd/system \
> +		$(@D)/build/{iscsi,iscsi-init,iscsid}.service \
> +		$(@D)/etc/systemd/iscsid.socket

Why isn't that installed automatically by the meson build system when
systemd support is enabled?

> +endef
> +endif
> +
> +ifeq ($(BR2_PACKAGE_OPEN_ISCSI_ISCSISTART),y)
> +define OPEN_ISCSI_INSTALL_ISCSISTART
> +	$(INSTALL) -D -m 755 {$(@D)/build,$(TARGET_DIR)/usr/sbin}/iscsistart
> +endef
> +endif

It's also a bit annoying that you have to reimplement all the
installation logic. What about improving the meson.build with
additional options, and contribute these improvements upstream?

Thanks a lot!

Thomas
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 54216450f4..7a698c31c0 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2791,6 +2791,7 @@  N:	Sven Oliver Moll <svolli@svolli.de>
 F:	package/most/
 
 N:	TIAN Yuanhao <tianyuanhao3@163.com>
+F:	package/open-iscsi/
 F:	package/open-isns/
 
 N:	Theo Debrouwere <t.debrouwere@televic.com>
diff --git a/package/Config.in b/package/Config.in
index de51be400b..dacc317132 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2357,6 +2357,7 @@  endif
 	source "package/odhcp6c/Config.in"
 	source "package/odhcploc/Config.in"
 	source "package/olsr/Config.in"
+	source "package/open-iscsi/Config.in"
 	source "package/open-lldp/Config.in"
 	source "package/open-plc-utils/Config.in"
 	source "package/openntpd/Config.in"
diff --git a/package/open-iscsi/Config.in b/package/open-iscsi/Config.in
new file mode 100644
index 0000000000..b13c518439
--- /dev/null
+++ b/package/open-iscsi/Config.in
@@ -0,0 +1,38 @@ 
+config BR2_PACKAGE_OPEN_ISCSI
+	bool "open-iscsi"
+	depends on BR2_USE_MMU # fork()
+	depends on BR2_TOOLCHAIN_HAS_THREADS # pthread
+	depends on !BR2_STATIC_LIBS # kmod
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_OPEN_ISCSI_ISCSISTART \
+		if !BR2_PACKAGE_OPEN_ISCSI_ISCSID
+	select BR2_PACKAGE_KMOD
+	select BR2_PACKAGE_UTIL_LINUX
+	select BR2_PACKAGE_UTIL_LINUX_LIBS
+	select BR2_PACKAGE_UTIL_LINUX_LIBMOUNT
+	help
+	  iSCSI tools for Linux.
+
+	  https://www.open-iscsi.com
+
+if BR2_PACKAGE_OPEN_ISCSI
+
+config BR2_PACKAGE_OPEN_ISCSI_ISCSID
+	bool "iscsid"
+	default y
+	select BR2_PACKAGE_OPEN_ISNS
+	help
+	  iscsid implements the control path of iSCSI protocol, plus
+	  some management facilities.
+
+config BR2_PACKAGE_OPEN_ISCSI_ISCSISTART
+	bool "iscsistart"
+	help
+	  iscsistart is used for attaching to iSCSI targets during
+	  bootup.
+
+endif
+
+comment "open-iscsi needs a toolchain w/ threads, dynamic library"
+	depends on BR2_USE_MMU
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS
diff --git a/package/open-iscsi/open-iscsi.hash b/package/open-iscsi/open-iscsi.hash
new file mode 100644
index 0000000000..ee6b0d41ce
--- /dev/null
+++ b/package/open-iscsi/open-iscsi.hash
@@ -0,0 +1,3 @@ 
+# Locally calculated
+sha256  f5d038583657030345711d50b6d8095a0f2da5076bfe7035d64a2beba53405e8  open-iscsi-f633c09a7a2976069b1dfd98d9979349e92c38b5.tar.gz
+sha256  8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643  COPYING
diff --git a/package/open-iscsi/open-iscsi.mk b/package/open-iscsi/open-iscsi.mk
new file mode 100644
index 0000000000..d777101824
--- /dev/null
+++ b/package/open-iscsi/open-iscsi.mk
@@ -0,0 +1,68 @@ 
+################################################################################
+#
+# open-iscsi
+#
+################################################################################
+
+OPEN_ISCSI_VERSION = f633c09a7a2976069b1dfd98d9979349e92c38b5
+OPEN_ISCSI_SITE = $(call github,open-iscsi,open-iscsi,$(OPEN_ISCSI_VERSION))
+OPEN_ISCSI_LICENSE = GPL-2.0+
+OPEN_ISCSI_LICENSE_FILES = COPYING
+OPEN_ISCSI_DEPENDENCIES = kmod openssl util-linux-libs
+
+OPEN_ISCSI_CONF_OPTS = -Ddbroot=/var/lib/iscsi
+
+ifeq ($(BR2_PACKAGE_SYSTEMD),y)
+OPEN_ISCSI_DEPENDENCIES += systemd
+OPEN_ISCSI_CONF_OPTS += -Dno_systemd=false
+else
+OPEN_ISCSI_CONF_OPTS += -Dno_systemd=true
+endif
+
+ifeq ($(BR2_PACKAGE_OPEN_ISNS),)
+define OPEN_ISCSI_DISABLE_ISNS
+	$(SED) "/'isns'/s/^/#/" $(@D)/meson.build
+	$(SED) "/'iscsid'/s/^/#/" $(@D)/usr/meson.build
+	$(SED) "/'iscsiadm'/s/^/#/" $(@D)/usr/meson.build
+endef
+OPEN_ISCSI_PRE_CONFIGURE_HOOKS += OPEN_ISCSI_DISABLE_ISNS
+else
+OPEN_ISCSI_DEPENDENCIES += open-isns
+endif
+
+define OPEN_ISCSI_INSTALL_TARGET_CMDS
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/usr/lib
+	cp -dpf $(@D)/build/libopeniscsiusr.so{,.0,.0.2.0} \
+		$(TARGET_DIR)/usr/lib/
+	$(OPEN_ISCSI_INSTALL_ISCSID)
+	$(OPEN_ISCSI_INSTALL_ISCSISTART)
+endef
+
+ifeq ($(BR2_PACKAGE_OPEN_ISCSI_ISCSID),y)
+define OPEN_ISCSI_INSTALL_ISCSID
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/usr/sbin
+	$(INSTALL) -m 755 -t $(TARGET_DIR)/usr/sbin \
+		$(@D)/build/{iscsi-iname,iscsiadm,iscsid}
+	$(INSTALL) -D -m 644 {$(@D)/etc,$(TARGET_DIR)/etc/iscsi}/iscsid.conf
+endef
+
+define OPEN_ISCSI_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/usr/lib/systemd/system
+	$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/systemd/system \
+		$(@D)/build/{iscsi,iscsi-init,iscsid}.service \
+		$(@D)/etc/systemd/iscsid.socket
+endef
+endif
+
+ifeq ($(BR2_PACKAGE_OPEN_ISCSI_ISCSISTART),y)
+define OPEN_ISCSI_INSTALL_ISCSISTART
+	$(INSTALL) -D -m 755 {$(@D)/build,$(TARGET_DIR)/usr/sbin}/iscsistart
+endef
+endif
+
+define OPEN_ISCSI_LINUX_CONFIG_FIXUPS
+	$(call KCONFIG_ENABLE_OPT,CONFIG_SCSI_LOWLEVEL)
+	$(call KCONFIG_ENABLE_OPT,CONFIG_ISCSI_TCP)
+endef
+
+$(eval $(meson-package))