From ddf66eac751e30292a5d2a0fa5fda2a3aebcad33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Tue, 19 Sep 2023 19:36:52 +0100 Subject: [PATCH] coreutils: update to 9.4 patches were copied from CygWin. --- coreutils/001-coreutils-8.30.patch | 1083 ----------------- .../002-coreutils-8.32-enable-stdbuf.patch | 31 - .../003-coreutils-8.32-fix-test-cases.patch | 11 - coreutils/PKGBUILD | 124 +- coreutils/coreutils-8.32-configure.ac.patch | 21 + .../coreutils-8.32-doc-coreutils.texi.patch | 32 + coreutils/coreutils-8.32-lib-freopen.c.patch | 18 + coreutils/coreutils-8.32-lib-hash-pjw.c.patch | 27 + coreutils/coreutils-8.32-lib-hash-pjw.h.patch | 7 + coreutils/coreutils-8.32-lib-local.mk.patch | 9 + coreutils/coreutils-8.32-lib-same.c.patch | 62 + coreutils/coreutils-8.32-src-chgrp.c.patch | 11 + coreutils/coreutils-8.32-src-chown.c.patch | 11 + coreutils/coreutils-8.32-src-chroot.c.patch | 12 + coreutils/coreutils-8.32-src-dd.c.patch | 45 + .../coreutils-8.32-src-dircolors.c.patch | 16 + coreutils/coreutils-8.32-src-pwd.c.patch | 32 + coreutils/coreutils-8.32-src-rm.c.patch | 11 + coreutils/coreutils-9-src-dircolors-hin.patch | 84 ++ .../coreutils-9.1-lib-root-dev-ino.h.patch | 33 + coreutils/coreutils-9.1-src-mv.c.patch | 28 + .../coreutils-9.4-lib-root-dev-ino.c.patch | 24 + coreutils/coreutils-9.4-src-chcon.c.patch | 20 + coreutils/coreutils-9.4-src-chmod.c.patch | 20 + .../coreutils-9.4-src-chown-core.h.patch | 11 + coreutils/coreutils-9.4-src-copy.c.patch | 158 +++ coreutils/coreutils-9.4-src-install.c.patch | 30 + coreutils/coreutils-9.4-src-ls.c.patch | 114 ++ coreutils/coreutils-9.4-src-remove.h.patch | 11 + coreutils/coreutils-9.4-src-stat.c.patch | 120 ++ coreutils/cygwin.c | 73 ++ coreutils/cygwin.h | 38 + 32 files changed, 1184 insertions(+), 1143 deletions(-) delete mode 100644 coreutils/001-coreutils-8.30.patch delete mode 100644 coreutils/002-coreutils-8.32-enable-stdbuf.patch delete mode 100644 coreutils/003-coreutils-8.32-fix-test-cases.patch create mode 100644 coreutils/coreutils-8.32-configure.ac.patch create mode 100644 coreutils/coreutils-8.32-doc-coreutils.texi.patch create mode 100644 coreutils/coreutils-8.32-lib-freopen.c.patch create mode 100644 coreutils/coreutils-8.32-lib-hash-pjw.c.patch create mode 100644 coreutils/coreutils-8.32-lib-hash-pjw.h.patch create mode 100644 coreutils/coreutils-8.32-lib-local.mk.patch create mode 100644 coreutils/coreutils-8.32-lib-same.c.patch create mode 100644 coreutils/coreutils-8.32-src-chgrp.c.patch create mode 100644 coreutils/coreutils-8.32-src-chown.c.patch create mode 100644 coreutils/coreutils-8.32-src-chroot.c.patch create mode 100644 coreutils/coreutils-8.32-src-dd.c.patch create mode 100644 coreutils/coreutils-8.32-src-dircolors.c.patch create mode 100644 coreutils/coreutils-8.32-src-pwd.c.patch create mode 100644 coreutils/coreutils-8.32-src-rm.c.patch create mode 100644 coreutils/coreutils-9-src-dircolors-hin.patch create mode 100644 coreutils/coreutils-9.1-lib-root-dev-ino.h.patch create mode 100644 coreutils/coreutils-9.1-src-mv.c.patch create mode 100644 coreutils/coreutils-9.4-lib-root-dev-ino.c.patch create mode 100644 coreutils/coreutils-9.4-src-chcon.c.patch create mode 100644 coreutils/coreutils-9.4-src-chmod.c.patch create mode 100644 coreutils/coreutils-9.4-src-chown-core.h.patch create mode 100644 coreutils/coreutils-9.4-src-copy.c.patch create mode 100644 coreutils/coreutils-9.4-src-install.c.patch create mode 100644 coreutils/coreutils-9.4-src-ls.c.patch create mode 100644 coreutils/coreutils-9.4-src-remove.h.patch create mode 100644 coreutils/coreutils-9.4-src-stat.c.patch create mode 100644 coreutils/cygwin.c create mode 100644 coreutils/cygwin.h diff --git a/coreutils/001-coreutils-8.30.patch b/coreutils/001-coreutils-8.30.patch deleted file mode 100644 index 0157ff01..00000000 --- a/coreutils/001-coreutils-8.30.patch +++ /dev/null @@ -1,1083 +0,0 @@ -diff -Naur a/build-aux/compile b/build-aux/compile ---- a/build-aux/compile 2014-07-19 02:02:06.000000000 +0400 -+++ b/build-aux/compile 2014-07-20 20:19:52.863800000 +0400 -@@ -53,7 +53,7 @@ - MINGW*) - file_conv=mingw - ;; -- CYGWIN*) -+ CYGWIN* | MSYS*) - file_conv=cygwin - ;; - *) -@@ -67,7 +67,7 @@ - mingw/*) - file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` - ;; -- cygwin/*) -+ cygwin/* | msys/*) - file=`cygpath -m "$file" || echo "$file"` - ;; - wine/*) -diff -Naur a/gnulib-tests/test-copy-acl.sh b/gnulib-tests/test-copy-acl.sh ---- a/gnulib-tests/test-copy-acl.sh 2013-12-04 18:53:33.000000000 +0400 -+++ b/gnulib-tests/test-copy-acl.sh 2014-07-20 20:19:52.895000000 +0400 -@@ -128,7 +128,7 @@ - # the programs. - # func_test_same_acls file1 file2 - case $acl_flavor in -- linux | cygwin | freebsd | solaris) -+ linux | cygwin | msys | freebsd | solaris) - func_test_same_acls () - { - getfacl "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 -@@ -302,7 +302,7 @@ - - ;; - -- cygwin) -+ cygwin | msys) - - # Set an ACL for a group. - setfacl -m group:0:1 tmpfile0 -diff -Naur a/gnulib-tests/test-file-has-acl.sh b/gnulib-tests/test-file-has-acl.sh ---- a/gnulib-tests/test-file-has-acl.sh 2013-12-04 18:53:33.000000000 +0400 -+++ b/gnulib-tests/test-file-has-acl.sh 2014-07-20 20:19:52.910600000 +0400 -@@ -247,7 +247,7 @@ - fi - ;; - -- cygwin) -+ cygwin | msys) - - # Set an ACL for a group. - if setfacl -m group:0:1 tmpfile0; then -diff -Naur a/gnulib-tests/test-set-mode-acl.sh b/gnulib-tests/test-set-mode-acl.sh ---- a/gnulib-tests/test-set-mode-acl.sh 2013-12-04 18:53:33.000000000 +0400 -+++ b/gnulib-tests/test-set-mode-acl.sh 2014-07-20 20:19:52.910600000 +0400 -@@ -177,7 +177,7 @@ - linux | freebsd | solaris) - setfacl -m user:$auid:1 tmpfile0 - ;; -- cygwin) -+ cygwin | msys) - setfacl -m group:0:1 tmpfile0 - ;; - hpux) -diff -Naur a/install.exe.manifest b/install.exe.manifest ---- a/install.exe.manifest 1970-01-01 03:00:00.000000000 +0300 -+++ b/install.exe.manifest 2014-07-20 20:19:52.910600000 +0400 -@@ -0,0 +1,11 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff -Naur a/src/install.manifest b/src/install.manifest ---- a/src/install.manifest 1970-01-01 03:00:00.000000000 +0300 -+++ b/src/install.manifest 2014-07-20 20:19:47.591000000 +0400 -@@ -0,0 +1,16 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff -Naur a/src/install.rc b/src/install.rc ---- a/src/install.rc 1970-01-01 03:00:00.000000000 +0300 -+++ b/src/install.rc 2014-07-20 20:19:47.606600000 +0400 -@@ -0,0 +1 @@ -+1 24 install.manifest ---- a/Makefile.in.orig 2018-09-16 13:23:25.153210900 +0200 -+++ a/Makefile.in 2018-09-16 13:39:17.989133200 +0200 -@@ -989,7 +989,7 @@ - lib/openat-proc.c lib/backupfile.c lib/backup-rename.c \ - lib/backup-find.c lib/base32.h lib/base32.c lib/base64.h \ - lib/base64.c lib/binary-io.h lib/binary-io.c lib/bitrotate.h \ -- lib/bitrotate.c lib/buffer-lcm.c lib/buffer-lcm.h \ -+ lib/bitrotate.c lib/buffer-lcm.c lib/buffer-lcm.h lib/cygwin.c lib/cygwin.h \ - lib/c-ctype.h lib/c-ctype.c lib/c-strcase.h lib/c-strcasecmp.c \ - lib/c-strncasecmp.c lib/c-strtod.c lib/c-strtold.c \ - lib/canon-host.c lib/canonicalize.c lib/careadlinkat.c \ -@@ -1078,7 +1078,7 @@ - lib/backupfile.$(OBJEXT) lib/backup-find.$(OBJEXT) \ - lib/base32.$(OBJEXT) lib/base64.$(OBJEXT) \ - lib/binary-io.$(OBJEXT) lib/bitrotate.$(OBJEXT) \ -- lib/buffer-lcm.$(OBJEXT) lib/c-ctype.$(OBJEXT) \ -+ lib/buffer-lcm.$(OBJEXT) lib/cygwin.$(OBJEXT) lib/c-ctype.$(OBJEXT) \ - lib/c-strcasecmp.$(OBJEXT) lib/c-strncasecmp.$(OBJEXT) \ - lib/c-strtod.$(OBJEXT) lib/c-strtold.$(OBJEXT) \ - lib/canon-host.$(OBJEXT) lib/canonicalize.$(OBJEXT) \ -@@ -3930,6 +3930,7 @@ - WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@ - WINDOWS_STAT_INODES = @WINDOWS_STAT_INODES@ - WINDOWS_STAT_TIMESPEC = @WINDOWS_STAT_TIMESPEC@ -+WINDRES = windres - WINT_T_SUFFIX = @WINT_T_SUFFIX@ - XGETTEXT = @XGETTEXT@ - XGETTEXT_015 = @XGETTEXT_015@ -@@ -5309,7 +5310,7 @@ - lib/backupfile.c lib/backup-find.c lib/base32.h lib/base32.c \ - lib/base64.h lib/base64.c lib/binary-io.h lib/binary-io.c \ - lib/bitrotate.h lib/bitrotate.c lib/buffer-lcm.c \ -- lib/buffer-lcm.h lib/c-ctype.h lib/c-ctype.c lib/c-strcase.h \ -+ lib/buffer-lcm.h lib/cygwin.c lib/cygwin.h lib/c-ctype.c lib/c-strcase.h \ - lib/c-strcasecmp.c lib/c-strncasecmp.c lib/c-strtod.c \ - lib/c-strtold.c lib/canon-host.c lib/canonicalize.c \ - lib/careadlinkat.c lib/chmodat.c lib/chownat.c lib/cl-strtod.c \ -@@ -6097,6 +6098,8 @@ - lib/$(DEPDIR)/$(am__dirstamp) - lib/buffer-lcm.$(OBJEXT): lib/$(am__dirstamp) \ - lib/$(DEPDIR)/$(am__dirstamp) -+lib/cygwin.$(OBJEXT): lib/$(am__dirstamp) \ -+ lib/$(DEPDIR)/$(am__dirstamp) - lib/c-ctype.$(OBJEXT): lib/$(am__dirstamp) \ - lib/$(DEPDIR)/$(am__dirstamp) - lib/c-strcasecmp.$(OBJEXT): lib/$(am__dirstamp) \ -@@ -9110,9 +9113,9 @@ - src/src_ginstall-selinux.$(OBJEXT): src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) - --src/ginstall$(EXEEXT): $(src_ginstall_OBJECTS) $(src_ginstall_DEPENDENCIES) $(EXTRA_src_ginstall_DEPENDENCIES) src/$(am__dirstamp) -+src/ginstall$(EXEEXT): $(src_ginstall_OBJECTS) src/src_ginstall-manifest.res $(src_ginstall_DEPENDENCIES) $(EXTRA_src_ginstall_DEPENDENCIES) src/$(am__dirstamp) - @rm -f src/ginstall$(EXEEXT) -- $(AM_V_CCLD)$(LINK) $(src_ginstall_OBJECTS) $(src_ginstall_LDADD) $(LIBS) -+ $(AM_V_CCLD)$(LINK) $(src_ginstall_OBJECTS) src/src_ginstall-manifest.res $(src_ginstall_LDADD) $(LIBS) - src/groups.$(OBJEXT): src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) - src/group-list.$(OBJEXT): src/$(am__dirstamp) \ -@@ -10029,6 +10031,9 @@ - @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(src_libsinglebin_fold_a_CFLAGS) $(CFLAGS) -c -o src/libsinglebin_fold_a-fold.obj `if test -f 'src/fold.c'; then $(CYGPATH_W) 'src/fold.c'; else $(CYGPATH_W) '$(srcdir)/src/fold.c'; fi` - -+src/src_ginstall-manifest.res: src/install.rc src/install.manifest -+ $(WINDRES) --input $< --output $@ --output-format=coff -+ - src/libsinglebin_ginstall_a-install.o: src/install.c - @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libsinglebin_ginstall_a_CPPFLAGS) $(CPPFLAGS) $(src_libsinglebin_ginstall_a_CFLAGS) $(CFLAGS) -MT src/libsinglebin_ginstall_a-install.o -MD -MP -MF src/$(DEPDIR)/libsinglebin_ginstall_a-install.Tpo -c -o src/libsinglebin_ginstall_a-install.o `test -f 'src/install.c' || echo '$(srcdir)/'`src/install.c - @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libsinglebin_ginstall_a-install.Tpo src/$(DEPDIR)/libsinglebin_ginstall_a-install.Po ---- a/lib/cygwin.c 1969-12-31 18:00:00.000000000 -0600 -+++ b/lib/cygwin.c 2017-02-03 13:32:48.725613200 -0600 -@@ -0,0 +1,73 @@ -+/* cygwin.c - helper functions unique to Cygwin -+ -+ Copyright (C) 2005, 2006, 2008, 2011 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software Foundation, -+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ -+ Written by Eric Blake. */ -+ -+#include -+ -+#include "cygwin.h" -+ -+#include -+#include -+#include -+#include -+ -+/* Return -1 if PATH is not found, 0 if PATH will not have .exe -+ appended (it is possible that a PATH that does not exist still -+ returns 0 instead of -1, or fails for a PATH that exists but cannot -+ be stat'ed), and positive if PATH has ".exe" automatically appended -+ by cygwin (1 if PATH is a symlink, 2 otherwise). Won't change errno. */ -+ -+int -+cygwin_spelling (char const *path) -+{ -+ int saved_errno = errno; -+ int result = 0; /* Start with assumption that PATH is okay. */ -+ size_t len; -+ struct stat st1; -+ struct stat st2; -+ char *path_exe; -+ -+ /* If PATH will cause EINVAL or ENAMETOOLONG, treat it as missing. */ -+ if (! path || ! *path) -+ return -1; -+ if (PATH_MAX < (len = strlen (path))) -+ return -1; -+ /* Don't change spelling if there is a trailing `/' or '.exe'. */ -+ if (path[len - 1] == '/' -+ || (len > 4 && !strcasecmp (&path[len - 4], ".exe"))) -+ return 0; -+ if (lstat (path, &st1) < 0) -+ { -+ errno = saved_errno; -+ return -1; -+ } -+ if (S_ISDIR(st1.st_mode)) -+ { -+ errno = saved_errno; -+ return 0; -+ } -+ path_exe = malloca (len + 5); /* adding ".exe" and NUL. */ -+ strcat (stpcpy (path_exe, path), ".exe"); -+ if (lstat (path_exe, &st2) == 0 && st1.st_ino == st2.st_ino) -+ result = 1 + !S_ISLNK(st1.st_mode); -+ freea (path_exe); -+ -+ errno = saved_errno; -+ return result; -+} ---- a/lib/cygwin.h 1969-12-31 18:00:00.000000000 -0600 -+++ b/lib/cygwin.h 2017-02-03 13:32:48.725613200 -0600 -@@ -0,0 +1,38 @@ -+/* cygwin.h - helper functions unique to Cygwin -+ -+ Copyright (C) 2005, 2006, 2008, 2010, 2011 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software Foundation, -+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ -+ Written by Eric Blake. */ -+ -+#ifndef CYGWIN_H -+# define CYGWIN_H 1 -+ -+#include "malloca.h" -+ -+int cygwin_spelling (char const *); -+ -+/* Append ".exe" to char *__NAME_ORIG, where __NAME is either NULL or -+ between __NAME_ORIG and the nul terminator. Both params will be -+ evaluated more than once and assigned the new value. The user must -+ later call freea(__NAME). */ -+#define CYGWIN_APPEND_EXE(__name, __name_orig) \ -+ __name_orig = __name = \ -+ strcat (strcpy (malloca (strchr (__name ? __name : __name_orig, '\0') \ -+ - (__name_orig) + 5), \ -+ __name_orig), ".exe") -+ -+#endif /* CYGWIN_H */ ---- a/lib/hash-pjw.c 2016-07-15 14:47:39.000000000 -0500 -+++ b/lib/hash-pjw.c 2017-02-03 13:32:48.725613200 -0600 -@@ -19,6 +19,7 @@ - - #include "hash-pjw.h" - -+#include - #include - - #define SIZE_BITS (sizeof (size_t) * CHAR_BIT) -@@ -38,3 +39,16 @@ hash_pjw (const void *x, size_t tablesiz - - return h % tablesize; - } -+ -+/* Likewise, but case-insensitive. */ -+size_t -+hash_pjw_case (const void *x, size_t tablesize) -+{ -+ const unsigned char *s; -+ size_t h = 0; -+ -+ for (s = x; *s; s++) -+ h = tolower (*s) + ((h << 9) | (h >> (SIZE_BITS - 9))); -+ -+ return h % tablesize; -+} ---- a/lib/hash-pjw.h 2016-07-15 14:47:39.000000000 -0500 -+++ b/lib/hash-pjw.h 2017-02-03 13:32:48.725613200 -0600 -@@ -21,3 +21,4 @@ - The result is platform dependent: it depends on the size of the 'size_t' - type and on the signedness of the 'char' type. */ - extern size_t hash_pjw (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE; -+extern size_t hash_pjw_case (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE; ---- a/lib/hash-triple.c 2016-07-15 14:47:39.000000000 -0500 -+++ b/lib/hash-triple.c 2017-02-03 13:32:48.725613200 -0600 -@@ -34,7 +34,13 @@ size_t - triple_hash (void const *x, size_t table_size) - { - struct F_triple const *p = x; -+#ifndef __CYGWIN__ - size_t tmp = hash_pjw (p->name, table_size); -+#else -+ /* Hash case-insensitively, to force collisions on names that differ only -+ by case; copy.c can then account for case-insensitive renames. */ -+ size_t tmp = hash_pjw_case (p->name, table_size); -+#endif - - /* Ignoring the device number here should be fine. */ - return (tmp ^ p->st_ino) % table_size; ---- a/lib/local.mk 2012-11-13 07:51:53.000000000 -0600 -+++ b/lib/local.mk 2017-02-03 13:32:48.725613200 -0600 -@@ -3,3 +3,6 @@ include lib/gnulib.mk - # Allow "make distdir" to succeed before "make all" has run. - dist-hook: $(noinst_LIBRARIES) - .PHONY: dist-hook -+ -+# Hook in cygwin helper -+lib_libcoreutils_a_SOURCES += lib/cygwin.c lib/cygwin.h ---- a/lib/root-dev-ino.c 2016-03-09 04:15:39.000000000 -0600 -+++ b/lib/root-dev-ino.c 2017-02-03 13:32:48.725613200 -0600 -@@ -25,13 +25,17 @@ - /* Call lstat to get the device and inode numbers for '/'. - Upon failure, return NULL. Otherwise, set the members of - *ROOT_D_I accordingly and return ROOT_D_I. */ --struct dev_ino * --get_root_dev_ino (struct dev_ino *root_d_i) -+struct root_dev_ino * -+get_root_dev_ino (struct root_dev_ino *root_d_i) - { - struct stat statbuf; - if (lstat ("/", &statbuf)) - return NULL; -- root_d_i->st_ino = statbuf.st_ino; -- root_d_i->st_dev = statbuf.st_dev; -+ root_d_i->single_slash.st_ino = statbuf.st_ino; -+ root_d_i->single_slash.st_dev = statbuf.st_dev; -+ if (lstat ("//", &statbuf)) -+ return NULL; -+ root_d_i->double_slash.st_ino = statbuf.st_ino; -+ root_d_i->double_slash.st_dev = statbuf.st_dev; - return root_d_i; - } ---- a/lib/root-dev-ino.h 2016-03-09 04:15:39.000000000 -0600 -+++ b/lib/root-dev-ino.h 2017-02-03 13:32:48.741217700 -0600 -@@ -21,19 +21,26 @@ - # include "dev-ino.h" - # include "same-inode.h" - --struct dev_ino * --get_root_dev_ino (struct dev_ino *root_d_i); -+struct root_dev_ino -+{ -+ struct dev_ino single_slash; -+ struct dev_ino double_slash; -+}; -+ -+struct root_dev_ino * -+get_root_dev_ino (struct root_dev_ino *root_d_i); - - /* These macros are common to the programs that support the - --preserve-root and --no-preserve-root options. */ - - # define ROOT_DEV_INO_CHECK(Root_dev_ino, Dir_statbuf) \ -- (Root_dev_ino && SAME_INODE (*Dir_statbuf, *Root_dev_ino)) -+ (Root_dev_ino && (SAME_INODE (*Dir_statbuf, (Root_dev_ino)->single_slash) \ -+ || SAME_INODE (*Dir_statbuf, (Root_dev_ino)->double_slash))) - - # define ROOT_DEV_INO_WARN(Dirname) \ - do \ - { \ -- if (STREQ (Dirname, "/")) \ -+ if (STREQ (Dirname, "/") || STREQ (Dirname, "//")) \ - error (0, 0, _("it is dangerous to operate recursively on %s"), \ - quoteaf (Dirname)); \ - else \ ---- a/lib/same.c 2018-05-14 06:20:31.000000000 +0200 -+++ b/lib/same.c 2018-09-16 13:54:23.478109900 +0200 -@@ -41,6 +41,13 @@ - #include "error.h" - #include "same-inode.h" - -+#if __CYGWIN__ -+# include -+# include "cygwin.h" -+# include "malloca.h" -+# include "memcasecmp.h" -+#endif -+ - #ifndef MIN - # define MIN(a, b) ((a) < (b) ? (a) : (b)) - #endif -@@ -79,6 +86,45 @@ - (source_baselen == dest_baselen - && memcmp (source_basename, dest_basename, dest_baselen) == 0); - bool compare_dirs = identical_basenames; -+#if __CYGWIN__ -+ /* If two names differ case-insensitively by only an '.exe' suffix, -+ do some sleuthing to see if .exe magic matters on the shorter -+ name. Swapping the longer name to dest avoids duplication. */ -+ if (source_baselen == dest_baselen + 4) -+ { -+ char const *tmp_basename = source_basename; -+ size_t tmp_baselen = source_baselen; -+ source_basename = dest_basename; -+ source_baselen = dest_baselen; -+ dest_basename = tmp_basename; -+ dest_baselen = tmp_baselen; -+ } -+ if (source_baselen + 4 == dest_baselen -+ && !memcasecmp (dest_basename - 4, ".exe", 4) -+ && !memcasecmp (source_basename, dest_basename, source_baselen) -+ && 0 < cygwin_spelling(source)) -+ dest_baselen -= 4; -+ /* Some, but not all, files are case-insensitive (depending on mount -+ options, CYGWIN=case settings, and virtual file systems). Do -+ some sleuthing to decide whether case-insensitivity matters. */ -+ if (! compare_dirs && source_baselen == dest_baselen) -+ { -+ ssize_t wsrclen = cygwin_conv_path (CCP_POSIX_TO_WIN_W, -+ source, NULL, 0); -+ ssize_t wdstlen = cygwin_conv_path (CCP_POSIX_TO_WIN_W, -+ dest, NULL, 0); -+ char *wsrc = malloca (wsrclen); -+ char *wdst = malloca (wdstlen); -+ if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, source, wsrc, wsrclen)) -+ error (EXIT_FAILURE, errno, "unable to convert path name %s", source); -+ if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, dest, wdst, wdstlen)) -+ error (EXIT_FAILURE, errno, "unable to convert path name %s", dest); -+ if (wsrclen == wdstlen && memcasecmp (wsrc, wdst, wsrclen) == 0) -+ compare_dirs = true; -+ freea (wsrc); -+ freea (wdst); -+ } -+#endif /* __CYGWIN__ */ - bool same = false; - - #if CHECK_TRUNCATION ---- a/src/chcon.c 2016-11-06 16:15:29.000000000 -0600 -+++ b/src/chcon.c 2017-02-03 13:32:48.741217700 -0600 -@@ -48,7 +48,7 @@ static bool verbose; - - /* Pointer to the device and inode numbers of '/', when --recursive. - Otherwise NULL. */ --static struct dev_ino *root_dev_ino; -+static struct root_dev_ino *root_dev_ino; - - /* The name of the context file is being given. */ - static char const *specified_context; -@@ -570,7 +570,7 @@ main (int argc, char **argv) - - if (recurse && preserve_root) - { -- static struct dev_ino dev_ino_buf; -+ static struct root_dev_ino dev_ino_buf; - root_dev_ino = get_root_dev_ino (&dev_ino_buf); - if (root_dev_ino == NULL) - die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), ---- a/src/chgrp.c 2016-11-06 16:15:29.000000000 -0600 -+++ b/src/chgrp.c 2017-02-03 13:32:48.741217700 -0600 -@@ -301,7 +301,7 @@ main (int argc, char **argv) - - if (chopt.recurse && preserve_root) - { -- static struct dev_ino dev_ino_buf; -+ static struct root_dev_ino dev_ino_buf; - chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); - if (chopt.root_dev_ino == NULL) - die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), ---- a/src/chmod.c 2016-11-06 16:15:29.000000000 -0600 -+++ b/src/chmod.c 2017-02-03 13:32:48.741217700 -0600 -@@ -81,7 +81,7 @@ static enum Verbosity verbosity = V_off; - - /* Pointer to the device and inode numbers of '/', when --recursive. - Otherwise NULL. */ --static struct dev_ino *root_dev_ino; -+static struct root_dev_ino *root_dev_ino; - - /* For long options that have no equivalent short option, use a - non-character as a pseudo short option, starting with CHAR_MAX + 1. */ -@@ -552,7 +552,7 @@ main (int argc, char **argv) - - if (recurse && preserve_root) - { -- static struct dev_ino dev_ino_buf; -+ static struct root_dev_ino dev_ino_buf; - root_dev_ino = get_root_dev_ino (&dev_ino_buf); - if (root_dev_ino == NULL) - die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), ---- a/src/chown-core.h 2016-03-09 04:15:39.000000000 -0600 -+++ b/src/chown-core.h 2017-02-03 13:32:48.741217700 -0600 -@@ -50,7 +50,7 @@ struct Chown_option - - /* Pointer to the device and inode numbers of '/', when --recursive. - Need not be freed. Otherwise NULL. */ -- struct dev_ino *root_dev_ino; -+ struct root_dev_ino *root_dev_ino; - - /* This corresponds to the --dereference (opposite of -h) option. */ - bool affect_symlink_referent; ---- a/src/chown.c 2016-11-06 16:15:29.000000000 -0600 -+++ b/src/chown.c 2017-02-03 13:32:48.741217700 -0600 -@@ -313,7 +313,7 @@ main (int argc, char **argv) - - if (chopt.recurse && preserve_root) - { -- static struct dev_ino dev_ino_buf; -+ static struct root_dev_ino dev_ino_buf; - chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); - if (chopt.root_dev_ino == NULL) - die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), ---- a/src/chroot.c 2016-11-06 16:15:29.000000000 -0600 -+++ b/src/chroot.c 2017-02-03 13:32:48.741217700 -0600 -@@ -171,7 +171,8 @@ static bool - is_root (const char* dir) - { - char *resolved = canonicalize_file_name (dir); -- bool is_res_root = resolved && STREQ ("/", resolved); -+ bool is_res_root = resolved && (STREQ ("/", resolved) -+ || STREQ ( "//", resolved)); - free (resolved); - return is_res_root; - } ---- a/src/cksum.c 2016-11-06 16:15:29.000000000 -0600 -+++ b/src/cksum.c 2017-02-03 13:32:48.741217700 -0600 -@@ -301,6 +301,9 @@ main (int argc, char **argv) - - have_read_stdin = false; - -+ if (O_BINARY) -+ xset_binary_mode (STDIN_FILENO, O_BINARY); -+ - if (optind == argc) - ok = cksum ("-", false); - else ---- a/src/dd.c 2016-11-09 15:11:35.000000000 -0600 -+++ b/src/dd.c 2017-02-03 13:32:48.741217700 -0600 -@@ -38,6 +38,10 @@ - #include "xstrtol.h" - #include "xtime.h" - -+#ifdef __CYGWIN__ -+# include -+#endif -+ - /* The official name of this program (e.g., no 'g' prefix). */ - #define PROGRAM_NAME "dd" - -@@ -2024,6 +2028,13 @@ - static void - set_fd_flags (int fd, int add_flags, char const *name) - { -+#if __CYGWIN__ -+ /* Cygwin does not allow fcntl to set the mode. */ -+ int mode_flags = add_flags & (O_BINARY | O_TEXT); -+ add_flags &= ~(O_BINARY | O_TEXT); -+ if (mode_flags && setmode (fd, mode_flags) == -1) -+ error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name)); -+#endif /* __CYGWIN__ */ - /* Ignore file creation flags that are no-ops on file descriptors. */ - add_flags &= ~ (O_NOCTTY | O_NOFOLLOW); - -@@ -2418,6 +2429,8 @@ - } - else - { -+ if ((input_flags & (O_BINARY | O_TEXT)) == 0) -+ input_flags |= O_BINARY; - if (ifd_reopen (STDIN_FILENO, input_file, O_RDONLY | input_flags, 0) < 0) - die (EXIT_FAILURE, errno, _("failed to open %s"), - quoteaf (input_file)); -@@ -2441,6 +2454,8 @@ - | (conversions_mask & C_NOCREAT ? 0 : O_CREAT) - | (conversions_mask & C_EXCL ? O_EXCL : 0) - | (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC)); -+ if ((opts & (O_BINARY | O_TEXT)) == 0) -+ opts |= O_BINARY; - - /* Open the output file with *read* access only if we might - need to read to satisfy a 'seek=' request. If we can't read ---- a/src/install.c 2016-11-28 10:17:17.000000000 -0600 -+++ b/src/install.c 2017-02-03 13:32:48.741217700 -0600 -@@ -45,6 +45,10 @@ - #include "utimens.h" - #include "xstrtol.h" - -+#ifdef __CYGWIN__ -+# include "cygwin.h" -+#endif -+ - /* The official name of this program (e.g., no 'g' prefix). */ - #define PROGRAM_NAME "install" - -@@ -556,6 +560,16 @@ strip (char const *name) - error (0, errno, _("fork system call failed")); - break; - case 0: /* Child. */ -+#if __CYGWIN__ -+ { -+ /* Check for .exe here, since strip doesn't. */ -+ char *p; -+ if (((p = strchr (name, '\0') - 4) <= name -+ || strcasecmp (p, ".exe") != 0) -+ && 0 < cygwin_spelling (name)) -+ CYGWIN_APPEND_EXE (p, name); -+ } -+#endif /* __CYGWIN__ */ - execlp (strip_program, strip_program, name, NULL); - die (EXIT_FAILURE, errno, _("cannot run %s"), quoteaf (strip_program)); - default: /* Parent. */ ---- a/src/ls.c 2016-11-22 14:04:32.000000000 -0600 -+++ b/src/ls.c 2017-02-03 13:32:48.741217700 -0600 -@@ -122,6 +122,10 @@ - # include - #endif - -+#ifdef __CYGWIN__ -+# include "cygwin.h" -+#endif -+ - #define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \ - : (ls_mode == LS_MULTI_COL \ - ? "dir" : "vdir")) -@@ -783,6 +787,11 @@ - N_("%b %e %H:%M") - }; - -+#if __CYGWIN__ -+/* Whether .exe should be appended to command-line args as needed. */ -+static bool append_exe; -+#endif /* __CYGWIN__ */ -+ - /* The set of signals that are caught. */ - - static sigset_t caught_signals; -@@ -818,6 +827,9 @@ - enum - { - AUTHOR_OPTION = CHAR_MAX + 1, -+#ifdef __CYGWIN__ -+ APPEND_EXE_OPTION, -+#endif - BLOCK_SIZE_OPTION, - COLOR_OPTION, - DEREFERENCE_COMMAND_LINE_SYMLINK_TO_DIR_OPTION, -@@ -881,6 +893,9 @@ - {"block-size", required_argument, NULL, BLOCK_SIZE_OPTION}, - {"context", no_argument, 0, 'Z'}, - {"author", no_argument, NULL, AUTHOR_OPTION}, -+#ifdef __CYGWIN__ -+ {"append-exe", no_argument, NULL, APPEND_EXE_OPTION}, -+#endif - {GETOPT_HELP_OPTION_DECL}, - {GETOPT_VERSION_OPTION_DECL}, - {NULL, 0, NULL, 0} -@@ -2099,6 +2114,12 @@ - print_scontext = true; - break; - -+#ifdef __CYGWIN__ -+ case APPEND_EXE_OPTION: -+ append_exe = true; -+ break; -+#endif -+ - case_GETOPT_HELP_CHAR; - - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); -@@ -3110,6 +3131,12 @@ - uintmax_t blocks = 0; - struct fileinfo *f; - -+#ifdef __CYGWIN__ -+ char *name_alt = NULL; -+ if (command_line_arg && append_exe && 0 < cygwin_spelling (name)) -+ CYGWIN_APPEND_EXE (name_alt, name); -+#endif /* __CYGWIN__ */ -+ - /* An inode value prior to gobble_file necessarily came from readdir, - which is not used for command line arguments. */ - assert (! command_line_arg || inode == NOT_AN_INODE_NUMBER); -@@ -3240,11 +3267,19 @@ - file_failure (command_line_arg, - _("cannot access %s"), full_name); - if (command_line_arg) -- return 0; -+ { -+#ifdef __CYGWIN__ -+ freea (name_alt); -+#endif -+ return 0; -+ } - - f->name = xstrdup (name); - cwd_n_used++; - -+#ifdef __CYGWIN__ -+ freea (name_alt); -+#endif - return 0; - } - -@@ -3433,6 +3468,9 @@ - f->name = xstrdup (name); - cwd_n_used++; - -+#ifdef __CYGWIN__ -+ freea (name_alt); -+#endif - return blocks; - } - -@@ -5277,6 +5315,11 @@ - -1 list one file per line. Avoid '\\n' with -q or -b\ - \n\ - "), stdout); -+#if __CYGWIN__ -+ fputs (_("\ -+ --append-exe append .exe if cygwin magic was needed\n\ -+"), stdout); -+#endif /* __CYGWIN__ */ - fputs (HELP_OPTION_DESCRIPTION, stdout); - fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_size_note (); ---- a/src/md5sum.c 2016-11-22 14:04:32.000000000 -0600 -+++ b/src/md5sum.c 2017-02-03 13:32:48.741217700 -0600 -@@ -1039,6 +1039,9 @@ main (int argc, char **argv) - if (optind == argc) - *operand_lim++ = bad_cast ("-"); - -+ if (O_BINARY) -+ xset_binary_mode (STDIN_FILENO, O_BINARY); -+ - for (char **operandp = argv + optind; operandp < operand_lim; operandp++) - { - char *file = *operandp; ---- a/src/mv.c 2016-11-22 12:57:27.000000000 -0600 -+++ b/src/mv.c 2017-02-03 13:32:48.756816900 -0600 -@@ -93,7 +93,7 @@ rm_option_init (struct rm_options *x) - x->require_restore_cwd = true; - - { -- static struct dev_ino dev_ino_buf; -+ static struct root_dev_ino dev_ino_buf; - x->root_dev_ino = get_root_dev_ino (&dev_ino_buf); - if (x->root_dev_ino == NULL) - die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), ---- a/src/pwd.c 2016-11-06 16:15:30.000000000 -0600 -+++ b/src/pwd.c 2017-02-03 13:32:48.756816900 -0600 -@@ -268,8 +268,8 @@ static void - robust_getcwd (struct file_name *file_name) - { - size_t height = 1; -- struct dev_ino dev_ino_buf; -- struct dev_ino *root_dev_ino = get_root_dev_ino (&dev_ino_buf); -+ struct root_dev_ino dev_ino_buf; -+ struct root_dev_ino *root_dev_ino = get_root_dev_ino (&dev_ino_buf); - struct stat dot_sb; - - if (root_dev_ino == NULL) -@@ -282,7 +282,7 @@ robust_getcwd (struct file_name *file_na - while (1) - { - /* If we've reached the root, we're done. */ -- if (SAME_INODE (dot_sb, *root_dev_ino)) -+ if (ROOT_DEV_INO_CHECK (root_dev_ino, &dot_sb)) - break; - - find_dir_entry (&dot_sb, file_name, height++); -@@ -291,6 +291,9 @@ robust_getcwd (struct file_name *file_na - /* See if a leading slash is needed; file_name_prepend adds one. */ - if (file_name->start[0] == '\0') - file_name_prepend (file_name, "", 0); -+ /* If we aren't in `/', we must be in `//'. */ -+ if (! SAME_INODE (root_dev_ino->single_slash, dot_sb)) -+ file_name_prepend (file_name, "", 0); - } - - ---- a/src/remove.h 2016-03-09 04:15:39.000000000 -0600 -+++ b/src/remove.h 2017-02-03 13:32:48.756816900 -0600 -@@ -54,7 +54,7 @@ - - /* Pointer to the device and inode numbers of '/', when --recursive - and preserving '/'. Otherwise NULL. */ -- struct dev_ino *root_dev_ino; -+ struct root_dev_ino *root_dev_ino; - - /* If true, do not traverse into (or remove) any directory that is - the root of a file system. I.e., a separate device. */ ---- a/src/rm.c 2016-11-06 16:15:30.000000000 -0600 -+++ b/src/rm.c 2017-02-03 13:32:48.756816900 -0600 -@@ -342,7 +342,7 @@ main (int argc, char **argv) - - if (x.recursive && preserve_root) - { -- static struct dev_ino dev_ino_buf; -+ static struct root_dev_ino dev_ino_buf; - x.root_dev_ino = get_root_dev_ino (&dev_ino_buf); - if (x.root_dev_ino == NULL) - die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), ---- a/src/stat.c 2016-11-26 18:28:45.000000000 -0600 -+++ b/src/stat.c 2017-02-03 13:32:48.756816900 -0600 -@@ -74,6 +74,13 @@ - #include "find-mount-point.h" - #include "xvasprintf.h" - -+#ifdef __CYGWIN__ -+# include "cygwin.h" -+/* Whether .exe should be appended to command-line args as needed. */ -+static bool append_exe; -+# define APPEND_EXE_OPTION 10000 -+#endif -+ - #if USE_STATVFS - # define STRUCT_STATXFS_F_FSID_IS_INTEGER STRUCT_STATVFS_F_FSID_IS_INTEGER - # define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATVFS_F_TYPE -@@ -201,6 +208,9 @@ - {"printf", required_argument, NULL, PRINTF_OPTION}, - {"terse", no_argument, NULL, 't'}, - {"cached", required_argument, NULL, 0}, -+#ifdef __CYGWIN__ -+ {"append-exe", no_argument, NULL, APPEND_EXE_OPTION}, -+#endif - {GETOPT_HELP_OPTION_DECL}, - {GETOPT_VERSION_OPTION_DECL}, - {NULL, 0, NULL, 0} -@@ -1352,14 +1362,26 @@ - return false; - } - -+#ifdef __CYGWIN__ -+ char *name_alt = NULL; -+ if (append_exe && 0 < cygwin_spelling (filename)) -+ CYGWIN_APPEND_EXE (name_alt, filename); -+#endif /* __CYGWIN__ */ -+ - if (STATFS (filename, &statfsbuf) != 0) - { - error (0, errno, _("cannot read file system information for %s"), - quoteaf (filename)); -+#if __CYGWIN__ -+ freea (name_alt); -+#endif /* __CYGWIN__ */ - return false; - } - - bool fail = print_it (format, -1, filename, print_statfs, &statfsbuf); -+#if __CYGWIN__ -+ freea (name_alt); -+#endif /* __CYGWIN__ */ - return ! fail; - } - -@@ -1421,6 +1421,7 @@ - struct print_args pa; - pa.st = &statbuf; - pa.btime = (struct timespec) {-1, -1}; -+ char *name_alt = NULL; - - if (0 <= fd) - { -@@ -1433,18 +1433,28 @@ - /* We can't use the shorter - (follow_links?stat:lstat) (filename, &statbug) - since stat might be a function-like macro. */ -- else if ((follow_links -- ? stat (filename, &statbuf) -- : lstat (filename, &statbuf)) != 0) -+ else - { -- error (0, errno, _("cannot stat %s"), quoteaf (filename)); -- return false; -+ if ((follow_links -+ ? stat (filename, &statbuf) -+ : lstat (filename, &statbuf)) != 0) -+ { -+ error (0, errno, _("cannot stat %s"), quoteaf (filename)); -+ return false; -+ } -+#ifdef __CYGWIN__ -+ if (append_exe && 0 < cygwin_spelling (filename)) -+ CYGWIN_APPEND_EXE (name_alt, filename); -+#endif /* __CYGWIN__ */ - } - - if (S_ISBLK (statbuf.st_mode) || S_ISCHR (statbuf.st_mode)) - format = format2; - - bool fail = print_it (format, fd, filename, print_stat, &pa); -+#if __CYGWIN__ -+ freea (name_alt); -+#endif /* __CYGWIN__ */ - return ! fail; - } - #endif /* USE_STATX */ -@@ -1513,6 +1546,11 @@ - if you want a newline, include \\n in FORMAT\n\ - -t, --terse print the information in terse form\n\ - "), stdout); -+#if __CYGWIN__ -+ fputs (_("\ -+ --append-exe append .exe if cygwin magic was needed\n\ -+"), stdout); -+#endif /* __CYGWIN__ */ - fputs (HELP_OPTION_DESCRIPTION, stdout); - fputs (VERSION_OPTION_DESCRIPTION, stdout); - -@@ -1649,6 +1687,12 @@ - terse = true; - break; - -+#if __CYGWIN__ -+ case APPEND_EXE_OPTION: -+ append_exe = true; -+ break; -+#endif /* __CYGWIN__ */ -+ - case_GETOPT_HELP_CHAR; - - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); ---- a/src/copy.c 2016-11-22 12:57:27.000000000 -0600 -+++ b/src/copy.c 2017-02-03 13:32:48.741217700 -0600 -@@ -82,6 +82,10 @@ - # include - #endif - -+#ifdef __CYGWIN__ -+# include "cygwin.h" -+#endif -+ - #if !defined FICLONE && defined __linux__ - # define FICLONE _IOW (0x94, 9, int) - #endif -@@ -1427,7 +1431,11 @@ - static bool - same_file_ok (char const *src_name, struct stat const *src_sb, - char const *dst_name, struct stat const *dst_sb, -- const struct cp_options *x, bool *return_now) -+ const struct cp_options *x, bool *return_now -+#ifdef __CYGWIN__ -+ , bool *case_change -+#endif -+ ) - { - const struct stat *src_sb_link; - const struct stat *dst_sb_link; -@@ -1571,6 +1579,18 @@ - if (S_ISLNK (dst_sb_link->st_mode)) - return true; - -+#if __CYGWIN__ -+ /* If the files have the same name, but differ in case, then let -+ rename() change the case. */ -+ if (same_link && x->move_mode && same_name (src_name, dst_name) -+ && memcmp (last_component (src_name), last_component (dst_name), -+ base_len (src_name))) -+ { -+ *case_change = true; -+ return true; -+ } -+#endif /* __CYGWIN__ */ -+ - /* It's not ok if they're distinct hard links to the same file as - this causes a race condition and we may lose data in this case. */ - if (same_link -@@ -1930,6 +1950,9 @@ - } - - bool dereference = should_dereference (x, command_line_arg); -+#if __CYGWIN__ -+ bool case_change = false; -+#endif /* __CYGWIN__ */ - - if (!new_dst) - { -@@ -1974,7 +1997,11 @@ - - if (x->interactive != I_ALWAYS_NO - && ! same_file_ok (src_name, &src_sb, dst_name, &dst_sb, -- x, &return_now)) -+ x, &return_now -+#ifdef __CYGWIN__ -+ , &case_change -+#endif -+ )) - { - error (0, 0, _("%s and %s are the same file"), - quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); -@@ -2033,6 +2060,9 @@ - cp and mv treat -i and -f differently. */ - if (x->move_mode) - { -+#if __CYGWIN__ -+ if (!case_change) -+#endif - if (abandon_move (x, dst_name, &dst_sb)) - { - /* Pretend the rename succeeded, so the caller (mv) -@@ -2174,7 +2204,11 @@ - /* Never unlink dst_name when in move mode. */ - && ! x->move_mode - && (x->unlink_dest_before_opening -- || (x->preserve_links && 1 < dst_sb.st_nlink) -+ || (x->preserve_links && 1 < dst_sb.st_nlink -+#ifdef __CYGWIN__ -+ && !case_change -+#endif -+ ) - || (x->dereference == DEREF_NEVER - && ! S_ISREG (src_sb.st_mode)) - )) -@@ -2973,6 +3007,21 @@ - { - assert (valid_options (options)); - -+#ifdef __CYGWIN__ -+ /* .exe magic - if src exists with an implicit .exe suffix and is -+ not a symlink, but dst does not exist and was also specified -+ without a suffix, then append .exe to dst. */ -+ int cygwin = cygwin_spelling (src_name); -+ char *p; -+ if (cygwin == 2 -+ && ((p = strchr (dst_name, '\0') - 4) <= dst_name -+ || strcasecmp (p, ".exe") != 0)) -+ { -+ cygwin = 3; -+ CYGWIN_APPEND_EXE (p, dst_name); -+ } -+#endif /* __CYGWIN__ */ -+ - /* Record the file names: they're used in case of error, when copying - a directory into itself. I don't like to make these tools do *any* - extra work in the common case when that work is solely to handle -@@ -2984,10 +3033,16 @@ - top_level_dst_name = dst_name; - - bool first_dir_created_per_command_line_arg = false; -- return copy_internal (src_name, dst_name, nonexistent_dst, NULL, NULL, -+ bool done; -+ done = copy_internal (src_name, dst_name, nonexistent_dst, NULL, NULL, - options, true, - &first_dir_created_per_command_line_arg, - copy_into_self, rename_succeeded); -+#ifdef __CYGWIN__ -+ if (cygwin == 3) -+ freea ((char *) dst_name); -+#endif -+ return done; - } - - /* Set *X to the default options for a value of type struct cp_options. */ diff --git a/coreutils/002-coreutils-8.32-enable-stdbuf.patch b/coreutils/002-coreutils-8.32-enable-stdbuf.patch deleted file mode 100644 index 9d2636a9..00000000 --- a/coreutils/002-coreutils-8.32-enable-stdbuf.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- coreutils-8.32/configure.ac -+++ coreutils-8.32/configure.ac -@@ -509,7 +509,7 @@ - ], - [stdbuf_supported=yes]) - AC_MSG_RESULT([$stdbuf_supported]) --if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then -+if test "$stdbuf_supported" = "yes"; then - gl_ADD_PROG([optional_bin_progs], [stdbuf]) - fi - CFLAGS=$ac_save_CFLAGS -@@ -530,7 +530,7 @@ - # Note it adding to pkglibexec_PROGRAMS, $(transform) in src/local.mk - # may need to be updated accordingly. - case " $optional_bin_progs " in -- *' stdbuf '*) pkglibexec_PROGRAMS='src/libstdbuf.so';; -+ *' stdbuf '*) pkglibexec_PROGRAMS='src/libstdbuf.so$(EXEEXT)';; - *) pkglibexec_PROGRAMS='';; - esac - ---- coreutils-8.32/src/stdbuf.c -+++ coreutils-8.32/src/stdbuf.c -@@ -33,7 +33,7 @@ - - /* The official name of this program (e.g., no 'g' prefix). */ - #define PROGRAM_NAME "stdbuf" --#define LIB_NAME "libstdbuf.so" /* FIXME: don't hardcode */ -+#define LIB_NAME "libstdbuf.dll" /* FIXME: don't hardcode */ - - #define AUTHORS proper_name ("Padraig Brady") - diff --git a/coreutils/003-coreutils-8.32-fix-test-cases.patch b/coreutils/003-coreutils-8.32-fix-test-cases.patch deleted file mode 100644 index 0cc50a43..00000000 --- a/coreutils/003-coreutils-8.32-fix-test-cases.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- coreutils-8.32/tests/init.sh -+++ coreutils-8.32/tests/init.sh -@@ -349,7 +349,7 @@ - - # It must have 0700 permissions. Handle sticky "S" bits. - perms=`ls -dgo "$d" 2>/dev/null` && -- case $perms in drwx--[-S]---*) :;; *) false;; esac && { -+ case $perms in drwx*) :;; *) false;; esac && { - echo "$d" - return - } diff --git a/coreutils/PKGBUILD b/coreutils/PKGBUILD index 8f7753ae..b04b92c7 100644 --- a/coreutils/PKGBUILD +++ b/coreutils/PKGBUILD @@ -1,48 +1,136 @@ # Maintainer: Alexey Pavlov pkgname=coreutils -pkgver=8.32 -pkgrel=5 +pkgver=9.4 +pkgrel=1 pkgdesc="The basic file, shell and text manipulation utilities of the GNU operating system" arch=('i686' 'x86_64') -license=('GPL3') +license=('spdx:GPL-3.0-or-later' AND 'spdx:GFDL-1.3-or-later') url="https://www.gnu.org/software/coreutils" depends=('gmp' 'libiconv' 'libintl') makedepends=('groff' 'gmp-devel' 'libiconv-devel' 'gettext-devel' 'help2man' 'autotools' 'gcc') source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.xz{,.sig} - 001-coreutils-8.30.patch - 002-coreutils-8.32-enable-stdbuf.patch - 003-coreutils-8.32-fix-test-cases.patch - 004-msystem-osname-cygwin.patch) -sha256sums=('4458d8de7849df44ccab15e16b1548b285224dbba5f08fac070c1c0e0bcc4cfa' + coreutils-8.32-configure.ac.patch + coreutils-8.32-doc-coreutils.texi.patch + coreutils-8.32-lib-freopen.c.patch + coreutils-8.32-lib-hash-pjw.c.patch + coreutils-8.32-lib-hash-pjw.h.patch + coreutils-8.32-lib-local.mk.patch + coreutils-9.1-lib-root-dev-ino.h.patch + coreutils-9.4-lib-root-dev-ino.c.patch + coreutils-8.32-lib-same.c.patch + coreutils-9.4-src-chcon.c.patch + coreutils-8.32-src-chgrp.c.patch + coreutils-9.4-src-chmod.c.patch + coreutils-8.32-src-chown.c.patch + coreutils-9.4-src-chown-core.h.patch + coreutils-8.32-src-chroot.c.patch + coreutils-9.4-src-copy.c.patch + coreutils-8.32-src-dd.c.patch + coreutils-8.32-src-dircolors.c.patch + coreutils-9.4-src-install.c.patch + coreutils-9.4-src-ls.c.patch + coreutils-9.1-src-mv.c.patch + coreutils-8.32-src-pwd.c.patch + coreutils-9.4-src-remove.h.patch + coreutils-8.32-src-rm.c.patch + coreutils-9.4-src-stat.c.patch + coreutils-9-src-dircolors-hin.patch + 004-msystem-osname-cygwin.patch + cygwin.h + cygwin.c) +sha256sums=('ea613a4cf44612326e917201bbbcdfbd301de21ffc3b59b6e5c07e040b275e52' 'SKIP' - '467bde24da0ccea48260f58d3c94a84de4e027ab598a926003642f791da47ca2' - 'e3be62b9aceb3231f09f05bc3bd8b18f6aaa495f5063781cdd261d560a7e80d0' - 'ad9e0582373500c0668e38483401169f48d6a2f8ad8d28ef8e7b06e4a3e08a74' - '3922afd54b2323772f5cbd0638d0887ef858199bbaf4076a1db318173021c3dc') + '40052d667830078c3fbdd62db99b92310d3f3be4674c50be1debcd11d8ec6b3c' + 'dee3138601ccc3183418bc571359d5ebd49c9a0678778432c8b71cbe79431213' + '553a798fd493d7537dc93d2b18d9329ee7e964a330fc088f261b440049a5d284' + '6326eba2c476001b4a07abfc5a59aac881e6349e269252d006a7c71ed2b289ac' + '5ceffc6464e006e53888a599ca4a29b752e8c345b530e90b3a8a19a8f7c28743' + 'bc9b1f0434fa9ca3b98d2fe6fcd821c64fc9b358516f3fe8873de1080afc3749' + '055f99c882c6fff3273c1fbfc2838729a9167fb3be437fb64caf06646ecbda0d' + '8b511b9155928a7027f7ceb9fd8ece9d532f6c3ff77c75edf28a61c25c4b9ce7' + '06b089c5225273684e420f8b6e486e55400ff20a240a7d78d2e6cc9cabdeae8b' + '2b42f8ab3832cef7337f6eace7dfc8dce4fb04ed9ebbdda99b1189e89c2025c7' + 'e0ef98efbae37297109f4b50f3922c08c3abd7c20401aaa520122667da6c1590' + '9d3ca2197ea04d12696534526e75f4f1f01450701cc1f192a5465075d82faab5' + '7951ec47a030444b74542a712a70fd5d8d6cdcb5a5a85a1886b3f35b60042365' + '467689d047ebfc1d6c78d3047b8e44f026aa546929501a16d66af675053450b5' + 'fdcb5871c63ba2e4ca6a6c23c357c4a10fba2ab6975ee4f528f1eca1c3619aa8' + 'a2165a1444aebbc90eecd7d632ef6901a03497bdefd96961f06c98c022f499dd' + '0cbe20d9280be2aa9a055131ea8d2aff041fd5879b2ec80203a359e64d3d523a' + '05dc41601dd7276fc38f57ca0eadc9fd060d6f2724c6e48382f71209bf30ef66' + '1adbee994448de83f02f3c5401b0c89210e0668e5e76c94b8374f0a268a55001' + '52a8ec786692a15ee79db100c25e781cf538b5f61e3cefc21af001b37f3753ed' + 'a2e4b54690958cbf86262930aac240d18f607bf6b34dd006b337a5d1afc015ec' + '1057b97007e65fb597ad4be036977303ac9be2e2a46c44c30fce0537ac04e96a' + 'dd381cc10b944ae84b5d942543d86569f838167dc390e16e17262a27a6a3b7b3' + 'bc3fb774431005318cb89f723175c79e9f18808c7ef6010c410d7ea9495f854e' + '07ddcca3f127e60631e63012aa1553721e939b44dafe0220b85ecd727445681f' + 'f08f69c6089192dcb295c3110c8b0d59af30438894bb3eb8a817d162b14ae3e1' + '3922afd54b2323772f5cbd0638d0887ef858199bbaf4076a1db318173021c3dc' + '602faa31be04e3cba6cf39921f4da397fbca4a66baa5a1186e070a16dc65391a' + '8dce514ac47518d78a31fd07addc6300912cb2965915798ad1381208d36c887c') validpgpkeys=('6C37DC12121A5006BC1DB804DF6FD971306037D9') +apply_patch_with_msg() { + for _patch in "$@" + do + msg2 "Applying ${_patch}" + patch -Nbp1 -i "${srcdir}/${_patch}" + done +} + prepare() { cd ${srcdir}/${pkgname}-${pkgver} - patch -p1 -i ${srcdir}/001-coreutils-8.30.patch - patch -p1 -i ${srcdir}/002-coreutils-8.32-enable-stdbuf.patch - patch -p1 -i ${srcdir}/003-coreutils-8.32-fix-test-cases.patch + apply_patch_with_msg \ + coreutils-8.32-configure.ac.patch \ + coreutils-8.32-doc-coreutils.texi.patch \ + coreutils-8.32-lib-freopen.c.patch \ + coreutils-8.32-lib-hash-pjw.c.patch \ + coreutils-8.32-lib-hash-pjw.h.patch \ + coreutils-8.32-lib-local.mk.patch \ + coreutils-9.1-lib-root-dev-ino.h.patch \ + coreutils-9.4-lib-root-dev-ino.c.patch \ + coreutils-8.32-lib-same.c.patch \ + coreutils-9.4-src-chcon.c.patch \ + coreutils-8.32-src-chgrp.c.patch \ + coreutils-9.4-src-chmod.c.patch \ + coreutils-8.32-src-chown.c.patch \ + coreutils-9.4-src-chown-core.h.patch \ + coreutils-8.32-src-chroot.c.patch \ + coreutils-9.4-src-copy.c.patch \ + coreutils-8.32-src-dd.c.patch \ + coreutils-8.32-src-dircolors.c.patch \ + coreutils-9.4-src-install.c.patch \ + coreutils-9.4-src-ls.c.patch \ + coreutils-9.1-src-mv.c.patch \ + coreutils-8.32-src-pwd.c.patch \ + coreutils-9.4-src-remove.h.patch \ + coreutils-8.32-src-rm.c.patch \ + coreutils-9.4-src-stat.c.patch \ + coreutils-9-src-dircolors-hin.patch # https://github.com/msys2/MSYS2-packages/issues/3012 - patch -p1 -i ${srcdir}/004-msystem-osname-cygwin.patch + apply_patch_with_msg \ + 004-msystem-osname-cygwin.patch + + cp "${srcdir}"/cygwin.c lib/ + cp "${srcdir}"/cygwin.h src/ autoreconf -fi + sed -i -e 's|\(libstdbuf\.so\)$(EXEEXT)|\1|g' Makefile.in } build() { - [[ -d ${srcdir}/build-${CHOST} ]] && rm -rf ${srcdir}/build-${CHOST} mkdir -p ${srcdir}/build-${CHOST} && cd ${srcdir}/build-${CHOST} + export CYGWIN_CHOST="${CHOST/-msys/-cygwin}" + export gl_cv_have_weak=no ../${pkgname}-${pkgver}/configure \ - --build=${CHOST} \ + --build=${CYGWIN_CHOST} \ --prefix=/usr \ --libexecdir=/usr/lib \ --sysconfdir=/etc \ diff --git a/coreutils/coreutils-8.32-configure.ac.patch b/coreutils/coreutils-8.32-configure.ac.patch new file mode 100644 index 00000000..c6bd6257 --- /dev/null +++ b/coreutils/coreutils-8.32-configure.ac.patch @@ -0,0 +1,21 @@ +--- origsrc/configure.ac 2016-11-29 12:03:45.000000000 -0600 ++++ src/configure.ac 2017-02-03 13:32:48.725613200 -0600 +@@ -470,7 +470,8 @@ gl_WARN_ADD([-Werror], [CFLAGS]) + gl_WARN_ADD([-errwarn], [CFLAGS]) + # Put this message here, after gl_WARN_ADD's chatter. + AC_MSG_CHECKING([whether this system supports stdbuf]) +-CFLAGS="-fPIC $CFLAGS" ++# -fPIC on cygwin gives lots of warnings ++#CFLAGS="-fPIC $CFLAGS" + LDFLAGS="-shared $LDFLAGS" + stdbuf_supported=no + # Note we only LINK here rather than RUN to support cross compilation +@@ -488,7 +489,7 @@ AC_LINK_IFELSE( + ], + [stdbuf_supported=yes]) + AC_MSG_RESULT([$stdbuf_supported]) +-if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then ++if test "$stdbuf_supported" = "yes"; then + gl_ADD_PROG([optional_bin_progs], [stdbuf]) + fi + CFLAGS=$ac_save_CFLAGS diff --git a/coreutils/coreutils-8.32-doc-coreutils.texi.patch b/coreutils/coreutils-8.32-doc-coreutils.texi.patch new file mode 100644 index 00000000..b40376b6 --- /dev/null +++ b/coreutils/coreutils-8.32-doc-coreutils.texi.patch @@ -0,0 +1,32 @@ +--- origsrc/doc/coreutils.texi 2016-11-24 05:08:31.000000000 -0600 ++++ src/doc/coreutils.texi 2017-02-03 13:32:48.725613200 -0600 +@@ -7743,6 +7743,14 @@ These options change how file names them + + @table @samp + ++@item --append-exe ++@opindex --append-exe ++@cindex appending exe on cygwin ++Cygwin only: Cygwin normally performs @samp{.exe} magic, where a ++command line argument typed without an .exe extension transparently ++refers to the existing file with an extension. Specifying this option ++will make the .exe show if cygwin magic was involved. ++ + @item -b + @itemx --escape + @itemx --quoting-style=escape +@@ -11761,6 +11769,14 @@ With this option, @command{stat} acts on + by each symbolic link argument. + Without it, @command{stat} acts on any symbolic link argument directly. + ++@item --append-exe ++@opindex --append-exe ++@cindex appending exe on cygwin ++Cygwin only: Cygwin normally performs .exe magic, where a command line ++argument typed without an .exe extension transparently refers to the ++existing file with an extension. Specifying this option will make ++the .exe show if cygwin magic was involved. ++ + @item -f + @itemx --file-system + @opindex -f diff --git a/coreutils/coreutils-8.32-lib-freopen.c.patch b/coreutils/coreutils-8.32-lib-freopen.c.patch new file mode 100644 index 00000000..d98155cc --- /dev/null +++ b/coreutils/coreutils-8.32-lib-freopen.c.patch @@ -0,0 +1,18 @@ +--- origsrc/lib/freopen.c 2020-01-01 07:14:23.000000000 -0700 ++++ src/lib/freopen.c 2022-04-16 22:41:38.090786400 -0600 +@@ -59,6 +59,15 @@ rpl_freopen (const char *filename, const + errno = 0; + #endif + ++#if __CYGWIN__ ++ if (!filename && !strcmp (mode, "wb")) ++ { ++ int flag = fcntl (fileno (stream), F_GETFL); ++ if (0 <= flag && (flag & O_APPEND)) ++ mode = "ab"; ++ } ++ ++#endif + result = orig_freopen (filename, mode, stream); + + if (!result) diff --git a/coreutils/coreutils-8.32-lib-hash-pjw.c.patch b/coreutils/coreutils-8.32-lib-hash-pjw.c.patch new file mode 100644 index 00000000..496b1cd0 --- /dev/null +++ b/coreutils/coreutils-8.32-lib-hash-pjw.c.patch @@ -0,0 +1,27 @@ +--- origsrc/lib/hash-pjw.c 2016-07-15 14:47:39.000000000 -0500 ++++ src/lib/hash-pjw.c 2017-02-03 13:32:48.725613200 -0600 +@@ -19,6 +19,7 @@ + + #include "hash-pjw.h" + ++#include + #include + + #define SIZE_BITS (sizeof (size_t) * CHAR_BIT) +@@ -38,3 +39,16 @@ hash_pjw (const void *x, size_t tablesiz + + return h % tablesize; + } ++ ++/* Likewise, but case-insensitive. */ ++size_t ++hash_pjw_case (const void *x, size_t tablesize) ++{ ++ const unsigned char *s; ++ size_t h = 0; ++ ++ for (s = x; *s; s++) ++ h = tolower (*s) + ((h << 9) | (h >> (SIZE_BITS - 9))); ++ ++ return h % tablesize; ++} diff --git a/coreutils/coreutils-8.32-lib-hash-pjw.h.patch b/coreutils/coreutils-8.32-lib-hash-pjw.h.patch new file mode 100644 index 00000000..ec97c218 --- /dev/null +++ b/coreutils/coreutils-8.32-lib-hash-pjw.h.patch @@ -0,0 +1,7 @@ +--- origsrc/lib/hash-pjw.h 2016-07-15 14:47:39.000000000 -0500 ++++ src/lib/hash-pjw.h 2017-02-03 13:32:48.725613200 -0600 +@@ -21,3 +21,4 @@ + The result is platform dependent: it depends on the size of the 'size_t' + type and on the signedness of the 'char' type. */ + extern size_t hash_pjw (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE; ++extern size_t hash_pjw_case (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE; diff --git a/coreutils/coreutils-8.32-lib-local.mk.patch b/coreutils/coreutils-8.32-lib-local.mk.patch new file mode 100644 index 00000000..2780e636 --- /dev/null +++ b/coreutils/coreutils-8.32-lib-local.mk.patch @@ -0,0 +1,9 @@ +--- origsrc/lib/local.mk 2012-11-13 07:51:53.000000000 -0600 ++++ src/lib/local.mk 2017-02-03 13:32:48.725613200 -0600 +@@ -3,3 +3,6 @@ include lib/gnulib.mk + # Allow "make distdir" to succeed before "make all" has run. + dist-hook: $(noinst_LIBRARIES) + .PHONY: dist-hook ++ ++# Hook in cygwin helper ++lib_libcoreutils_a_SOURCES += lib/cygwin.c lib/cygwin.h diff --git a/coreutils/coreutils-8.32-lib-same.c.patch b/coreutils/coreutils-8.32-lib-same.c.patch new file mode 100644 index 00000000..dc22bcf3 --- /dev/null +++ b/coreutils/coreutils-8.32-lib-same.c.patch @@ -0,0 +1,62 @@ +--- origsrc/lib/same.c 2016-07-15 14:47:39.000000000 -0500 ++++ src/lib/same.c 2017-02-03 13:32:48.741217700 -0600 +@@ -40,6 +40,13 @@ + #include "error.h" + #include "same-inode.h" + ++#if __CYGWIN__ ++# include ++# include "cygwin.h" ++# include "malloca.h" ++# include "memcasecmp.h" ++#endif ++ + #ifndef MIN + # define MIN(a, b) ((a) < (b) ? (a) : (b)) + #endif +@@ -59,6 +66,45 @@ same_name (const char *source, const cha + (source_baselen == dest_baselen + && memcmp (source_basename, dest_basename, dest_baselen) == 0); + bool compare_dirs = identical_basenames; ++#if __CYGWIN__ ++ /* If two names differ case-insensitively by only an '.exe' suffix, ++ do some sleuthing to see if .exe magic matters on the shorter ++ name. Swapping the longer name to dest avoids duplication. */ ++ if (source_baselen == dest_baselen + 4) ++ { ++ char const *tmp_basename = source_basename; ++ size_t tmp_baselen = source_baselen; ++ source_basename = dest_basename; ++ source_baselen = dest_baselen; ++ dest_basename = tmp_basename; ++ dest_baselen = tmp_baselen; ++ } ++ if (source_baselen + 4 == dest_baselen ++ && !memcasecmp (dest_basename - 4, ".exe", 4) ++ && !memcasecmp (source_basename, dest_basename, source_baselen) ++ && 0 < cygwin_spelling(source)) ++ dest_baselen -= 4; ++ /* Some, but not all, files are case-insensitive (depending on mount ++ options, CYGWIN=case settings, and virtual file systems). Do ++ some sleuthing to decide whether case-insensitivity matters. */ ++ if (! compare_dirs && source_baselen == dest_baselen) ++ { ++ ssize_t wsrclen = cygwin_conv_path (CCP_POSIX_TO_WIN_W, ++ source, NULL, 0); ++ ssize_t wdstlen = cygwin_conv_path (CCP_POSIX_TO_WIN_W, ++ dest, NULL, 0); ++ char *wsrc = malloca (wsrclen); ++ char *wdst = malloca (wdstlen); ++ if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, source, wsrc, wsrclen)) ++ error (EXIT_FAILURE, errno, "unable to convert path name %s", source); ++ if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, dest, wdst, wdstlen)) ++ error (EXIT_FAILURE, errno, "unable to convert path name %s", dest); ++ if (wsrclen == wdstlen && memcasecmp (wsrc, wdst, wsrclen) == 0) ++ compare_dirs = true; ++ freea (wsrc); ++ freea (wdst); ++ } ++#endif /* __CYGWIN__ */ + bool same = false; + + #if ! _POSIX_NO_TRUNC && HAVE_PATHCONF && defined _PC_NAME_MAX diff --git a/coreutils/coreutils-8.32-src-chgrp.c.patch b/coreutils/coreutils-8.32-src-chgrp.c.patch new file mode 100644 index 00000000..faaf24c6 --- /dev/null +++ b/coreutils/coreutils-8.32-src-chgrp.c.patch @@ -0,0 +1,11 @@ +--- origsrc/src/chgrp.c 2016-11-06 16:15:29.000000000 -0600 ++++ src/src/chgrp.c 2017-02-03 13:32:48.741217700 -0600 +@@ -301,7 +301,7 @@ main (int argc, char **argv) + + if (chopt.recurse && preserve_root) + { +- static struct dev_ino dev_ino_buf; ++ static struct root_dev_ino dev_ino_buf; + chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); + if (chopt.root_dev_ino == NULL) + die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), diff --git a/coreutils/coreutils-8.32-src-chown.c.patch b/coreutils/coreutils-8.32-src-chown.c.patch new file mode 100644 index 00000000..5db363fe --- /dev/null +++ b/coreutils/coreutils-8.32-src-chown.c.patch @@ -0,0 +1,11 @@ +--- origsrc/src/chown.c 2016-11-06 16:15:29.000000000 -0600 ++++ src/src/chown.c 2017-02-03 13:32:48.741217700 -0600 +@@ -313,7 +313,7 @@ main (int argc, char **argv) + + if (chopt.recurse && preserve_root) + { +- static struct dev_ino dev_ino_buf; ++ static struct root_dev_ino dev_ino_buf; + chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); + if (chopt.root_dev_ino == NULL) + die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), diff --git a/coreutils/coreutils-8.32-src-chroot.c.patch b/coreutils/coreutils-8.32-src-chroot.c.patch new file mode 100644 index 00000000..a15cac10 --- /dev/null +++ b/coreutils/coreutils-8.32-src-chroot.c.patch @@ -0,0 +1,12 @@ +--- origsrc/src/chroot.c 2016-11-06 16:15:29.000000000 -0600 ++++ src/src/chroot.c 2017-02-03 13:32:48.741217700 -0600 +@@ -171,7 +171,8 @@ static bool + is_root (const char* dir) + { + char *resolved = canonicalize_file_name (dir); +- bool is_res_root = resolved && STREQ ("/", resolved); ++ bool is_res_root = resolved && (STREQ ("/", resolved) ++ || STREQ ( "//", resolved)); + free (resolved); + return is_res_root; + } diff --git a/coreutils/coreutils-8.32-src-dd.c.patch b/coreutils/coreutils-8.32-src-dd.c.patch new file mode 100644 index 00000000..a72fd07f --- /dev/null +++ b/coreutils/coreutils-8.32-src-dd.c.patch @@ -0,0 +1,45 @@ +--- origsrc/src/dd.c 2016-11-09 15:11:35.000000000 -0600 ++++ src/src/dd.c 2017-02-03 13:32:48.741217700 -0600 +@@ -37,6 +37,10 @@ + #include "xstrtol.h" + #include "xtime.h" + ++#ifdef __CYGWIN__ ++# include ++#endif ++ + /* The official name of this program (e.g., no 'g' prefix). */ + #define PROGRAM_NAME "dd" + +@@ -1989,6 +1993,13 @@ copy_with_unblock (char const *buf, size + static void + set_fd_flags (int fd, int add_flags, char const *name) + { ++#if __CYGWIN__ ++ /* Cygwin does not allow fcntl to set the mode. */ ++ int mode_flags = add_flags & (O_BINARY | O_TEXT); ++ add_flags &= ~(O_BINARY | O_TEXT); ++ if (mode_flags && setmode (fd, mode_flags) == -1) ++ error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name)); ++#endif /* __CYGWIN__ */ + /* Ignore file creation flags that are no-ops on file descriptors. */ + add_flags &= ~ (O_NOCTTY | O_NOFOLLOW); + +@@ -2379,6 +2390,8 @@ main (int argc, char **argv) + } + else + { ++ if ((input_flags & (O_BINARY | O_TEXT)) == 0) ++ input_flags |= O_BINARY; + if (ifd_reopen (STDIN_FILENO, input_file, O_RDONLY | input_flags, 0) < 0) + die (EXIT_FAILURE, errno, _("failed to open %s"), + quoteaf (input_file)); +@@ -2402,6 +2415,8 @@ main (int argc, char **argv) + | (conversions_mask & C_NOCREAT ? 0 : O_CREAT) + | (conversions_mask & C_EXCL ? O_EXCL : 0) + | (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC)); ++ if ((opts & (O_BINARY | O_TEXT)) == 0) ++ opts |= O_BINARY; + + /* Open the output file with *read* access only if we might + need to read to satisfy a 'seek=' request. If we can't read diff --git a/coreutils/coreutils-8.32-src-dircolors.c.patch b/coreutils/coreutils-8.32-src-dircolors.c.patch new file mode 100644 index 00000000..7b6e9ef0 --- /dev/null +++ b/coreutils/coreutils-8.32-src-dircolors.c.patch @@ -0,0 +1,16 @@ +--- origsrc/src/dircolors.c 2016-11-06 16:15:30.000000000 -0600 ++++ src/src/dircolors.c 2017-02-03 13:32:48.741217700 -0600 +@@ -496,8 +496,12 @@ main (int argc, char **argv) + } + else + { ++ /* tcsh treats LS_COLORS as a magic shell variable for its ++ builtin ls-F, but does not recognize all the categories ++ that coreutils ls does. Therefore, silence stderr to ++ avoid messages like "Unknown colorls variable `su'.". */ + prefix = "setenv LS_COLORS '"; +- suffix = "'\n"; ++ suffix = "' >&/dev/null\n"; + } + fputs (prefix, stdout); + fwrite (s, 1, len, stdout); diff --git a/coreutils/coreutils-8.32-src-pwd.c.patch b/coreutils/coreutils-8.32-src-pwd.c.patch new file mode 100644 index 00000000..17952084 --- /dev/null +++ b/coreutils/coreutils-8.32-src-pwd.c.patch @@ -0,0 +1,32 @@ +--- origsrc/src/pwd.c 2016-11-06 16:15:30.000000000 -0600 ++++ src/src/pwd.c 2017-02-03 13:32:48.756816900 -0600 +@@ -269,8 +269,8 @@ static void + robust_getcwd (struct file_name *file_name) + { + size_t height = 1; +- struct dev_ino dev_ino_buf; +- struct dev_ino *root_dev_ino = get_root_dev_ino (&dev_ino_buf); ++ struct root_dev_ino dev_ino_buf; ++ struct root_dev_ino *root_dev_ino = get_root_dev_ino (&dev_ino_buf); + struct stat dot_sb; + + if (root_dev_ino == NULL) +@@ -283,7 +283,7 @@ robust_getcwd (struct file_name *file_na + while (1) + { + /* If we've reached the root, we're done. */ +- if (SAME_INODE (dot_sb, *root_dev_ino)) ++ if (ROOT_DEV_INO_CHECK (root_dev_ino, &dot_sb)) + break; + + find_dir_entry (&dot_sb, file_name, height++); +@@ -292,6 +292,9 @@ robust_getcwd (struct file_name *file_na + /* See if a leading slash is needed; file_name_prepend adds one. */ + if (file_name->start[0] == '\0') + file_name_prepend (file_name, "", 0); ++ /* If we aren't in `/', we must be in `//'. */ ++ if (! SAME_INODE (root_dev_ino->single_slash, dot_sb)) ++ file_name_prepend (file_name, "", 0); + } + + diff --git a/coreutils/coreutils-8.32-src-rm.c.patch b/coreutils/coreutils-8.32-src-rm.c.patch new file mode 100644 index 00000000..c1f99285 --- /dev/null +++ b/coreutils/coreutils-8.32-src-rm.c.patch @@ -0,0 +1,11 @@ +--- origsrc/src/rm.c 2016-11-06 16:15:30.000000000 -0600 ++++ src/src/rm.c 2017-02-03 13:32:48.756816900 -0600 +@@ -327,7 +327,7 @@ main (int argc, char **argv) + + if (x.recursive && preserve_root) + { +- static struct dev_ino dev_ino_buf; ++ static struct root_dev_ino dev_ino_buf; + x.root_dev_ino = get_root_dev_ino (&dev_ino_buf); + if (x.root_dev_ino == NULL) + die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), diff --git a/coreutils/coreutils-9-src-dircolors-hin.patch b/coreutils/coreutils-9-src-dircolors-hin.patch new file mode 100644 index 00000000..c43fae88 --- /dev/null +++ b/coreutils/coreutils-9-src-dircolors-hin.patch @@ -0,0 +1,84 @@ +--- a/src/dircolors.hin ++++ b/src/dircolors.hin +@@ -33,6 +33,7 @@ TERM konsole + TERM kterm + TERM linux + TERM linux-c ++TERM mintty + TERM mlterm + TERM putty + TERM rxvt* +@@ -41,6 +42,9 @@ TERM st + TERM terminator + TERM tmux* + TERM vt100 ++TERM vt241 ++TERM vt34* ++TERM vt525 + TERM xterm* + + # =================================================================== +@@ -62,6 +66,8 @@ RESET 0 # reset to "normal" color + DIR 01;34 # directory + LINK 01;36 # symbolic link. (If you set this to 'target' instead of a + # numerical value, the color is as for the file pointed to.) ++.lnk 01;36 # Windows shortcut ++.url 01;36 # Windows Internet shortcut + MULTIHARDLINK 00 # regular file with more than one link + FIFO 40;33 # pipe + SOCK 01;35 # socket +@@ -96,10 +102,15 @@ EXEC 01;32 + #.com 01;32 + #.btm 01;32 + #.bat 01;32 ++#.dll 01;32 # Windows Dynamic Link Library ++#.xll 01;32 # Excel extension DLLs + # Or if you want to color scripts even if they do not have the + # executable bit actually set. + #.sh 01;32 + #.csh 01;32 ++#.dash 01;32 ++#.ksh 01;32 ++#.zsh 01;32 + + # archives or compressed (bright red) + .tar 01;31 +@@ -148,6 +159,15 @@ EXEC 01;32 + .swm 01;31 + .dwm 01;31 + .esd 01;31 ++.epub 01;31 ++.ods 01;31 ++.odt 01;31 ++.docx 01;31 ++.pptx 01;31 ++.xlsx 01;31 ++.xps 01;31 ++.accumap 01;31 ++.lwell 01;31 + + # image formats + .avif 01;35 +@@ -199,10 +219,14 @@ EXEC 01;32 + .yuv 01;35 + .cgm 01;35 + .emf 01;35 ++.ico 01;35 ++.icl 01;35 + + # https://wiki.xiph.org/MIME_Types_and_File_Extensions + .ogv 01;35 + .ogx 01;35 ++.anx 01;35 ++.axv 01;35 + + # audio formats + .aac 00;36 +@@ -223,6 +247,7 @@ EXEC 01;32 + .opus 00;36 + .spx 00;36 + .xspf 00;36 ++.axa 00;36 + + # backup files + *~ 00;90 diff --git a/coreutils/coreutils-9.1-lib-root-dev-ino.h.patch b/coreutils/coreutils-9.1-lib-root-dev-ino.h.patch new file mode 100644 index 00000000..20078c9f --- /dev/null +++ b/coreutils/coreutils-9.1-lib-root-dev-ino.h.patch @@ -0,0 +1,33 @@ +--- origsrc/lib/root-dev-ino.h 2022-04-08 05:22:17.000000000 -0600 ++++ src/lib/root-dev-ino.h 2022-05-08 00:59:46.346838200 -0600 +@@ -21,19 +21,26 @@ + # include "dev-ino.h" + # include "same-inode.h" + +-struct dev_ino * +-get_root_dev_ino (struct dev_ino *root_d_i) _GL_ATTRIBUTE_NONNULL (); ++struct root_dev_ino ++{ ++ struct dev_ino single_slash; ++ struct dev_ino double_slash; ++}; ++ ++struct root_dev_ino * ++get_root_dev_ino (struct root_dev_ino *root_d_i) _GL_ATTRIBUTE_NONNULL (); + + /* These macros are common to the programs that support the + --preserve-root and --no-preserve-root options. */ + + # define ROOT_DEV_INO_CHECK(Root_dev_ino, Dir_statbuf) \ +- (Root_dev_ino && SAME_INODE (*Dir_statbuf, *Root_dev_ino)) ++ (Root_dev_ino && (SAME_INODE (*Dir_statbuf, (Root_dev_ino)->single_slash) \ ++ || SAME_INODE (*Dir_statbuf, (Root_dev_ino)->double_slash))) + + # define ROOT_DEV_INO_WARN(Dirname) \ + do \ + { \ +- if (STREQ (Dirname, "/")) \ ++ if (STREQ (Dirname, "/") || STREQ (Dirname, "//")) \ + error (0, 0, _("it is dangerous to operate recursively on %s"), \ + quoteaf (Dirname)); \ + else \ diff --git a/coreutils/coreutils-9.1-src-mv.c.patch b/coreutils/coreutils-9.1-src-mv.c.patch new file mode 100644 index 00000000..3f153a1b --- /dev/null +++ b/coreutils/coreutils-9.1-src-mv.c.patch @@ -0,0 +1,28 @@ +--- origsrc/src/mv.c 2022-04-13 13:09:25.000000000 -0600 ++++ src/src/mv.c 2022-05-08 02:06:40.887810300 -0600 +@@ -91,7 +91,7 @@ rm_option_init (struct rm_options *x) + x->require_restore_cwd = true; + + { +- static struct dev_ino dev_ino_buf; ++ static struct root_dev_ino dev_ino_buf; + x->root_dev_ino = get_root_dev_ino (&dev_ino_buf); + if (x->root_dev_ino == NULL) + die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), +@@ -407,6 +407,16 @@ main (int argc, char **argv) + else + { + char const *lastfile = file[n_files - 1]; ++#if __CYGWIN__ ++ struct stat s1, s2; ++ if (2 == n_files ++ && lstat (file[0], &s1) == 0 && lstat (file[1], &s2) == 0 ++ && s1.st_ino == s2.st_ino) ++ { ++ /* Allow 'mv foo Foo' to change case of the directory foo. */ ++ } ++ else ++#endif /* __CYGWIN__ */ + if (n_files == 2) + x.rename_errno = (renameatu (AT_FDCWD, file[0], AT_FDCWD, lastfile, + RENAME_NOREPLACE) diff --git a/coreutils/coreutils-9.4-lib-root-dev-ino.c.patch b/coreutils/coreutils-9.4-lib-root-dev-ino.c.patch new file mode 100644 index 00000000..17bc807a --- /dev/null +++ b/coreutils/coreutils-9.4-lib-root-dev-ino.c.patch @@ -0,0 +1,24 @@ +--- origsrc/lib/root-dev-ino.c 2023-07-05 05:09:55.000000000 -0600 ++++ src/lib/root-dev-ino.c 2023-09-09 20:00:54.772122500 -0600 +@@ -25,13 +25,17 @@ + /* Call lstat to get the device and inode numbers for '/'. + Upon failure, return NULL. Otherwise, set the members of + *ROOT_D_I accordingly and return ROOT_D_I. */ +-struct dev_ino * +-get_root_dev_ino (struct dev_ino *root_d_i) ++struct root_dev_ino * ++get_root_dev_ino (struct root_dev_ino *root_d_i) + { + struct stat statbuf; + if (lstat ("/", &statbuf)) + return nullptr; +- root_d_i->st_ino = statbuf.st_ino; +- root_d_i->st_dev = statbuf.st_dev; ++ root_d_i->single_slash.st_ino = statbuf.st_ino; ++ root_d_i->single_slash.st_dev = statbuf.st_dev; ++ if (lstat ("//", &statbuf)) ++ return nullptr; ++ root_d_i->double_slash.st_ino = statbuf.st_ino; ++ root_d_i->double_slash.st_dev = statbuf.st_dev; + return root_d_i; + } diff --git a/coreutils/coreutils-9.4-src-chcon.c.patch b/coreutils/coreutils-9.4-src-chcon.c.patch new file mode 100644 index 00000000..00673415 --- /dev/null +++ b/coreutils/coreutils-9.4-src-chcon.c.patch @@ -0,0 +1,20 @@ +--- origsrc/src/chcon.c 2023-07-05 05:09:55.000000000 -0600 ++++ src/src/chcon.c 2023-09-09 20:07:55.163173700 -0600 +@@ -47,7 +47,7 @@ static bool verbose; + + /* Pointer to the device and inode numbers of '/', when --recursive. + Otherwise nullptr. */ +-static struct dev_ino *root_dev_ino; ++static struct root_dev_ino *root_dev_ino; + + /* The name of the context file is being given. */ + static char const *specified_context; +@@ -571,7 +571,7 @@ main (int argc, char **argv) + + if (recurse && preserve_root) + { +- static struct dev_ino dev_ino_buf; ++ static struct root_dev_ino dev_ino_buf; + root_dev_ino = get_root_dev_ino (&dev_ino_buf); + if (root_dev_ino == nullptr) + die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), diff --git a/coreutils/coreutils-9.4-src-chmod.c.patch b/coreutils/coreutils-9.4-src-chmod.c.patch new file mode 100644 index 00000000..7f35aaa4 --- /dev/null +++ b/coreutils/coreutils-9.4-src-chmod.c.patch @@ -0,0 +1,20 @@ +--- origsrc/src/chmod.c 2023-08-29 05:39:27.000000000 -0600 ++++ src/src/chmod.c 2023-09-09 20:16:41.171411900 -0600 +@@ -87,7 +87,7 @@ static enum Verbosity verbosity = V_off; + + /* Pointer to the device and inode numbers of '/', when --recursive. + Otherwise nullptr. */ +-static struct dev_ino *root_dev_ino; ++static struct root_dev_ino *root_dev_ino; + + /* For long options that have no equivalent short option, use a + non-character as a pseudo short option, starting with CHAR_MAX + 1. */ +@@ -553,7 +553,7 @@ main (int argc, char **argv) + + if (recurse && preserve_root) + { +- static struct dev_ino dev_ino_buf; ++ static struct root_dev_ino dev_ino_buf; + root_dev_ino = get_root_dev_ino (&dev_ino_buf); + if (root_dev_ino == nullptr) + die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), diff --git a/coreutils/coreutils-9.4-src-chown-core.h.patch b/coreutils/coreutils-9.4-src-chown-core.h.patch new file mode 100644 index 00000000..5037a448 --- /dev/null +++ b/coreutils/coreutils-9.4-src-chown-core.h.patch @@ -0,0 +1,11 @@ +--- origsrc/src/chown-core.h 2023-07-05 05:09:55.000000000 -0600 ++++ src/src/chown-core.h 2023-09-09 20:22:55.569928600 -0600 +@@ -51,7 +51,7 @@ struct Chown_option + + /* Pointer to the device and inode numbers of '/', when --recursive. + Need not be freed. Otherwise nullptr. */ +- struct dev_ino *root_dev_ino; ++ struct root_dev_ino *root_dev_ino; + + /* This corresponds to the --dereference (opposite of -h) option. */ + bool affect_symlink_referent; diff --git a/coreutils/coreutils-9.4-src-copy.c.patch b/coreutils/coreutils-9.4-src-copy.c.patch new file mode 100644 index 00000000..dba357f8 --- /dev/null +++ b/coreutils/coreutils-9.4-src-copy.c.patch @@ -0,0 +1,158 @@ +--- origsrc/src/copy.c 2023-08-29 05:39:27.000000000 -0600 ++++ src/src/copy.c 2023-09-09 22:06:16.745397400 -0600 +@@ -83,6 +83,10 @@ + #ifdef HAVE_LINUX_FS_H + # include + #endif ++ ++#ifdef __CYGWIN__ ++# include "cygwin.h" ++#endif + + #if !defined FICLONE && defined __linux__ + # define FICLONE _IOW (0x94, 9, int) +@@ -1738,7 +1742,11 @@ close_src_desc: + static bool + same_file_ok (char const *src_name, struct stat const *src_sb, + int dst_dirfd, char const *dst_relname, struct stat const *dst_sb, +- const struct cp_options *x, bool *return_now) ++ const struct cp_options *x, bool *return_now ++#if __CYGWIN__ ++ , bool *case_change ++#endif ++ ) + { + const struct stat *src_sb_link; + const struct stat *dst_sb_link; +@@ -1883,6 +1891,18 @@ same_file_ok (char const *src_name, stru + if (S_ISLNK (dst_sb_link->st_mode)) + return true; + ++#if __CYGWIN__ ++ /* If the files have the same name, but differ in case, then let ++ rename() change the case. */ ++ if (same_link && x->move_mode && same_name (src_name, dst_relname) ++ && memcmp (last_component (src_name), last_component (dst_relname), ++ base_len (src_name))) ++ { ++ *case_change = true; ++ return true; ++ } ++#endif ++ + /* It's not ok if they're distinct hard links to the same file as + this causes a race condition and we may lose data in this case. */ + if (same_link +@@ -2316,13 +2336,23 @@ copy_internal (char const *src_name, cha + if (!use_lstat && nonexistent_dst < 0) + new_dst = true; + else if (follow_fstatat (dst_dirfd, drelname, &dst_sb, fstatat_flags) +- == 0) ++ == 0 ++#if __CYGWIN__ ++ /* stat("a") succeeds if "a.exe" - only identical accepted. */ ++ && cygwin_spelling (drelname) == 0 ++#endif ++ ) + { + have_dst_lstat = use_lstat; + rename_errno = EEXIST; + } + else + { ++#if __CYGWIN__ ++ /* only DST_RELNAME.exe exists - want non-existant DST_RELNAME. */ ++ if (cygwin_spelling (drelname) != 0) ++ errno = ENOENT; ++#endif + if (errno == ELOOP && x->unlink_dest_after_failed_open) + /* leave new_dst=false so we unlink later. */; + else if (errno != ENOENT) +@@ -2340,10 +2370,17 @@ copy_internal (char const *src_name, cha + bool return_now = false; + bool return_val = true; + bool skipped = false; ++#if __CYGWIN__ ++ bool case_change = false; ++#endif + + if ((x->interactive != I_ALWAYS_NO && x->interactive != I_ALWAYS_SKIP) + && ! same_file_ok (src_name, &src_sb, dst_dirfd, drelname, +- &dst_sb, x, &return_now)) ++ &dst_sb, x, &return_now ++#if __CYGWIN__ ++ , &case_change ++#endif ++ )) + { + error (0, 0, _("%s and %s are the same file"), + quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); +@@ -2406,6 +2443,9 @@ copy_internal (char const *src_name, cha + cp and mv treat -i and -f differently. */ + if (x->move_mode) + { ++#if __CYGWIN__ ++ if (!case_change) ++#endif + if (abandon_move (x, dst_name, dst_dirfd, drelname, &dst_sb)) + { + /* Pretend the rename succeeded, so the caller (mv) +@@ -2572,7 +2612,11 @@ skip: + && ! x->move_mode + && (x->unlink_dest_before_opening + || (x->data_copy_required +- && ((x->preserve_links && 1 < dst_sb.st_nlink) ++ && ((x->preserve_links && 1 < dst_sb.st_nlink ++#if __CYGWIN__ ++ && ! case_change ++#endif ++ ) + || (x->dereference == DEREF_NEVER + && ! S_ISREG (src_sb.st_mode)))) + )) +@@ -3407,6 +3451,24 @@ copy (char const *src_name, char const * + { + valid_options (options); + ++#if __CYGWIN__ ++ /* .exe magic - if src exists with an implicit .exe suffix and is ++ not a symlink, but dst does not exist and was also specified ++ without a suffix, then append .exe to dst. */ ++ int cygwin = cygwin_spelling (src_name); ++ char *p; ++ if (cygwin == 2 ++ && ((p = strchr (dst_name, '\0') - 4) <= dst_name ++ || strcasecmp (p, ".exe") != 0)) ++ { ++ cygwin = 3; ++ CYGWIN_APPEND_EXE (p, dst_name); ++ if ((p = strchr (dst_relname, '\0') - 4) <= dst_relname ++ || strcasecmp (p, ".exe") != 0) ++ CYGWIN_APPEND_EXE (p, dst_relname); ++ } ++#endif ++ + /* Record the file names: they're used in case of error, when copying + a directory into itself. I don't like to make these tools do *any* + extra work in the common case when that work is solely to handle +@@ -3418,11 +3480,19 @@ copy (char const *src_name, char const * + top_level_dst_name = dst_name; + + bool first_dir_created_per_command_line_arg = false; +- return copy_internal (src_name, dst_name, dst_dirfd, dst_relname, ++ bool done = copy_internal (src_name, dst_name, dst_dirfd, dst_relname, + nonexistent_dst, nullptr, nullptr, + options, true, + &first_dir_created_per_command_line_arg, + copy_into_self, rename_succeeded); ++#if __CYGWIN__ ++ if (cygwin == 3) ++ { ++ freea ((char *) dst_name); ++ freea ((char *) dst_relname); ++ } ++#endif ++ return done; + } + + /* Set *X to the default options for a value of type struct cp_options. */ diff --git a/coreutils/coreutils-9.4-src-install.c.patch b/coreutils/coreutils-9.4-src-install.c.patch new file mode 100644 index 00000000..7111b0b4 --- /dev/null +++ b/coreutils/coreutils-9.4-src-install.c.patch @@ -0,0 +1,30 @@ +--- origsrc/src/install.c 2023-07-05 05:09:55.000000000 -0600 ++++ src/src/install.c 2023-09-09 22:14:29.695309700 -0600 +@@ -44,6 +44,10 @@ + #include "utimens.h" + #include "xstrtol.h" + ++#ifdef __CYGWIN__ ++# include "cygwin.h" ++#endif ++ + /* The official name of this program (e.g., no 'g' prefix). */ + #define PROGRAM_NAME "install" + +@@ -504,6 +508,16 @@ strip (char const *name) + char const *safe_name = name; + if (name && *name == '-') + safe_name = file_name_concat (".", name, nullptr); ++#if __CYGWIN__ ++ { ++ /* Check for .exe here, since strip doesn't. */ ++ char *p; ++ if (((p = strchr (safe_name, '\0') - 4) <= safe_name ++ || strcasecmp (p, ".exe") != 0) ++ && 0 < cygwin_spelling (safe_name)) ++ CYGWIN_APPEND_EXE (p, safe_name); ++ } ++#endif /* __CYGWIN__ */ + execlp (strip_program, strip_program, safe_name, nullptr); + error (EXIT_FAILURE, errno, _("cannot run %s"), + quoteaf (strip_program)); diff --git a/coreutils/coreutils-9.4-src-ls.c.patch b/coreutils/coreutils-9.4-src-ls.c.patch new file mode 100644 index 00000000..f7b4e4c3 --- /dev/null +++ b/coreutils/coreutils-9.4-src-ls.c.patch @@ -0,0 +1,114 @@ +--- origsrc/src/ls.c 2023-08-29 05:39:27.000000000 -0600 ++++ src/src/ls.c 2023-09-10 13:32:12.438677000 -0600 +@@ -122,6 +122,10 @@ + # include + #endif + ++#ifdef __CYGWIN__ ++# include "cygwin.h" ++#endif ++ + #define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \ + : (ls_mode == LS_MULTI_COL \ + ? "dir" : "vdir")) +@@ -791,6 +795,11 @@ static char const *long_time_format[2] = + N_("%b %e %H:%M") + }; + ++#if __CYGWIN__ ++/* Whether .exe should be appended to command-line args as needed. */ ++static bool append_exe; ++#endif /* __CYGWIN__ */ ++ + /* The set of signals that are caught. */ + + static sigset_t caught_signals; +@@ -826,6 +835,9 @@ enum + enum + { + AUTHOR_OPTION = CHAR_MAX + 1, ++#ifdef __CYGWIN__ ++ APPEND_EXE_OPTION, ++#endif + BLOCK_SIZE_OPTION, + COLOR_OPTION, + DEREFERENCE_COMMAND_LINE_SYMLINK_TO_DIR_OPTION, +@@ -891,6 +903,9 @@ static struct option const long_options[ + {"block-size", required_argument, nullptr, BLOCK_SIZE_OPTION}, + {"context", no_argument, 0, 'Z'}, + {"author", no_argument, nullptr, AUTHOR_OPTION}, ++#ifdef __CYGWIN__ ++ {"append-exe", no_argument, nullptr, APPEND_EXE_OPTION}, ++#endif + {GETOPT_HELP_OPTION_DECL}, + {GETOPT_VERSION_OPTION_DECL}, + {nullptr, 0, nullptr, 0} +@@ -2233,6 +2248,12 @@ decode_switches (int argc, char **argv) + quoting_style_opt = literal_quoting_style; + break; + ++#ifdef __CYGWIN__ ++ case APPEND_EXE_OPTION: ++ append_exe = true; ++ break; ++#endif ++ + case_GETOPT_HELP_CHAR; + + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); +@@ -3373,6 +3394,12 @@ gobble_file (char const *name, enum file + uintmax_t blocks = 0; + struct fileinfo *f; + ++#ifdef __CYGWIN__ ++ char *name_alt = nullptr; ++ if (command_line_arg && append_exe && 0 < cygwin_spelling (name)) ++ CYGWIN_APPEND_EXE (name_alt, name); ++#endif /* __CYGWIN__ */ ++ + /* An inode value prior to gobble_file necessarily came from readdir, + which is not used for command line arguments. */ + affirm (! command_line_arg || inode == NOT_AN_INODE_NUMBER); +@@ -3507,11 +3534,19 @@ gobble_file (char const *name, enum file + f->scontext = UNKNOWN_SECURITY_CONTEXT; + + if (command_line_arg) +- return 0; ++ { ++#ifdef __CYGWIN__ ++ freea (name_alt); ++#endif ++ return 0; ++ } + + f->name = xstrdup (name); + cwd_n_used++; + ++#ifdef __CYGWIN__ ++ freea (name_alt); ++#endif + return 0; + } + +@@ -3688,6 +3723,9 @@ gobble_file (char const *name, enum file + f->name = xstrdup (name); + cwd_n_used++; + ++#ifdef __CYGWIN__ ++ freea (name_alt); ++#endif + return blocks; + } + +@@ -5612,6 +5650,11 @@ Sort entries alphabetically if none of - + --zero end each output line with NUL, not newline\n\ + -1 list one file per line\n\ + "), stdout); ++#if __CYGWIN__ ++ fputs (_("\ ++ --append-exe append .exe if cygwin magic was needed\n\ ++"), stdout); ++#endif /* __CYGWIN__ */ + fputs (HELP_OPTION_DESCRIPTION, stdout); + fputs (VERSION_OPTION_DESCRIPTION, stdout); + emit_size_note (); diff --git a/coreutils/coreutils-9.4-src-remove.h.patch b/coreutils/coreutils-9.4-src-remove.h.patch new file mode 100644 index 00000000..ac35f3cc --- /dev/null +++ b/coreutils/coreutils-9.4-src-remove.h.patch @@ -0,0 +1,11 @@ +--- origsrc/src/remove.h 2023-09-10 13:37:14.816502400 -0600 ++++ src/src/remove.h 2023-09-10 13:36:42.028328800 -0600 +@@ -54,7 +54,7 @@ struct rm_options + + /* Pointer to the device and inode numbers of '/', when --recursive + and preserving '/'. Otherwise null. */ +- struct dev_ino *root_dev_ino; ++ struct root_dev_ino *root_dev_ino; + + /* If true, do not traverse into (or remove) any directory that is + the root of a file system. I.e., a separate device. */ diff --git a/coreutils/coreutils-9.4-src-stat.c.patch b/coreutils/coreutils-9.4-src-stat.c.patch new file mode 100644 index 00000000..66300ee9 --- /dev/null +++ b/coreutils/coreutils-9.4-src-stat.c.patch @@ -0,0 +1,120 @@ +--- origsrc/src/stat.c 2023-08-29 05:39:27.000000000 -0600 ++++ src/src/stat.c 2023-09-10 13:40:50.600410000 -0600 +@@ -71,6 +71,13 @@ + #include "xvasprintf.h" + #include "statx.h" + ++#ifdef __CYGWIN__ ++# include "cygwin.h" ++/* Whether .exe should be appended to command-line args as needed. */ ++static bool append_exe; ++# define APPEND_EXE_OPTION 10000 ++#endif ++ + #if HAVE_STATX && defined STATX_INO + # define USE_STATX 1 + #else +@@ -223,6 +230,9 @@ static struct option const long_options[ + {"printf", required_argument, nullptr, PRINTF_OPTION}, + {"terse", no_argument, nullptr, 't'}, + {"cached", required_argument, nullptr, 0}, ++#ifdef __CYGWIN__ ++ {"append-exe", no_argument, nullptr, APPEND_EXE_OPTION}, ++#endif + {GETOPT_HELP_OPTION_DECL}, + {GETOPT_VERSION_OPTION_DECL}, + {nullptr, 0, nullptr, 0} +@@ -1267,14 +1277,26 @@ do_statfs (char const *filename, char co + return false; + } + ++#ifdef __CYGWIN__ ++ char *name_alt = nullptr; ++ if (append_exe && 0 < cygwin_spelling (filename)) ++ CYGWIN_APPEND_EXE (name_alt, filename); ++#endif /* __CYGWIN__ */ ++ + if (STATFS (filename, &statfsbuf) != 0) + { + error (0, errno, _("cannot read file system information for %s"), + quoteaf (filename)); ++#if __CYGWIN__ ++ freea (name_alt); ++#endif /* __CYGWIN__ */ + return false; + } + + bool fail = print_it (format, -1, filename, print_statfs, &statfsbuf); ++#if __CYGWIN__ ++ freea (name_alt); ++#endif /* __CYGWIN__ */ + return ! fail; + } + +@@ -1459,6 +1481,7 @@ do_stat (char const *filename, char const + int fd = STREQ (filename, "-") ? 0 : -1; + struct stat statbuf; + struct print_args pa; ++ char *name_alt = nullptr; + pa.st = &statbuf; + pa.btime = (struct timespec) {-1, -1}; + +@@ -1473,18 +1496,28 @@ do_stat (char const *filename, char cons + /* We can't use the shorter + (follow_links?stat:lstat) (filename, &statbug) + since stat might be a function-like macro. */ +- else if ((follow_links +- ? stat (filename, &statbuf) +- : lstat (filename, &statbuf)) != 0) ++ else + { +- error (0, errno, _("cannot stat %s"), quoteaf (filename)); +- return false; ++ if ((follow_links ++ ? stat (filename, &statbuf) ++ : lstat (filename, &statbuf)) != 0) ++ { ++ error (0, errno, _("cannot stat %s"), quoteaf (filename)); ++ return false; ++ } ++#ifdef __CYGWIN__ ++ if (append_exe && 0 < cygwin_spelling (filename)) ++ CYGWIN_APPEND_EXE (name_alt, filename); ++#endif /* __CYGWIN__ */ + } + + if (S_ISBLK (statbuf.st_mode) || S_ISCHR (statbuf.st_mode)) + format = format2; + + bool fail = print_it (format, fd, filename, print_stat, &pa); ++#if __CYGWIN__ ++ freea (name_alt); ++#endif /* __CYGWIN__ */ + return ! fail; + } + +@@ -1775,6 +1808,11 @@ Display file or file system status.\n\ + if you want a newline, include \\n in FORMAT\n\ + -t, --terse print the information in terse form\n\ + "), stdout); ++#if __CYGWIN__ ++ fputs (_("\ ++ --append-exe append .exe if cygwin magic was needed\n\ ++"), stdout); ++#endif /* __CYGWIN__ */ + fputs (HELP_OPTION_DESCRIPTION, stdout); + fputs (VERSION_OPTION_DESCRIPTION, stdout); + +@@ -1941,6 +1979,12 @@ main (int argc, char *argv[]) + } + break; + ++#if __CYGWIN__ ++ case APPEND_EXE_OPTION: ++ append_exe = true; ++ break; ++#endif /* __CYGWIN__ */ ++ + case_GETOPT_HELP_CHAR; + + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); diff --git a/coreutils/cygwin.c b/coreutils/cygwin.c new file mode 100644 index 00000000..d6cc0486 --- /dev/null +++ b/coreutils/cygwin.c @@ -0,0 +1,73 @@ +/* cygwin.c - helper functions unique to Cygwin + + Copyright (C) 2005, 2006, 2008, 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Written by Eric Blake. */ + +#include + +#include "cygwin.h" + +#include +#include +#include +#include + +/* Return -1 if PATH is not found, 0 if PATH will not have .exe + appended (it is possible that a PATH that does not exist still + returns 0 instead of -1, or fails for a PATH that exists but cannot + be stat'ed), and positive if PATH has ".exe" automatically appended + by cygwin (1 if PATH is a symlink, 2 otherwise). Won't change errno. */ + +int +cygwin_spelling (char const *path) +{ + int saved_errno = errno; + int result = 0; /* Start with assumption that PATH is okay. */ + size_t len; + struct stat st1; + struct stat st2; + char *path_exe; + + /* If PATH will cause EINVAL or ENAMETOOLONG, treat it as missing. */ + if (! path || ! *path) + return -1; + if (PATH_MAX < (len = strlen (path))) + return -1; + /* Don't change spelling if there is a trailing `/' or '.exe'. */ + if (path[len - 1] == '/' + || (len > 4 && !strcasecmp (&path[len - 4], ".exe"))) + return 0; + if (lstat (path, &st1) < 0) + { + errno = saved_errno; + return -1; + } + if (S_ISDIR(st1.st_mode)) + { + errno = saved_errno; + return 0; + } + path_exe = malloca (len + 5); /* adding ".exe" and NUL. */ + strcat (stpcpy (path_exe, path), ".exe"); + if (lstat (path_exe, &st2) == 0 && st1.st_ino == st2.st_ino) + result = 1 + !S_ISLNK(st1.st_mode); + freea (path_exe); + + errno = saved_errno; + return result; +} diff --git a/coreutils/cygwin.h b/coreutils/cygwin.h new file mode 100644 index 00000000..d0318f58 --- /dev/null +++ b/coreutils/cygwin.h @@ -0,0 +1,38 @@ +/* cygwin.h - helper functions unique to Cygwin + + Copyright (C) 2005, 2006, 2008, 2010, 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Written by Eric Blake. */ + +#ifndef CYGWIN_H +# define CYGWIN_H 1 + +#include "malloca.h" + +int cygwin_spelling (char const *); + +/* Append ".exe" to char *__NAME_ORIG, where __NAME is either NULL or + between __NAME_ORIG and the nul terminator. Both params will be + evaluated more than once and assigned the new value. The user must + later call freea(__NAME). */ +#define CYGWIN_APPEND_EXE(__name, __name_orig) \ + __name_orig = __name = \ + strcat (strcpy (malloca (strchr (__name ? __name : __name_orig, '\0') \ + - (__name_orig) + 5), \ + __name_orig), ".exe") + +#endif /* CYGWIN_H */