From patchwork Fri Jun 7 02:15:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Mayer X-Patchwork-Id: 1111557 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.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="L84ow+Gs"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45KmNB1XCNz9s6w for ; Fri, 7 Jun 2019 12:15:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A3B4186689; Fri, 7 Jun 2019 02:15:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sO3rVuRvhNGu; Fri, 7 Jun 2019 02:15:45 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id A19008613C; Fri, 7 Jun 2019 02:15:45 +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 BEFBF1BF37F for ; Fri, 7 Jun 2019 02:15:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 9924720516 for ; Fri, 7 Jun 2019 02:15:44 +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 8kbYAehEKrfM for ; Fri, 7 Jun 2019 02:15:43 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by silver.osuosl.org (Postfix) with ESMTPS id 96A1820371 for ; Fri, 7 Jun 2019 02:15:43 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id i2so208275plt.1 for ; Thu, 06 Jun 2019 19:15:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=uAFaGfze/X8FSBiLCSeMVAdd86W9V5WY5GeYDtVCF5w=; b=L84ow+Gst4SqLPS0DYD+uIT36NJLPBpOamVBFKb7sDfn/Mir729wxlrvZXBGacYNvK qL0a6h6QwEeOiRrY1nzt5qnK1vU2kEJL33dH8KoLTjkRz97zOKmO5n7G5tx1pws+F7at pSCZBhodn7xExppV9gc35ed7DWE+8CWNYLl9s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uAFaGfze/X8FSBiLCSeMVAdd86W9V5WY5GeYDtVCF5w=; b=Zgw4Y0vlZg543leT3yVO34WFNFyT3Xatd+JTCr2Aagv0KNoeisV9rnEJEoyFZu3otT zPA07JtI2cgxiksfIe1W+ieKSNbQtfolohyIKMZdBshO1Y7jF3LkihNsRjCmmk46efSC z3yHl7jZDNbLoYZ3mCDO0LklhCrQn9LfOrCl7tfJRuxOgAJ/k7Xj3N4mGDuutHGb9yJF gbet/NUcrMY0Z989Ez2gOciHAvcDdde6DtDZzeBMjT4LJsfLfNjS+bfZWCV32S1hakMC 541xDD5zaSPWYo1R93TLScU9Yjqc2CAkKzjPT290SyYBIiwFr0mubPnqesTgNHSzeTnU cDfw== X-Gm-Message-State: APjAAAVZLDWf6Lj43ilSQutfyYcqrjznMMqLGukeyQ5C15TlKJkwl9CV B4CccxInnM5n/TgGSVxTizL+a7CXYrV94ogZmCZEF8pOdn4GhK6jg1KYbEDrpHvvcBnwDvgJB4d 16S8XcdFbI53r+1y0o/OVb2wtSlu/lQ8RAoFshnQiEC1falaeNs9GU7KCozDnS0LRgSo5 X-Google-Smtp-Source: APXvYqyVO7O8rhyalNJ1BS6+x34ytcMa6vr0UiX0mqgGFK0NUNlTp9svzs3EC7z1Pb+NV9z5YBZdBA== X-Received: by 2002:a17:902:8303:: with SMTP id bd3mr53177769plb.240.1559873742526; Thu, 06 Jun 2019 19:15:42 -0700 (PDT) Received: from lbrmn-mmayer.ric.broadcom.com ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id j8sm415064pfi.148.2019.06.06.19.15.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jun 2019 19:15:41 -0700 (PDT) From: Markus Mayer To: Buildroot Mailing List Date: Thu, 6 Jun 2019 19:15:34 -0700 Message-Id: <20190607021534.4657-1-mmayer@broadcom.com> X-Mailer: git-send-email 2.17.1 Subject: [Buildroot] [PATCH v3] package/coreutils: allow building individual binaries 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: , Cc: Markus Mayer MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" We add configuration option BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES so that coreutils can be built and installed as individual binaries. It can be used if the target file system doesn't support symlinks or symlinks are undesirable. The approach is modelled after Busybox's similarly named configuration option. Signed-off-by: Markus Mayer --- package/coreutils/Config.in | 18 ++++++++++++++ package/coreutils/coreutils.mk | 45 +++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/package/coreutils/Config.in b/package/coreutils/Config.in index 11a6019e820f..a0a84c220a48 100644 --- a/package/coreutils/Config.in +++ b/package/coreutils/Config.in @@ -19,3 +19,21 @@ comment "coreutils needs a toolchain w/ wchar" depends on BR2_USE_MMU depends on !BR2_USE_WCHAR depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS + +if BR2_PACKAGE_COREUTILS + +config BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES + bool "Individual binaries" + depends on !BR2_STATIC_LIBS + help + By default (i.e. with this option disabled), coreutils is + installed as a single binary (Busybox style) called + /usr/bin/coreutils, and all core utilities are symbolic + links to this binary. + + With this option enabled, each utility is a separate binary. + +comment "coreutils individual binaries need a toolchain w/ dynamic library" + depends on BR2_STATIC_LIBS + +endif diff --git a/package/coreutils/coreutils.mk b/package/coreutils/coreutils.mk index 8e5518f6383e..05232163a747 100644 --- a/package/coreutils/coreutils.mk +++ b/package/coreutils/coreutils.mk @@ -14,8 +14,13 @@ COREUTILS_LICENSE_FILES = COPYING COREUTILS_AUTORECONF = YES COREUTILS_GETTEXTIZE = YES -COREUTILS_CONF_OPTS = --disable-rpath --enable-single-binary=symlinks \ +COREUTILS_CONF_OPTS = --disable-rpath \ $(if $(BR2_TOOLCHAIN_USES_MUSL),--with-included-regex) + +ifeq ($(BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES),) +COREUTILS_CONF_OPTS += --enable-single-binary=symlinks +endif + COREUTILS_CONF_ENV = ac_cv_c_restrict=no \ ac_cv_func_chown_works=yes \ ac_cv_func_euidaccess=no \ @@ -59,6 +64,13 @@ COREUTILS_BIN_PROGS = base64 cat chgrp chmod chown cp date dd df dir echo false kill link ln ls mkdir mknod mktemp mv nice printenv pwd rm rmdir \ vdir sleep stty sync touch true uname join +# This is where our '[' symlink will point to. +ifeq ($(BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES),) +TEST_BINARY = coreutils +else +TEST_BINARY = test +endif + ifeq ($(BR2_PACKAGE_ACL),y) COREUTILS_DEPENDENCIES += acl else @@ -96,13 +108,24 @@ COREUTILS_DEPENDENCIES += openssl endif ifeq ($(BR2_ROOTFS_MERGED_USR),) +# We want to move a few binaries from /usr/bin to /bin. In the case of +# coreutils being built as multi-call binary, we do so by re-creating the +# corresponding symlinks. If coreutils is built with individual binaries, we +# actually move the binaries. +ifeq ($(BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES),) define COREUTILS_CLEANUP_BIN - # some things go in /bin rather than /usr/bin $(foreach f,$(COREUTILS_BIN_PROGS), \ rm -f $(TARGET_DIR)/usr/bin/$(f) && \ ln -sf ../usr/bin/coreutils $(TARGET_DIR)/bin/$(f) ) endef +else +define COREUTILS_CLEANUP_BIN + $(foreach f,$(COREUTILS_BIN_PROGS), \ + mv $(TARGET_DIR)/usr/bin/$(f) $(TARGET_DIR)/bin + ) +endef +endif COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_CLEANUP_BIN endif @@ -110,14 +133,24 @@ ifeq ($(BR2_STATIC_LIBS),y) COREUTILS_CONF_OPTS += --enable-no-install-program=stdbuf endif -define COREUTILS_CLEANUP +define COREUTILS_TEST_SYMLINK # link for archaic shells - ln -fs coreutils $(TARGET_DIR)/usr/bin/[ - # gnu thinks chroot is in bin, debian thinks it's in sbin + ln -fs $(TEST_BINARY) $(TARGET_DIR)/usr/bin/[ +endef +COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_TEST_SYMLINK + +# GNU thinks chroot is in bin, debian thinks it's in sbin. We move chroot to +# /usr/sbin, either by re-creating a symlink or by actually moving it. +ifeq ($(BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES),) +define COREUTILS_CLEANUP rm -f $(TARGET_DIR)/usr/bin/chroot ln -sf ../bin/coreutils $(TARGET_DIR)/usr/sbin/chroot endef - +else +define COREUTILS_CLEANUP + mv $(TARGET_DIR)/usr/bin/chroot $(TARGET_DIR)/usr/sbin +endef +endif COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_CLEANUP $(eval $(autotools-package))