Make patches relative to where tarballs are extracted

Ever since an old patch version, it has (for reasonable security
reasons) not supported patched with ../ in the filename.
Many of our patches have been relying on this behaviour being OK,
because we start off with an ancient patch version that didn't perform
such checks. As soon as we need this behaviour after we build a newer
patch though, we will have problems.

So, let's change the policy.
Patches are relative to where tarballs are extracted, rather than the
"working directory" - e.g. have patches for `coreutils-9.4/src/cp.c`
instead of `src/cp.c`.
Keeping this consistent has a few implications;
- patches are applied from the build/ directory in bash era now, with
  `-p0`
- when patches are manually applied in the bash era, use `-p` as
  required, usually `-p1`
- in kaem era where patches are always manually applied, `-p1` is used
This commit is contained in:
fosslinux 2024-12-21 16:50:23 +11:00
parent 749b2bfe37
commit a67db8fcbd
156 changed files with 1265 additions and 1263 deletions

View file

@ -35,15 +35,15 @@ rm src/false.c
rm src/dircolors.h
patch -Np0 -i ../../patches/modechange.patch
patch -Np0 -i ../../patches/mbstate.patch
patch -Np0 -i ../../patches/ls-strcmp.patch
patch -Np0 -i ../../patches/touch-getdate.patch
patch -Np0 -i ../../patches/touch-dereference.patch
patch -Np0 -i ../../patches/tac-uint64.patch
patch -Np0 -i ../../patches/expr-strcmp.patch
patch -Np0 -i ../../patches/sort-locale.patch
patch -Np0 -i ../../patches/uniq-fopen.patch
patch -Np1 -i ../../patches/modechange.patch
patch -Np1 -i ../../patches/mbstate.patch
patch -Np1 -i ../../patches/ls-strcmp.patch
patch -Np1 -i ../../patches/touch-getdate.patch
patch -Np1 -i ../../patches/touch-dereference.patch
patch -Np1 -i ../../patches/tac-uint64.patch
patch -Np1 -i ../../patches/expr-strcmp.patch
patch -Np1 -i ../../patches/sort-locale.patch
patch -Np1 -i ../../patches/uniq-fopen.patch
# Build and install
make -f Makefile PREFIX=${PREFIX}

View file

@ -4,8 +4,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
strcoll() does not exist in mes libc, change it to strcmp.
--- src/expr.c
+++ src/expr.c
--- coreutils-5.0/src/expr.c
+++ coreutils-5.0/src/expr.c
@@ -332,7 +332,7 @@ nextarg (char *str)
return 0;
else

View file

@ -5,8 +5,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
strcoll() does not exist in mes libc, change it to strcmp.
--- src/ls.c
+++ src/ls.c
--- coreutils-5.0/src/ls.c
+++ coreutils-5.0/src/ls.c
@@ -2597,7 +2597,7 @@ xstrcoll (char const *a, char const *b)
{
int diff;

View file

@ -6,8 +6,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
mbstate_t is a struct that is required. However, it is not defined by mes libc.
This implementation was taken from glibc 2.32.
--- lib/quotearg.c 2002-11-23 07:08:10.000000000 +0000
+++ lib/quotearg.c 2021-01-17 19:41:59.461095532 +0000
--- coreutils-5.0/lib/quotearg.c 2002-11-23 07:08:10.000000000 +0000
+++ coreutils-5.0/lib/quotearg.c 2021-01-17 19:41:59.461095532 +0000
@@ -21,6 +21,7 @@
# include <config.h>
#endif
@ -16,8 +16,8 @@ This implementation was taken from glibc 2.32.
#include "quotearg.h"
#include "xalloc.h"
--- lib/mbstate_t.h 1970-01-01 01:00:00.000000000 +0100
+++ lib/mbstate_t.h 2021-01-17 19:42:21.341658668 +0000
--- coreutils-5.0/lib/mbstate_t.h 1970-01-01 01:00:00.000000000 +0100
+++ coreutils-5.0/lib/mbstate_t.h 2021-01-17 19:42:21.341658668 +0000
@@ -0,0 +1,23 @@
+#ifndef ____mbstate_t_defined
+#define ____mbstate_t_defined 1

View file

@ -6,8 +6,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
modechange.h uses functions defined in sys/stat.h, so we need to move it to
after sys/stat.h include.
--- lib/modechange.c 2001-12-09 22:54:19.000000000 +0000
+++ lib/modechange.c 2021-01-17 18:34:22.016427148 +0000
--- coreutils-5.0/lib/modechange.c 2001-12-09 22:54:19.000000000 +0000
+++ coreutils-5.0/lib/modechange.c 2021-01-17 18:34:22.016427148 +0000
@@ -28,8 +28,8 @@
# include <config.h>
#endif

View file

@ -5,8 +5,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
strcoll() does not exist in mes libc, change it to strcmp.
hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset.
--- lib/memcoll.c
+++ lib/memcoll.c
--- coreutils-5.0/lib/memcoll.c
+++ coreutils-5.0/lib/memcoll.c
@@ -47,7 +47,7 @@ memcoll (char *s1, size_t s1len, char *s2, size_t s2len)
s1[s1len++] = '\0';
s2[s2len++] = '\0';
@ -17,8 +17,8 @@ hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset.
/* strcoll found no difference, but perhaps it was fooled by NUL
characters in the data. Work around this problem by advancing
--- src/sort.c
+++ src/sort.c
--- coreutils-5.0/src/sort.c
+++ coreutils-5.0/src/sort.c
@@ -91,13 +91,13 @@ double strtod ();
#define NEGATION_SIGN '-'
#define NUMERIC_ZERO '0'

View file

@ -3,8 +3,8 @@ SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
SPDX-License-Identifier: GPL-2.0-or-later
uint64_t is not supported in tcc 0.9.27
--- lib/tempname.c 2002-12-01 10:40:32.000000000 +0000
+++ lib/tempname.c 2022-06-22 20:57:37.449423973 +0100
--- coreutils-5.0/lib/tempname.c 2002-12-01 10:40:32.000000000 +0000
+++ coreutils-5.0/lib/tempname.c 2022-06-22 20:57:37.449423973 +0100
@@ -231,8 +231,8 @@
{
int len;

View file

@ -6,8 +6,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
touch: add -h to change symlink timestamps, where supported
diff -r -U3 coreutils-5.0.orig/src/touch.c coreutils-5.0/src/touch.c
--- src/touch.c 2002-12-20 20:09:22.000000000 +0000
+++ src/touch.c 2022-05-16 20:31:37.801988595 +0100
--- coreutils-5.0/src/touch.c 2002-12-20 20:09:22.000000000 +0000
+++ coreutils-5.0/src/touch.c 2022-05-16 20:31:37.801988595 +0100
@@ -77,6 +77,9 @@
/* (-r) If nonzero, use times from a reference file. */
static int use_ref;

View file

@ -6,8 +6,8 @@ getdate.c is pre-compiled from getdate.y
At this point we don't have bison yet and in any case getdate.y does not
compile when generated with modern bison.
--- src/touch.c.orig 2021-03-13 18:16:05.344355958 +0000
+++ src/touch.c 2021-03-13 18:16:26.204891355 +0000
--- coreutils-5.0/src/touch.c.orig 2021-03-13 18:16:05.344355958 +0000
+++ coreutils-5.0/src/touch.c 2021-03-13 18:16:26.204891355 +0000
@@ -306,7 +306,7 @@
case 'd':

View file

@ -6,8 +6,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
uniq: don't assume fopen cannot return stdin or stdout.
Backport of https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=786ebb2ceca72f69aa2de701671fb41f53cb1489
--- src/uniq.c
+++ src/uniq.c
--- coreutils-5.0/src/uniq.c
+++ coreutils-5.0/src/uniq.c
@@ -30,6 +30,7 @@
#include "error.h"
#include "hard-locale.h"