aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGeorgi Valkov <gvalkov@gmail.com>2023-03-21 11:39:21 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2023-04-02 16:51:53 +0200
commit4467cf8e418e8003324990541b199d313b7c9235 (patch)
treeeb1ea978363a25849e916674b08a7f4ae9e6db26 /tools
parent2715aff5df836c1d3eb8cbf5afdb0c197902ee4b (diff)
downloadupstream-4467cf8e418e8003324990541b199d313b7c9235.tar.gz
upstream-4467cf8e418e8003324990541b199d313b7c9235.tar.bz2
upstream-4467cf8e418e8003324990541b199d313b7c9235.zip
tools/coreutils: update to 9.2
This resolves an error when building toolchain/musl on macOS due to improper hole-detection caused by a bug in macOS/APFS [1]. As long as we don't reconfigure, 001-m4.patch is not needed. If we keep it, it will force reconfigure the project, since m4 files are changed. This works, but may not be optimal, because the build should use files from coreutils/m4, but OpenWRT uses legacy files from staging_dir/host/share/aclocal [2]. backport a couple of upstream patches date: diagnose -f read errors copy: fix --reflink=auto to fallback in more cases [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61386 [2] https://github.com/openwrt/openwrt/pull/12233#issuecomment-1481097456 Co-developed-by: Michael Pratt <mcpratt@pm.me> Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/coreutils/Makefile5
-rw-r--r--tools/coreutils/patches/001-copy-fix-reflink-auto-to-fallback-in-more-cases.patch126
-rw-r--r--tools/coreutils/patches/001-m4.patch95
-rw-r--r--tools/coreutils/patches/002-date-diagnose-f-read-errors.patch20
4 files changed, 148 insertions, 98 deletions
diff --git a/tools/coreutils/Makefile b/tools/coreutils/Makefile
index 2b7b40cddc..23f2ea2cfb 100644
--- a/tools/coreutils/Makefile
+++ b/tools/coreutils/Makefile
@@ -8,14 +8,13 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=coreutils
PKG_CPE_ID:=cpe:/a:gnu:coreutils
-PKG_VERSION:=9.1
+PKG_VERSION:=9.2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@GNU/coreutils
-PKG_HASH:=61a1f410d78ba7e7f37a5a4f50e6d1320aca33375484a3255eddf17a38580423
+PKG_HASH:=6885ff47b9cdb211de47d368c17853f406daaf98b148aaecdf10de29cc04b0b3
HOST_BUILD_PARALLEL := 1
-PKG_FIXUP:=autoreconf
BUILD_PROGRAMS = date readlink touch ln chown ginstall
diff --git a/tools/coreutils/patches/001-copy-fix-reflink-auto-to-fallback-in-more-cases.patch b/tools/coreutils/patches/001-copy-fix-reflink-auto-to-fallback-in-more-cases.patch
new file mode 100644
index 0000000000..5416177a15
--- /dev/null
+++ b/tools/coreutils/patches/001-copy-fix-reflink-auto-to-fallback-in-more-cases.patch
@@ -0,0 +1,126 @@
+From 093a8b4bfaba60005f14493ce7ef11ed665a0176 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
+Date: Thu, 23 Mar 2023 13:19:04 +0000
+Subject: [PATCH] copy: fix --reflink=auto to fallback in more cases
+
+On restricted systems like android or some containers,
+FICLONE could return EPERM, EACCES, or ENOTTY,
+which would have induced the command to fail to copy
+rather than falling back to a more standard copy.
+
+* src/copy.c (is_terminal_failure): A new function refactored
+from handle_clone_fail().
+(is_CLONENOTSUP): Merge in the handling of EACCES, ENOTTY, EPERM
+as they also pertain to determination of whether cloning is supported
+if we ever use this function in that context.
+(handle_clone_fail): Use is_terminal_failure() in all cases,
+so that we assume a terminal failure in less errno cases.
+* NEWS: Mention the bug fix.
+Addresses https://bugs.gnu.org/62404
+---
+--- a/src/copy.c
++++ b/src/copy.c
+@@ -278,15 +278,27 @@ create_hole (int fd, char const *name, b
+ }
+
+
+-/* Whether the errno from FICLONE, or copy_file_range
+- indicates operation is not supported for this file or file system. */
++/* Whether the errno indicates the operation is a transient failure.
++ I.e., a failure that would indicate the operation _is_ supported,
++ but has failed in a terminal way. */
++
++static bool
++is_terminal_error (int err)
++{
++ return err == EIO || err == ENOMEM || err == ENOSPC || err == EDQUOT;
++}
++
++
++/* Whether the errno from FICLONE, or copy_file_range indicates
++ the operation is not supported/allowed for this file or process. */
+
+ static bool
+ is_CLONENOTSUP (int err)
+ {
+- return err == ENOSYS || is_ENOTSUP (err)
++ return err == ENOSYS || err == ENOTTY || is_ENOTSUP (err)
+ || err == EINVAL || err == EBADF
+- || err == EXDEV || err == ETXTBSY;
++ || err == EXDEV || err == ETXTBSY
++ || err == EPERM || err == EACCES;
+ }
+
+
+@@ -339,20 +351,18 @@ sparse_copy (int src_fd, int dest_fd, ch
+ {
+ copy_debug.offload = COPY_DEBUG_UNSUPPORTED;
+
+- if (is_CLONENOTSUP (errno))
+- break;
+-
+- /* copy_file_range might not be enabled in seccomp filters,
+- so retry with a standard copy. EPERM can also occur
+- for immutable files, but that would only be in the edge case
+- where the file is made immutable after creating/truncating,
++ /* Consider operation unsupported only if no data copied.
++ For example, EPERM could occur if copy_file_range not enabled
++ in seccomp filters, so retry with a standard copy. EPERM can
++ also occur for immutable files, but that would only be in the
++ edge case where the file is made immutable after creating,
+ in which case the (more accurate) error is still shown. */
+- if (errno == EPERM && *total_n_read == 0)
++ if (*total_n_read == 0 && is_CLONENOTSUP (errno))
+ break;
+
+ /* ENOENT was seen sometimes across CIFS shares, resulting in
+ no data being copied, but subsequent standard copies succeed. */
+- if (errno == ENOENT && *total_n_read == 0)
++ if (*total_n_read == 0 && errno == ENOENT)
+ break;
+
+ if (errno == EINTR)
+@@ -1172,17 +1182,15 @@ handle_clone_fail (int dst_dirfd, char c
+ char const* src_name, char const* dst_name,
+ int dest_desc, bool new_dst, enum Reflink_type reflink_mode)
+ {
+- /* If the clone operation is creating the destination,
+- then don't try and cater for all non transient file system errors,
+- and instead only cater for specific transient errors. */
+- bool transient_failure;
+- if (dest_desc < 0) /* currently for fclonefileat(). */
+- transient_failure = errno == EIO || errno == ENOMEM
+- || errno == ENOSPC || errno == EDQUOT;
+- else /* currently for FICLONE. */
+- transient_failure = ! is_CLONENOTSUP (errno);
++ /* When the clone operation fails, report failure only with errno values
++ known to mean trouble when the clone is supported and called properly.
++ Do not report failure merely because !is_CLONENOTSUP (errno),
++ as systems may yield oddball errno values here with FICLONE.
++ Also is_CLONENOTSUP() is not appropriate for the range of errnos
++ possible from fclonefileat(), so it's more consistent to avoid. */
++ bool report_failure = is_terminal_error (errno);
+
+- if (reflink_mode == REFLINK_ALWAYS || transient_failure)
++ if (reflink_mode == REFLINK_ALWAYS || report_failure)
+ error (0, errno, _("failed to clone %s from %s"),
+ quoteaf_n (0, dst_name), quoteaf_n (1, src_name));
+
+@@ -1190,14 +1198,14 @@ handle_clone_fail (int dst_dirfd, char c
+ but cloned no data. */
+ if (new_dst /* currently not for fclonefileat(). */
+ && reflink_mode == REFLINK_ALWAYS
+- && ((! transient_failure) || lseek (dest_desc, 0, SEEK_END) == 0)
++ && ((! report_failure) || lseek (dest_desc, 0, SEEK_END) == 0)
+ && unlinkat (dst_dirfd, dst_relname, 0) != 0 && errno != ENOENT)
+ error (0, errno, _("cannot remove %s"), quoteaf (dst_name));
+
+- if (! transient_failure)
++ if (! report_failure)
+ copy_debug.reflink = COPY_DEBUG_UNSUPPORTED;
+
+- if (reflink_mode == REFLINK_ALWAYS || transient_failure)
++ if (reflink_mode == REFLINK_ALWAYS || report_failure)
+ return false;
+
+ return true;
diff --git a/tools/coreutils/patches/001-m4.patch b/tools/coreutils/patches/001-m4.patch
deleted file mode 100644
index f3d7018332..0000000000
--- a/tools/coreutils/patches/001-m4.patch
+++ /dev/null
@@ -1,95 +0,0 @@
---- a/m4/gnulib-comp.m4
-+++ b/m4/gnulib-comp.m4
-@@ -2671,7 +2671,7 @@ changequote([, ])dnl
- fi
- gl_SYS_SOCKET_MODULE_INDICATOR([socket])
- AC_REQUIRE([gt_TYPE_WCHAR_T])
-- AC_REQUIRE([gt_TYPE_WINT_T])
-+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
- gl_FUNC_STRERROR_R
- AS_IF([test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1], [
- AC_LIBOBJ([strerror_r])
---- a/m4/stdint.m4
-+++ b/m4/stdint.m4
-@@ -15,7 +15,7 @@ AC_DEFUN_ONCE([gl_STDINT_H],
- AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-
- AC_REQUIRE([gl_LIMITS_H])
-- AC_REQUIRE([gt_TYPE_WINT_T])
-+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
-
- dnl For backward compatibility. Some packages may still be testing these
- dnl macros.
---- a/m4/vasnprintf.m4
-+++ b/m4/vasnprintf.m4
-@@ -33,7 +33,7 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF],
- AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
- [
- AC_REQUIRE([gt_TYPE_WCHAR_T])
-- AC_REQUIRE([gt_TYPE_WINT_T])
-+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
- ])
-
- # Prerequisites of lib/printf-parse.h, lib/printf-parse.c.
-@@ -41,7 +41,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
- [
- AC_REQUIRE([gl_FEATURES_H])
- AC_REQUIRE([gt_TYPE_WCHAR_T])
-- AC_REQUIRE([gt_TYPE_WINT_T])
-+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
- AC_REQUIRE([AC_TYPE_SIZE_T])
- AC_CHECK_TYPE([ptrdiff_t], ,
- [AC_DEFINE([ptrdiff_t], [long],
-@@ -55,7 +55,7 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
- [
- AC_REQUIRE([AC_FUNC_ALLOCA])
- AC_REQUIRE([gt_TYPE_WCHAR_T])
-- AC_REQUIRE([gt_TYPE_WINT_T])
-+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
- AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
- dnl Use the _snprintf function only if it is declared (because on NetBSD it
- dnl is defined as a weak alias of snprintf; we prefer to use the latter).
---- a/m4/wchar_h.m4
-+++ b/m4/wchar_h.m4
-@@ -27,7 +27,7 @@ AC_DEFUN_ONCE([gl_WCHAR_H],
-
- AC_REQUIRE([gl_FEATURES_H])
-
-- AC_REQUIRE([gt_TYPE_WINT_T])
-+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
- if test $gt_cv_c_wint_t = yes; then
- HAVE_WINT_T=1
- else
---- a/m4/wctype_h.m4
-+++ b/m4/wctype_h.m4
-@@ -22,7 +22,7 @@ AC_DEFUN_ONCE([gl_WCTYPE_H],
- fi
- AC_SUBST([HAVE_ISWCNTRL])
-
-- AC_REQUIRE([gt_TYPE_WINT_T])
-+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
- if test $gt_cv_c_wint_t = yes; then
- HAVE_WINT_T=1
- else
---- a/m4/wcwidth.m4
-+++ b/m4/wcwidth.m4
-@@ -13,7 +13,7 @@ AC_DEFUN([gl_FUNC_WCWIDTH],
- AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
-
- AC_REQUIRE([gt_TYPE_WCHAR_T])
-- AC_REQUIRE([gt_TYPE_WINT_T])
-+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
-
- AC_CHECK_HEADERS_ONCE([wchar.h])
- AC_CHECK_FUNCS_ONCE([wcwidth])
---- a/m4/wint_t.m4
-+++ b/m4/wint_t.m4
-@@ -9,7 +9,7 @@ dnl Test whether <wchar.h> has the 'wint
- dnl <wchar.h> or <wctype.h> would, if present, override 'wint_t'.
- dnl Prerequisite: AC_PROG_CC
-
--AC_DEFUN([gt_TYPE_WINT_T],
-+AC_DEFUN([gt_TYPE_WINT_T_GNUTLS],
- [
- AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
- [AC_COMPILE_IFELSE(
diff --git a/tools/coreutils/patches/002-date-diagnose-f-read-errors.patch b/tools/coreutils/patches/002-date-diagnose-f-read-errors.patch
new file mode 100644
index 0000000000..5174af1aa0
--- /dev/null
+++ b/tools/coreutils/patches/002-date-diagnose-f-read-errors.patch
@@ -0,0 +1,20 @@
+From 9c5e542fd190a14431092e3b6cb45d18fe95f26f Mon Sep 17 00:00:00 2001
+From: Paul Eggert <eggert@cs.ucla.edu>
+Date: Tue, 28 Mar 2023 01:52:43 -0700
+Subject: [PATCH] date: diagnose -f read errors
+
+* src/date.c (batch_convert): Diagnose read errors, fixing Bug#62497.
+---
+--- a/src/date.c
++++ b/src/date.c
+@@ -368,7 +368,9 @@ batch_convert (char const *input_filenam
+ ssize_t line_length = getline (&line, &buflen, in_stream);
+ if (line_length < 0)
+ {
+- /* FIXME: detect/handle error here. */
++ if (ferror (in_stream))
++ die (EXIT_FAILURE, errno, _("%s: read error"),
++ quotef (input_filename));
+ break;
+ }
+