From patchwork Sun Sep 15 10:05:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alejandro_Gonz=C3=A1lez?= X-Patchwork-Id: 1162439 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="RlgAn5iX"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46WQ4T5Gp3z9sP3 for ; Sun, 15 Sep 2019 20:05:58 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7DDAE84F33; Sun, 15 Sep 2019 10:05:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d8PwmKuaDPK0; Sun, 15 Sep 2019 10:05:54 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 40B9685A1E; Sun, 15 Sep 2019 10:05:54 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 9A4741BF5B4 for ; Sun, 15 Sep 2019 10:05:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 958652051D for ; Sun, 15 Sep 2019 10:05:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pYaCwyeYSA6m for ; Sun, 15 Sep 2019 10:05:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by silver.osuosl.org (Postfix) with ESMTPS id 2B00120362 for ; Sun, 15 Sep 2019 10:05:51 +0000 (UTC) Received: by mail-wm1-f41.google.com with SMTP id 5so1084074wmg.0 for ; Sun, 15 Sep 2019 03:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=PXUy2qWgQyU6JaWR1zI6OGSRWHP0JCjL7QqP1g7+3Ys=; b=RlgAn5iXl8ooIlUlZzJgAFGd86tPpyxq3CKK1OR0/KvC6SMNQ7OnFqdLA8EntJVTR9 iLIJEWpDyRfkw7DtOGaJunrHm19F5wOe9xqSZ2ARdeKLs5+Tg7LFwx7CCbHgscuCdgXy H1PKX4QBKK4DcvjI5z0TWlClBWAbrbkwfNjdsgatTF+YxSqB4h7yjoGNwE1h065NVitP ceRdWkjTSLtmN1v9cOzz7uUFSR86XkZBCAjcnKPD8khJ/s5xDuP66cz+GMlhCgOHgueh GH2wOHYszuwJWVg7n8S2Hpec5IYMAkKYJOgH4r1jAznkDwjQ/zGAgQJNDJwJoAqK9Lab +hkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PXUy2qWgQyU6JaWR1zI6OGSRWHP0JCjL7QqP1g7+3Ys=; b=OMCc/rLaZVn8bnkT3pLYfyLMuEY44RhuZJdp2E6ESUljLXhBuN3ZV7jsFCftaKJoiA bK52Bt6fFsocIpcI6gFOhkzPa/rkLTPRpJ8YLpnMERjbZxh4qWTFevGEO0E9cO/mOMqg Cxk+9eXtU7dBZT8H3aX9Rs9jdvAxAcs/WOfZK7iuM6Z/iIzQcUpQUWPTzOLU15rXYvym 5XyzkKoTSZtNePrhTkHCcRiqG63Od8UL7XmWa/X6NPOhxmQq5rEDJpkSyTNIr/Z8nwuk S0JTizpwUjWp+qumFDHgTACsbvdA2+KX2ZBYC8TdT2Ikr0KuZGQBc6mlVNXNQz/rSITK 0wcQ== X-Gm-Message-State: APjAAAWT4xiff0Mf3y/upPZQZcpyGeaJFb7OLw7+Z0dskRaSse4xcout 4ai4aZYzMqDb+tBGnHor51E= X-Google-Smtp-Source: APXvYqz85rwbvVjPs5zNXCVyPLKh+COoIV16/0SlPL8Cssgd05Y0JhNCkMA7TXTib5vwOHOqFod59w== X-Received: by 2002:a1c:a7c6:: with SMTP id q189mr9268317wme.22.1568541949319; Sun, 15 Sep 2019 03:05:49 -0700 (PDT) Received: from [192.168.0.27] (57.166.117.91.dynamic.reverse-mundo-r.com. [91.117.166.57]) by smtp.gmail.com with ESMTPSA id c10sm44972444wrf.58.2019.09.15.03.05.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 15 Sep 2019 03:05:48 -0700 (PDT) To: buildroot@buildroot.org References: <20190829191722.18761-1-alejandro.gonzalez.correo@gmail.com> From: =?utf-8?q?Alejandro_Gonz=C3=A1lez?= Message-ID: <4e8f64ec-1797-a418-79d7-701380a767db@gmail.com> Date: Sun, 15 Sep 2019 12:05:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190829191722.18761-1-alejandro.gonzalez.correo@gmail.com> Content-Language: es-ES Subject: [Buildroot] [RESEND PATCH v3 1/1] package/iputils: add configs to select which binaries are built X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" By default, the iputils build script might build binaries which are useless for certain applications, like tftpd or ninfod. Those binaries will add to the target filesystem size unless a post-build script removes them manually, which is cumbersome and doesn't shorten build times. In particular, in a certain aarch64 Buildroot project with musl selected as a C library, this patch allowed to shrink the full iputils package from 219 KiB (if every option is selected) to 63 KiB (with only the ping binary selected) - a 71.2% relative size decrease. Moreover, upstream recently introduced a commit that disabled tftpd from building by default, like rarpd. In the current state of things, this change will introduce inconveniences for Buildroot users which prefer to use the tftpd implementation provided by this package. With this patch, however, that decision and similar future ones won't be a concern, because they will have complete control of what binaries are built. These changes add Kconfig options which let the user select what binaries are built with ease. Signed-off-by: Alejandro González --- Changes v2 -> v3: - Several style revisions (suggested by Arnout) - Simplify ninfod crypto dependencies logic (suggested by Arnout) - Better explain the rationale for this patch in the commit message Changes v2 -> v1: - Fix several typos package/iputils/Config.in | 68 ++++++++++++++++++++++ package/iputils/iputils.mk | 116 +++++++++++++++++++++++++------------ 2 files changed, 147 insertions(+), 37 deletions(-) diff --git a/package/iputils/Config.in b/package/iputils/Config.in index b5d9141a7d..7d106fa2d7 100644 --- a/package/iputils/Config.in +++ b/package/iputils/Config.in @@ -7,3 +7,71 @@ config BR2_PACKAGE_IPUTILS etc. https://github.com/iputils/iputils + +if BR2_PACKAGE_IPUTILS + +config BR2_PACKAGE_IPUTILS_ARPING + bool "arping" + default y + help + Installs arping. + +config BR2_PACKAGE_IPUTILS_CLOCKDIFF + bool "clockdiff" + default y + help + Installs clockdiff. + +config BR2_PACKAGE_IPUTILS_PING + bool "ping" + default y + help + Installs ping. + +config BR2_PACKAGE_IPUTILS_RARPD + bool "rarpd" + help + Installs rarpd. + +config BR2_PACKAGE_IPUTILS_RDISC + bool "rdisc" + default y + help + Installs rdisc. + +config BR2_PACKAGE_IPUTILS_RDISC_SERVER + bool "rdisc (server code)" + depends on BR2_PACKAGE_IPUTILS_RDISC + default y + help + Builds rdisc with server code. + +config BR2_PACKAGE_IPUTILS_TFTPD + bool "tftpd" + help + Installs tftpd. + +config BR2_PACKAGE_IPUTILS_TRACEPATH + bool "tracepath" + default y + help + Installs tracepath. + +config BR2_PACKAGE_IPUTILS_TRACEROUTE6 + bool "traceroute6" + default y + help + Installs traceroute6. + +config BR2_PACKAGE_IPUTILS_NINFOD + bool "ninfod" + depends on BR2_TOOLCHAIN_HAS_THREADS # ninfod requires + depends on BR2_PACKAGE_NETTLE || BR2_PACKAGE_LIBGCRYPT || BR2_PACKAGE_OPENSSL || BR2_PACKAGE_LINUX_HEADERS + default y + help + Installs ninfod. + +comment "ninfod needs nettle, libgcrypt, openssl or Linux headers and a toolchain w/ threads" + depends on !BR2_TOOLCHAIN_HAS_THREADS || (!BR2_PACKAGE_NETTLE && !BR2_PACKAGE_LIBGCRYPT && !BR2_PACKAGE_OPENSSL && !BR2_PACKAGE_LINUX_HEADERS) + +endif diff --git a/package/iputils/iputils.mk b/package/iputils/iputils.mk index 4a06581790..c2bbf0f96d 100644 --- a/package/iputils/iputils.mk +++ b/package/iputils/iputils.mk @@ -17,6 +17,66 @@ IPUTILS_LICENSE = GPL-2.0+, BSD-3-Clause IPUTILS_LICENSE_FILES = LICENSE Documentation/LICENSE.BSD3 Documentation/LICENSE.GPL2 IPUTILS_DEPENDENCIES = $(TARGET_NLS_DEPENDENCIES) +# Selectively build binaries +IPUTILS_CONF_OPTS += \ + -DBUILD_CLOCKDIFF=$(if $(BR2_PACKAGE_IPUTILS_CLOCKDIFF),true,false) \ + -DBUILD_RARPD=$(if $(BR2_PACKAGE_IPUTILS_RARPD),true,false) \ + -DBUILD_RDISC=$(if $(BR2_PACKAGE_IPUTILS_RDISC),true,false) \ + -DBUILD_RDISC_SERVER=$(if $(BR2_PACKAGE_IPUTILS_RDISC_SERVER),true,false) \ + -DBUILD_TRACEPATH=$(if $(BR2_PACKAGE_IPUTILS_TRACEPATH),true,false) \ + -DBUILD_TRACEROUTE6=$(if $(BR2_PACKAGE_IPUTILS_TRACEROUTE6),true,false) \ + -DBUILD_NINFOD=$(if $(BR2_PACKAGE_IPUTILS_NINFOD),true,false) + +# Handle binaries with hooks +ifeq ($(BR2_PACKAGE_IPUTILS_ARPING),y) +IPUTILS_CONF_OPTS += -DBUILD_ARPING=true + +# move some binaries to the same location as where Busybox installs +# the corresponding applets, so that we have a single version of the +# tools (from iputils) +define IPUTILS_MOVE_ARPING_BINARY + mv $(TARGET_DIR)/usr/bin/arping $(TARGET_DIR)/usr/sbin/arping +endef +IPUTILS_POST_INSTALL_TARGET_HOOKS += IPUTILS_MOVE_ARPING_BINARY + +else +IPUTILS_CONF_OPTS += -DBUILD_ARPING=false +endif + +ifeq ($(BR2_PACKAGE_IPUTILS_PING),y) +IPUTILS_CONF_OPTS += -DBUILD_PING=true + +# same reason to move the ping binary as for arping +ifeq ($(BR2_ROOTFS_MERGED_USR),) +define IPUTILS_MOVE_PING_BINARY + mv $(TARGET_DIR)/usr/bin/ping $(TARGET_DIR)/bin/ping +endef +IPUTILS_POST_INSTALL_TARGET_HOOKS += IPUTILS_MOVE_PING_BINARY +endif + +# upstream requires distros to create symlink +define IPUTILS_CREATE_PING6_SYMLINK + ln -sf $(TARGET_DIR)/bin/ping $(TARGET_DIR)/bin/ping6 +endef +IPUTILS_POST_INSTALL_TARGET_HOOKS += IPUTILS_CREATE_PING6_SYMLINK + +else +IPUTILS_CONF_OPTS += -DBUILD_PING=false +endif + +ifeq ($(BR2_PACKAGE_IPUTILS_TFTPD),y) +IPUTILS_CONF_OPTS += -DBUILD_TFTPD=true + +define IPUTILS_MOVE_TFTPD_BINARY + mv $(TARGET_DIR)/usr/bin/tftpd $(TARGET_DIR)/usr/sbin/tftpd +endef +IPUTILS_POST_INSTALL_TARGET_HOOKS += IPUTILS_MOVE_TFTPD_BINARY + +else +IPUTILS_CONF_OPTS += -DBUILD_TFTPD=false +endif + +# Handle libraries ifeq ($(BR2_PACKAGE_LIBCAP),y) IPUTILS_CONF_OPTS += -DUSE_CAP=true IPUTILS_DEPENDENCIES += libcap @@ -45,13 +105,6 @@ IPUTILS_CONF_OPTS += -DUSE_CRYPTO=kernel IPUTILS_DEPENDENCIES += linux-headers else IPUTILS_CONF_OPTS += -DUSE_CRYPTO=none -# BUILD_NINFOD=true and USE_CRYPTO=none cannot be combined -IPUTILS_CONF_OPTS += -DBUILD_NINFOD=false -endif - -# ninfod requires -ifneq ($(BR2_TOOLCHAIN_HAS_THREADS),y) -IPUTILS_CONF_OPTS += -DBUILD_NINFOD=false endif ifeq ($(BR2_SYSTEM_ENABLE_NLS),y) @@ -60,46 +113,35 @@ else IPUTILS_CONF_OPTS += -DUSE_GETTEXT=false endif -IPUTILS_CONF_OPTS += -DBUILD_TRACEROUTE6=true - # XSL Stylesheets for DocBook 5 not packaged for buildroot IPUTILS_CONF_OPTS += -DBUILD_MANS=false -DBUILD_HTML_MANS=false -# move iputils binaries to the same location as where Busybox installs -# the corresponding applets, so that we have a single version of the -# tools (from iputils) -define IPUTILS_MOVE_BINARIES - mv $(TARGET_DIR)/usr/bin/arping $(TARGET_DIR)/usr/sbin/arping - $(if $(BR2_ROOTFS_MERGED_USR),,\ - mv $(TARGET_DIR)/usr/bin/ping $(TARGET_DIR)/bin/ping) - mv $(TARGET_DIR)/usr/bin/tftpd $(TARGET_DIR)/usr/sbin/tftpd -endef -IPUTILS_POST_INSTALL_TARGET_HOOKS += IPUTILS_MOVE_BINARIES - -# upstream requires distros to create symlink -define IPUTILS_CREATE_PING6_SYMLINK - ln -sf $(TARGET_DIR)/bin/ping $(TARGET_DIR)/bin/ping6 -endef -IPUTILS_POST_INSTALL_TARGET_HOOKS += IPUTILS_CREATE_PING6_SYMLINK - # handle permissions ourselves IPUTILS_CONF_OPTS += -DNO_SETCAP_OR_SUID=true ifeq ($(BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES),y) define IPUTILS_PERMISSIONS - /usr/sbin/arping f 755 0 0 - - - - - - /usr/bin/clockdiff f 755 0 0 - - - - - - |xattr cap_net_raw+p - /bin/ping f 755 0 0 - - - - - - |xattr cap_net_raw+p - /usr/bin/traceroute6 f 755 0 0 - - - - - - |xattr cap_net_raw+p + $(if $(BR2_PACKAGE_IPUTILS_ARPING),\ + /usr/sbin/arping f 755 0 0 - - - - -,) + $(if $(BR2_PACKAGE_IPUTILS_CLOCKDIFF),\ + /usr/bin/clockdiff f 755 0 0 - - - - - + |xattr cap_net_raw+p,) + $(if $(BR2_PACKAGE_IPUTILS_PING),\ + /bin/ping f 755 0 0 - - - - - + |xattr cap_net_raw+p,) + $(if $(BR2_PACKAGE_IPUTILS_TRACEROUTE6),\ + /usr/bin/traceroute6 f 755 0 0 - - - - - + |xattr cap_net_raw+p,) endef else define IPUTILS_PERMISSIONS - /usr/sbin/arping f 755 0 0 - - - - - - /usr/bin/clockdiff f 4755 0 0 - - - - - - /bin/ping f 4755 0 0 - - - - - - /usr/bin/traceroute6 f 4755 0 0 - - - - - + $(if $(BR2_PACKAGE_IPUTILS_ARPING),\ + /usr/sbin/arping f 755 0 0 - - - - -,) + $(if $(BR2_PACKAGE_IPUTILS_CLOCKDIFF),\ + /usr/bin/clockdiff f 4755 0 0 - - - - -,) + $(if $(BR2_PACKAGE_IPUTILS_PING),\ + /bin/ping f 4755 0 0 - - - - -,) + $(if $(BR2_PACKAGE_IPUTILS_TRACEROUTE6),\ + /usr/bin/traceroute6 f 4755 0 0 - - - - -,) endef endif