From 34d13369e198edadaafe7712e331d0e0cabeebfb Mon Sep 17 00:00:00 2001 From: dkwo Date: Mon, 5 Dec 2022 20:16:46 -0500 Subject: [PATCH] coreutils: update to 9.2 skip test-getcwd.sh test-getlogin Add [.1 man page symlink so "man [" works. --- ...8.31-behavior-on-removed-directories.patch | 120 ---------------- srcpkgs/coreutils/patches/cksum.patch | 64 +++++++++ srcpkgs/coreutils/patches/copy.patch | 130 ++++++++++++++++++ srcpkgs/coreutils/template | 12 +- 4 files changed, 203 insertions(+), 123 deletions(-) delete mode 100644 srcpkgs/coreutils/patches/0001-ls-restore-8.31-behavior-on-removed-directories.patch create mode 100644 srcpkgs/coreutils/patches/cksum.patch create mode 100644 srcpkgs/coreutils/patches/copy.patch diff --git a/srcpkgs/coreutils/patches/0001-ls-restore-8.31-behavior-on-removed-directories.patch b/srcpkgs/coreutils/patches/0001-ls-restore-8.31-behavior-on-removed-directories.patch deleted file mode 100644 index 93ec0fd84c74..000000000000 --- a/srcpkgs/coreutils/patches/0001-ls-restore-8.31-behavior-on-removed-directories.patch +++ /dev/null @@ -1,120 +0,0 @@ -From 10fcb97bd728f09d4a027eddf8ad2900f0819b0a Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Thu, 5 Mar 2020 17:25:29 -0800 -Subject: [PATCH] ls: restore 8.31 behavior on removed directories -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -* NEWS: Mention this. -* src/ls.c: Do not include -(print_dir): Don't worry about whether the directory is removed. -* tests/ls/removed-directory.sh: Adjust to match new (i.e., old) -behavior. ---- - NEWS | 6 ++++++ - src/ls.c | 22 ---------------------- - tests/ls/removed-directory.sh | 10 ++-------- - 3 files changed, 8 insertions(+), 30 deletions(-) - -diff --git NEWS NEWS -index fdc8bf5db..653e7178b 100644 ---- a/NEWS -+++ b/NEWS -@@ -2,6 +2,12 @@ GNU coreutils NEWS -*- outline -*- - - * Noteworthy changes in release ?.? (????-??-??) [?] - -+** Changes in behavior -+ -+ On GNU/Linux systems, ls no longer issues an error message on -+ directory merely because it was removed. This reverts a change -+ that was made in release 8.32. -+ - - * Noteworthy changes in release 8.32 (2020-03-05) [stable] - -diff --git src/ls.c src/ls.c -index 24b983287..4acf5f44d 100644 ---- a/src/ls.c -+++ b/src/ls.c -@@ -49,10 +49,6 @@ - # include - #endif - --#ifdef __linux__ --# include --#endif -- - #include - #include - #include -@@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg) - struct dirent *next; - uintmax_t total_blocks = 0; - static bool first = true; -- bool found_any_entries = false; - - errno = 0; - dirp = opendir (name); -@@ -2972,7 +2967,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg) - next = readdir (dirp); - if (next) - { -- found_any_entries = true; - if (! file_ignored (next->d_name)) - { - enum filetype type = unknown; -@@ -3018,22 +3012,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg) - if (errno != EOVERFLOW) - break; - } --#ifdef __linux__ -- else if (! found_any_entries) -- { -- /* If readdir finds no directory entries at all, not even "." or -- "..", then double check that the directory exists. */ -- if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1 -- && errno != EINVAL) -- { -- /* We exclude EINVAL as that pertains to buffer handling, -- and we've passed NULL as the buffer for simplicity. -- ENOENT is returned if appropriate before buffer handling. */ -- file_failure (command_line_arg, _("reading directory %s"), name); -- } -- break; -- } --#endif - else - break; - -diff --git tests/ls/removed-directory.sh tests/ls/removed-directory.sh -index e8c835dab..fe8f929a1 100755 ---- a/tests/ls/removed-directory.sh -+++ b/tests/ls/removed-directory.sh -@@ -26,20 +26,14 @@ case $host_triplet in - *) skip_ 'non linux kernel' ;; - esac - --LS_FAILURE=2 -- --cat <<\EOF >exp-err || framework_failure_ --ls: reading directory '.': No such file or directory --EOF -- - cwd=$(pwd) - mkdir d || framework_failure_ - cd d || framework_failure_ - rmdir ../d || framework_failure_ - --returns_ $LS_FAILURE ls >../out 2>../err || fail=1 -+ls >../out 2>../err || fail=1 - cd "$cwd" || framework_failure_ - compare /dev/null out || fail=1 --compare exp-err err || fail=1 -+compare /dev/null err || fail=1 - - Exit $fail --- -2.24.0.375.geb5ae68d41 - diff --git a/srcpkgs/coreutils/patches/cksum.patch b/srcpkgs/coreutils/patches/cksum.patch new file mode 100644 index 000000000000..d2e1a98c193f --- /dev/null +++ b/srcpkgs/coreutils/patches/cksum.patch @@ -0,0 +1,64 @@ +From 76f2fb627118a26c25003dbd98c22c153b7ee1d2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Thu, 23 Mar 2023 12:31:24 +0000 +Subject: cksum: fix reporting of failed checks + +This applies to all checksumming utilities, +where we incorrectly report all subsequent files as checking 'OK' +once any file has passed a digest check. +The exit status was not impacted, only the printed status. + +* src/digest.c (digest_check): Use the correct state variable +to determine if the _current_ file has passed or not. +* tests/misc/md5sum.pl: Add a test case. +Fixes https://bugs.gnu.org/62403 +--- + src/digest.c | 4 ++-- + tests/misc/md5sum.pl | 10 ++++++++++ + 2 files changed, 12 insertions(+), 2 deletions(-) + +diff --git a/src/digest.c b/src/digest.c +index 6ee8a48..ab32968 100644 +--- a/src/digest.c ++++ b/src/digest.c +@@ -1254,14 +1254,14 @@ digest_check (char const *checkfile_name) + + if (!status_only) + { +- if ( ! matched_checksums || ! quiet) ++ if (! match || ! quiet) + { + if (needs_escape) + putchar ('\\'); + print_filename (filename, needs_escape); + } + +- if ( ! matched_checksums) ++ if (! match) + printf (": %s\n", _("FAILED")); + else if (!quiet) + printf (": %s\n", _("OK")); +diff --git a/tests/misc/md5sum.pl b/tests/misc/md5sum.pl +index 186aca9..d712664 100755 +--- a/tests/misc/md5sum.pl ++++ b/tests/misc/md5sum.pl +@@ -101,6 +101,16 @@ my @Tests = + . "md5sum: WARNING: 1 line is improperly formatted\n" + . "md5sum: WARNING: 2 computed checksums did NOT match\n"}, + {EXIT=> 1}], ++ # Ensure we use appropriate state to track failures (broken in 9.2) ++ ['check-multifail-state', '--check', '--warn', ++ {IN=>{'f.md5' => ++ "$degenerate f\n" ++ . "$degenerate g\n" ++ . "$degenerate f\n" }}, ++ {AUX=> {f=> ''}}, {AUX=> {g=> 'a'}}, ++ {OUT=>"f: OK\ng: FAILED\nf: OK\n"}, ++ {ERR=>"md5sum: WARNING: 1 computed checksum did NOT match\n"}, ++ {EXIT=> 1}], + # The sha1sum and md5sum drivers share a lot of code. + # Ensure that md5sum does *not* share the part that makes + # sha1sum accept BSD format. +-- +cgit v1.1 + diff --git a/srcpkgs/coreutils/patches/copy.patch b/srcpkgs/coreutils/patches/copy.patch new file mode 100644 index 000000000000..68384992ed75 --- /dev/null +++ b/srcpkgs/coreutils/patches/copy.patch @@ -0,0 +1,130 @@ +From 093a8b4bfaba60005f14493ce7ef11ed665a0176 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Thu, 23 Mar 2023 13:19:04 +0000 +Subject: 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, bool punch_holes, off_t size) + } + + +-/* 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, char **abuf, size_t buf_size, + { + 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 const* dst_relname, + 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); +- +- if (reflink_mode == REFLINK_ALWAYS || transient_failure) ++ /* 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 || 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 const* dst_relname, + 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; +-- +cgit v1.1 + diff --git a/srcpkgs/coreutils/template b/srcpkgs/coreutils/template index b9148c854960..af027c615380 100644 --- a/srcpkgs/coreutils/template +++ b/srcpkgs/coreutils/template @@ -1,7 +1,7 @@ # Template file for 'coreutils' pkgname=coreutils -version=8.32 -revision=4 +version=9.2 +revision=1 bootstrap=yes makedepends="gmp-devel acl-devel libcap-devel" short_desc="GNU core utilities" @@ -10,7 +10,7 @@ license="GPL-3.0-or-later" homepage="https://www.gnu.org/software/coreutils" changelog="https://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob_plain;f=NEWS;hb=HEAD" distfiles="${GNU_SITE}/coreutils/coreutils-${version}.tar.xz" -checksum=4458d8de7849df44ccab15e16b1548b285224dbba5f08fac070c1c0e0bcc4cfa +checksum=6885ff47b9cdb211de47d368c17853f406daaf98b148aaecdf10de29cc04b0b3 replaces="chroot-coreutils>=0 coreutils-doc>=0 b2sum>=0" @@ -104,6 +104,10 @@ do_check() { # Tests that depend on the tests removed exeext_tests+=" fchmodat fchdir" + # temporarily disable two tests (coreutils9.1) + vsed -i "s/test-getcwd.sh //" gnulib-tests/Makefile + exeext_tests+=" getlogin" + for test in $exeext_tests ; do vsed -i "s/test-$test\$(EXEEXT) //" gnulib-tests/Makefile done @@ -121,4 +125,6 @@ do_install() { fi mv ${DESTDIR}/usr/bin/hostname ${DESTDIR}/usr/bin/hostname-coreutils mv ${DESTDIR}/usr/share/man/man1/hostname.1 ${DESTDIR}/usr/share/man/man1/hostname-coreutils.1 + + ln -s test.1 "${DESTDIR}/usr/share/man/man1/[.1" }