All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] nc: new virtual package providing "netcat" functionality
@ 2017-09-17  7:15 Carlos Santos
  2017-09-17 21:45 ` [Buildroot] [PATCH v2] " Carlos Santos
  0 siblings, 1 reply; 21+ messages in thread
From: Carlos Santos @ 2017-09-17  7:15 UTC (permalink / raw)
  To: buildroot

Add the "nc" virtual package and modify netcat, netcat-openbsd and nmap
to become providers.

Make the nmap recipe install "ncat" (with a symbolic link to nc) if the
BR2_PACKAGE_NMAP_NCAT option is set. Other programs (ncat, ndiff, etc.)
are still chosen via BR2_PACKAGE_NMAP, in the "Networking applications"
menu.

So far the "nc" options available to build with uClibc were the ancient
GNU netcat and its Busybox double. Both lack features available in more
modern netcats like IPv6, proxies, and Unix sockets.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
---
 package/Config.in                        |  3 +-
 package/nc/Config.in                     | 83 ++++++++++++++++++++++++++++++++
 package/nc/nc.mk                         |  7 +++
 package/netcat-openbsd/Config.in         | 25 ----------
 package/netcat-openbsd/netcat-openbsd.mk |  2 +
 package/netcat/Config.in                 | 13 -----
 package/netcat/netcat.mk                 |  1 +
 package/nmap/nmap.mk                     | 30 +++++++++++-
 8 files changed, 122 insertions(+), 42 deletions(-)
 create mode 100644 package/nc/Config.in
 create mode 100644 package/nc/nc.mk

diff --git a/package/Config.in b/package/Config.in
index d4e40a6326..275461321f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1676,11 +1676,10 @@ menu "Networking applications"
 	source "package/mrouted/Config.in"
 	source "package/mtr/Config.in"
 	source "package/nbd/Config.in"
+	source "package/nc/Config.in"
 	source "package/ncftp/Config.in"
 	source "package/ndisc6/Config.in"
 	source "package/netatalk/Config.in"
-	source "package/netcat/Config.in"
-	source "package/netcat-openbsd/Config.in"
 	source "package/netplug/Config.in"
 	source "package/netsnmp/Config.in"
 	source "package/netstat-nat/Config.in"
diff --git a/package/nc/Config.in b/package/nc/Config.in
new file mode 100644
index 0000000000..c75e856c58
--- /dev/null
+++ b/package/nc/Config.in
@@ -0,0 +1,83 @@
+config BR2_PACKAGE_NC
+	bool "nc (netcat)"
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+	help
+	  Select the desired "nc" command provider.
+
+if BR2_PACKAGE_NC
+
+choice
+	prompt "nc variant"
+	default BR2_PACKAGE_NETCAT
+	help
+	  Select either the venerable netcat (default), netcat-openbsd
+	  or nmap-ncat.
+
+config BR2_PACKAGE_NETCAT
+	bool "netcat"
+	select BR2_PACKAGE_HAS_NC
+	help
+	  Netcat is a featured networking utility which reads and writes
+	  data across network connections, using the TCP/IP protocol.
+	  It is designed to be a reliable "back-end" tool that can be
+	  used directly or easily driven by other programs and scripts.
+	  At the same time, it is a feature-rich network debugging and
+	  exploration tool, since it can create almost any kind of
+	  connection you would need and has several interesting built-in
+	  capabilities.
+
+	  http://netcat.sourceforge.net/download.php
+
+config BR2_PACKAGE_NETCAT_OPENBSD
+	bool "netcat-openbsd"
+	select BR2_PACKAGE_HAS_NC
+	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+	select BR2_PACKAGE_LIBBSD
+	help
+	  This OpenBSD rewrite of netcat, including support for IPv6,
+	  proxies, and Unix sockets. Reads and writes data using TCP or
+	  UDP protocol. It is designed to be a reliable "back-end" tool
+	  that can be used directly or easily driven by other programs
+	  and scripts. At the same time it is a feature-rich network
+	  debugging and exploration tool, since it can create almost any
+	  kind of connection you would need and has several interesting
+	  built-in capabilities.
+
+	  https://packages.debian.org/sid/netcat-openbsd
+
+comment "netcat-openbsd needs a toolchain w/ glibc, threads"
+	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+
+config BR2_PACKAGE_NMAP_NCAT
+	bool "nmap-ncat"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_USE_MMU # fork()
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_LIBPCAP
+	help
+	  Ncat is a feature-packed networking utility which reads and
+	  writes data across networks from the command line. Ncat was
+	  written for the Nmap Project as a much-improved
+	  reimplementation of the venerable Netcat.
+
+comment "nmap-nmap needs a toolchain w/ C++, threads"
+	depends on BR2_USE_MMU
+	depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)
+
+endchoice
+
+config BR2_PACKAGE_HAS_NC
+	bool
+
+config BR2_PACKAGE_PROVIDES_NC
+	string
+	default "netcat"         if BR2_PACKAGE_NETCAT
+	default "netcat-openbsd" if BR2_PACKAGE_NETCAT_OPENBSD
+	default "nmap"           if BR2_PACKAGE_NMAP_NCAT
+
+endif
diff --git a/package/nc/nc.mk b/package/nc/nc.mk
new file mode 100644
index 0000000000..e04b2bd017
--- /dev/null
+++ b/package/nc/nc.mk
@@ -0,0 +1,7 @@
+################################################################################
+#
+# nc
+#
+################################################################################
+
+$(eval $(virtual-package))
diff --git a/package/netcat-openbsd/Config.in b/package/netcat-openbsd/Config.in
index 6df87ec688..e69de29bb2 100644
--- a/package/netcat-openbsd/Config.in
+++ b/package/netcat-openbsd/Config.in
@@ -1,25 +0,0 @@
-config BR2_PACKAGE_NETCAT_OPENBSD
-	bool "netcat-openbsd"
-	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
-	depends on BR2_TOOLCHAIN_HAS_THREADS
-	depends on BR2_TOOLCHAIN_USES_GLIBC
-	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
-	select BR2_PACKAGE_LIBBSD
-	help
-	  A simple Unix utility which reads and writes data across network
-	  connections using TCP or UDP protocol. It is designed to be a
-	  reliable "back-end" tool that can be used directly or easily driven
-	  by other programs and scripts. At the same time it is a feature-rich
-	  network debugging and exploration tool, since it can create almost
-	  any kind of connection you would need and has several interesting
-	  built-in capabilities.
-
-	  This package contains the OpenBSD rewrite of netcat, including
-	  support for IPv6, proxies, and Unix sockets.
-
-	  https://packages.debian.org/sid/netcat-openbsd
-
-comment "netcat-openbsd needs a glibc toolchain w/ threads"
-	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
-	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC
-	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
diff --git a/package/netcat-openbsd/netcat-openbsd.mk b/package/netcat-openbsd/netcat-openbsd.mk
index e1a6fee574..5395f85e92 100644
--- a/package/netcat-openbsd/netcat-openbsd.mk
+++ b/package/netcat-openbsd/netcat-openbsd.mk
@@ -8,6 +8,8 @@ NETCAT_OPENBSD_VERSION = debian/1.105-7
 NETCAT_OPENBSD_SITE = git://anonscm.debian.org/collab-maint/netcat-openbsd
 NETCAT_OPENBSD_LICENSE = BSD-3-Clause
 NETCAT_OPENBSD_LICENSE_FILES = debian/copyright
+NETCAT_OPENBSD_PROVIDES = nc
+
 NETCAT_OPENBSD_DEPENDENCIES = host-pkgconf libbsd
 
 # Ensure Busybox gets built/installed before, so that this package
diff --git a/package/netcat/Config.in b/package/netcat/Config.in
index 924069ee1f..e69de29bb2 100644
--- a/package/netcat/Config.in
+++ b/package/netcat/Config.in
@@ -1,13 +0,0 @@
-config BR2_PACKAGE_NETCAT
-	bool "netcat"
-	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
-	help
-	  Netcat is a featured networking utility which reads and writes data
-	  across network connections, using the TCP/IP protocol.
-	  It is designed to be a reliable "back-end" tool that can be used
-	  directly or easily driven by other programs and scripts. At the
-	  same time, it is a feature-rich network debugging and exploration
-	  tool, since it can create almost any kind of connection you would
-	  need and has several interesting built-in capabilities.
-
-	  http://netcat.sourceforge.net/download.php
diff --git a/package/netcat/netcat.mk b/package/netcat/netcat.mk
index eb7ddcac27..94786fc124 100644
--- a/package/netcat/netcat.mk
+++ b/package/netcat/netcat.mk
@@ -8,5 +8,6 @@ NETCAT_VERSION = 0.7.1
 NETCAT_SITE = http://downloads.sourceforge.net/project/netcat/netcat/$(NETCAT_VERSION)
 NETCAT_LICENSE = GPL-2.0+
 NETCAT_LICENSE_FILES = COPYING
+NETCAT_PROVIDES = nc
 
 $(eval $(autotools-package))
diff --git a/package/nmap/nmap.mk b/package/nmap/nmap.mk
index 37720e2cad..ad92cfd6f8 100644
--- a/package/nmap/nmap.mk
+++ b/package/nmap/nmap.mk
@@ -7,12 +7,14 @@
 NMAP_VERSION = 7.40
 NMAP_SITE = http://nmap.org/dist
 NMAP_SOURCE = nmap-$(NMAP_VERSION).tar.bz2
-NMAP_DEPENDENCIES = libpcap pcre
+NMAP_DEPENDENCIES = libpcap
 NMAP_CONF_OPTS = --without-liblua --without-zenmap \
 	--with-libdnet=included --with-liblinear=included \
-	--with-libpcre="$(STAGING_DIR)/usr" --without-ncat
+	--with-libpcre="$(STAGING_DIR)/usr"
 NMAP_LICENSE = GPL-2.0
 NMAP_LICENSE_FILES = COPYING
+NMAP_PROVIDES = nc
+
 
 # needed by libpcap
 NMAP_LIBS_FOR_STATIC_LINK += `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`
@@ -35,6 +37,9 @@ else
 NMAP_CONF_OPTS += --without-openssl
 endif
 
+ifeq ($(BR2_PACKAGE_NMAP),y)
+
+NMAP_DEPENDENCIES += pcre
 # ndiff only works with python2.x
 ifeq ($(BR2_PACKAGE_PYTHON),y)
 NMAP_DEPENDENCIES += python
@@ -42,4 +47,25 @@ else
 NMAP_CONF_OPTS += --without-ndiff
 endif
 
+else # only ncat
+
+NMAP_CONF_OPTS += --without-ndiff --without-zenmap --without-nping --without-nmap-update
+define NMAP_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) build-ncat
+endef
+define NMAP_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install-ncat
+endef
+
+endif
+
+ifeq ($(BR2_PACKAGE_NMAP_NCAT),y)
+define NMAP_INSTALL_NCAT_SYMLINK
+        ln -fs ncat $(TARGET_DIR)/usr/bin/nc
+endef
+NMAP_POST_INSTALL_TARGET_HOOKS += NMAP_INSTALL_NCAT_SYMLINK
+else
+NMAP_CONF_OPTS += --without-ncat
+endif
+
 $(eval $(autotools-package))
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v2] nc: new virtual package providing "netcat" functionality
  2017-09-17  7:15 [Buildroot] [PATCH] nc: new virtual package providing "netcat" functionality Carlos Santos
@ 2017-09-17 21:45 ` Carlos Santos
  2017-10-02 14:13   ` [Buildroot] [PATCH v3] " Carlos Santos
  0 siblings, 1 reply; 21+ messages in thread
From: Carlos Santos @ 2017-09-17 21:45 UTC (permalink / raw)
  To: buildroot

Add the "nc" virtual package and modify netcat, netcat-openbsd and nmap
to become providers.

Make the nmap recipe install "ncat" (with a symbolic link to nc) if the
BR2_PACKAGE_NMAP_NCAT option is set. Other programs (ncat, ndiff, etc.)
are still chosen via BR2_PACKAGE_NMAP, in the "Networking applications"
menu.

So far the "nc" options available to build with uClibc were the ancient
GNU netcat and its Busybox double. Both lack features available in more
modern netcats like IPv6, proxies, and Unix sockets.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
---
Changes v1->v2:
  - Prevent build error
    Makefile:537: *** nmap is in the dependency chain of nc that has \
    added it to its _DEPENDENCIES variable without selecting it or \
    depending on it from Config.in.  Stop.
---
 package/Config.in                        |  3 +-
 package/nc/Config.in                     | 84 ++++++++++++++++++++++++++++++++
 package/nc/nc.mk                         |  7 +++
 package/netcat-openbsd/Config.in         | 25 ----------
 package/netcat-openbsd/netcat-openbsd.mk |  2 +
 package/netcat/Config.in                 | 13 -----
 package/netcat/netcat.mk                 |  1 +
 package/nmap/Config.in                   |  4 ++
 package/nmap/nmap.mk                     | 30 +++++++++++-
 9 files changed, 127 insertions(+), 42 deletions(-)
 create mode 100644 package/nc/Config.in
 create mode 100644 package/nc/nc.mk

diff --git a/package/Config.in b/package/Config.in
index d4e40a6326..275461321f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1676,11 +1676,10 @@ menu "Networking applications"
 	source "package/mrouted/Config.in"
 	source "package/mtr/Config.in"
 	source "package/nbd/Config.in"
+	source "package/nc/Config.in"
 	source "package/ncftp/Config.in"
 	source "package/ndisc6/Config.in"
 	source "package/netatalk/Config.in"
-	source "package/netcat/Config.in"
-	source "package/netcat-openbsd/Config.in"
 	source "package/netplug/Config.in"
 	source "package/netsnmp/Config.in"
 	source "package/netstat-nat/Config.in"
diff --git a/package/nc/Config.in b/package/nc/Config.in
new file mode 100644
index 0000000000..c599f0d8bc
--- /dev/null
+++ b/package/nc/Config.in
@@ -0,0 +1,84 @@
+config BR2_PACKAGE_NC
+	bool "nc (netcat)"
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+	help
+	  Select the desired "nc" command provider.
+
+if BR2_PACKAGE_NC
+
+choice
+	prompt "nc variant"
+	default BR2_PACKAGE_NETCAT
+	help
+	  Select either the venerable netcat (default), netcat-openbsd
+	  or nmap-ncat.
+
+config BR2_PACKAGE_NETCAT
+	bool "netcat"
+	select BR2_PACKAGE_HAS_NC
+	help
+	  Netcat is a featured networking utility which reads and writes
+	  data across network connections, using the TCP/IP protocol.
+	  It is designed to be a reliable "back-end" tool that can be
+	  used directly or easily driven by other programs and scripts.
+	  At the same time, it is a feature-rich network debugging and
+	  exploration tool, since it can create almost any kind of
+	  connection you would need and has several interesting built-in
+	  capabilities.
+
+	  http://netcat.sourceforge.net/download.php
+
+config BR2_PACKAGE_NETCAT_OPENBSD
+	bool "netcat-openbsd"
+	select BR2_PACKAGE_HAS_NC
+	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+	select BR2_PACKAGE_LIBBSD
+	help
+	  This OpenBSD rewrite of netcat, including support for IPv6,
+	  proxies, and Unix sockets. Reads and writes data using TCP or
+	  UDP protocol. It is designed to be a reliable "back-end" tool
+	  that can be used directly or easily driven by other programs
+	  and scripts. At the same time it is a feature-rich network
+	  debugging and exploration tool, since it can create almost any
+	  kind of connection you would need and has several interesting
+	  built-in capabilities.
+
+	  https://packages.debian.org/sid/netcat-openbsd
+
+comment "netcat-openbsd needs a toolchain w/ glibc, threads"
+	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+
+config BR2_PACKAGE_NMAP_NCAT
+	bool "nmap-ncat"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_USE_MMU # fork()
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_NMAP
+	select BR2_PACKAGE_LIBPCAP
+	help
+	  Ncat is a feature-packed networking utility which reads and
+	  writes data across networks from the command line. Ncat was
+	  written for the Nmap Project as a much-improved
+	  reimplementation of the venerable Netcat.
+
+comment "nmap-nmap needs a toolchain w/ C++, threads"
+	depends on BR2_USE_MMU
+	depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)
+
+endchoice
+
+config BR2_PACKAGE_HAS_NC
+	bool
+
+config BR2_PACKAGE_PROVIDES_NC
+	string
+	default "netcat"         if BR2_PACKAGE_NETCAT
+	default "netcat-openbsd" if BR2_PACKAGE_NETCAT_OPENBSD
+	default "nmap"           if BR2_PACKAGE_NMAP_NCAT
+
+endif
diff --git a/package/nc/nc.mk b/package/nc/nc.mk
new file mode 100644
index 0000000000..e04b2bd017
--- /dev/null
+++ b/package/nc/nc.mk
@@ -0,0 +1,7 @@
+################################################################################
+#
+# nc
+#
+################################################################################
+
+$(eval $(virtual-package))
diff --git a/package/netcat-openbsd/Config.in b/package/netcat-openbsd/Config.in
index 6df87ec688..e69de29bb2 100644
--- a/package/netcat-openbsd/Config.in
+++ b/package/netcat-openbsd/Config.in
@@ -1,25 +0,0 @@
-config BR2_PACKAGE_NETCAT_OPENBSD
-	bool "netcat-openbsd"
-	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
-	depends on BR2_TOOLCHAIN_HAS_THREADS
-	depends on BR2_TOOLCHAIN_USES_GLIBC
-	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
-	select BR2_PACKAGE_LIBBSD
-	help
-	  A simple Unix utility which reads and writes data across network
-	  connections using TCP or UDP protocol. It is designed to be a
-	  reliable "back-end" tool that can be used directly or easily driven
-	  by other programs and scripts. At the same time it is a feature-rich
-	  network debugging and exploration tool, since it can create almost
-	  any kind of connection you would need and has several interesting
-	  built-in capabilities.
-
-	  This package contains the OpenBSD rewrite of netcat, including
-	  support for IPv6, proxies, and Unix sockets.
-
-	  https://packages.debian.org/sid/netcat-openbsd
-
-comment "netcat-openbsd needs a glibc toolchain w/ threads"
-	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
-	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC
-	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
diff --git a/package/netcat-openbsd/netcat-openbsd.mk b/package/netcat-openbsd/netcat-openbsd.mk
index e1a6fee574..5395f85e92 100644
--- a/package/netcat-openbsd/netcat-openbsd.mk
+++ b/package/netcat-openbsd/netcat-openbsd.mk
@@ -8,6 +8,8 @@ NETCAT_OPENBSD_VERSION = debian/1.105-7
 NETCAT_OPENBSD_SITE = git://anonscm.debian.org/collab-maint/netcat-openbsd
 NETCAT_OPENBSD_LICENSE = BSD-3-Clause
 NETCAT_OPENBSD_LICENSE_FILES = debian/copyright
+NETCAT_OPENBSD_PROVIDES = nc
+
 NETCAT_OPENBSD_DEPENDENCIES = host-pkgconf libbsd
 
 # Ensure Busybox gets built/installed before, so that this package
diff --git a/package/netcat/Config.in b/package/netcat/Config.in
index 924069ee1f..e69de29bb2 100644
--- a/package/netcat/Config.in
+++ b/package/netcat/Config.in
@@ -1,13 +0,0 @@
-config BR2_PACKAGE_NETCAT
-	bool "netcat"
-	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
-	help
-	  Netcat is a featured networking utility which reads and writes data
-	  across network connections, using the TCP/IP protocol.
-	  It is designed to be a reliable "back-end" tool that can be used
-	  directly or easily driven by other programs and scripts. At the
-	  same time, it is a feature-rich network debugging and exploration
-	  tool, since it can create almost any kind of connection you would
-	  need and has several interesting built-in capabilities.
-
-	  http://netcat.sourceforge.net/download.php
diff --git a/package/netcat/netcat.mk b/package/netcat/netcat.mk
index eb7ddcac27..94786fc124 100644
--- a/package/netcat/netcat.mk
+++ b/package/netcat/netcat.mk
@@ -8,5 +8,6 @@ NETCAT_VERSION = 0.7.1
 NETCAT_SITE = http://downloads.sourceforge.net/project/netcat/netcat/$(NETCAT_VERSION)
 NETCAT_LICENSE = GPL-2.0+
 NETCAT_LICENSE_FILES = COPYING
+NETCAT_PROVIDES = nc
 
 $(eval $(autotools-package))
diff --git a/package/nmap/Config.in b/package/nmap/Config.in
index 79f587afd1..3203c3e24b 100644
--- a/package/nmap/Config.in
+++ b/package/nmap/Config.in
@@ -1,8 +1,12 @@
 config BR2_PACKAGE_NMAP
+	bool
+
+config BR2_PACKAGE_NMAP_NMAP
 	bool "nmap"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_USE_MMU # fork()
 	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_NMAP
 	select BR2_PACKAGE_LIBPCAP
 	select BR2_PACKAGE_PCRE
 	help
diff --git a/package/nmap/nmap.mk b/package/nmap/nmap.mk
index 37720e2cad..705687d9d0 100644
--- a/package/nmap/nmap.mk
+++ b/package/nmap/nmap.mk
@@ -7,12 +7,14 @@
 NMAP_VERSION = 7.40
 NMAP_SITE = http://nmap.org/dist
 NMAP_SOURCE = nmap-$(NMAP_VERSION).tar.bz2
-NMAP_DEPENDENCIES = libpcap pcre
+NMAP_DEPENDENCIES = libpcap
 NMAP_CONF_OPTS = --without-liblua --without-zenmap \
 	--with-libdnet=included --with-liblinear=included \
-	--with-libpcre="$(STAGING_DIR)/usr" --without-ncat
+	--with-libpcre="$(STAGING_DIR)/usr"
 NMAP_LICENSE = GPL-2.0
 NMAP_LICENSE_FILES = COPYING
+NMAP_PROVIDES = nc
+
 
 # needed by libpcap
 NMAP_LIBS_FOR_STATIC_LINK += `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`
@@ -35,6 +37,9 @@ else
 NMAP_CONF_OPTS += --without-openssl
 endif
 
+ifeq ($(BR2_PACKAGE_NMAP_NMAP),y)
+
+NMAP_DEPENDENCIES += pcre
 # ndiff only works with python2.x
 ifeq ($(BR2_PACKAGE_PYTHON),y)
 NMAP_DEPENDENCIES += python
@@ -42,4 +47,25 @@ else
 NMAP_CONF_OPTS += --without-ndiff
 endif
 
+else # only ncat
+
+NMAP_CONF_OPTS += --without-ndiff --without-zenmap --without-nping --without-nmap-update
+define NMAP_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) build-ncat
+endef
+define NMAP_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install-ncat
+endef
+
+endif
+
+ifeq ($(BR2_PACKAGE_NMAP_NCAT),y)
+define NMAP_INSTALL_NCAT_SYMLINK
+        ln -fs ncat $(TARGET_DIR)/usr/bin/nc
+endef
+NMAP_POST_INSTALL_TARGET_HOOKS += NMAP_INSTALL_NCAT_SYMLINK
+else
+NMAP_CONF_OPTS += --without-ncat
+endif
+
 $(eval $(autotools-package))
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality
  2017-09-17 21:45 ` [Buildroot] [PATCH v2] " Carlos Santos
@ 2017-10-02 14:13   ` Carlos Santos
  2017-10-02 19:18     ` Thomas Petazzoni
  0 siblings, 1 reply; 21+ messages in thread
From: Carlos Santos @ 2017-10-02 14:13 UTC (permalink / raw)
  To: buildroot

Add the "nc" virtual package and modify netcat, netcat-openbsd and nmap
to become providers.

Make the nmap recipe install "ncat" (with a symbolic link to nc) if the
BR2_PACKAGE_NMAP_NCAT option is set. Other programs (ncat, ndiff, etc.)
are still chosen via BR2_PACKAGE_NMAP, in the "Networking applications"
menu.

So far the "nc" options available to build with uClibc were the ancient
GNU netcat and its Busybox double. Both lack features available in more
modern netcats like IPv6, proxies, and Unix sockets.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
---
Changes v1->v2:
  - Prevent build error
    Makefile:537: *** nmap is in the dependency chain of nc that has \
    added it to its _DEPENDENCIES variable without selecting it or \
    depending on it from Config.in.  Stop.
Changes v1->v2:
  - Remove package/netcat-openbsd/Config.in (was left empty)
---
 package/Config.in                        |  3 +-
 package/nc/Config.in                     | 84 ++++++++++++++++++++++++++++++++
 package/nc/nc.mk                         |  7 +++
 package/netcat-openbsd/Config.in         | 25 ----------
 package/netcat-openbsd/netcat-openbsd.mk |  2 +
 package/netcat/Config.in                 | 13 -----
 package/netcat/netcat.mk                 |  1 +
 package/nmap/Config.in                   |  4 ++
 package/nmap/nmap.mk                     | 30 +++++++++++-
 9 files changed, 127 insertions(+), 42 deletions(-)
 create mode 100644 package/nc/Config.in
 create mode 100644 package/nc/nc.mk
 delete mode 100644 package/netcat-openbsd/Config.in

diff --git a/package/Config.in b/package/Config.in
index ccd42c7..0b81f85 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1665,11 +1665,10 @@ menu "Networking applications"
 	source "package/mrouted/Config.in"
 	source "package/mtr/Config.in"
 	source "package/nbd/Config.in"
+	source "package/nc/Config.in"
 	source "package/ncftp/Config.in"
 	source "package/ndisc6/Config.in"
 	source "package/netatalk/Config.in"
-	source "package/netcat/Config.in"
-	source "package/netcat-openbsd/Config.in"
 	source "package/netplug/Config.in"
 	source "package/netsnmp/Config.in"
 	source "package/netstat-nat/Config.in"
diff --git a/package/nc/Config.in b/package/nc/Config.in
new file mode 100644
index 0000000..c599f0d
--- /dev/null
+++ b/package/nc/Config.in
@@ -0,0 +1,84 @@
+config BR2_PACKAGE_NC
+	bool "nc (netcat)"
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+	help
+	  Select the desired "nc" command provider.
+
+if BR2_PACKAGE_NC
+
+choice
+	prompt "nc variant"
+	default BR2_PACKAGE_NETCAT
+	help
+	  Select either the venerable netcat (default), netcat-openbsd
+	  or nmap-ncat.
+
+config BR2_PACKAGE_NETCAT
+	bool "netcat"
+	select BR2_PACKAGE_HAS_NC
+	help
+	  Netcat is a featured networking utility which reads and writes
+	  data across network connections, using the TCP/IP protocol.
+	  It is designed to be a reliable "back-end" tool that can be
+	  used directly or easily driven by other programs and scripts.
+	  At the same time, it is a feature-rich network debugging and
+	  exploration tool, since it can create almost any kind of
+	  connection you would need and has several interesting built-in
+	  capabilities.
+
+	  http://netcat.sourceforge.net/download.php
+
+config BR2_PACKAGE_NETCAT_OPENBSD
+	bool "netcat-openbsd"
+	select BR2_PACKAGE_HAS_NC
+	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+	select BR2_PACKAGE_LIBBSD
+	help
+	  This OpenBSD rewrite of netcat, including support for IPv6,
+	  proxies, and Unix sockets. Reads and writes data using TCP or
+	  UDP protocol. It is designed to be a reliable "back-end" tool
+	  that can be used directly or easily driven by other programs
+	  and scripts. At the same time it is a feature-rich network
+	  debugging and exploration tool, since it can create almost any
+	  kind of connection you would need and has several interesting
+	  built-in capabilities.
+
+	  https://packages.debian.org/sid/netcat-openbsd
+
+comment "netcat-openbsd needs a toolchain w/ glibc, threads"
+	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+
+config BR2_PACKAGE_NMAP_NCAT
+	bool "nmap-ncat"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_USE_MMU # fork()
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_NMAP
+	select BR2_PACKAGE_LIBPCAP
+	help
+	  Ncat is a feature-packed networking utility which reads and
+	  writes data across networks from the command line. Ncat was
+	  written for the Nmap Project as a much-improved
+	  reimplementation of the venerable Netcat.
+
+comment "nmap-nmap needs a toolchain w/ C++, threads"
+	depends on BR2_USE_MMU
+	depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)
+
+endchoice
+
+config BR2_PACKAGE_HAS_NC
+	bool
+
+config BR2_PACKAGE_PROVIDES_NC
+	string
+	default "netcat"         if BR2_PACKAGE_NETCAT
+	default "netcat-openbsd" if BR2_PACKAGE_NETCAT_OPENBSD
+	default "nmap"           if BR2_PACKAGE_NMAP_NCAT
+
+endif
diff --git a/package/nc/nc.mk b/package/nc/nc.mk
new file mode 100644
index 0000000..e04b2bd
--- /dev/null
+++ b/package/nc/nc.mk
@@ -0,0 +1,7 @@
+################################################################################
+#
+# nc
+#
+################################################################################
+
+$(eval $(virtual-package))
diff --git a/package/netcat-openbsd/Config.in b/package/netcat-openbsd/Config.in
deleted file mode 100644
index 6df87ec..0000000
--- a/package/netcat-openbsd/Config.in
+++ /dev/null
@@ -1,25 +0,0 @@
-config BR2_PACKAGE_NETCAT_OPENBSD
-	bool "netcat-openbsd"
-	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
-	depends on BR2_TOOLCHAIN_HAS_THREADS
-	depends on BR2_TOOLCHAIN_USES_GLIBC
-	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
-	select BR2_PACKAGE_LIBBSD
-	help
-	  A simple Unix utility which reads and writes data across network
-	  connections using TCP or UDP protocol. It is designed to be a
-	  reliable "back-end" tool that can be used directly or easily driven
-	  by other programs and scripts. At the same time it is a feature-rich
-	  network debugging and exploration tool, since it can create almost
-	  any kind of connection you would need and has several interesting
-	  built-in capabilities.
-
-	  This package contains the OpenBSD rewrite of netcat, including
-	  support for IPv6, proxies, and Unix sockets.
-
-	  https://packages.debian.org/sid/netcat-openbsd
-
-comment "netcat-openbsd needs a glibc toolchain w/ threads"
-	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
-	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC
-	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
diff --git a/package/netcat-openbsd/netcat-openbsd.mk b/package/netcat-openbsd/netcat-openbsd.mk
index e1a6fee..5395f85 100644
--- a/package/netcat-openbsd/netcat-openbsd.mk
+++ b/package/netcat-openbsd/netcat-openbsd.mk
@@ -8,6 +8,8 @@ NETCAT_OPENBSD_VERSION = debian/1.105-7
 NETCAT_OPENBSD_SITE = git://anonscm.debian.org/collab-maint/netcat-openbsd
 NETCAT_OPENBSD_LICENSE = BSD-3-Clause
 NETCAT_OPENBSD_LICENSE_FILES = debian/copyright
+NETCAT_OPENBSD_PROVIDES = nc
+
 NETCAT_OPENBSD_DEPENDENCIES = host-pkgconf libbsd
 
 # Ensure Busybox gets built/installed before, so that this package
diff --git a/package/netcat/Config.in b/package/netcat/Config.in
index 924069e..e69de29 100644
--- a/package/netcat/Config.in
+++ b/package/netcat/Config.in
@@ -1,13 +0,0 @@
-config BR2_PACKAGE_NETCAT
-	bool "netcat"
-	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
-	help
-	  Netcat is a featured networking utility which reads and writes data
-	  across network connections, using the TCP/IP protocol.
-	  It is designed to be a reliable "back-end" tool that can be used
-	  directly or easily driven by other programs and scripts. At the
-	  same time, it is a feature-rich network debugging and exploration
-	  tool, since it can create almost any kind of connection you would
-	  need and has several interesting built-in capabilities.
-
-	  http://netcat.sourceforge.net/download.php
diff --git a/package/netcat/netcat.mk b/package/netcat/netcat.mk
index eb7ddca..94786fc 100644
--- a/package/netcat/netcat.mk
+++ b/package/netcat/netcat.mk
@@ -8,5 +8,6 @@ NETCAT_VERSION = 0.7.1
 NETCAT_SITE = http://downloads.sourceforge.net/project/netcat/netcat/$(NETCAT_VERSION)
 NETCAT_LICENSE = GPL-2.0+
 NETCAT_LICENSE_FILES = COPYING
+NETCAT_PROVIDES = nc
 
 $(eval $(autotools-package))
diff --git a/package/nmap/Config.in b/package/nmap/Config.in
index 79f587a..3203c3e 100644
--- a/package/nmap/Config.in
+++ b/package/nmap/Config.in
@@ -1,8 +1,12 @@
 config BR2_PACKAGE_NMAP
+	bool
+
+config BR2_PACKAGE_NMAP_NMAP
 	bool "nmap"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_USE_MMU # fork()
 	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_NMAP
 	select BR2_PACKAGE_LIBPCAP
 	select BR2_PACKAGE_PCRE
 	help
diff --git a/package/nmap/nmap.mk b/package/nmap/nmap.mk
index 37720e2..705687d 100644
--- a/package/nmap/nmap.mk
+++ b/package/nmap/nmap.mk
@@ -7,12 +7,14 @@
 NMAP_VERSION = 7.40
 NMAP_SITE = http://nmap.org/dist
 NMAP_SOURCE = nmap-$(NMAP_VERSION).tar.bz2
-NMAP_DEPENDENCIES = libpcap pcre
+NMAP_DEPENDENCIES = libpcap
 NMAP_CONF_OPTS = --without-liblua --without-zenmap \
 	--with-libdnet=included --with-liblinear=included \
-	--with-libpcre="$(STAGING_DIR)/usr" --without-ncat
+	--with-libpcre="$(STAGING_DIR)/usr"
 NMAP_LICENSE = GPL-2.0
 NMAP_LICENSE_FILES = COPYING
+NMAP_PROVIDES = nc
+
 
 # needed by libpcap
 NMAP_LIBS_FOR_STATIC_LINK += `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`
@@ -35,6 +37,9 @@ else
 NMAP_CONF_OPTS += --without-openssl
 endif
 
+ifeq ($(BR2_PACKAGE_NMAP_NMAP),y)
+
+NMAP_DEPENDENCIES += pcre
 # ndiff only works with python2.x
 ifeq ($(BR2_PACKAGE_PYTHON),y)
 NMAP_DEPENDENCIES += python
@@ -42,4 +47,25 @@ else
 NMAP_CONF_OPTS += --without-ndiff
 endif
 
+else # only ncat
+
+NMAP_CONF_OPTS += --without-ndiff --without-zenmap --without-nping --without-nmap-update
+define NMAP_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) build-ncat
+endef
+define NMAP_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install-ncat
+endef
+
+endif
+
+ifeq ($(BR2_PACKAGE_NMAP_NCAT),y)
+define NMAP_INSTALL_NCAT_SYMLINK
+        ln -fs ncat $(TARGET_DIR)/usr/bin/nc
+endef
+NMAP_POST_INSTALL_TARGET_HOOKS += NMAP_INSTALL_NCAT_SYMLINK
+else
+NMAP_CONF_OPTS += --without-ncat
+endif
+
 $(eval $(autotools-package))
-- 
2.7.5

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality
  2017-10-02 14:13   ` [Buildroot] [PATCH v3] " Carlos Santos
@ 2017-10-02 19:18     ` Thomas Petazzoni
  2017-10-02 19:44       ` Peter Korsgaard
  2017-10-02 20:09       ` Carlos Santos
  0 siblings, 2 replies; 21+ messages in thread
From: Thomas Petazzoni @ 2017-10-02 19:18 UTC (permalink / raw)
  To: buildroot

Hello,

On Mon,  2 Oct 2017 11:13:02 -0300, Carlos Santos wrote:
> Add the "nc" virtual package and modify netcat, netcat-openbsd and nmap
> to become providers.
> 
> Make the nmap recipe install "ncat" (with a symbolic link to nc) if the
> BR2_PACKAGE_NMAP_NCAT option is set. Other programs (ncat, ndiff, etc.)
> are still chosen via BR2_PACKAGE_NMAP, in the "Networking applications"
> menu.
> 
> So far the "nc" options available to build with uClibc were the ancient
> GNU netcat and its Busybox double. Both lack features available in more
> modern netcats like IPv6, proxies, and Unix sockets.
> 
> Signed-off-by: Carlos Santos <casantos@datacom.ind.br>

What is the benefit of having a virtual package for this ?

Virtual packages are mainly useful when several variants of a given
library provide the same API, but different implementations, and we
have N consumers of this API. In such a case, a virtual package avoids
having each consumer explicitly handle every possible provider of the
API.

However, in the case of netcat, I don't see the point. Yes, you can
currently enable several packages that provide the netcat
functionality, and they will step on each other in some combinations.

But you can also enable several Web servers that will try to listen on
port 80 at boot time, leaving only one functional, and still we're not
going to have a "webserver" virtual package.

So, I don't see where the problem is, and therefore I don't think a
solution is necessary :-)

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality
  2017-10-02 19:18     ` Thomas Petazzoni
@ 2017-10-02 19:44       ` Peter Korsgaard
  2017-10-02 20:28         ` Carlos Santos
  2017-10-02 20:09       ` Carlos Santos
  1 sibling, 1 reply; 21+ messages in thread
From: Peter Korsgaard @ 2017-10-02 19:44 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

Hi,

 > What is the benefit of having a virtual package for this ?

 > Virtual packages are mainly useful when several variants of a given
 > library provide the same API, but different implementations, and we
 > have N consumers of this API. In such a case, a virtual package avoids
 > having each consumer explicitly handle every possible provider of the
 > API.

 > However, in the case of netcat, I don't see the point. Yes, you can
 > currently enable several packages that provide the netcat
 > functionality, and they will step on each other in some combinations.

 > But you can also enable several Web servers that will try to listen on
 > port 80 at boot time, leaving only one functional, and still we're not
 > going to have a "webserver" virtual package.

 > So, I don't see where the problem is, and therefore I don't think a
 > solution is necessary :-)

FYI, this is my feeling as well. The current setup afaik only has issues
if you enable more than one package providing a nc implementation (this
solution fixes it by not allowing such setup), but I'm not sure if
there's really a realistic use case where somebody would want to do this
in the first place?

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality
  2017-10-02 19:18     ` Thomas Petazzoni
  2017-10-02 19:44       ` Peter Korsgaard
@ 2017-10-02 20:09       ` Carlos Santos
  2017-10-04  9:20         ` Thomas Petazzoni
  1 sibling, 1 reply; 21+ messages in thread
From: Carlos Santos @ 2017-10-02 20:09 UTC (permalink / raw)
  To: buildroot

> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
> To: "Carlos Santos" <casantos@datacom.ind.br>
> Cc: buildroot at buildroot.org, "Maxime Hadjinlian" <maxime.hadjinlian@gmail.com>
> Sent: Monday, October 2, 2017 4:18:40 PM
> Subject: Re: [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality

> Hello,
> 
> On Mon,  2 Oct 2017 11:13:02 -0300, Carlos Santos wrote:
>> Add the "nc" virtual package and modify netcat, netcat-openbsd and nmap
>> to become providers.
>> 
>> Make the nmap recipe install "ncat" (with a symbolic link to nc) if the
>> BR2_PACKAGE_NMAP_NCAT option is set. Other programs (ncat, ndiff, etc.)
>> are still chosen via BR2_PACKAGE_NMAP, in the "Networking applications"
>> menu.
>> 
>> So far the "nc" options available to build with uClibc were the ancient
>> GNU netcat and its Busybox double. Both lack features available in more
>> modern netcats like IPv6, proxies, and Unix sockets.
>> 
>> Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
> 
> What is the benefit of having a virtual package for this ?

My first solution just allowed the user to build and install ncat with
a symlink to "nc".

> Virtual packages are mainly useful when several variants of a given
> library provide the same API, but different implementations, and we
> have N consumers of this API. In such a case, a virtual package avoids
> having each consumer explicitly handle every possible provider of the
> API.

There are three packages able to provide the "nc" command (four, if
we count busybox). I want to allow the user to choose only one of them,
unambiguously.

> However, in the case of netcat, I don't see the point. Yes, you can
> currently enable several packages that provide the netcat
> functionality, and they will step on each other in some combinations.

The problem with this approach is that it does not prevent the user
from selecting netcat and/or openbsd-netcat along with nmap, leading
to the same tricky situation we have now with BusyBox, coreutils and
util-linux, which compete for the ownership os some commands.

Right now the problem is solved (wiped down the carpet) by making
coreutils depend on busybox, for instance, but this works just because
the busybox install step does not override existing files.

> But you can also enable several Web servers that will try to listen on
> port 80 at boot time, leaving only one functional, and still we're not
> going to have a "webserver" virtual package.

I'm following your own example: check luainterpreter, mysql and udev.

> So, I don't see where the problem is, and therefore I don't think a
> solution is necessary :-)

I admit that is not mandatory but I still believe that it would lead
to a more organized selection of packages/features.

-- 
Carlos Santos (Casantos) - DATACOM, P&D
?The greatest triumph that modern PR can offer is the transcendent 
success of having your words and actions judged by your reputation, 
rather than the other way about.? ? Christopher Hitchens

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality
  2017-10-02 19:44       ` Peter Korsgaard
@ 2017-10-02 20:28         ` Carlos Santos
  0 siblings, 0 replies; 21+ messages in thread
From: Carlos Santos @ 2017-10-02 20:28 UTC (permalink / raw)
  To: buildroot

> From: "Peter Korsgaard" <peter@korsgaard.com>
> To: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
> Cc: "Carlos Santos" <casantos@datacom.ind.br>, "Maxime Hadjinlian" <maxime.hadjinlian@gmail.com>,
> buildroot at buildroot.org
> Sent: Monday, October 2, 2017 4:44:56 PM
> Subject: Re: [PATCH v3] nc: new virtual package providing "netcat" functionality

>>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:
> 
> Hi,
> 
> > What is the benefit of having a virtual package for this ?
> 
> > Virtual packages are mainly useful when several variants of a given
> > library provide the same API, but different implementations, and we
> > have N consumers of this API. In such a case, a virtual package avoids
> > having each consumer explicitly handle every possible provider of the
> > API.
> 
> > However, in the case of netcat, I don't see the point. Yes, you can
> > currently enable several packages that provide the netcat
> > functionality, and they will step on each other in some combinations.
> 
> > But you can also enable several Web servers that will try to listen on
> > port 80 at boot time, leaving only one functional, and still we're not
> > going to have a "webserver" virtual package.
> 
> > So, I don't see where the problem is, and therefore I don't think a
> > solution is necessary :-)
> 
> FYI, this is my feeling as well. The current setup afaik only has issues
> if you enable more than one package providing a nc implementation (this
> solution fixes it by not allowing such setup), but I'm not sure if
> there's really a realistic use case where somebody would want to do this
> in the first place?

I'm currenly working on porting libvirt to buildroor. It requires a
modern "nc" command (with support for unix sockets) to provide remote
access via ssh using virt-manager. Currently this is impossible with
uClibc because openbsd-netcat depends on GLIBC.

At the same time I think it's waste of space to install the full
nmap suite just to have one command.

By the way, nmap's ncat is the "nc" command used on Fedora Linux while
Debian uses openbsd-netcat by default.

-- 
Carlos Santos (Casantos) - DATACOM, P&D
?The greatest triumph that modern PR can offer is the transcendent 
success of having your words and actions judged by your reputation, 
rather than the other way about.? ? Christopher Hitchens

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality
  2017-10-02 20:09       ` Carlos Santos
@ 2017-10-04  9:20         ` Thomas Petazzoni
  2017-10-04 12:49           ` [Buildroot] [PATCH] nmap: add option to build/install "ncat" Carlos Santos
  2017-10-04 12:58           ` [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality Carlos Santos
  0 siblings, 2 replies; 21+ messages in thread
From: Thomas Petazzoni @ 2017-10-04  9:20 UTC (permalink / raw)
  To: buildroot

Hello Carlos,

On Mon, 2 Oct 2017 17:09:55 -0300 (BRT), Carlos Santos wrote:

> > Virtual packages are mainly useful when several variants of a given
> > library provide the same API, but different implementations, and we
> > have N consumers of this API. In such a case, a virtual package avoids
> > having each consumer explicitly handle every possible provider of the
> > API.  
> 
> There are three packages able to provide the "nc" command (four, if
> we count busybox). I want to allow the user to choose only one of them,
> unambiguously.

I'm sorry, but I really don't think we want to go down this route. As I
explained, there are lots of other packages in Buildroot that conflict
with each other. If you select two web servers, they will compete to
bind to port 80. If you select two SSH servers, they will compete to
bind to port 22. And so on and so on. We are not going to add virtual
packages for all of those cases.

The only situation where virtual packages make sense is when we have
multiple packages using an API provided by multiple packages (OpenGL,
jpeg, etc.).

> > But you can also enable several Web servers that will try to listen on
> > port 80 at boot time, leaving only one functional, and still we're not
> > going to have a "webserver" virtual package.  
> 
> I'm following your own example: check luainterpreter, mysql and udev.

All of those are providing an implementation to other packages:

 - luainterpreter is used by all Lua modules, because they can support
   using different Lua interpreters

 - mysql because it provides a client library that is used by numerous
   packages

 - udev because it is provided either by systemd or by eudev, and is a
   library API used by a large number of packages.

So, I'm sorry but no, we are not going to add a virtual packages for
netcat.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH] nmap: add option to build/install "ncat"
  2017-10-04  9:20         ` Thomas Petazzoni
@ 2017-10-04 12:49           ` Carlos Santos
  2017-10-04 14:08             ` Baruch Siach
  2017-10-04 15:43             ` [Buildroot] [PATCH v2] " Carlos Santos
  2017-10-04 12:58           ` [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality Carlos Santos
  1 sibling, 2 replies; 21+ messages in thread
From: Carlos Santos @ 2017-10-04 12:49 UTC (permalink / raw)
  To: buildroot

Ncat is a much-improved reimplementation of the venerable Netcat and is
compatible with uClibc.

So far the "nc" options available to build with uClibc were the ancient
GNU netcat and its Busybox double (the openbsd-netcat package cannot be
used because it requires GLIBC). Both lack features available in modern
netcats like IPv6, proxies, and Unix sockets.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
------
Changes v1->v2:
  - Prevent build error
    Makefile:537: *** nmap is in the dependency chain of nc that has \
    added it to its _DEPENDENCIES variable without selecting it or \
    depending on it from Config.in.  Stop.
------
 package/Config.in                        |  3 +-
 package/nc/Config.in                     | 84 ++++++++++++++++++++++++++++++++
 package/nc/nc.mk                         |  7 +++
 package/netcat-openbsd/Config.in         | 25 ----------
 package/netcat-openbsd/netcat-openbsd.mk |  2 +
 package/netcat/Config.in                 | 13 -----
 package/netcat/netcat.mk                 |  1 +
 package/nmap/Config.in                   |  4 ++
 package/nmap/nmap.mk                     | 30 +++++++++++-
 9 files changed, 127 insertions(+), 42 deletions(-)
 create mode 100644 package/nc/Config.in
 create mode 100644 package/nc/nc.mk
---
 package/nmap/Config.in | 12 ++++++++++++
 package/nmap/nmap.mk   | 21 ++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/package/nmap/Config.in b/package/nmap/Config.in
index 79f587afd1..7986bd6544 100644
--- a/package/nmap/Config.in
+++ b/package/nmap/Config.in
@@ -11,6 +11,18 @@ config BR2_PACKAGE_NMAP
 
 	  http://nmap.org
 
+if BR2_PACKAGE_NMAP
+
+config BR2_PACKAGE_NMAP_NCAT
+	bool "nmap-ncat"
+	help
+	  Ncat is a feature-packed networking utility which reads and
+	  writes data across networks from the command line. Ncat was
+	  written for the Nmap Project as a much-improved
+	  reimplementation of the venerable Netcat.
+
+endif
+
 comment "nmap needs a toolchain w/ C++, threads"
 	depends on BR2_USE_MMU
 	depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)
diff --git a/package/nmap/nmap.mk b/package/nmap/nmap.mk
index 9db06d1455..e41a66927c 100644
--- a/package/nmap/nmap.mk
+++ b/package/nmap/nmap.mk
@@ -10,7 +10,7 @@ NMAP_SOURCE = nmap-$(NMAP_VERSION).tar.bz2
 NMAP_DEPENDENCIES = libpcap pcre
 NMAP_CONF_OPTS = --without-liblua --without-zenmap \
 	--with-libdnet=included --with-liblinear=included \
-	--with-libpcre="$(STAGING_DIR)/usr" --without-ncat
+	--with-libpcre="$(STAGING_DIR)/usr"
 NMAP_LICENSE = GPL-2.0
 NMAP_LICENSE_FILES = COPYING
 
@@ -50,4 +50,23 @@ else
 NMAP_CONF_OPTS += --without-ndiff
 endif
 
+ifeq ($(BR2_PACKAGE_NMAP_NCAT),y)
+
+# If both nmap-ncat and busybox are selected, make certain coreutils
+# wins the fight over who gets to have their utils actually installed.
+ifeq ($(BR2_PACKAGE_BUSYBOX),Y)
+NMAP_DEPENDENCIES += busybox
+endif
+
+define NMAP_INSTALL_NCAT_SYMLINK
+        ln -fs ncat $(TARGET_DIR)/usr/bin/nc
+endef
+NMAP_POST_INSTALL_TARGET_HOOKS += NMAP_INSTALL_NCAT_SYMLINK
+
+else
+
+NMAP_CONF_OPTS += --without-ncat
+
+endif
+
 $(eval $(autotools-package))
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality
  2017-10-04  9:20         ` Thomas Petazzoni
  2017-10-04 12:49           ` [Buildroot] [PATCH] nmap: add option to build/install "ncat" Carlos Santos
@ 2017-10-04 12:58           ` Carlos Santos
  1 sibling, 0 replies; 21+ messages in thread
From: Carlos Santos @ 2017-10-04 12:58 UTC (permalink / raw)
  To: buildroot

> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
> To: "Carlos Santos" <casantos@datacom.ind.br>
> Cc: buildroot at buildroot.org, "Maxime Hadjinlian" <maxime.hadjinlian@gmail.com>
> Sent: Wednesday, October 4, 2017 6:20:08 AM
> Subject: Re: [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality

> Hello Carlos,
> 
> On Mon, 2 Oct 2017 17:09:55 -0300 (BRT), Carlos Santos wrote:
> 
>> > Virtual packages are mainly useful when several variants of a given
>> > library provide the same API, but different implementations, and we
>> > have N consumers of this API. In such a case, a virtual package avoids
>> > having each consumer explicitly handle every possible provider of the
>> > API.
>> 
>> There are three packages able to provide the "nc" command (four, if
>> we count busybox). I want to allow the user to choose only one of them,
>> unambiguously.
> 
> I'm sorry, but I really don't think we want to go down this route.
---8<---

OK, I sent a smaller patch which simply adds an option to build/install
ncat.

-- 
Carlos Santos (Casantos) - DATACOM, P&D
?The greatest triumph that modern PR can offer is the transcendent 
success of having your words and actions judged by your reputation, 
rather than the other way about.? ? Christopher Hitchens

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH] nmap: add option to build/install "ncat"
  2017-10-04 12:49           ` [Buildroot] [PATCH] nmap: add option to build/install "ncat" Carlos Santos
@ 2017-10-04 14:08             ` Baruch Siach
  2017-10-04 15:43             ` [Buildroot] [PATCH v2] " Carlos Santos
  1 sibling, 0 replies; 21+ messages in thread
From: Baruch Siach @ 2017-10-04 14:08 UTC (permalink / raw)
  To: buildroot

Hi Carlos,

On Wed, Oct 04, 2017 at 09:49:20AM -0300, Carlos Santos wrote:
> Ncat is a much-improved reimplementation of the venerable Netcat and is
> compatible with uClibc.
> 
> So far the "nc" options available to build with uClibc were the ancient
> GNU netcat and its Busybox double (the openbsd-netcat package cannot be
> used because it requires GLIBC). Both lack features available in modern
> netcats like IPv6, proxies, and Unix sockets.
> 
> Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
> ------
> Changes v1->v2:
>   - Prevent build error
>     Makefile:537: *** nmap is in the dependency chain of nc that has \
>     added it to its _DEPENDENCIES variable without selecting it or \
>     depending on it from Config.in.  Stop.
> ------
>  package/Config.in                        |  3 +-
>  package/nc/Config.in                     | 84 ++++++++++++++++++++++++++++++++
>  package/nc/nc.mk                         |  7 +++
>  package/netcat-openbsd/Config.in         | 25 ----------
>  package/netcat-openbsd/netcat-openbsd.mk |  2 +
>  package/netcat/Config.in                 | 13 -----
>  package/netcat/netcat.mk                 |  1 +
>  package/nmap/Config.in                   |  4 ++
>  package/nmap/nmap.mk                     | 30 +++++++++++-
>  9 files changed, 127 insertions(+), 42 deletions(-)
>  create mode 100644 package/nc/Config.in
>  create mode 100644 package/nc/nc.mk
> ---
>  package/nmap/Config.in | 12 ++++++++++++
>  package/nmap/nmap.mk   | 21 ++++++++++++++++++++-
>  2 files changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/package/nmap/Config.in b/package/nmap/Config.in
> index 79f587afd1..7986bd6544 100644
> --- a/package/nmap/Config.in
> +++ b/package/nmap/Config.in
> @@ -11,6 +11,18 @@ config BR2_PACKAGE_NMAP
>  
>  	  http://nmap.org
>  
> +if BR2_PACKAGE_NMAP
> +
> +config BR2_PACKAGE_NMAP_NCAT
> +	bool "nmap-ncat"
> +	help
> +	  Ncat is a feature-packed networking utility which reads and
> +	  writes data across networks from the command line. Ncat was
> +	  written for the Nmap Project as a much-improved
> +	  reimplementation of the venerable Netcat.
> +
> +endif
> +
>  comment "nmap needs a toolchain w/ C++, threads"
>  	depends on BR2_USE_MMU
>  	depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)
> diff --git a/package/nmap/nmap.mk b/package/nmap/nmap.mk
> index 9db06d1455..e41a66927c 100644
> --- a/package/nmap/nmap.mk
> +++ b/package/nmap/nmap.mk
> @@ -10,7 +10,7 @@ NMAP_SOURCE = nmap-$(NMAP_VERSION).tar.bz2
>  NMAP_DEPENDENCIES = libpcap pcre
>  NMAP_CONF_OPTS = --without-liblua --without-zenmap \
>  	--with-libdnet=included --with-liblinear=included \
> -	--with-libpcre="$(STAGING_DIR)/usr" --without-ncat
> +	--with-libpcre="$(STAGING_DIR)/usr"
>  NMAP_LICENSE = GPL-2.0
>  NMAP_LICENSE_FILES = COPYING
>  
> @@ -50,4 +50,23 @@ else
>  NMAP_CONF_OPTS += --without-ndiff
>  endif
>  
> +ifeq ($(BR2_PACKAGE_NMAP_NCAT),y)
> +
> +# If both nmap-ncat and busybox are selected, make certain coreutils

coreutils?

> +# wins the fight over who gets to have their utils actually installed.
> +ifeq ($(BR2_PACKAGE_BUSYBOX),Y)
> +NMAP_DEPENDENCIES += busybox
> +endif
> +
> +define NMAP_INSTALL_NCAT_SYMLINK
> +        ln -fs ncat $(TARGET_DIR)/usr/bin/nc
> +endef
> +NMAP_POST_INSTALL_TARGET_HOOKS += NMAP_INSTALL_NCAT_SYMLINK
> +
> +else
> +
> +NMAP_CONF_OPTS += --without-ncat
> +
> +endif
> +
>  $(eval $(autotools-package))

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"
  2017-10-04 12:49           ` [Buildroot] [PATCH] nmap: add option to build/install "ncat" Carlos Santos
  2017-10-04 14:08             ` Baruch Siach
@ 2017-10-04 15:43             ` Carlos Santos
  2017-10-06 19:58               ` Arnout Vandecappelle
  2017-10-10 13:32               ` [Buildroot] [PATCH] nmap: add option to build/install ncat Carlos Santos
  1 sibling, 2 replies; 21+ messages in thread
From: Carlos Santos @ 2017-10-04 15:43 UTC (permalink / raw)
  To: buildroot

Ncat is a much-improved reimplementation of the venerable Netcat and is
compatible with uClibc.

So far the "nc" options available to build with uClibc were the ancient
GNU netcat and its Busybox double (the openbsd-netcat package cannot be
used because it requires GLIBC). Both lack features available in modern
netcats like IPv6, proxies, and Unix sockets.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
---
Changes v1->v2:
  - Add dependens on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS, like netcat does
  - Remove forced dependence on busybox, since its installation script
    does not override existing programs.
---
 package/nmap/Config.in | 13 +++++++++++++
 package/nmap/nmap.mk   | 15 ++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/package/nmap/Config.in b/package/nmap/Config.in
index 79f587afd1..a2e330dacd 100644
--- a/package/nmap/Config.in
+++ b/package/nmap/Config.in
@@ -11,6 +11,19 @@ config BR2_PACKAGE_NMAP
 
 	  http://nmap.org
 
+if BR2_PACKAGE_NMAP
+
+config BR2_PACKAGE_NMAP_NCAT
+	bool "nmap-ncat"
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+	help
+	  Ncat is a feature-packed networking utility which reads and
+	  writes data across networks from the command line. Ncat was
+	  written for the Nmap Project as a much-improved
+	  reimplementation of the venerable Netcat.
+
+endif
+
 comment "nmap needs a toolchain w/ C++, threads"
 	depends on BR2_USE_MMU
 	depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)
diff --git a/package/nmap/nmap.mk b/package/nmap/nmap.mk
index 9db06d1455..fb16c2887d 100644
--- a/package/nmap/nmap.mk
+++ b/package/nmap/nmap.mk
@@ -10,7 +10,7 @@ NMAP_SOURCE = nmap-$(NMAP_VERSION).tar.bz2
 NMAP_DEPENDENCIES = libpcap pcre
 NMAP_CONF_OPTS = --without-liblua --without-zenmap \
 	--with-libdnet=included --with-liblinear=included \
-	--with-libpcre="$(STAGING_DIR)/usr" --without-ncat
+	--with-libpcre="$(STAGING_DIR)/usr"
 NMAP_LICENSE = GPL-2.0
 NMAP_LICENSE_FILES = COPYING
 
@@ -50,4 +50,17 @@ else
 NMAP_CONF_OPTS += --without-ndiff
 endif
 
+ifeq ($(BR2_PACKAGE_NMAP_NCAT),y)
+
+define NMAP_INSTALL_NCAT_SYMLINK
+        ln -fs ncat $(TARGET_DIR)/usr/bin/nc
+endef
+NMAP_POST_INSTALL_TARGET_HOOKS += NMAP_INSTALL_NCAT_SYMLINK
+
+else
+
+NMAP_CONF_OPTS += --without-ncat
+
+endif
+
 $(eval $(autotools-package))
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"
  2017-10-04 15:43             ` [Buildroot] [PATCH v2] " Carlos Santos
@ 2017-10-06 19:58               ` Arnout Vandecappelle
  2017-10-09 16:13                 ` Carlos Santos
  2017-10-10 13:32               ` [Buildroot] [PATCH] nmap: add option to build/install ncat Carlos Santos
  1 sibling, 1 reply; 21+ messages in thread
From: Arnout Vandecappelle @ 2017-10-06 19:58 UTC (permalink / raw)
  To: buildroot

 Hi Carlos,

 Sorry to iterate yet another time on this patch...

On 04-10-17 17:43, Carlos Santos wrote:
> Ncat is a much-improved reimplementation of the venerable Netcat and is
> compatible with uClibc.
> 
> So far the "nc" options available to build with uClibc were the ancient

 uClibc and musl.

> GNU netcat and its Busybox double (the openbsd-netcat package cannot be

 The package is called netcat-openbsd.

> used because it requires GLIBC). Both lack features available in modern
> netcats like IPv6, proxies, and Unix sockets.
> 
> Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[snip]
> diff --git a/package/nmap/Config.in b/package/nmap/Config.in
> index 79f587afd1..a2e330dacd 100644
> --- a/package/nmap/Config.in
> +++ b/package/nmap/Config.in
> @@ -11,6 +11,19 @@ config BR2_PACKAGE_NMAP
>  
>  	  http://nmap.org
>  
> +if BR2_PACKAGE_NMAP
> +
> +config BR2_PACKAGE_NMAP_NCAT
> +	bool "nmap-ncat"

 ncat itself is very small (+- 150K) compared to the rest of nmap (+- 2.5M), so
it's not really worth making a config option for it.

 Conversely, it *could* be worthwhile to have an option
BR2_PACKAGE_NMAP_NCAT_ONLY that just installs the ncat tool (+symlink) from the
package. So my idea would be:

- always build with ncat and install the symlink;
- if BR2_PACKAGE_NMAP_NCAT_ONLY is selected, override the install commands to
just install ncat + symlink.

 Perhaps to be sure you can do it as two patches, first one that always enables
ncat and installs symlink, second one that adds the BR2_PACKAGE_NMAP_NCAT_ONLY
option. That kind of option is a bit controversial (it's a "negative" option
because it removes stuff from the nmap package; we generally  prefer additive
options instead, but that would be a bit complicated here).


 One more thing though: are the ncat options compatible with those for
netcat-openbsd? And I'm talking about the options that are not in busybox or GNU
netcat now. If they are not compatible (and a quick look at the man pages tells
me that only the -6 and -U options are the same), I feel awkward about creating
the symlink: since you need to know which netcat type you're using, you could
just as well call ncat directly. And for scripts that don't rely on any of
these, the busybox or GNU nc is enough.

 Regards,
 Arnout

> +	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
> +	help
> +	  Ncat is a feature-packed networking utility which reads and
> +	  writes data across networks from the command line. Ncat was
> +	  written for the Nmap Project as a much-improved
> +	  reimplementation of the venerable Netcat.
> +
> +endif
> +
>  comment "nmap needs a toolchain w/ C++, threads"
>  	depends on BR2_USE_MMU
>  	depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)
> diff --git a/package/nmap/nmap.mk b/package/nmap/nmap.mk
> index 9db06d1455..fb16c2887d 100644
> --- a/package/nmap/nmap.mk
> +++ b/package/nmap/nmap.mk
> @@ -10,7 +10,7 @@ NMAP_SOURCE = nmap-$(NMAP_VERSION).tar.bz2
>  NMAP_DEPENDENCIES = libpcap pcre
>  NMAP_CONF_OPTS = --without-liblua --without-zenmap \
>  	--with-libdnet=included --with-liblinear=included \
> -	--with-libpcre="$(STAGING_DIR)/usr" --without-ncat
> +	--with-libpcre="$(STAGING_DIR)/usr"
>  NMAP_LICENSE = GPL-2.0
>  NMAP_LICENSE_FILES = COPYING
>  
> @@ -50,4 +50,17 @@ else
>  NMAP_CONF_OPTS += --without-ndiff
>  endif
>  
> +ifeq ($(BR2_PACKAGE_NMAP_NCAT),y)
> +
> +define NMAP_INSTALL_NCAT_SYMLINK
> +        ln -fs ncat $(TARGET_DIR)/usr/bin/nc
> +endef
> +NMAP_POST_INSTALL_TARGET_HOOKS += NMAP_INSTALL_NCAT_SYMLINK
> +
> +else
> +
> +NMAP_CONF_OPTS += --without-ncat
> +
> +endif
> +
>  $(eval $(autotools-package))
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"
  2017-10-06 19:58               ` Arnout Vandecappelle
@ 2017-10-09 16:13                 ` Carlos Santos
  2017-10-09 22:08                   ` Arnout Vandecappelle
  0 siblings, 1 reply; 21+ messages in thread
From: Carlos Santos @ 2017-10-09 16:13 UTC (permalink / raw)
  To: buildroot

> From: "Arnout Vandecappelle" <arnout@mind.be>
> To: "Carlos Santos" <casantos@datacom.ind.br>, buildroot at buildroot.org
> Cc: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>, "Maxime Hadjinlian" <maxime.hadjinlian@gmail.com>
> Sent: Friday, October 6, 2017 4:58:19 PM
> Subject: Re: [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"

> Hi Carlos,
> 
> Sorry to iterate yet another time on this patch...
> 
> On 04-10-17 17:43, Carlos Santos wrote:
>> Ncat is a much-improved reimplementation of the venerable Netcat and is
>> compatible with uClibc.
>> 
>> So far the "nc" options available to build with uClibc were the ancient
> 
> uClibc and musl.

OK

>> GNU netcat and its Busybox double (the openbsd-netcat package cannot be
> 
> The package is called netcat-openbsd.

OK

>> used because it requires GLIBC). Both lack features available in modern
>> netcats like IPv6, proxies, and Unix sockets.
>> 
>> Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
> [snip]
>> diff --git a/package/nmap/Config.in b/package/nmap/Config.in
>> index 79f587afd1..a2e330dacd 100644
>> --- a/package/nmap/Config.in
>> +++ b/package/nmap/Config.in
>> @@ -11,6 +11,19 @@ config BR2_PACKAGE_NMAP
>>  
>>  	  http://nmap.org
>>  
>> +if BR2_PACKAGE_NMAP
>> +
>> +config BR2_PACKAGE_NMAP_NCAT
>> +	bool "nmap-ncat"
> 
> ncat itself is very small (+- 150K) compared to the rest of nmap (+- 2.5M), so
> it's not really worth making a config option for it.
> 
> Conversely, it *could* be worthwhile to have an option
> BR2_PACKAGE_NMAP_NCAT_ONLY that just installs the ncat tool (+symlink) from the
> package. So my idea would be:
> 
> - always build with ncat and install the symlink;
> - if BR2_PACKAGE_NMAP_NCAT_ONLY is selected, override the install commands to
> just install ncat + symlink.
> 
> Perhaps to be sure you can do it as two patches, first one that always enables
> ncat and installs symlink, second one that adds the BR2_PACKAGE_NMAP_NCAT_ONLY
> option. That kind of option is a bit controversial (it's a "negative" option
> because it removes stuff from the nmap package; we generally  prefer additive
> options instead, but that would be a bit complicated here).

That's what I did in https://patchwork.ozlabs.org/patch/820503/.
I can give it a another try but I hope you guys reach an agreement
about what you want. :-)

> One more thing though: are the ncat options compatible with those for
> netcat-openbsd? And I'm talking about the options that are not in busybox or GNU
> netcat now. If they are not compatible (and a quick look at the man pages tells
> me that only the -6 and -U options are the same), I feel awkward about creating
> the symlink: since you need to know which netcat type you're using, you could
> just as well call ncat directly. And for scripts that don't rely on any of
> these, the busybox or GNU nc is enough.

This diversity is already known. Debian/Ubuntu uses netcat-openbsd
as its nc command while Fedora/RHEL uses nmap-ncat. The user of "nc"
that I have in mind is virt-manager, which is used to manage libvirtd
(check https://patchwork.ozlabs.org/patch/814396/).

virt-manager accesses the target machine via ssh and there it runs nc
connect to the unix socket on which libvirtd listens. The connection
script tests what syntax the nc command recognizes.

Obviously the same restrictions would apply to any software depending
on nc but already happens, since buildroot provides three different nc
commands, so I do not consider the diversity a regression.

-- 
Carlos Santos (Casantos) - DATACOM, P&D
?The greatest triumph that modern PR can offer is the transcendent 
success of having your words and actions judged by your reputation, 
rather than the other way about.? ? Christopher Hitchens

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"
  2017-10-09 16:13                 ` Carlos Santos
@ 2017-10-09 22:08                   ` Arnout Vandecappelle
  2017-10-09 22:10                     ` Arnout Vandecappelle
  2017-10-10  8:12                     ` Thomas Petazzoni
  0 siblings, 2 replies; 21+ messages in thread
From: Arnout Vandecappelle @ 2017-10-09 22:08 UTC (permalink / raw)
  To: buildroot



On 09-10-17 18:13, Carlos Santos wrote:
[snip]
>> ncat itself is very small (+- 150K) compared to the rest of nmap (+- 2.5M), so
>> it's not really worth making a config option for it.
>>
>> Conversely, it *could* be worthwhile to have an option
>> BR2_PACKAGE_NMAP_NCAT_ONLY that just installs the ncat tool (+symlink) from the
>> package. So my idea would be:
>>
>> - always build with ncat and install the symlink;
>> - if BR2_PACKAGE_NMAP_NCAT_ONLY is selected, override the install commands to
>> just install ncat + symlink.
>>
>> Perhaps to be sure you can do it as two patches, first one that always enables
>> ncat and installs symlink, second one that adds the BR2_PACKAGE_NMAP_NCAT_ONLY
>> option. That kind of option is a bit controversial (it's a "negative" option
>> because it removes stuff from the nmap package; we generally  prefer additive
>> options instead, but that would be a bit complicated here).
> 
> That's what I did in https://patchwork.ozlabs.org/patch/820503/.
> I can give it a another try but I hope you guys reach an agreement
> about what you want. :-)

 Well, that patch (and its v1 and v2) introduced a virtual package for nc and
AFAICS you only got comments on the virtual package aspect. I don't think
anybody commented on having a BR2_PACKAGE_NMAP_NCAT_ONLY option. You anyway
didn't have that, you had a BR2_PACKAGE_NMAP_NMAP option, but I don't think you
got any direct comments on that choice.

 That said, it's indeed a good idea to converge on the right approach upfront.
Thomas, Peter, what do you think? I'm also adding Yann in Cc, he usually has
bright ideas about this kind of thing. The options (that I see):

1. Current patch, i.e. BR2_PACKAGE_NMAP builds just nmap and
BR2_PACKAGE_NMAP_NCAT builds nmap + ncat.

2. No specific option, always install nmap + ncat if BR2_PACKAGE_NMAP is
selected. Note that this might create a problem if both nmap and netcat-openbsd
are selected, so there should probably be a dependency introduced and a check
that nc doesn't exist yet before creating the symlink.

3. BR2_PACKAGE_NMAP_NCAT_ONLY *disables* nmap.

4. New option BR2_PACKAGE_NMAP_NMAP to build nmap (this option should default y
for backward compatibility). ncat is always built if BR2_PACKAGE_NMAP is
selected. So BR2_PACKAGE_NMAP means ncat, and BR2_PACKAGE_NMAP_NMAP means nmap +
ncat.

5. BR2_PACKAGE_NMAP builds nothing, two new options BR2_PACKAGE_NMAP_NMAP and
BR2_PACKAGE_NMAP_NCAT build nmap resp. ncat. To avoid building nothing, you
could try something like

config BR2_PACKAGE_NMAP
	select BR2_PACKAGE_NMAP_NCAT if !BR2_PACKAGE_NMAP_NMAP

if BR2_PACKAGE_NMAP
config BR2_PACKAGE_NMAP_NMAP
	default y

config BR2_PACKAGE_NMAP_NCAT
endif

but that might give a circular dependency.


>> One more thing though: are the ncat options compatible with those for
>> netcat-openbsd? And I'm talking about the options that are not in busybox or GNU
>> netcat now. If they are not compatible (and a quick look at the man pages tells
>> me that only the -6 and -U options are the same), I feel awkward about creating
>> the symlink: since you need to know which netcat type you're using, you could
>> just as well call ncat directly. And for scripts that don't rely on any of
>> these, the busybox or GNU nc is enough.
> 
> This diversity is already known. Debian/Ubuntu uses netcat-openbsd
> as its nc command while Fedora/RHEL uses nmap-ncat. The user of "nc"
> that I have in mind is virt-manager, which is used to manage libvirtd
> (check https://patchwork.ozlabs.org/patch/814396/).
> 
> virt-manager accesses the target machine via ssh and there it runs nc
> connect to the unix socket on which libvirtd listens. The connection
> script tests what syntax the nc command recognizes.
> 
> Obviously the same restrictions would apply to any software depending
> on nc but already happens, since buildroot provides three different nc
> commands, so I do not consider the diversity a regression.

 OK, makes sense. Perhaps you can add something like this to the commit log.

We symlink 'nc' to ncat, even though ncat does not have the same interface as
netcat-openbsd. However, since Fedora/RHEL install nmap-ncat as 'nc', it can be
assumed that packages that depend on 'nc' know how to deal with this diversity.
For example, the virt-manager package does that. Also user-supplied scripts can
be assumed to do the right thing, since the user also selects whether nmap-ncat
or netcat-openbsd is installed.


 Regards,
 Arnout
-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"
  2017-10-09 22:08                   ` Arnout Vandecappelle
@ 2017-10-09 22:10                     ` Arnout Vandecappelle
  2017-10-09 23:55                       ` Carlos Santos
  2017-10-10  8:12                     ` Thomas Petazzoni
  1 sibling, 1 reply; 21+ messages in thread
From: Arnout Vandecappelle @ 2017-10-09 22:10 UTC (permalink / raw)
  To: buildroot



On 10-10-17 00:08, Arnout Vandecappelle wrote:
> 2. No specific option, always install nmap + ncat if BR2_PACKAGE_NMAP is
> selected. Note that this might create a problem if both nmap and netcat-openbsd
> are selected, so there should probably be a dependency introduced and a check
> that nc doesn't exist yet before creating the symlink.

 Let me clarify that bit: in all the other options, the user makes a conscious
decision to enable ncat (and therefore the nc symlink). With this option,
however, the nc symlink will be created without the user being aware of it, so
it could be that it is not what the user intended. This is only a problem if
netcat-openbsd is also installed (since ncat is a strict superset of GNU and
busybox nc).

 Regards,
 Arnout

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"
  2017-10-09 22:10                     ` Arnout Vandecappelle
@ 2017-10-09 23:55                       ` Carlos Santos
  2017-10-10  0:25                         ` Arnout Vandecappelle
  0 siblings, 1 reply; 21+ messages in thread
From: Carlos Santos @ 2017-10-09 23:55 UTC (permalink / raw)
  To: buildroot

> From: "Arnout Vandecappelle" <arnout@mind.be>
> To: "Carlos Santos" <casantos@datacom.ind.br>
> Cc: buildroot at buildroot.org, "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>, "Maxime Hadjinlian"
> <maxime.hadjinlian@gmail.com>, "Peter Korsgaard" <peter@korsgaard.com>, "Yann E. MORIN" <yann.morin.1998@free.fr>
> Sent: Monday, October 9, 2017 7:10:55 PM
> Subject: Re: [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"

> On 10-10-17 00:08, Arnout Vandecappelle wrote:
>> 2. No specific option, always install nmap + ncat if BR2_PACKAGE_NMAP is
>> selected. Note that this might create a problem if both nmap and netcat-openbsd
>> are selected, so there should probably be a dependency introduced and a check
>> that nc doesn't exist yet before creating the symlink.
> 
> Let me clarify that bit: in all the other options, the user makes a conscious
> decision to enable ncat (and therefore the nc symlink). With this option,
> however, the nc symlink will be created without the user being aware of it, so
> it could be that it is not what the user intended. This is only a problem if
> netcat-openbsd is also installed (since ncat is a strict superset of GNU and
> busybox nc).

That was one of the advantages of the virtual package "nc": it
would require the user to choose only one netcat variant at a time.

Anyway, I can make the link creation optional or create it only if
none of the competing netcat variants is selected.

-- 
Carlos Santos (Casantos) - DATACOM, P&D
?The greatest triumph that modern PR can offer is the transcendent 
success of having your words and actions judged by your reputation, 
rather than the other way about.? ? Christopher Hitchens

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"
  2017-10-09 23:55                       ` Carlos Santos
@ 2017-10-10  0:25                         ` Arnout Vandecappelle
  0 siblings, 0 replies; 21+ messages in thread
From: Arnout Vandecappelle @ 2017-10-10  0:25 UTC (permalink / raw)
  To: buildroot



On 10-10-17 01:55, Carlos Santos wrote:
>> From: "Arnout Vandecappelle" <arnout@mind.be>
>> To: "Carlos Santos" <casantos@datacom.ind.br>
>> Cc: buildroot at buildroot.org, "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>, "Maxime Hadjinlian"
>> <maxime.hadjinlian@gmail.com>, "Peter Korsgaard" <peter@korsgaard.com>, "Yann E. MORIN" <yann.morin.1998@free.fr>
>> Sent: Monday, October 9, 2017 7:10:55 PM
>> Subject: Re: [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"
> 
>> On 10-10-17 00:08, Arnout Vandecappelle wrote:
>>> 2. No specific option, always install nmap + ncat if BR2_PACKAGE_NMAP is
>>> selected. Note that this might create a problem if both nmap and netcat-openbsd
>>> are selected, so there should probably be a dependency introduced and a check
>>> that nc doesn't exist yet before creating the symlink.
>>
>> Let me clarify that bit: in all the other options, the user makes a conscious
>> decision to enable ncat (and therefore the nc symlink). With this option,
>> however, the nc symlink will be created without the user being aware of it, so
>> it could be that it is not what the user intended. This is only a problem if
>> netcat-openbsd is also installed (since ncat is a strict superset of GNU and
>> busybox nc).
> 
> That was one of the advantages of the virtual package "nc": it
> would require the user to choose only one netcat variant at a time.
> 
> Anyway, I can make the link creation optional or create it only if
> none of the competing netcat variants is selected.

 Good plan indeed.

 Regards,
 Arnout

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"
  2017-10-09 22:08                   ` Arnout Vandecappelle
  2017-10-09 22:10                     ` Arnout Vandecappelle
@ 2017-10-10  8:12                     ` Thomas Petazzoni
  2017-10-10 12:42                       ` Yann E. MORIN
  1 sibling, 1 reply; 21+ messages in thread
From: Thomas Petazzoni @ 2017-10-10  8:12 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue, 10 Oct 2017 00:08:38 +0200, Arnout Vandecappelle wrote:

> 5. BR2_PACKAGE_NMAP builds nothing, two new options BR2_PACKAGE_NMAP_NMAP and
> BR2_PACKAGE_NMAP_NCAT build nmap resp. ncat. To avoid building nothing, you
> could try something like
> 
> config BR2_PACKAGE_NMAP
> 	select BR2_PACKAGE_NMAP_NCAT if !BR2_PACKAGE_NMAP_NMAP
> 
> if BR2_PACKAGE_NMAP
> config BR2_PACKAGE_NMAP_NMAP
> 	default y
> 
> config BR2_PACKAGE_NMAP_NCAT
> endif
> 
> but that might give a circular dependency.

This option has my preference. And it doesn't have a circular
dependency, we use this construct in several places already.

One example:

config BR2_PACKAGE_ANDROID_TOOLS
        bool "android-tools"
        select BR2_PACKAGE_ANDROID_TOOLS_ADBD if \
              !BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT && \
              !BR2_PACKAGE_ANDROID_TOOLS_ADB

if BR2_PACKAGE_ANDROID_TOOLS

config BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT
        bool "fastboot"

config BR2_PACKAGE_ANDROID_TOOLS_ADB
        bool "adb"

config BR2_PACKAGE_ANDROID_TOOLS_ADBD
        bool "adbd"

endif

However, perhaps we should invert the select:

	select BR2_PACKAGE_NMAP_NMAP if !BR2_PACKAGE_NMAP_NCAT

and drop the "default y" in BR2_PACKAGE_NMAP_NMAP. This way, we still
have "nmap" enabled by default, and now allow the option to select ncat.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH v2] nmap: add option to build/install "ncat"
  2017-10-10  8:12                     ` Thomas Petazzoni
@ 2017-10-10 12:42                       ` Yann E. MORIN
  0 siblings, 0 replies; 21+ messages in thread
From: Yann E. MORIN @ 2017-10-10 12:42 UTC (permalink / raw)
  To: buildroot

Thomas, Carlos, Arnout, All,

On 2017-10-10 10:12 +0200, Thomas Petazzoni spake thusly:
> On Tue, 10 Oct 2017 00:08:38 +0200, Arnout Vandecappelle wrote:
> > 5. BR2_PACKAGE_NMAP builds nothing, two new options BR2_PACKAGE_NMAP_NMAP and
> > BR2_PACKAGE_NMAP_NCAT build nmap resp. ncat. To avoid building nothing, you
> > could try something like
> > 
> > config BR2_PACKAGE_NMAP
> > 	select BR2_PACKAGE_NMAP_NCAT if !BR2_PACKAGE_NMAP_NMAP
> > 
> > if BR2_PACKAGE_NMAP
> > config BR2_PACKAGE_NMAP_NMAP
> > 	default y
> > 
> > config BR2_PACKAGE_NMAP_NCAT
> > endif
> > 
> > but that might give a circular dependency.
> 
> This option has my preference. And it doesn't have a circular
> dependency, we use this construct in several places already.
> 
> One example:
> 
> config BR2_PACKAGE_ANDROID_TOOLS
>         bool "android-tools"
>         select BR2_PACKAGE_ANDROID_TOOLS_ADBD if \
>               !BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT && \
>               !BR2_PACKAGE_ANDROID_TOOLS_ADB
> 
> if BR2_PACKAGE_ANDROID_TOOLS
> 
> config BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT
>         bool "fastboot"
> 
> config BR2_PACKAGE_ANDROID_TOOLS_ADB
>         bool "adb"
> 
> config BR2_PACKAGE_ANDROID_TOOLS_ADBD
>         bool "adbd"
> 
> endif
> 
> However, perhaps we should invert the select:
> 
> 	select BR2_PACKAGE_NMAP_NMAP if !BR2_PACKAGE_NMAP_NCAT
> 
> and drop the "default y" in BR2_PACKAGE_NMAP_NMAP. This way, we still
> have "nmap" enabled by default, and now allow the option to select ncat.

Since Arnout pulled me in the discussion, here is my stake at it: I
second Thomas' position on this. ;-)

Regards,
Yann E. MORIN.

> Best regards,
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Buildroot] [PATCH] nmap: add option to build/install ncat
  2017-10-04 15:43             ` [Buildroot] [PATCH v2] " Carlos Santos
  2017-10-06 19:58               ` Arnout Vandecappelle
@ 2017-10-10 13:32               ` Carlos Santos
  1 sibling, 0 replies; 21+ messages in thread
From: Carlos Santos @ 2017-10-10 13:32 UTC (permalink / raw)
  To: buildroot

Ncat is a much-improved reimplementation of the venerable Netcat and is
compatible with uClibc and musl. It provides features not available in
the ancient GNU netcat and its Busybox double like IPv6, proxies, and
Unix sockets.

Tha nmap package now installs ncat if the BR2_PACKAGE_NMAP_NCAT option
is selected. The other programs (nmap, ndiff, etc.) are chosen via the
BR2_PACKAGE_NMAP_NMAP option.

We symlink 'nc' to ncat if neiter netcat nor netcat-openbsd is selected,
even though ncat does not have the same interface as netcat-openbsd.
However, since Fedora/RHEL install nmap-ncat as 'nc', it can be assumed
that packages that depend on 'nc' know how to deal with this diversity.
For example, the virt-manager package does that. Also user-supplied
scripts can be assumed to do the right thing, since the user also
selects whether nmap-ncat, netcat or netcat-openbsd is installed.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
---
Changes v1->v2:
  - Add dependens on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS, like netcat does
  - Remove forced dependence on busybox, since its installation script
    does not override existing programs.
Changes v2->v3:
  - Use a better logic to select either ncat tools, nmap or both, as
    suggested by Arnout Vandecappelle and Thomas Petazzoni.
  - Add a prominent comment about the symlink to 'nc', as suggested by
    Arnout.
---
 package/nmap/Config.in | 27 ++++++++++++++++++++++++++-
 package/nmap/nmap.mk   | 32 ++++++++++++++++++++++++++++++--
 2 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/package/nmap/Config.in b/package/nmap/Config.in
index 79f587a..1843bb6 100644
--- a/package/nmap/Config.in
+++ b/package/nmap/Config.in
@@ -4,6 +4,12 @@ config BR2_PACKAGE_NMAP
 	depends on BR2_USE_MMU # fork()
 	depends on BR2_TOOLCHAIN_HAS_THREADS
 	select BR2_PACKAGE_LIBPCAP
+	select BR2_PACKAGE_NMAP_NMAP if !BR2_PACKAGE_NMAP_NCAT
+
+if  BR2_PACKAGE_NMAP
+
+config BR2_PACKAGE_NMAP_NMAP
+	bool "install nmap tools"
 	select BR2_PACKAGE_PCRE
 	help
 	  Nmap ("Network Mapper") is a free and open source (license)
@@ -11,6 +17,25 @@ config BR2_PACKAGE_NMAP
 
 	  http://nmap.org
 
-comment "nmap needs a toolchain w/ C++, threads"
+config BR2_PACKAGE_NMAP_NCAT
+	bool "install ncat"
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+	help
+	  Ncat is a feature-packed networking utility which reads and
+	  writes data across networks from the command line. Ncat was
+	  written for the Nmap Project as a much-improved
+	  reimplementation of the venerable Netcat.
+
+	  If symlink to "nc" is installed if neither netcat or
+	  netcat-openbsd is selected.
+
+comment "a symlink from ncat to 'nc' will be installed"
+	depends on BR2_PACKAGE_NMAP_NCAT
+	depends on !BR2_PACKAGE_NETCAT
+	depends on !BR2_PACKAGE_NETCAT_OPENBSD
+
+endif
+
+comment "nmap-nmap needs a toolchain w/ C++, threads"
 	depends on BR2_USE_MMU
 	depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)
diff --git a/package/nmap/nmap.mk b/package/nmap/nmap.mk
index 37720e2..cd8f34a 100644
--- a/package/nmap/nmap.mk
+++ b/package/nmap/nmap.mk
@@ -7,10 +7,10 @@
 NMAP_VERSION = 7.40
 NMAP_SITE = http://nmap.org/dist
 NMAP_SOURCE = nmap-$(NMAP_VERSION).tar.bz2
-NMAP_DEPENDENCIES = libpcap pcre
+NMAP_DEPENDENCIES = libpcap
 NMAP_CONF_OPTS = --without-liblua --without-zenmap \
 	--with-libdnet=included --with-liblinear=included \
-	--with-libpcre="$(STAGING_DIR)/usr" --without-ncat
+	--with-libpcre="$(STAGING_DIR)/usr"
 NMAP_LICENSE = GPL-2.0
 NMAP_LICENSE_FILES = COPYING
 
@@ -35,6 +35,10 @@ else
 NMAP_CONF_OPTS += --without-openssl
 endif
 
+ifeq ($(BR2_PACKAGE_NMAP_NMAP),y)
+
+NMAP_DEPENDENCIES += pcre
+
 # ndiff only works with python2.x
 ifeq ($(BR2_PACKAGE_PYTHON),y)
 NMAP_DEPENDENCIES += python
@@ -42,4 +46,28 @@ else
 NMAP_CONF_OPTS += --without-ndiff
 endif
 
+ifeq ($(BR2_PACKAGE_NMAP_NCAT),)
+NMAP_CONF_OPTS += --without-ncat
+endif
+
+else # only ncat
+
+NMAP_CONF_OPTS += --without-ndiff --without-zenmap --without-nping --without-nmap-update
+define NMAP_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) build-ncat
+endef
+define NMAP_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install-ncat
+endef
+
+endif
+
+# Add a symlink to "nc" if none of the competing netcats is selected
+ifeq ($(BR2_PACKAGE_NMAP_NCAT):$(BR2_PACKAGE_NETCAT)$(BR2_PACKAGE_NETCAT_OPENBSD),y:)
+define NMAP_INSTALL_NCAT_SYMLINK
+        ln -fs ncat $(TARGET_DIR)/usr/bin/nc
+endef
+NMAP_POST_INSTALL_TARGET_HOOKS += NMAP_INSTALL_NCAT_SYMLINK
+endif
+
 $(eval $(autotools-package))
-- 
2.7.5

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2017-10-10 13:32 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-17  7:15 [Buildroot] [PATCH] nc: new virtual package providing "netcat" functionality Carlos Santos
2017-09-17 21:45 ` [Buildroot] [PATCH v2] " Carlos Santos
2017-10-02 14:13   ` [Buildroot] [PATCH v3] " Carlos Santos
2017-10-02 19:18     ` Thomas Petazzoni
2017-10-02 19:44       ` Peter Korsgaard
2017-10-02 20:28         ` Carlos Santos
2017-10-02 20:09       ` Carlos Santos
2017-10-04  9:20         ` Thomas Petazzoni
2017-10-04 12:49           ` [Buildroot] [PATCH] nmap: add option to build/install "ncat" Carlos Santos
2017-10-04 14:08             ` Baruch Siach
2017-10-04 15:43             ` [Buildroot] [PATCH v2] " Carlos Santos
2017-10-06 19:58               ` Arnout Vandecappelle
2017-10-09 16:13                 ` Carlos Santos
2017-10-09 22:08                   ` Arnout Vandecappelle
2017-10-09 22:10                     ` Arnout Vandecappelle
2017-10-09 23:55                       ` Carlos Santos
2017-10-10  0:25                         ` Arnout Vandecappelle
2017-10-10  8:12                     ` Thomas Petazzoni
2017-10-10 12:42                       ` Yann E. MORIN
2017-10-10 13:32               ` [Buildroot] [PATCH] nmap: add option to build/install ncat Carlos Santos
2017-10-04 12:58           ` [Buildroot] [PATCH v3] nc: new virtual package providing "netcat" functionality Carlos Santos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.