[openwrt/openwrt] tools/coreutils: bootstrap to local gnulib source

LEDE Commits lede-commits at lists.infradead.org
Thu May 4 11:07:30 PDT 2023


ansuel pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/09f8f21ae33402201c14a125a37b64746415642d

commit 09f8f21ae33402201c14a125a37b64746415642d
Author: Michael Pratt <mcpratt at pm.me>
AuthorDate: Thu Mar 23 03:49:01 2023 -0400

    tools/coreutils: bootstrap to local gnulib source
    
    Using the local gnulib source during bootstrap
    allows for fine-grained control over the macros
    and source files for use with coreutils
    but part of gnulib instead of coreutils,
    without having to wait for a release
    or deal with gnulib as a git submodule.
    
    In this case, the execution of autotools
    must be skipped by force.
    Autoconf and Automake during bootstrap on coreutils
    only works right when using directly checked-out source.
    
    There is a symbol in gnulib, @GNULIB_TIME@
    that is not yet defined in coreutils source,
    so we use the backup of lib/time.in.h instead
    of the one provided by gnulib source.
    
    Signed-off-by: Michael Pratt <mcpratt at pm.me>
---
 tools/Makefile                              |  1 +
 tools/coreutils/Makefile                    | 27 +++++++++++++++++
 tools/coreutils/patches/000-bootstrap.patch | 45 +++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+)

diff --git a/tools/Makefile b/tools/Makefile
index 3f12828a8f..40c3ec1ab0 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -127,6 +127,7 @@ $(curdir)/squashfs4/compile := $(curdir)/xz/compile $(curdir)/zlib/compile
 $(curdir)/zstd/compile := $(curdir)/meson/compile
 
 ifneq ($(HOST_OS),Linux)
+  $(curdir)/coreutils/compile += $(curdir)/automake/compile $(curdir)/bison/compile $(curdir)/gnulib/compile
   $(curdir)/squashfs4/compile += $(curdir)/coreutils/compile
   tools-y += coreutils
 endif
diff --git a/tools/coreutils/Makefile b/tools/coreutils/Makefile
index f799e83c5b..233ab1585d 100644
--- a/tools/coreutils/Makefile
+++ b/tools/coreutils/Makefile
@@ -20,15 +20,42 @@ BUILD_PROGRAMS = date readlink touch ln chown ginstall
 
 include $(INCLUDE_DIR)/host-build.mk
 
+export GNULIB_SRCDIR:=$(HOST_GNULIB_SRCDIR)
+
 BUILD_BINS = $(patsubst %,src/%,$(BUILD_PROGRAMS))
 
 HOST_CONFIGURE_ARGS += \
 	 --enable-install-program=$(subst $(space),$(comma),$(strip $(BUILD_PROGRAMS)))
 
 HOST_MAKE_FLAGS += \
+	$(AM_TOOL_PATHS_FAKE) \
 	PROGRAMS="$(BUILD_BINS)" \
 	LIBRARIES= MANS= SUBDIRS=.
 
+define Host/Bootstrap
+	( \
+		cd $(HOST_BUILD_DIR); \
+		$(AM_TOOL_PATHS_FAKE) \
+		./bootstrap \
+			--bootstrap-sync \
+			--force \
+			--no-git \
+			--skip-po \
+			--gnulib-srcdir=$(GNULIB_SRCDIR) \
+	)
+endef
+
+define Host/Prepare
+	$(call Host/Prepare/Default)
+	$(if $(QUILT),,$(call Host/Bootstrap))
+endef
+
+define Host/Configure
+	$(if $(QUILT),$(call Host/Bootstrap))
+	-$(CP) $(HOST_BUILD_DIR)/lib/time.in.h~ $(HOST_BUILD_DIR)/lib/time.in.h # @GNULIB_TIME@ not defined
+	$(call Host/Configure/Default)
+endef
+
 define Host/Install
 	$(INSTALL_DIR) $(1)/bin
 	$(INSTALL_BIN) $(patsubst %,$(HOST_BUILD_DIR)/%,$(BUILD_BINS)) $(1)/bin/
diff --git a/tools/coreutils/patches/000-bootstrap.patch b/tools/coreutils/patches/000-bootstrap.patch
new file mode 100644
index 0000000000..91be9d338a
--- /dev/null
+++ b/tools/coreutils/patches/000-bootstrap.patch
@@ -0,0 +1,45 @@
+--- a/bootstrap
++++ b/bootstrap
+@@ -278,7 +278,7 @@ check_exists() {
+       ($2 --version </dev/null)
+     fi
+   else
+-    ($1 --version </dev/null) >/dev/null 2>&1
++    ($@ --version </dev/null) >/dev/null 2>&1
+   fi
+ 
+   test $? -lt 126
+@@ -563,7 +563,7 @@ p
+ q'
+ 
+ get_version() {
+-  app=$1
++  app="$@"
+ 
+   $app --version >/dev/null 2>&1 || { $app --version; return 1; }
+ 
+@@ -620,13 +620,13 @@ check_versions() {
+     if [ "$req_ver" = "-" ]; then
+       # Merely require app to exist; not all prereq apps are well-behaved
+       # so we have to rely on $? rather than get_version.
+-      if ! check_exists --verbose $app; then
++      if ! check_exists --verbose "$app"; then
+         warn_ "Error: '$app' not found"
+         ret=1
+       fi
+     else
+       # Require app to produce a new enough version string.
+-      inst_ver=$(get_version $app)
++      inst_ver=$(get_version "$app")
+       if [ ! "$inst_ver" ]; then
+         warn_ "Error: '$app' not found"
+         ret=1
+@@ -923,7 +923,7 @@ version_controlled_file() {
+ # two just-pre-run programs.
+ 
+ # Import from gettext.
+-with_gettext=yes
++with_gettext=no
+ grep '^[	 ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
+     with_gettext=no
+ 




More information about the lede-commits mailing list