aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches
diff options
context:
space:
mode:
authorLiliana Marie Prikler <liliana.prikler@gmail.com>2023-07-23 10:11:29 +0200
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2023-07-23 10:11:29 +0200
commit4c204d01d57ac7da11a5772d5d4e3254d1c2408f (patch)
treec7e5cb013abc742734acd9613674df4ebddfdeef /gnu/packages/patches
parent82bdb77082fa4e100761f70086b745dfb280c3ac (diff)
parent445a0359083388b5ee686e6e855f94a3aac5f79c (diff)
downloadguix-4c204d01d57ac7da11a5772d5d4e3254d1c2408f.tar
guix-4c204d01d57ac7da11a5772d5d4e3254d1c2408f.tar.gz
Merge branch 'master' into gnome-team
Diffstat (limited to 'gnu/packages/patches')
-rw-r--r--gnu/packages/patches/arpack-ng-propagate-rng-state.patch523
-rw-r--r--gnu/packages/patches/biber-adapt-perl-5.36.patch40
-rw-r--r--gnu/packages/patches/doxygen-hurd.patch30
-rw-r--r--gnu/packages/patches/fontforge-hurd.patch82
-rw-r--r--gnu/packages/patches/ghostscript-CVE-2023-36664-fixup.patch56
-rw-r--r--gnu/packages/patches/ghostscript-CVE-2023-36664.patch142
-rw-r--r--gnu/packages/patches/ghostscript-leptonica-hurd.patch78
-rw-r--r--gnu/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch61
-rw-r--r--gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch135
-rw-r--r--gnu/packages/patches/glibc-2.37-versioned-locpath.patch264
-rw-r--r--gnu/packages/patches/gnumach-add-missing-const_mach_port_name_array_t-type.patch32
-rw-r--r--gnu/packages/patches/gnumach-support-noide.patch25
-rw-r--r--gnu/packages/patches/hurd-fix-rumpdisk-build.patch41
-rw-r--r--gnu/packages/patches/hurd-rumpdisk-no-hd.patch26
-rw-r--r--gnu/packages/patches/libmateweather-use-TZDIR.patch42
-rw-r--r--gnu/packages/patches/linux-libre-wireguard-postup-privkey.patch119
-rw-r--r--gnu/packages/patches/mactelnet-remove-init.patch98
-rw-r--r--gnu/packages/patches/mig-cpu.h-generation.patch16
-rw-r--r--gnu/packages/patches/netdde-build-fix.patch28
-rw-r--r--gnu/packages/patches/oath-toolkit-xmlsec-compat.patch79
-rw-r--r--gnu/packages/patches/qxlsx-fix-include-directory.patch24
-rw-r--r--gnu/packages/patches/racket-rktboot-riscv64-support.patch15
-rw-r--r--gnu/packages/patches/sssd-system-directories.patch19
-rw-r--r--gnu/packages/patches/texlive-hyph-utf8-no-byebug.patch13
-rw-r--r--gnu/packages/patches/u-boot-allow-disabling-openssl.patch13
-rw-r--r--gnu/packages/patches/u-boot-fix-u-boot-lib-build.patch24
-rw-r--r--gnu/packages/patches/u-boot-infodocs-target.patch84
-rw-r--r--gnu/packages/patches/u-boot-patman-guix-integration.patch1244
-rw-r--r--gnu/packages/patches/u-boot-sifive-prevent-reloc-initrd-fdt.patch8
-rw-r--r--gnu/packages/patches/zig-0.9-riscv-support.patch47
30 files changed, 1875 insertions, 1533 deletions
diff --git a/gnu/packages/patches/arpack-ng-propagate-rng-state.patch b/gnu/packages/patches/arpack-ng-propagate-rng-state.patch
new file mode 100644
index 0000000000..4466bb8e50
--- /dev/null
+++ b/gnu/packages/patches/arpack-ng-propagate-rng-state.patch
@@ -0,0 +1,523 @@
+Fix a bug that manifests while running the test suite of 'python-igraph':
+
+ https://github.com/opencollab/arpack-ng/issues/401
+ https://github.com/opencollab/arpack-ng/pull/414
+
+From d885b7be4ecdc9c1496f2d6f256f6c0d34962459 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Szabolcs=20Horva=CC=81t?= <szhorvat@gmail.com>
+Date: Sun, 9 Apr 2023 16:36:35 +0200
+Subject: [PATCH] fix: ensure that LAPACK RNG state is propagated
+
+ - fixes #401, #410, #411
+ - restores 'inits' variable removed in ce2e69a849da1d10dad5d6d3ec4db6120b3ecf50, ensuring that the RNG state is propagated
+ - reverts e0d67054f573da351f12a226f7c7cc65a690ef3d to ensure that seed is different on each parallel thread
+ - updates seed initialization of parallel pdgetv0/psgetv0 so that they match that of pzgetv0/pcgetv0
+---
+ PARPACK/SRC/MPI/pcgetv0.f | 48 +++++++++++++++++++++++----------------
+ PARPACK/SRC/MPI/pdgetv0.f | 40 ++++++++++++++++++++++++++------
+ PARPACK/SRC/MPI/psgetv0.f | 43 ++++++++++++++++++++++++++---------
+ PARPACK/SRC/MPI/pzgetv0.f | 48 +++++++++++++++++++++++----------------
+ SRC/cgetv0.f | 21 ++++++++++++-----
+ SRC/dgetv0.f | 21 ++++++++++++-----
+ SRC/sgetv0.f | 21 ++++++++++++-----
+ SRC/zgetv0.f | 21 ++++++++++++-----
+ 8 files changed, 183 insertions(+), 80 deletions(-)
+
+diff --git a/PARPACK/SRC/MPI/pcgetv0.f b/PARPACK/SRC/MPI/pcgetv0.f
+index 59e3d1658..24fe8a0f1 100644
+--- a/PARPACK/SRC/MPI/pcgetv0.f
++++ b/PARPACK/SRC/MPI/pcgetv0.f
+@@ -176,13 +176,13 @@ subroutine pcgetv0
+ c | Local Scalars & Arrays |
+ c %------------------------%
+ c
+- logical first, orth
++ logical first, inits, orth
+ integer idist, iseed(4), iter, msglvl, jj, myid, igen
+ Real
+ & rnorm0
+ Complex
+ & cnorm, cnorm2
+- save first, iseed, iter, msglvl, orth, rnorm0
++ save first, iseed, inits, iter, msglvl, orth, rnorm0
+ c
+ Complex
+ & cnorm_buf, buf2(1)
+@@ -203,6 +203,12 @@ subroutine pcgetv0
+ & ccdotc
+ external ccdotc, pscnorm2, slapy2
+ c
++c %-----------------%
++c | Data Statements |
++c %-----------------%
++c
++ data inits /.true./
++c
+ c %-----------------------%
+ c | Executable Statements |
+ c %-----------------------%
+@@ -213,26 +219,30 @@ subroutine pcgetv0
+ c | random number generator |
+ c %-----------------------------------%
+ c
++ if (inits) then
+ c
+-c %-----------------------------------%
+-c | Generate a seed on each processor |
+-c | using process id (myid). |
+-c | Note: the seed must be between 1 |
+-c | and 4095. iseed(4) must be odd. |
+-c %-----------------------------------%
++c %-----------------------------------%
++c | Generate a seed on each processor |
++c | using process id (myid). |
++c | Note: the seed must be between 1 |
++c | and 4095. iseed(4) must be odd. |
++c %-----------------------------------%
+ c
+- call MPI_COMM_RANK(comm, myid, ierr)
+- igen = 1000 + 2*myid + 1
+- if (igen .gt. 4095) then
+- write(0,*) 'Error in p_getv0: seed exceeds 4095!'
+- end if
++ call MPI_COMM_RANK(comm, myid, ierr)
++ igen = 1000 + 2*myid + 1
++ if (igen .gt. 4095) then
++ write(0,*) 'Error in p_getv0: seed exceeds 4095!'
++ end if
++c
++ iseed(1) = igen/1000
++ igen = mod(igen,1000)
++ iseed(2) = igen/100
++ igen = mod(igen,100)
++ iseed(3) = igen/10
++ iseed(4) = mod(igen,10)
+ c
+- iseed(1) = igen/1000
+- igen = mod(igen,1000)
+- iseed(2) = igen/100
+- igen = mod(igen,100)
+- iseed(3) = igen/10
+- iseed(4) = 7
++ inits = .false.
++ end if
+ c
+ if (ido .eq. 0) then
+ c
+diff --git a/PARPACK/SRC/MPI/pdgetv0.f b/PARPACK/SRC/MPI/pdgetv0.f
+index 0f348b820..5a1956997 100644
+--- a/PARPACK/SRC/MPI/pdgetv0.f
++++ b/PARPACK/SRC/MPI/pdgetv0.f
+@@ -177,11 +177,11 @@ subroutine pdgetv0
+ c | Local Scalars & Arrays |
+ c %------------------------%
+ c
+- logical first, orth
+- integer idist, iseed(4), iter, msglvl, jj
++ logical first, inits, orth
++ integer idist, iseed(4), iter, msglvl, jj, myid, igen
+ Double precision
+ & rnorm0, buf2(1)
+- save first, iseed, iter, msglvl, orth, rnorm0
++ save first, iseed, inits, iter, msglvl, orth, rnorm0
+ c
+ Double precision
+ & rnorm_buf
+@@ -206,6 +206,12 @@ subroutine pdgetv0
+ c
+ intrinsic abs, sqrt
+ c
++c %-----------------%
++c | Data Statements |
++c %-----------------%
++c
++ data inits /.true./
++c
+ c %-----------------------%
+ c | Executable Statements |
+ c %-----------------------%
+@@ -216,10 +222,30 @@ subroutine pdgetv0
+ c | random number generator |
+ c %-----------------------------------%
+ c
+- iseed(1) = 1
+- iseed(2) = 3
+- iseed(3) = 5
+- iseed(4) = 7
++ if (inits) then
++c
++c %-----------------------------------%
++c | Generate a seed on each processor |
++c | using process id (myid). |
++c | Note: the seed must be between 1 |
++c | and 4095. iseed(4) must be odd. |
++c %-----------------------------------%
++c
++ call MPI_COMM_RANK(comm, myid, ierr)
++ igen = 1000 + 2*myid + 1
++ if (igen .gt. 4095) then
++ write(0,*) 'Error in p_getv0: seed exceeds 4095!'
++ end if
++c
++ iseed(1) = igen/1000
++ igen = mod(igen,1000)
++ iseed(2) = igen/100
++ igen = mod(igen,100)
++ iseed(3) = igen/10
++ iseed(4) = mod(igen,10)
++c
++ inits = .false.
++ end if
+ c
+ if (ido .eq. 0) then
+ c
+diff --git a/PARPACK/SRC/MPI/psgetv0.f b/PARPACK/SRC/MPI/psgetv0.f
+index d79a513b2..078e4fa8c 100644
+--- a/PARPACK/SRC/MPI/psgetv0.f
++++ b/PARPACK/SRC/MPI/psgetv0.f
+@@ -177,11 +177,11 @@ subroutine psgetv0
+ c | Local Scalars & Arrays |
+ c %------------------------%
+ c
+- logical first, orth
+- integer idist, iseed(4), iter, msglvl, jj
++ logical first, inits, orth
++ integer idist, iseed(4), iter, msglvl, jj, myid, igen
+ Real
+ & rnorm0
+- save first, iseed, iter, msglvl, orth, rnorm0
++ save first, iseed, inits, iter, msglvl, orth, rnorm0
+ c
+ Real
+ & rnorm_buf
+@@ -206,20 +206,41 @@ subroutine psgetv0
+ c
+ intrinsic abs, sqrt
+ c
++c %-----------------%
++c | Data Statements |
++c %-----------------%
++c
++ data inits /.true./
++c
+ c %-----------------------%
+ c | Executable Statements |
+ c %-----------------------%
+ c
+ c
+-c %-----------------------------------%
+-c | Initialize the seed of the LAPACK |
+-c | random number generator |
+-c %-----------------------------------%
++ if (inits) then
+ c
+- iseed(1) = 1
+- iseed(2) = 3
+- iseed(3) = 5
+- iseed(4) = 7
++c %-----------------------------------%
++c | Generate a seed on each processor |
++c | using process id (myid). |
++c | Note: the seed must be between 1 |
++c | and 4095. iseed(4) must be odd. |
++c %-----------------------------------%
++c
++ call MPI_COMM_RANK(comm, myid, ierr)
++ igen = 1000 + 2*myid + 1
++ if (igen .gt. 4095) then
++ write(0,*) 'Error in p_getv0: seed exceeds 4095!'
++ end if
++c
++ iseed(1) = igen/1000
++ igen = mod(igen,1000)
++ iseed(2) = igen/100
++ igen = mod(igen,100)
++ iseed(3) = igen/10
++ iseed(4) = mod(igen,10)
++c
++ inits = .false.
++ end if
+ c
+ if (ido .eq. 0) then
+ c
+diff --git a/PARPACK/SRC/MPI/pzgetv0.f b/PARPACK/SRC/MPI/pzgetv0.f
+index 731fb319f..94fb705f3 100644
+--- a/PARPACK/SRC/MPI/pzgetv0.f
++++ b/PARPACK/SRC/MPI/pzgetv0.f
+@@ -176,13 +176,13 @@ subroutine pzgetv0
+ c | Local Scalars & Arrays |
+ c %------------------------%
+ c
+- logical first, orth
++ logical first, inits, orth
+ integer idist, iseed(4), iter, msglvl, jj, myid, igen
+ Double precision
+ & rnorm0
+ Complex*16
+ & cnorm, cnorm2
+- save first, iseed, iter, msglvl, orth, rnorm0
++ save first, iseed, inits, iter, msglvl, orth, rnorm0
+ c
+ Complex*16
+ & cnorm_buf, buf2(1)
+@@ -203,6 +203,12 @@ subroutine pzgetv0
+ & zzdotc
+ external zzdotc , pdznorm2 , dlapy2
+ c
++c %-----------------%
++c | Data Statements |
++c %-----------------%
++c
++ data inits /.true./
++c
+ c %-----------------------%
+ c | Executable Statements |
+ c %-----------------------%
+@@ -213,26 +219,30 @@ subroutine pzgetv0
+ c | random number generator |
+ c %-----------------------------------%
+ c
++ if (inits) then
+ c
+-c %-----------------------------------%
+-c | Generate a seed on each processor |
+-c | using process id (myid). |
+-c | Note: the seed must be between 1 |
+-c | and 4095. iseed(4) must be odd. |
+-c %-----------------------------------%
++c %-----------------------------------%
++c | Generate a seed on each processor |
++c | using process id (myid). |
++c | Note: the seed must be between 1 |
++c | and 4095. iseed(4) must be odd. |
++c %-----------------------------------%
+ c
+- call MPI_COMM_RANK(comm, myid, ierr)
+- igen = 1000 + 2*myid + 1
+- if (igen .gt. 4095) then
+- write(0,*) 'Error in p_getv0: seed exceeds 4095!'
+- end if
++ call MPI_COMM_RANK(comm, myid, ierr)
++ igen = 1000 + 2*myid + 1
++ if (igen .gt. 4095) then
++ write(0,*) 'Error in p_getv0: seed exceeds 4095!'
++ end if
++c
++ iseed(1) = igen/1000
++ igen = mod(igen,1000)
++ iseed(2) = igen/100
++ igen = mod(igen,100)
++ iseed(3) = igen/10
++ iseed(4) = mod(igen,10)
+ c
+- iseed(1) = igen/1000
+- igen = mod(igen,1000)
+- iseed(2) = igen/100
+- igen = mod(igen,100)
+- iseed(3) = igen/10
+- iseed(4) = 7
++ inits = .false.
++ end if
+ c
+ if (ido .eq. 0) then
+ c
+diff --git a/SRC/cgetv0.f b/SRC/cgetv0.f
+index b49e66708..c231eadcb 100644
+--- a/SRC/cgetv0.f
++++ b/SRC/cgetv0.f
+@@ -156,13 +156,13 @@ subroutine cgetv0
+ c | Local Scalars & Arrays |
+ c %------------------------%
+ c
+- logical first, orth
++ logical first, inits, orth
+ integer idist, iseed(4), iter, msglvl, jj
+ Real
+ & rnorm0
+ Complex
+ & cnorm
+- save first, iseed, iter, msglvl, orth, rnorm0
++ save first, iseed, inits, iter, msglvl, orth, rnorm0
+ c
+ c %----------------------%
+ c | External Subroutines |
+@@ -180,6 +180,12 @@ subroutine cgetv0
+ & ccdotc
+ external ccdotc, scnrm2, slapy2
+ c
++c %-----------------%
++c | Data Statements |
++c %-----------------%
++c
++ data inits /.true./
++c
+ c %-----------------------%
+ c | Executable Statements |
+ c %-----------------------%
+@@ -190,10 +196,13 @@ subroutine cgetv0
+ c | random number generator |
+ c %-----------------------------------%
+ c
+- iseed(1) = 1
+- iseed(2) = 3
+- iseed(3) = 5
+- iseed(4) = 7
++ if (inits) then
++ iseed(1) = 1
++ iseed(2) = 3
++ iseed(3) = 5
++ iseed(4) = 7
++ inits = .false.
++ end if
+ c
+ if (ido .eq. 0) then
+ c
+diff --git a/SRC/dgetv0.f b/SRC/dgetv0.f
+index 8be4fa26d..1d6dc01bd 100644
+--- a/SRC/dgetv0.f
++++ b/SRC/dgetv0.f
+@@ -157,11 +157,11 @@ subroutine dgetv0
+ c | Local Scalars & Arrays |
+ c %------------------------%
+ c
+- logical first, orth
++ logical first, inits, orth
+ integer idist, iseed(4), iter, msglvl, jj
+ Double precision
+ & rnorm0
+- save first, iseed, iter, msglvl, orth, rnorm0
++ save first, iseed, inits, iter, msglvl, orth, rnorm0
+ c
+ c %----------------------%
+ c | External Subroutines |
+@@ -183,6 +183,12 @@ subroutine dgetv0
+ c
+ intrinsic abs, sqrt
+ c
++c %-----------------%
++c | Data Statements |
++c %-----------------%
++c
++ data inits /.true./
++c
+ c %-----------------------%
+ c | Executable Statements |
+ c %-----------------------%
+@@ -193,10 +199,13 @@ subroutine dgetv0
+ c | random number generator |
+ c %-----------------------------------%
+ c
+- iseed(1) = 1
+- iseed(2) = 3
+- iseed(3) = 5
+- iseed(4) = 7
++ if (inits) then
++ iseed(1) = 1
++ iseed(2) = 3
++ iseed(3) = 5
++ iseed(4) = 7
++ inits = .false.
++ end if
+ c
+ if (ido .eq. 0) then
+ c
+diff --git a/SRC/sgetv0.f b/SRC/sgetv0.f
+index 26130a014..d861b2d6d 100644
+--- a/SRC/sgetv0.f
++++ b/SRC/sgetv0.f
+@@ -157,11 +157,11 @@ subroutine sgetv0
+ c | Local Scalars & Arrays |
+ c %------------------------%
+ c
+- logical first, orth
++ logical first, inits, orth
+ integer idist, iseed(4), iter, msglvl, jj
+ Real
+ & rnorm0
+- save first, iseed, iter, msglvl, orth, rnorm0
++ save first, iseed, inits, iter, msglvl, orth, rnorm0
+ c
+ c %----------------------%
+ c | External Subroutines |
+@@ -183,6 +183,12 @@ subroutine sgetv0
+ c
+ intrinsic abs, sqrt
+ c
++c %-----------------%
++c | Data Statements |
++c %-----------------%
++c
++ data inits /.true./
++c
+ c %-----------------------%
+ c | Executable Statements |
+ c %-----------------------%
+@@ -193,10 +199,13 @@ subroutine sgetv0
+ c | random number generator |
+ c %-----------------------------------%
+ c
+- iseed(1) = 1
+- iseed(2) = 3
+- iseed(3) = 5
+- iseed(4) = 7
++ if (inits) then
++ iseed(1) = 1
++ iseed(2) = 3
++ iseed(3) = 5
++ iseed(4) = 7
++ inits = .false.
++ end if
+ c
+ if (ido .eq. 0) then
+ c
+diff --git a/SRC/zgetv0.f b/SRC/zgetv0.f
+index cc13c3cfb..1fbd50851 100644
+--- a/SRC/zgetv0.f
++++ b/SRC/zgetv0.f
+@@ -156,13 +156,13 @@ subroutine zgetv0
+ c | Local Scalars & Arrays |
+ c %------------------------%
+ c
+- logical first, orth
++ logical first, inits, orth
+ integer idist, iseed(4), iter, msglvl, jj
+ Double precision
+ & rnorm0
+ Complex*16
+ & cnorm
+- save first, iseed, iter, msglvl, orth, rnorm0
++ save first, iseed, inits, iter, msglvl, orth, rnorm0
+ c
+ c %----------------------%
+ c | External Subroutines |
+@@ -180,6 +180,12 @@ subroutine zgetv0
+ & zzdotc
+ external zzdotc, dznrm2, dlapy2
+ c
++c %-----------------%
++c | Data Statements |
++c %-----------------%
++c
++ data inits /.true./
++c
+ c %-----------------------%
+ c | Executable Statements |
+ c %-----------------------%
+@@ -190,10 +196,13 @@ subroutine zgetv0
+ c | random number generator |
+ c %-----------------------------------%
+ c
+- iseed(1) = 1
+- iseed(2) = 3
+- iseed(3) = 5
+- iseed(4) = 7
++ if (inits) then
++ iseed(1) = 1
++ iseed(2) = 3
++ iseed(3) = 5
++ iseed(4) = 7
++ inits = .false.
++ end if
+ c
+ if (ido .eq. 0) then
+ c
diff --git a/gnu/packages/patches/biber-adapt-perl-5.36.patch b/gnu/packages/patches/biber-adapt-perl-5.36.patch
deleted file mode 100644
index 895813c1f2..0000000000
--- a/gnu/packages/patches/biber-adapt-perl-5.36.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From d9e961710074d266ad6bdf395c98868d91952088 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
-Date: Wed, 25 May 2022 12:41:59 +0200
-Subject: [PATCH] Adapt to Perl 5.36
-
-A developmental release of Perl 5.36.0 fails to run tests with:
-
- $ perl -Ilib t/basic-misc.t
- 1..72
- Can't modify undef operator in scalar assignment at lib/Biber/Section.pm line 433, near "undef;"
- Compilation failed in require at lib/Biber.pm line 24.
- BEGIN failed--compilation aborted at lib/Biber.pm line 24.
- Compilation failed in require at t/basic-misc.t line 11.
- BEGIN failed--compilation aborted at t/basic-misc.t line 11.
- # Looks like your test exited with 255 before it could output anything.
-
-This is because of a missing semicolon between commands in
-del_everykeys(). The new perl is more strict and raises a compile-time
-error:
-
- $ perl -e '$a = undef $b = undef;'
- Can't modify undef operator in scalar assignment at -e line 1, near "undef;"
- Execution of -e aborted due to compilation errors.
----
- lib/Biber/Section.pm | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/lib/Biber/Section.pm b/lib/Biber/Section.pm
-index 03ed69a51..a78942f57 100644
---- a/lib/Biber/Section.pm
-+++ b/lib/Biber/Section.pm
-@@ -429,7 +429,7 @@ sub add_everykey {
-
- sub del_everykeys {
- my $self = shift;
-- $self->{everykey} = undef
-+ $self->{everykey} = undef;
- $self->{everykey_lc} = undef;
- return;
- }
diff --git a/gnu/packages/patches/doxygen-hurd.patch b/gnu/packages/patches/doxygen-hurd.patch
new file mode 100644
index 0000000000..a40923184b
--- /dev/null
+++ b/gnu/packages/patches/doxygen-hurd.patch
@@ -0,0 +1,30 @@
+Upstream status: Adapted from upstream.
+
+From d3d968e5835f449d7ea715f45160db81ea906303 Mon Sep 17 00:00:00 2001
+From: Samuel Thibault <samuel.thibault@ens-lyon.org>
+Date: Tue, 16 Aug 2022 20:29:54 +0200
+Subject: [PATCH] Fix build on GNU/Hurd
+
+There is no path length limitation there, even via pathconf. But glibc
+provides a getcwd function that allocates the buffer dynamically so we can
+just leverage that.
+---
+ include/ghc/filesystem.hpp | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/filesystem/filesystem.hpp.orig 2022-08-11 22:14:32.000000000 +0200
++++ b/filesystem/filesystem.hpp 2023-06-13 07:26:25.310000000 +0200
+@@ -4081,6 +4081,13 @@
+ return path();
+ }
+ return path(std::wstring(buffer.get()), path::native_format);
++#elif defined(__GLIBC__)
++ std::unique_ptr<char, decltype(&std::free)> buffer { ::getcwd(NULL, 0), std::free };
++ if (buffer == nullptr) {
++ ec = detail::make_system_error();
++ return path();
++ }
++ return path(buffer.get());
+ #else
+ size_t pathlen = static_cast<size_t>(std::max(int(::pathconf(".", _PC_PATH_MAX)), int(PATH_MAX)));
+ std::unique_ptr<char[]> buffer(new char[pathlen + 1]);
diff --git a/gnu/packages/patches/fontforge-hurd.patch b/gnu/packages/patches/fontforge-hurd.patch
new file mode 100644
index 0000000000..20d62b8ce2
--- /dev/null
+++ b/gnu/packages/patches/fontforge-hurd.patch
@@ -0,0 +1,82 @@
+Upstream status: Taken from upstream.
+
+From dca87c025665f0f010f906a4eba96da9794a4d04 Mon Sep 17 00:00:00 2001
+From: Anthony Fok <foka@debian.org>
+Date: Thu, 16 Jun 2022 02:40:23 -0600
+Subject: [PATCH] Define PATH_MAX and MAXPATHLEN for GNU/Hurd compatibility
+
+Special thanks to @henrich, @ucko and @kilobyte for reporting the issue
+and offering suggestions on a fix.
+
+See also https://bugs.debian.org/877795
+
+Fixes #3119
+---
+ inc/basics.h | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/inc/basics.h b/inc/basics.h
+index b8d65823b..14590c5b1 100644
+--- a/inc/basics.h
++++ b/inc/basics.h
+@@ -123,5 +123,13 @@ static inline int imax(int a, int b)
+ last = newitem; \
+ }
+
++#ifdef __GNU__
++# ifndef PATH_MAX
++# define PATH_MAX 4096
++# endif
++# ifndef MAXPATHLEN
++# define MAXPATHLEN 4096
++# endif
++#endif
+
+ #endif /* FONTFORGE_BASICS_H */
+--
+2.40.1
+
+From e0480f143f27f8f2686b5b14d7d302fe22f35002 Mon Sep 17 00:00:00 2001
+From: Anthony Fok <foka@debian.org>
+Date: Thu, 16 Jun 2022 03:06:56 -0600
+Subject: [PATCH] Undefine "extended" macro temporarily on GNU Hurd
+
+GNU Mach microkernel header files (gnumach-dev 1.8+git20201129) added to
+struct i386_xfp_save in /usr/include/i386-gnu/include/mach/i386/fp_reg.h
+a new "extended" field which happens to collide with the macro definition
+"#define extended double" in FontForge, leading to FTBFS on GNU Hurd.
+
+This issue may be circumvented by temporarily undefining the "extended"
+macro before loading `<gio/gio.h>` and friends, and redefining the
+"extended" macro right after.
+---
+ inc/ffglib.h | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/inc/ffglib.h b/inc/ffglib.h
+index f3419f0ab..25fe9ebde 100644
+--- a/inc/ffglib.h
++++ b/inc/ffglib.h
+@@ -26,11 +26,19 @@
+ #define GMenuItem GMenuItem_GIO
+ #define GTimer GTimer_GTK
+
++#ifdef __GNU__
++# undef extended
++#endif
++
+ #include <gio/gio.h>
+ #include <glib-object.h>
+ #include <glib.h>
+ #include <glib/gstdio.h>
+
++#ifdef __GNU__
++# define extended double
++#endif
++
+ #undef GList
+ #undef GMenuItem
+ #undef GTimer
+--
+2.40.1
+
diff --git a/gnu/packages/patches/ghostscript-CVE-2023-36664-fixup.patch b/gnu/packages/patches/ghostscript-CVE-2023-36664-fixup.patch
new file mode 100644
index 0000000000..c2a222701f
--- /dev/null
+++ b/gnu/packages/patches/ghostscript-CVE-2023-36664-fixup.patch
@@ -0,0 +1,56 @@
+From 0974e4f2ac0005d3731e0b5c13ebc7e965540f4d Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell@artifex.com>
+Date: Wed, 14 Jun 2023 09:08:12 +0100
+Subject: [PATCH] Bug 706778: 706761 revisit
+
+Two problems with the original commit. The first a silly typo inverting the
+logic of a test.
+
+The second was forgetting that we actually actually validate two candidate
+strings for pipe devices. One with the expected "%pipe%" prefix, the other
+using the pipe character prefix: "|".
+
+This addresses both those.
+---
+ base/gpmisc.c | 2 +-
+ base/gslibctx.c | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/base/gpmisc.c b/base/gpmisc.c
+index 58511270e..2b0064bea 100644
+--- a/base/gpmisc.c
++++ b/base/gpmisc.c
+@@ -1081,7 +1081,7 @@ gp_validate_path_len(const gs_memory_t *mem,
+ /* "%pipe%" do not follow the normal rules for path definitions, so we
+ don't "reduce" them to avoid unexpected results
+ */
+- if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
++ if (path[0] == '|' || (len > 5 && memcmp(path, "%pipe", 5) == 0)) {
+ bufferfull = buffer = (char *)gs_alloc_bytes(mem->thread_safe_memory, len + 1, "gp_validate_path");
+ if (buffer == NULL)
+ return gs_error_VMerror;
+diff --git a/base/gslibctx.c b/base/gslibctx.c
+index d2a1aa91d..42af99090 100644
+--- a/base/gslibctx.c
++++ b/base/gslibctx.c
+@@ -743,7 +743,7 @@ gs_add_control_path_len_flags(const gs_memory_t *mem, gs_path_control_t type, co
+ /* "%pipe%" do not follow the normal rules for path definitions, so we
+ don't "reduce" them to avoid unexpected results
+ */
+- if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
++ if (path[0] == '|' || (len > 5 && memcmp(path, "%pipe", 5) == 0)) {
+ buffer = (char *)gs_alloc_bytes(core->memory, len + 1, "gs_add_control_path_len");
+ if (buffer == NULL)
+ return gs_error_VMerror;
+@@ -850,7 +850,7 @@ gs_remove_control_path_len_flags(const gs_memory_t *mem, gs_path_control_t type,
+ /* "%pipe%" do not follow the normal rules for path definitions, so we
+ don't "reduce" them to avoid unexpected results
+ */
+- if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
++ if (path[0] == '|' || (len > 5 && memcmp(path, "%pipe", 5) == 0)) {
+ buffer = (char *)gs_alloc_bytes(core->memory, len + 1, "gs_remove_control_path_len");
+ if (buffer == NULL)
+ return gs_error_VMerror;
+--
+2.34.1
+
diff --git a/gnu/packages/patches/ghostscript-CVE-2023-36664.patch b/gnu/packages/patches/ghostscript-CVE-2023-36664.patch
new file mode 100644
index 0000000000..e9c53c1f87
--- /dev/null
+++ b/gnu/packages/patches/ghostscript-CVE-2023-36664.patch
@@ -0,0 +1,142 @@
+From 505eab7782b429017eb434b2b95120855f2b0e3c Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell@artifex.com>
+Date: Wed, 7 Jun 2023 10:23:06 +0100
+Subject: [PATCH] Bug 706761: Don't "reduce" %pipe% file names for permission
+ validation
+
+For regular file names, we try to simplfy relative paths before we use them.
+
+Because the %pipe% device can, effectively, accept command line calls, we
+shouldn't be simplifying that string, because the command line syntax can end
+up confusing the path simplifying code. That can result in permitting a pipe
+command which does not match what was originally permitted.
+
+Special case "%pipe" in the validation code so we always deal with the entire
+string.
+---
+ base/gpmisc.c | 31 +++++++++++++++++++--------
+ base/gslibctx.c | 56 ++++++++++++++++++++++++++++++++++++-------------
+ 2 files changed, 64 insertions(+), 23 deletions(-)
+
+diff --git a/base/gpmisc.c b/base/gpmisc.c
+index 5f39ebba7..2fb87f769 100644
+--- a/base/gpmisc.c
++++ b/base/gpmisc.c
+@@ -1076,16 +1076,29 @@ gp_validate_path_len(const gs_memory_t *mem,
+ && !memcmp(path + cdirstrl, dirsepstr, dirsepstrl)) {
+ prefix_len = 0;
+ }
+- rlen = len+1;
+- bufferfull = (char *)gs_alloc_bytes(mem->thread_safe_memory, rlen + prefix_len, "gp_validate_path");
+- if (bufferfull == NULL)
+- return gs_error_VMerror;
+-
+- buffer = bufferfull + prefix_len;
+- if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
+- return gs_error_invalidfileaccess;
+- buffer[rlen] = 0;
+
++ /* "%pipe%" do not follow the normal rules for path definitions, so we
++ don't "reduce" them to avoid unexpected results
++ */
++ if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
++ bufferfull = buffer = (char *)gs_alloc_bytes(mem->thread_safe_memory, len + 1, "gp_validate_path");
++ if (buffer == NULL)
++ return gs_error_VMerror;
++ memcpy(buffer, path, len);
++ buffer[len] = 0;
++ rlen = len;
++ }
++ else {
++ rlen = len+1;
++ bufferfull = (char *)gs_alloc_bytes(mem->thread_safe_memory, rlen + prefix_len, "gp_validate_path");
++ if (bufferfull == NULL)
++ return gs_error_VMerror;
++
++ buffer = bufferfull + prefix_len;
++ if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
++ return gs_error_invalidfileaccess;
++ buffer[rlen] = 0;
++ }
+ while (1) {
+ switch (mode[0])
+ {
+diff --git a/base/gslibctx.c b/base/gslibctx.c
+index eb566ed06..d2a1aa91d 100644
+--- a/base/gslibctx.c
++++ b/base/gslibctx.c
+@@ -740,14 +740,28 @@ gs_add_control_path_len_flags(const gs_memory_t *mem, gs_path_control_t type, co
+ return gs_error_rangecheck;
+ }
+
+- rlen = len+1;
+- buffer = (char *)gs_alloc_bytes(core->memory, rlen, "gp_validate_path");
+- if (buffer == NULL)
+- return gs_error_VMerror;
++ /* "%pipe%" do not follow the normal rules for path definitions, so we
++ don't "reduce" them to avoid unexpected results
++ */
++ if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
++ buffer = (char *)gs_alloc_bytes(core->memory, len + 1, "gs_add_control_path_len");
++ if (buffer == NULL)
++ return gs_error_VMerror;
++ memcpy(buffer, path, len);
++ buffer[len] = 0;
++ rlen = len;
++ }
++ else {
++ rlen = len + 1;
+
+- if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
+- return gs_error_invalidfileaccess;
+- buffer[rlen] = 0;
++ buffer = (char *)gs_alloc_bytes(core->memory, rlen, "gs_add_control_path_len");
++ if (buffer == NULL)
++ return gs_error_VMerror;
++
++ if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
++ return gs_error_invalidfileaccess;
++ buffer[rlen] = 0;
++ }
+
+ n = control->num;
+ for (i = 0; i < n; i++)
+@@ -833,14 +847,28 @@ gs_remove_control_path_len_flags(const gs_memory_t *mem, gs_path_control_t type,
+ return gs_error_rangecheck;
+ }
+
+- rlen = len+1;
+- buffer = (char *)gs_alloc_bytes(core->memory, rlen, "gp_validate_path");
+- if (buffer == NULL)
+- return gs_error_VMerror;
++ /* "%pipe%" do not follow the normal rules for path definitions, so we
++ don't "reduce" them to avoid unexpected results
++ */
++ if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
++ buffer = (char *)gs_alloc_bytes(core->memory, len + 1, "gs_remove_control_path_len");
++ if (buffer == NULL)
++ return gs_error_VMerror;
++ memcpy(buffer, path, len);
++ buffer[len] = 0;
++ rlen = len;
++ }
++ else {
++ rlen = len+1;
+
+- if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
+- return gs_error_invalidfileaccess;
+- buffer[rlen] = 0;
++ buffer = (char *)gs_alloc_bytes(core->memory, rlen, "gs_remove_control_path_len");
++ if (buffer == NULL)
++ return gs_error_VMerror;
++
++ if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
++ return gs_error_invalidfileaccess;
++ buffer[rlen] = 0;
++ }
+
+ n = control->num;
+ for (i = 0; i < n; i++) {
+--
+2.34.1
+
diff --git a/gnu/packages/patches/ghostscript-leptonica-hurd.patch b/gnu/packages/patches/ghostscript-leptonica-hurd.patch
new file mode 100644
index 0000000000..124365b3e6
--- /dev/null
+++ b/gnu/packages/patches/ghostscript-leptonica-hurd.patch
@@ -0,0 +1,78 @@
+Upstream status: This patch was taken from leptonica upstream.
+
+Backported to ghostscripts bundled leptonica.
+
+From f04da7c816feb1d5f689c34f3d0e7e3621edf1f5 Mon Sep 17 00:00:00 2001
+From: Samuel Thibault <samuel.thibault@ens-lyon.org>
+Date: Wed, 1 Feb 2023 19:35:43 +0100
+Subject: [PATCH] Fix GNU/Hurd build
+
+There is no PATH_MAX limitation on GNU/Hurd, and realpath() can be
+safely be used with its second parameter set to NULL (as required by
+posix since its version 2001).
+---
+ src/sarray1.c | 29 +++++++++++++++++++++++------
+ 1 file changed, 23 insertions(+), 6 deletions(-)
+
+--- a/src/sarray1.c 2023-06-13 12:31:13.393672916 +0200
++++ a/src/sarray1.c 2023-06-13 12:34:13.574237149 +0200
+@@ -1953,7 +1953,11 @@
+ SARRAY *
+ getFilenamesInDirectory(const char *dirname)
+ {
++#if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
++char *dir;
++#else
+ char dir[PATH_MAX + 1];
++#endif
+ char *realdir, *stat_path, *ignore;
+ size_t size;
+ SARRAY *safiles;
+@@ -1976,17 +1980,28 @@
+ * If the file or directory exists, realpath returns its path;
+ else it returns NULL.
+ * If the second arg to realpath is passed in, the canonical path
+- is returned there. Use a buffer of sufficient size. If the
+- second arg is NULL, the path is malloc'd and returned if the
+- file or directory exists.
+- We pass in a buffer for the second arg, and check that the canonical
+- directory path was made. The existence of the directory is checked
+- later, after its actual path is returned by genPathname(). */
++ is returned there. Use a buffer of sufficient size.
++ We pass in a buffer for the second arg, and check that the
++ canonical directory path was made. The existence of the
++ directory is checked later, after its actual path is returned by
++ genPathname().
++ With GNU libc or Posix 2001, if the second arg is NULL, the path
++ is malloc'd and returned if the file or directory exists.
++ */
++#if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
++ dir = realpath(dirname, NULL);
++ if (dir == NULL)
++ return (SARRAY *)ERROR_PTR("dir not made", __func__, NULL);
++#else
+ dir[0] = '\0'; /* init empty in case realpath() fails to write it */
+ ignore = realpath(dirname, dir);
+ if (dir[0] == '\0')
+ return (SARRAY *)ERROR_PTR("dir not made", procName, NULL);
++#endif
+ realdir = genPathname(dir, NULL);
++#if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
++ LEPT_FREE(dir);
++#endif
+ if ((pdir = opendir(realdir)) == NULL) {
+ LEPT_FREE(realdir);
+ return (SARRAY *)ERROR_PTR("pdir not opened", procName, NULL);
+@@ -1998,10 +2013,12 @@
+ stat_ret = fstatat(dfd, pdirentry->d_name, &st, 0);
+ #else
+ size = strlen(realdir) + strlen(pdirentry->d_name) + 2;
++#if _POSIX_VERSION < 200112 && !defined(__GLIBC__)
+ if (size > PATH_MAX) {
+ L_ERROR("size = %zu too large; skipping\n", procName, size);
+ continue;
+ }
++#endif
+ stat_path = (char *)LEPT_CALLOC(size, 1);
+ snprintf(stat_path, size, "%s/%s", realdir, pdirentry->d_name);
+ stat_ret = stat(stat_path, &st);
diff --git a/gnu/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch b/gnu/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch
new file mode 100644
index 0000000000..944b2fe8df
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch
@@ -0,0 +1,61 @@
+Taken from: https://salsa.debian.org/glibc-team/glibc/-/blob/9ce19663f00176f30d6eab29fd14db3e7cd53dcf/debian/patches/hurd-i386/unsubmitted-clock_t_centiseconds.diff
+
+Some applications assume centisecond precision, or at most millisecond precision
+(e.g. guile). This is a work-around for them.
+
+---
+ getclktck.c | 5 ++---
+ setitimer.c | 2 +-
+ times.c | 2 +-
+ 4 files changed, 8 insertions(+), 9 deletions(-)
+commit d57f2f9b4bd007846af2fb4217486ea572579010
+Author: Richard Braun <rbraun@sceen.net>
+Date: Tue Aug 27 11:35:31 2013 +0200
+
+ Express CPU time (clock_t of times(2)) in centiseconds
+
+diff --git a/sysdeps/mach/hurd/getclktck.c b/sysdeps/mach/hurd/getclktck.c
+index 69be2cc..5f7d946 100644
+--- a/sysdeps/mach/hurd/getclktck.c
++++ b/sysdeps/mach/hurd/getclktck.c
+@@ -18,12 +18,11 @@
+
+ #include <time.h>
+
+-/* Return frequency of `times'.
+- Since Mach reports CPU times in microseconds, we always use 1 million. */
++/* Return frequency of `times'. */
+ int
+ __getclktck (void)
+ {
+- return 1000000;
++ return 100;
+ }
+
+ /* Before glibc 2.2, the Hurd actually did this differently, so we
+diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c
+index 39b6b16..4992c89 100644
+--- a/sysdeps/mach/hurd/setitimer.c
++++ b/sysdeps/mach/hurd/setitimer.c
+@@ -42,7 +42,7 @@ quantize_timeval (struct timeval *tv)
+ static time_t quantum = -1;
+
+ if (quantum == -1)
+- quantum = 1000000 / __getclktck ();
++ quantum = 100 / __getclktck ();
+
+ tv->tv_usec = ((tv->tv_usec + (quantum - 1)) / quantum) * quantum;
+ if (tv->tv_usec >= 1000000)
+diff --git a/sysdeps/mach/hurd/times.c b/sysdeps/mach/hurd/times.c
+index 9e13a75..593c33a 100644
+--- a/sysdeps/mach/hurd/times.c
++++ b/sysdeps/mach/hurd/times.c
+@@ -29,7 +29,7 @@
+ static inline clock_t
+ clock_from_time_value (const time_value_t *t)
+ {
+- return t->seconds * 1000000 + t->microseconds;
++ return t->seconds * 100 + t->microseconds / 10000;
+ }
+
+ /* Store the CPU time used by this process and all its
diff --git a/gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch b/gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch
new file mode 100644
index 0000000000..63e06b8519
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch
@@ -0,0 +1,135 @@
+Taken from: https://salsa.debian.org/glibc-team/glibc/-/blob/9ce19663f00176f30d6eab29fd14db3e7cd53dcf/debian/patches/hurd-i386/local-clock_gettime_MONOTONIC.diff
+
+Use the realtime clock for the monotonic clock. This is of course not a proper
+implementation (which is being done in Mach), but will permit to fix at least
+the iceweasel stack.
+
+vlc however doesn't build when _POSIX_CLOCK_SELECTION is enabled but
+_POSIX_TIMERS is not, and they refuse to fix that (see #765578), so disable the
+former.
+
+---
+ sysdeps/mach/hurd/bits/posix_opt.h | 2 +-
+ sysdeps/unix/clock_gettime.c | 1 +
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+Index: glibc-2.27/sysdeps/mach/clock_gettime.c
+===================================================================
+--- glibc-2.27.orig/sysdeps/mach/clock_gettime.c
++++ glibc-2.27/sysdeps/mach/clock_gettime.c
+@@ -31,6 +31,10 @@ __clock_gettime (clockid_t clock_id, str
+ switch (clock_id) {
+
+ case CLOCK_REALTIME:
++ case CLOCK_MONOTONIC:
++ case CLOCK_MONOTONIC_RAW:
++ case CLOCK_REALTIME_COARSE:
++ case CLOCK_MONOTONIC_COARSE:
+ {
+ /* __host_get_time can only fail if passed an invalid host_t.
+ __mach_host_self could theoretically fail (producing an
+Index: glibc-2.27/rt/timer_create.c
+===================================================================
+--- glibc-2.27.orig/rt/timer_create.c
++++ glibc-2.27/rt/timer_create.c
+@@ -48,7 +48,7 @@ timer_create (clockid_t clock_id, struct
+ return -1;
+ }
+
+- if (clock_id != CLOCK_REALTIME)
++ if (clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_MONOTONIC_RAW && clock_id != CLOCK_REALTIME_COARSE && clock_id != CLOCK_MONOTONIC_COARSE)
+ {
+ __set_errno (EINVAL);
+ return -1;
+Index: glibc-2.27/sysdeps/mach/hurd/bits/posix_opt.h
+===================================================================
+--- glibc-2.27.orig/sysdeps/mach/hurd/bits/posix_opt.h
++++ glibc-2.27/sysdeps/mach/hurd/bits/posix_opt.h
+@@ -163,10 +163,10 @@
+ #define _POSIX_THREAD_PROCESS_SHARED -1
+
+ /* The monotonic clock might be available. */
+-#define _POSIX_MONOTONIC_CLOCK 0
++#define _POSIX_MONOTONIC_CLOCK 200809L
+
+-/* The clock selection interfaces are available. */
+-#define _POSIX_CLOCK_SELECTION 200809L
++/* The clock selection interfaces are not really available yet. */
++#define _POSIX_CLOCK_SELECTION -1
+
+ /* Advisory information interfaces could be available in future. */
+ #define _POSIX_ADVISORY_INFO 0
+Index: glibc-upstream/sysdeps/posix/clock_getres.c
+===================================================================
+--- glibc-upstream.orig/sysdeps/posix/clock_getres.c
++++ glibc-upstream/sysdeps/posix/clock_getres.c
+@@ -52,6 +52,10 @@ __clock_getres (clockid_t clock_id, stru
+ switch (clock_id)
+ {
+ case CLOCK_REALTIME:
++ case CLOCK_MONOTONIC:
++ case CLOCK_MONOTONIC_RAW:
++ case CLOCK_REALTIME_COARSE:
++ case CLOCK_MONOTONIC_COARSE:
+ retval = realtime_getres (res);
+ break;
+
+--- ./sysdeps/mach/clock_nanosleep.c.original 2020-07-21 00:31:35.226113142 +0200
++++ ./sysdeps/mach/clock_nanosleep.c 2020-07-21 00:31:49.026185761 +0200
+@@ -62,7 +62,7 @@
+ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
+ struct timespec *rem)
+ {
+- if (clock_id != CLOCK_REALTIME
++ if ((clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_MONOTONIC_RAW && clock_id != CLOCK_REALTIME_COARSE && clock_id != CLOCK_MONOTONIC_COARSE)
+ || !valid_nanoseconds (req->tv_nsec)
+ || (flags != 0 && flags != TIMER_ABSTIME))
+ return EINVAL;
+Index: glibc-2.32/hurd/hurdlock.c
+===================================================================
+--- glibc-2.32.orig/hurd/hurdlock.c
++++ glibc-2.32/hurd/hurdlock.c
+@@ -47,7 +47,7 @@ int
+ __lll_abstimed_wait (void *ptr, int val,
+ const struct timespec *tsp, int flags, int clk)
+ {
+- if (clk != CLOCK_REALTIME)
++ if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
+ return EINVAL;
+
+ int mlsec = compute_reltime (tsp, clk);
+@@ -59,7 +59,7 @@ int
+ __lll_abstimed_wait_intr (void *ptr, int val,
+ const struct timespec *tsp, int flags, int clk)
+ {
+- if (clk != CLOCK_REALTIME)
++ if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
+ return EINVAL;
+
+ int mlsec = compute_reltime (tsp, clk);
+@@ -79,7 +79,7 @@ int
+ __lll_abstimed_xwait (void *ptr, int lo, int hi,
+ const struct timespec *tsp, int flags, int clk)
+ {
+- if (clk != CLOCK_REALTIME)
++ if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
+ return EINVAL;
+
+ int mlsec = compute_reltime (tsp, clk);
+@@ -91,7 +91,7 @@ int
+ __lll_abstimed_lock (void *ptr,
+ const struct timespec *tsp, int flags, int clk)
+ {
+- if (clk != CLOCK_REALTIME)
++ if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
+ return EINVAL;
+
+ if (__lll_trylock (ptr) == 0)
+@@ -177,7 +177,7 @@ __lll_robust_abstimed_lock (void *ptr,
+ int wait_time = 25;
+ unsigned int val;
+
+- if (clk != CLOCK_REALTIME)
++ if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
+ return EINVAL;
+
+ while (1)
diff --git a/gnu/packages/patches/glibc-2.37-versioned-locpath.patch b/gnu/packages/patches/glibc-2.37-versioned-locpath.patch
new file mode 100644
index 0000000000..0acaeb1e46
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.37-versioned-locpath.patch
@@ -0,0 +1,264 @@
+From d73ba2caa10b8e9f51ff4239cc32eeb4e0de4279 Mon Sep 17 00:00:00 2001
+Message-Id: <d73ba2caa10b8e9f51ff4239cc32eeb4e0de4279.1683980025.git.dev@jpoiret.xyz>
+From: Josselin Poiret <dev@jpoiret.xyz>
+Date: Sat, 13 May 2023 14:10:43 +0200
+Subject: [PATCH] Add versioned locpath
+
+From: Josselin Poiret <dev@jpoiret.xyz>
+
+The format of locale data can be incompatible between libc versions, and
+loading incompatible data can lead to 'setlocale' returning EINVAL at best
+or triggering an assertion failure at worst. See
+https://lists.gnu.org/archive/html/guix-devel/2015-09/msg00717.html
+for background information.
+
+To address that, this patch changes libc to honor a new 'GUIX_LOCPATH'
+variable, and to look for locale data in version-specific sub-directories of
+that variable. So, if GUIX_LOCPATH=/foo:/bar, locale data is searched for in
+/foo/X.Y and /bar/X.Y, where X.Y is the libc version number.
+
+That way, a single 'GUIX_LOCPATH' setting can work even if different libc
+versions coexist on the system.
+
+
+This patch is adapted from the 2.35 patch.
+
+---
+ locale/newlocale.c | 15 ++--------
+ locale/setlocale.c | 68 +++++++++++++++++++++++++++++++++++++-------
+ string/Makefile | 1 +
+ string/argz-suffix.c | 56 ++++++++++++++++++++++++++++++++++++
+ string/argz.h | 10 +++++++
+ 5 files changed, 127 insertions(+), 23 deletions(-)
+ create mode 100644 string/argz-suffix.c
+
+diff --git a/locale/newlocale.c b/locale/newlocale.c
+index 108d2428bf..6218e0fa77 100644
+--- a/locale/newlocale.c
++++ b/locale/newlocale.c
+@@ -29,6 +29,7 @@
+ /* Lock for protecting global data. */
+ __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden)
+
++extern error_t compute_locale_search_path (char **, size_t *);
+
+ /* Use this when we come along an error. */
+ #define ERROR_RETURN \
+@@ -47,7 +48,6 @@ __newlocale (int category_mask, const char *locale, locale_t base)
+ locale_t result_ptr;
+ char *locale_path;
+ size_t locale_path_len;
+- const char *locpath_var;
+ int cnt;
+ size_t names_len;
+
+@@ -101,17 +101,8 @@ __newlocale (int category_mask, const char *locale, locale_t base)
+ locale_path = NULL;
+ locale_path_len = 0;
+
+- locpath_var = getenv ("LOCPATH");
+- if (locpath_var != NULL && locpath_var[0] != '\0')
+- {
+- if (__argz_create_sep (locpath_var, ':',
+- &locale_path, &locale_path_len) != 0)
+- return NULL;
+-
+- if (__argz_add_sep (&locale_path, &locale_path_len,
+- _nl_default_locale_path, ':') != 0)
+- return NULL;
+- }
++ if (compute_locale_search_path (&locale_path, &locale_path_len) != 0)
++ return NULL;
+
+ /* Get the names for the locales we are interested in. We either
+ allow a composite name or a single name. */
+diff --git a/locale/setlocale.c b/locale/setlocale.c
+index dd73fa4248..d8eb799384 100644
+--- a/locale/setlocale.c
++++ b/locale/setlocale.c
+@@ -213,12 +213,65 @@ setdata (int category, struct __locale_data *data)
+ }
+ }
+
++/* Return in *LOCALE_PATH and *LOCALE_PATH_LEN the locale data search path as
++ a colon-separated list. Return ENOMEN on error, zero otherwise. */
++error_t
++compute_locale_search_path (char **locale_path, size_t *locale_path_len)
++{
++ char* guix_locpath_var = getenv ("GUIX_LOCPATH");
++ char *locpath_var = getenv ("LOCPATH");
++
++ if (guix_locpath_var != NULL && guix_locpath_var[0] != '\0')
++ {
++ /* Entries in 'GUIX_LOCPATH' take precedence over 'LOCPATH'. These
++ entries are systematically prefixed with "/X.Y" where "X.Y" is the
++ libc version. */
++ if (__argz_create_sep (guix_locpath_var, ':',
++ locale_path, locale_path_len) != 0
++ || __argz_suffix_entries (locale_path, locale_path_len,
++ "/" VERSION) != 0)
++ goto bail_out;
++ }
++
++ if (locpath_var != NULL && locpath_var[0] != '\0')
++ {
++ char *reg_locale_path = NULL;
++ size_t reg_locale_path_len = 0;
++
++ if (__argz_create_sep (locpath_var, ':',
++ &reg_locale_path, &reg_locale_path_len) != 0)
++ goto bail_out;
++
++ if (__argz_append (locale_path, locale_path_len,
++ reg_locale_path, reg_locale_path_len) != 0)
++ goto bail_out;
++
++ free (reg_locale_path);
++ }
++
++ if (*locale_path != NULL)
++ {
++ /* Append the system default locale directory. */
++ if (__argz_add_sep (locale_path, locale_path_len,
++ _nl_default_locale_path, ':') != 0)
++ goto bail_out;
++ }
++
++ return 0;
++
++ bail_out:
++ free (*locale_path);
++ *locale_path = NULL;
++ *locale_path_len = 0;
++
++ return ENOMEM;
++}
++
+ char *
+ setlocale (int category, const char *locale)
+ {
+ char *locale_path;
+ size_t locale_path_len;
+- const char *locpath_var;
+ char *composite;
+
+ /* Sanity check for CATEGORY argument. */
+@@ -249,17 +302,10 @@ setlocale (int category, const char *locale)
+ locale_path = NULL;
+ locale_path_len = 0;
+
+- locpath_var = getenv ("LOCPATH");
+- if (locpath_var != NULL && locpath_var[0] != '\0')
++ if (compute_locale_search_path (&locale_path, &locale_path_len) != 0)
+ {
+- if (__argz_create_sep (locpath_var, ':',
+- &locale_path, &locale_path_len) != 0
+- || __argz_add_sep (&locale_path, &locale_path_len,
+- _nl_default_locale_path, ':') != 0)
+- {
+- __libc_rwlock_unlock (__libc_setlocale_lock);
+- return NULL;
+- }
++ __libc_rwlock_unlock (__libc_setlocale_lock);
++ return NULL;
+ }
+
+ if (category == LC_ALL)
+diff --git a/string/Makefile b/string/Makefile
+index 3eced0d027..a7e68729ad 100644
+--- a/string/Makefile
++++ b/string/Makefile
+@@ -51,6 +51,7 @@ routines := \
+ argz-next \
+ argz-replace \
+ argz-stringify \
++ argz-suffix \
+ basename \
+ bcopy \
+ bzero \
+diff --git a/string/argz-suffix.c b/string/argz-suffix.c
+new file mode 100644
+index 0000000000..505b0f248c
+--- /dev/null
++++ b/string/argz-suffix.c
+@@ -0,0 +1,56 @@
++/* Copyright (C) 2015 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++ Contributed by Ludovic Courtès <ludo@gnu.org>.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library 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
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
++
++#include <argz.h>
++#include <errno.h>
++#include <stdlib.h>
++#include <string.h>
++
++
++error_t
++__argz_suffix_entries (char **argz, size_t *argz_len, const char *suffix)
++
++{
++ size_t suffix_len = strlen (suffix);
++ size_t count = __argz_count (*argz, *argz_len);
++ size_t new_argz_len = *argz_len + count * suffix_len;
++ char *new_argz = malloc (new_argz_len);
++
++ if (new_argz)
++ {
++ char *p = new_argz, *entry;
++
++ for (entry = *argz;
++ entry != NULL;
++ entry = argz_next (*argz, *argz_len, entry))
++ {
++ p = stpcpy (p, entry);
++ p = stpcpy (p, suffix);
++ p++;
++ }
++
++ free (*argz);
++ *argz = new_argz;
++ *argz_len = new_argz_len;
++
++ return 0;
++ }
++ else
++ return ENOMEM;
++}
++weak_alias (__argz_suffix_entries, argz_suffix_entries)
+diff --git a/string/argz.h b/string/argz.h
+index cbc588a8e6..bc6e484c9d 100644
+--- a/string/argz.h
++++ b/string/argz.h
+@@ -108,6 +108,16 @@ extern error_t argz_replace (char **__restrict __argz,
+ const char *__restrict __str,
+ const char *__restrict __with,
+ unsigned int *__restrict __replace_count);
++
++/* Suffix each entry of ARGZ & ARGZ_LEN with SUFFIX. Return 0 on success,
++ and ENOMEN if memory cannot be allocated. */
++extern error_t __argz_suffix_entries (char **__restrict __argz,
++ size_t *__restrict __argz_len,
++ const char *__restrict __suffix);
++extern error_t argz_suffix_entries (char **__restrict __argz,
++ size_t *__restrict __argz_len,
++ const char *__restrict __suffix);
++
+
+ /* Returns the next entry in ARGZ & ARGZ_LEN after ENTRY, or NULL if there
+ are no more. If entry is NULL, then the first entry is returned. This
+--
+2.40.1
+
diff --git a/gnu/packages/patches/gnumach-add-missing-const_mach_port_name_array_t-type.patch b/gnu/packages/patches/gnumach-add-missing-const_mach_port_name_array_t-type.patch
deleted file mode 100644
index 73c99ade23..0000000000
--- a/gnu/packages/patches/gnumach-add-missing-const_mach_port_name_array_t-type.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From 17335d49a3c9e866a81abc051420d73a59d669bf Mon Sep 17 00:00:00 2001
-Message-Id: <17335d49a3c9e866a81abc051420d73a59d669bf.1678745341.git.dev@jpoiret.xyz>
-From: Josselin Poiret <dev@jpoiret.xyz>
-Date: Sun, 28 Aug 2022 01:17:34 +0200
-Subject: [PATCH] Add missing const_mach_port_name_array_t type
-
-From: Samuel Thibault <samuel.thibault@ens-lyon.org>
-
----
- include/mach/port.h | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/include/mach/port.h b/include/mach/port.h
-index 3c226f6c..d25eb0b4 100644
---- a/include/mach/port.h
-+++ b/include/mach/port.h
-@@ -43,6 +43,7 @@
- */
- typedef unsigned int mach_port_name_t;
- typedef mach_port_name_t *mach_port_name_array_t;
-+typedef const mach_port_name_t *const_mach_port_name_array_t;
-
- /*
- * A port is represented
-
-base-commit: 3e1702a65fb3caf50c8d09a1b383b0056a5efc82
-prerequisite-patch-id: 4688654277aef235ccd1797a72dce27d52b04616
-prerequisite-patch-id: 8f1e7dd6429c15cc8ed1d411dba0a75b6e745236
-prerequisite-patch-id: 605553ee086473ad9bc24e59c91d49a12dbf8631
---
-2.39.1
-
diff --git a/gnu/packages/patches/gnumach-support-noide.patch b/gnu/packages/patches/gnumach-support-noide.patch
new file mode 100644
index 0000000000..723d4bcac4
--- /dev/null
+++ b/gnu/packages/patches/gnumach-support-noide.patch
@@ -0,0 +1,25 @@
+Upstream status: Taken from Debian/upsream.
+
+ https://salsa.debian.org/hurd-team/gnumach/-/blob/master/debian/patches/90_noide.patch
+
+This supports using `noide' on the gnumach command line, disabling
+gnumach IDE support and thus forcing use of rumdisk.
+
+---
+ linux/dev/glue/block.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/linux/dev/glue/block.c
++++ b/linux/dev/glue/block.c
+@@ -207,7 +207,10 @@ int
+ blk_dev_init ()
+ {
+ #ifdef CONFIG_BLK_DEV_IDE
+- ide_init ();
++ extern char *kernel_cmdline;
++ if (strncmp(kernel_cmdline, "noide", 5) &&
++ !strstr(kernel_cmdline, " noide"))
++ ide_init ();
+ #endif
+ #ifdef CONFIG_BLK_DEV_FD
+ floppy_init ();
diff --git a/gnu/packages/patches/hurd-fix-rumpdisk-build.patch b/gnu/packages/patches/hurd-fix-rumpdisk-build.patch
new file mode 100644
index 0000000000..4ecd5ed0ee
--- /dev/null
+++ b/gnu/packages/patches/hurd-fix-rumpdisk-build.patch
@@ -0,0 +1,41 @@
+Upstream status: taken from upstream.
+
+From a2b0f721d077fdc5c9decb21b975b58fb51a3e8f Mon Sep 17 00:00:00 2001
+From: Janneke Nieuwenhuizen <janneke@gnu.org>
+Date: Mon, 22 May 2023 19:21:47 +0200
+Subject: [PATCH] rumpdisk: Do not assume FHS /usr/lib, fixes Guix cross-build.
+
+---
+ rumpdisk/Makefile | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/rumpdisk/Makefile b/rumpdisk/Makefile
+index 60a209b3..b59aaf9a 100644
+--- a/rumpdisk/Makefile
++++ b/rumpdisk/Makefile
+@@ -1,5 +1,5 @@
+ #
+-# Copyright (C) 2019 Free Software Foundation, Inc.
++# Copyright (C) 2019, 2023 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
+@@ -15,7 +15,6 @@
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+-RUMPPATH=/usr/lib
+ RUMPLIBS=rump rumpuser rumpdev rumpdev_disk rumpdev_pci rumpvfs rumpdev_ahcisata rumpdev_piixide rumpdev_ata
+ RUMPEXTRA=rumpdev_scsipi
+
+@@ -38,6 +37,6 @@ target = rumpdisk
+ OBJS = $(SRCS:.c=.o)
+ HURDLIBS = machdev ports trivfs shouldbeinlibc iohelp ihash fshelp
+ LDLIBS += -lpthread -lpciaccess -ldl
+-LDLIBS += -Wl,--whole-archive $(RUMPLIBS:%=$(RUMPPATH)/lib%_pic.a) -Wl,--no-whole-archive $(RUMPEXTRA:%=$(RUMPPATH)/lib%_pic.a)
++LDLIBS += -Wl,--whole-archive $(RUMPLIBS:%=-l%_pic) -Wl,--no-whole-archive $(RUMPEXTRA:%=-l%_pic)
+
+ include ../Makeconf
+--
+2.40.1
+
diff --git a/gnu/packages/patches/hurd-rumpdisk-no-hd.patch b/gnu/packages/patches/hurd-rumpdisk-no-hd.patch
new file mode 100644
index 0000000000..4e5d41917d
--- /dev/null
+++ b/gnu/packages/patches/hurd-rumpdisk-no-hd.patch
@@ -0,0 +1,26 @@
+This avoids rumpdisk crash when booting without "noide".
+
+Upstream status: Taken from Debian Salsa package git
+
+ https://salsa.debian.org/hurd-team/hurd/-/blob/f40ff84260b5a98bea949013415a1c92c127a43e/debian/patches/rumpdisk-no-hd
+
+Index: hurd-debian/rumpdisk/block-rump.c
+===================================================================
+--- hurd-debian.orig/rumpdisk/block-rump.c
++++ hurd-debian/rumpdisk/block-rump.c
+@@ -143,7 +143,6 @@ rumpdisk_device_init (void)
+ {
+ device_t device;
+
+-#if 0
+ if (! device_open (device_master, D_READ, "hd0", &device)
+ || ! device_open (device_master, D_READ, "hd1", &device)
+ || ! device_open (device_master, D_READ, "hd3", &device)
+@@ -154,7 +153,6 @@ rumpdisk_device_init (void)
+ disabled = 1;
+ return;
+ }
+-#endif
+
+ if (! device_open (device_master, D_READ, "sd0", &device)
+ || ! device_open (device_master, D_READ, "sd1", &device)
diff --git a/gnu/packages/patches/libmateweather-use-TZDIR.patch b/gnu/packages/patches/libmateweather-use-TZDIR.patch
new file mode 100644
index 0000000000..5f72043986
--- /dev/null
+++ b/gnu/packages/patches/libmateweather-use-TZDIR.patch
@@ -0,0 +1,42 @@
+From 109fef8208188ddf4be76d6899f7d8fde5b8b3be Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@member.fsf.org>
+Date: Sat, 22 Jul 2023 14:40:31 +0800
+Subject: [PATCH] Use TZDIR for ZONEINFO_DIR if the variable is set.
+
+---
+ libmateweather/mateweather-timezone.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/libmateweather/mateweather-timezone.c b/libmateweather/mateweather-timezone.c
+index 2754728..6c858c4 100644
+--- a/libmateweather/mateweather-timezone.c
++++ b/libmateweather/mateweather-timezone.c
+@@ -61,7 +61,7 @@ static gboolean
+ parse_tzdata (const char *tzname, time_t start, time_t end,
+ int *offset, gboolean *has_dst, int *dst_offset)
+ {
+- char *filename, *contents;
++ char *tzdir, *filename, *contents;
+ gsize length;
+ int timecnt, transitions_size, ttinfo_map_size;
+ int initial_transition = -1, second_transition = -1;
+@@ -71,7 +71,10 @@ parse_tzdata (const char *tzname, time_t start, time_t end,
+ char initial_isdst, second_isdst;
+ int i;
+
+- filename = g_build_filename (ZONEINFO_DIR, tzname, NULL);
++ tzdir = g_getenv("TZDIR");
++ if (tzdir == NULL)
++ tzdir = ZONEINFO_DIR;
++ filename = g_build_filename (tzdir, tzname, NULL);
+ if (!g_file_get_contents (filename, &contents, &length, NULL)) {
+ g_free (filename);
+ return FALSE;
+@@ -403,4 +406,3 @@ mateweather_timezone_get_dst_offset (MateWeatherTimezone *zone)
+ g_return_val_if_fail (zone->has_dst, 0);
+ return zone->dst_offset;
+ }
+-
+--
+2.41.0
+
diff --git a/gnu/packages/patches/linux-libre-wireguard-postup-privkey.patch b/gnu/packages/patches/linux-libre-wireguard-postup-privkey.patch
new file mode 100644
index 0000000000..a6050499e1
--- /dev/null
+++ b/gnu/packages/patches/linux-libre-wireguard-postup-privkey.patch
@@ -0,0 +1,119 @@
+From 3ac1bf099766f1e9735883d5127148054cd5b30a Mon Sep 17 00:00:00 2001
+From: "Jason A. Donenfeld" <Jason@zx2c4.com>
+Date: Thu, 18 May 2023 03:08:44 +0200
+Subject: wireguard: netlink: send staged packets when setting initial private
+ key
+
+Packets bound for peers can queue up prior to the device private key
+being set. For example, if persistent keepalive is set, a packet is
+queued up to be sent as soon as the device comes up. However, if the
+private key hasn't been set yet, the handshake message never sends, and
+no timer is armed to retry, since that would be pointless.
+
+But, if a user later sets a private key, the expectation is that those
+queued packets, such as a persistent keepalive, are actually sent. So
+adjust the configuration logic to account for this edge case, and add a
+test case to make sure this works.
+
+Maxim noticed this with a wg-quick(8) config to the tune of:
+
+ [Interface]
+ PostUp = wg set %i private-key somefile
+
+ [Peer]
+ PublicKey = ...
+ Endpoint = ...
+ PersistentKeepalive = 25
+
+Here, the private key gets set after the device comes up using a PostUp
+script, triggering the bug.
+
+Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
+Cc: stable@vger.kernel.org
+Reported-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
+Link: https://lore.kernel.org/wireguard/87fs7xtqrv.fsf@gmail.com/
+Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
+---
+ drivers/net/wireguard/netlink.c | 14 +++++++++-----
+ tools/testing/selftests/wireguard/netns.sh | 30 ++++++++++++++++++++++++++----
+ 2 files changed, 35 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlink.c
+index 43c8c84e7ea8..6d1bd9f52d02 100644
+--- a/drivers/net/wireguard/netlink.c
++++ b/drivers/net/wireguard/netlink.c
+@@ -546,6 +546,7 @@ static int wg_set_device(struct sk_buff *skb, struct genl_info *info)
+ u8 *private_key = nla_data(info->attrs[WGDEVICE_A_PRIVATE_KEY]);
+ u8 public_key[NOISE_PUBLIC_KEY_LEN];
+ struct wg_peer *peer, *temp;
++ bool send_staged_packets;
+
+ if (!crypto_memneq(wg->static_identity.static_private,
+ private_key, NOISE_PUBLIC_KEY_LEN))
+@@ -564,14 +565,17 @@ static int wg_set_device(struct sk_buff *skb, struct genl_info *info)
+ }
+
+ down_write(&wg->static_identity.lock);
+- wg_noise_set_static_identity_private_key(&wg->static_identity,
+- private_key);
+- list_for_each_entry_safe(peer, temp, &wg->peer_list,
+- peer_list) {
++ send_staged_packets = !wg->static_identity.has_identity && netif_running(wg->dev);
++ wg_noise_set_static_identity_private_key(&wg->static_identity, private_key);
++ send_staged_packets = send_staged_packets && wg->static_identity.has_identity;
++
++ wg_cookie_checker_precompute_device_keys(&wg->cookie_checker);
++ list_for_each_entry_safe(peer, temp, &wg->peer_list, peer_list) {
+ wg_noise_precompute_static_static(peer);
+ wg_noise_expire_current_peer_keypairs(peer);
++ if (send_staged_packets)
++ wg_packet_send_staged_packets(peer);
+ }
+- wg_cookie_checker_precompute_device_keys(&wg->cookie_checker);
+ up_write(&wg->static_identity.lock);
+ }
+ skip_set_private_key:
+diff --git a/tools/testing/selftests/wireguard/netns.sh b/tools/testing/selftests/wireguard/netns.sh
+index 69c7796c7ca9..405ff262ca93 100755
+--- a/tools/testing/selftests/wireguard/netns.sh
++++ b/tools/testing/selftests/wireguard/netns.sh
+@@ -514,10 +514,32 @@ n2 bash -c 'printf 0 > /proc/sys/net/ipv4/conf/all/rp_filter'
+ n1 ping -W 1 -c 1 192.168.241.2
+ [[ $(n2 wg show wg0 endpoints) == "$pub1 10.0.0.3:1" ]]
+
+-ip1 link del veth1
+-ip1 link del veth3
+-ip1 link del wg0
+-ip2 link del wg0
++ip1 link del dev veth3
++ip1 link del dev wg0
++ip2 link del dev wg0
++
++# Make sure persistent keep alives are sent when an adapter comes up
++ip1 link add dev wg0 type wireguard
++n1 wg set wg0 private-key <(echo "$key1") peer "$pub2" endpoint 10.0.0.1:1 persistent-keepalive 1
++read _ _ tx_bytes < <(n1 wg show wg0 transfer)
++[[ $tx_bytes -eq 0 ]]
++ip1 link set dev wg0 up
++read _ _ tx_bytes < <(n1 wg show wg0 transfer)
++[[ $tx_bytes -gt 0 ]]
++ip1 link del dev wg0
++# This should also happen even if the private key is set later
++ip1 link add dev wg0 type wireguard
++n1 wg set wg0 peer "$pub2" endpoint 10.0.0.1:1 persistent-keepalive 1
++read _ _ tx_bytes < <(n1 wg show wg0 transfer)
++[[ $tx_bytes -eq 0 ]]
++ip1 link set dev wg0 up
++read _ _ tx_bytes < <(n1 wg show wg0 transfer)
++[[ $tx_bytes -eq 0 ]]
++n1 wg set wg0 private-key <(echo "$key1")
++read _ _ tx_bytes < <(n1 wg show wg0 transfer)
++[[ $tx_bytes -gt 0 ]]
++ip1 link del dev veth1
++ip1 link del dev wg0
+
+ # We test that Netlink/IPC is working properly by doing things that usually cause split responses
+ ip0 link add dev wg0 type wireguard
+--
+cgit v1.2.3-59-g8ed1b
+
diff --git a/gnu/packages/patches/mactelnet-remove-init.patch b/gnu/packages/patches/mactelnet-remove-init.patch
new file mode 100644
index 0000000000..82372e3fe4
--- /dev/null
+++ b/gnu/packages/patches/mactelnet-remove-init.patch
@@ -0,0 +1,98 @@
+From ca2dff0b97df0ceb8f6357de3a4375ebc09646dd Mon Sep 17 00:00:00 2001
+Message-Id: <ca2dff0b97df0ceb8f6357de3a4375ebc09646dd.1688572750.git.mirai@makinata.eu>
+From: Bruno Victal <mirai@makinata.eu>
+Date: Wed, 5 Jul 2023 16:43:31 +0100
+Subject: [PATCH] Skip installing init file.
+
+The file refers to hardcoded paths.
+---
+ Makefile.am | 2 +-
+ config/Makefile.am | 5 -----
+ config/mactelnetd.init | 21 ---------------------
+ config/mactelnetd.users | 12 ------------
+ configure.ac | 2 +-
+ 5 files changed, 2 insertions(+), 40 deletions(-)
+ delete mode 100644 config/Makefile.am
+ delete mode 100644 config/mactelnetd.init
+ delete mode 100644 config/mactelnetd.users
+
+diff --git a/Makefile.am b/Makefile.am
+index 4e67178..264d8ea 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,5 +1,5 @@
+ AUTOMAKE_OPTIONS = foreign
+-SUBDIRS = src doc config po
++SUBDIRS = src doc po
+
+ CFLAGS = --pedantic -Wall -std=c99 -O3
+ LDFLAGS =
+diff --git a/config/Makefile.am b/config/Makefile.am
+deleted file mode 100644
+index 574a2e0..0000000
+--- a/config/Makefile.am
++++ /dev/null
+@@ -1,5 +0,0 @@
+-dist_sysconf_DATA = mactelnetd.users
+-
+-install-exec-hook:
+- chmod 600 $(DESTDIR)$(sysconfdir)/mactelnetd.users
+- chown root $(DESTDIR)$(sysconfdir)/mactelnetd.users
+diff --git a/config/mactelnetd.init b/config/mactelnetd.init
+deleted file mode 100644
+index b7ddddf..0000000
+--- a/config/mactelnetd.init
++++ /dev/null
+@@ -1,21 +0,0 @@
+-# mactelnetd - MAC-Telnet server
+-#
+-# The MAC-Telnet server provides telnet access via MAC addresses.
+-#
+-# Ubuntu upstart config:
+-
+-description "MAC-Telnet server"
+-
+-start on filesystem
+-stop on runlevel [!2345]
+-
+-respawn
+-respawn limit 10 5
+-umask 022
+-
+-pre-start script
+- test -O /etc/mactelnetd.users || { stop; exit 0; }
+- test -x /usr/sbin/mactelnetd || { stop; exit 0; }
+-end script
+-
+-exec /usr/sbin/mactelnetd -f
+diff --git a/config/mactelnetd.users b/config/mactelnetd.users
+deleted file mode 100644
+index c140e36..0000000
+--- a/config/mactelnetd.users
++++ /dev/null
+@@ -1,12 +0,0 @@
+-# Users file for MAC-Telnetd
+-#
+-####################################################################
+-# WARNING: This file has passwords written in plain-text. #
+-# Make sure this file is owned and only readable by root. #
+-####################################################################
+-#
+-# Each line consists of a username and a password seperated by :.
+-# Usernames must be existing users from passwd.
+-#
+-# Format:
+-#username:password
+diff --git a/configure.ac b/configure.ac
+index c0fdda4..9d2f7d7 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -34,4 +34,4 @@ AC_FUNC_MALLOC
+ AC_FUNC_STRNLEN
+ AC_CHECK_FUNCS([alarm bzero clock_gettime getpass gettimeofday inet_ntoa memset select setenv setlocale socket strcasecmp strerror strncasecmp sysinfo uname])
+
+-AC_OUTPUT(Makefile src/Makefile doc/Makefile config/Makefile po/Makefile.in)
++AC_OUTPUT(Makefile src/Makefile doc/Makefile po/Makefile.in)
+--
+2.40.1
+
diff --git a/gnu/packages/patches/mig-cpu.h-generation.patch b/gnu/packages/patches/mig-cpu.h-generation.patch
deleted file mode 100644
index 3030eaeaa6..0000000000
--- a/gnu/packages/patches/mig-cpu.h-generation.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-Backport MiG commit 73fbf2504ae606dda81372701a67dad6fee0865e:
-
- From: Flavio Cruz <flaviocruz@gmail.com>
- Subject: Generate cpu.h with -ffreestanding
-
---- a/Makefile.in 2023-03-26 23:02:51.384318331 +0200
-+++ b/Makefile.in 2023-03-26 23:03:03.300329369 +0200
-@@ -1051,7 +1051,7 @@ uninstall-am: uninstall-binSCRIPTS unins
- .sym.symc:
- $(AWK_V) $(AWK) -f $(srcdir)/gensym.awk $< > $@
- .symc.symo:
-- $(AM_V_CC) $(TARGET_CC) -S $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -x c -o $@ $<
-+ $(AM_V_CC) $(TARGET_CC) -S $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -ffreestanding -x c -o $@ $<
- .symo.h:
- $(AM_V_GEN) sed -e '/^[^*].*$$/d' -e 's/^[*]/#define/' -e 's/mAgIc[^-0-9]*//' \
- $< > $@
diff --git a/gnu/packages/patches/netdde-build-fix.patch b/gnu/packages/patches/netdde-build-fix.patch
new file mode 100644
index 0000000000..f7f0fc35a9
--- /dev/null
+++ b/gnu/packages/patches/netdde-build-fix.patch
@@ -0,0 +1,28 @@
+Upstream status: Presented upstream.
+
+ https://lists.gnu.org/archive/html/bug-hurd/2023-05//msg00449.html
+
+From b0a7e4f2706bea8d1c80d5af7a095941f9635033 Mon Sep 17 00:00:00 2001
+From: Janneke Nieuwenhuizen <janneke@gnu.org>
+Date: Fri, 26 May 2023 17:39:17 +0200
+Subject: [PATCH] Update for .../rumpdisk: Fix race condition in bootstrap
+
+---
+ machdev.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/machdev.c b/machdev.c
+index dda5eb8ba..1a6811072 100644
+--- a/machdev.c
++++ b/machdev.c
+@@ -18,5 +18,6 @@ void machdev_run1 (void *arg)
+
+ void machdev_run2(void)
+ {
+- machdev_trivfs_server(bootstrap);
++ machdev_trivfs_server_startup(bootstrap);
++ machdev_trivfs_server_loop(NULL);
+ }
+--
+2.40.1
+
diff --git a/gnu/packages/patches/oath-toolkit-xmlsec-compat.patch b/gnu/packages/patches/oath-toolkit-xmlsec-compat.patch
deleted file mode 100644
index 18589366a9..0000000000
--- a/gnu/packages/patches/oath-toolkit-xmlsec-compat.patch
+++ /dev/null
@@ -1,79 +0,0 @@
-Adjust tests for compatibility with newer xmlsec.
-
-Taken from upstream:
-
- https://gitlab.com/oath-toolkit/oath-toolkit/-/commit/0ae59b9c72f69ee21044e736e292b73051df3272
-
-diff --git a/libpskc/examples/pskc-hotp-signed.xml b/libpskc/examples/pskc-hotp-signed.xml
-index 359dd4723cf2b5ae1ca53d793cc6900a15bd4969..396e0829ff245b3ad6953cc3523d77568c8a18f4 100644
---- a/libpskc/examples/pskc-hotp-signed.xml
-+++ b/libpskc/examples/pskc-hotp-signed.xml
-@@ -38,7 +38,8 @@ rIXbwqKhnBP943U4Ch31oEbZtbo+XRbiq11wv6dLNsi76TNGDqsjTKgEcSIYI6Vd
- rMxnil6ChoIBvSSPGHhJuj1bW1EPW92JtIa6byrAj1m4RwSviQy2i65YoIdtrhRt
- CWekj2zuL/0szv5rZMCCvxioOCA8znqELEPMfs0Aa/cACD2MZcC4gGXehNCvzYJr
- TmB6lFpxP6f0g6eO7PVcqYN9NCwECxb5Cvx2j2uNlereY35/9oPR6YJx+V7sL+DB
--n6F0mN8OUAFxDamepKdGRApU8uZ35624o/I4</X509Certificate>
-+n6F0mN8OUAFxDamepKdGRApU8uZ35624o/I4
-+</X509Certificate>
- </X509Data>
- </KeyInfo>
- </Signature></KeyContainer>
-diff --git a/pskctool/tests/pskc-all-signed.xml b/pskctool/tests/pskc-all-signed.xml
-index 39cf8af5bb00e34fa5e1acb97cea59ff742758f4..5d44e72d928ccf1f46975e6ccca58297e235be95 100644
---- a/pskctool/tests/pskc-all-signed.xml
-+++ b/pskctool/tests/pskc-all-signed.xml
-@@ -38,7 +38,8 @@ rIXbwqKhnBP943U4Ch31oEbZtbo+XRbiq11wv6dLNsi76TNGDqsjTKgEcSIYI6Vd
- rMxnil6ChoIBvSSPGHhJuj1bW1EPW92JtIa6byrAj1m4RwSviQy2i65YoIdtrhRt
- CWekj2zuL/0szv5rZMCCvxioOCA8znqELEPMfs0Aa/cACD2MZcC4gGXehNCvzYJr
- TmB6lFpxP6f0g6eO7PVcqYN9NCwECxb5Cvx2j2uNlereY35/9oPR6YJx+V7sL+DB
--n6F0mN8OUAFxDamepKdGRApU8uZ35624o/I4</X509Certificate>
-+n6F0mN8OUAFxDamepKdGRApU8uZ35624o/I4
-+</X509Certificate>
- </X509Data>
- </KeyInfo>
- </Signature></KeyContainer>
-diff --git a/pskctool/tests/tst_libexamples.sh b/pskctool/tests/tst_libexamples.sh
-index 0e8e558b4cbefbac9f2ca301fddb2ac4b8cfbdfa..5cb52ce44f40a78ab886ff12d2eac64e5b5c4c7e 100755
---- a/pskctool/tests/tst_libexamples.sh
-+++ b/pskctool/tests/tst_libexamples.sh
-@@ -1,7 +1,7 @@
- #!/bin/sh
-
- # tst_libexamples.sh - keep pskctool output in GTK-DOC manual up to date
--# Copyright (C) 2012-2021 Simon Josefsson
-+# Copyright (C) 2012-2022 Simon Josefsson
-
- # 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
-@@ -45,7 +45,8 @@ fi
-
- $PSKCTOOL --sign --sign-key $srcdir/pskc-ee-key.pem \
- --sign-crt $srcdir/pskc-ee-crt.pem \
-- $srcdir/../../libpskc/examples/pskc-hotp.xml > foo
-+ $srcdir/../../libpskc/examples/pskc-hotp.xml \
-+ | sed 's,4</X509Cert,4\n</X509Cert,' > foo
- if ! diff -ur $srcdir/../../libpskc/examples/pskc-hotp-signed.xml foo; then
- echo "FAIL: pskctool --sign output change, commit updated file."
- exit 1
-diff --git a/pskctool/tests/tst_sign.sh b/pskctool/tests/tst_sign.sh
-index b62757336061394746d60f706369127fe1db466d..2d452d69f2e6595ff85a34540939801324dbdfea 100755
---- a/pskctool/tests/tst_sign.sh
-+++ b/pskctool/tests/tst_sign.sh
-@@ -1,7 +1,7 @@
- #!/bin/sh
-
- # tst_sign.sh - test that pskctool can sign and verify
--# Copyright (C) 2012-2021 Simon Josefsson
-+# Copyright (C) 2012-2022 Simon Josefsson
-
- # 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
-@@ -32,7 +32,7 @@ $PSKCTOOL --info --strict --debug $pskc_all > tmp-pre-human.txt
- $PSKCTOOL --sign \
- --sign-key $pskc_ee_key \
- --sign-crt $pskc_ee_crt \
-- $pskc_all > tmp-signed.xml
-+ $pskc_all | sed 's,4</X509Cert,4\n</X509Cert,' > tmp-signed.xml
-
- diff -ur $pskc_all_signed tmp-signed.xml
-
diff --git a/gnu/packages/patches/qxlsx-fix-include-directory.patch b/gnu/packages/patches/qxlsx-fix-include-directory.patch
new file mode 100644
index 0000000000..a68ca0cc3b
--- /dev/null
+++ b/gnu/packages/patches/qxlsx-fix-include-directory.patch
@@ -0,0 +1,24 @@
+From 8c3e6633e3c901bc5a5cd477383421b0980dcd26 Mon Sep 17 00:00:00 2001
+From: Alexey Sokolov <sokolov@google.com>
+Date: Mon, 17 Apr 2023 23:43:59 +0100
+Subject: [PATCH] Fix #278
+
+There's no real reason to install the same headers twice, but at least
+now clients of the library can build again
+---
+ QXlsx/CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/QXlsx/CMakeLists.txt b/QXlsx/CMakeLists.txt
+index 4fa7f7f1..074922a8 100644
+--- a/QXlsx/CMakeLists.txt
++++ b/QXlsx/CMakeLists.txt
+@@ -179,7 +179,7 @@ PRIVATE
+ ${QXLSX_HEADERPATH}
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/header>
+- $<INSTALL_INTERFACE:include/QXlsx>
++ $<INSTALL_INTERFACE:include/QXlsxQt${QT_VERSION_MAJOR}>
+ )
+
+ set_target_properties(QXlsx PROPERTIES
diff --git a/gnu/packages/patches/racket-rktboot-riscv64-support.patch b/gnu/packages/patches/racket-rktboot-riscv64-support.patch
new file mode 100644
index 0000000000..f268b1e7f8
--- /dev/null
+++ b/gnu/packages/patches/racket-rktboot-riscv64-support.patch
@@ -0,0 +1,15 @@
+Submitted upstream:
+https://github.com/racket/racket/pull/4703
+
+diff --git a/racket/src/rktboot/machine-def.rkt b/racket/src/rktboot/machine-def.rkt
+index 8ff0688..59ebfc8 100644
+--- a/racket/src/rktboot/machine-def.rkt
++++ b/racket/src/rktboot/machine-def.rkt
+@@ -25,6 +25,7 @@
+ [(regexp-match? #rx"^t?arm32" target-machine) "arm32"]
+ [(regexp-match? #rx"^t?arm64" target-machine) "arm64"]
+ [(regexp-match? #rx"^t?ppc32" target-machine) "ppc32"]
++ [(regexp-match? #rx"^t?rv64" target-machine) "rv64"]
+ [(regexp-match? #rx"^t?pb" target-machine) "pb"]
+ [else (error "machine.def: cannot infer architecture")]))]
+ [s (regexp-replace* #rx"[$][(]Mend[)]" s
diff --git a/gnu/packages/patches/sssd-system-directories.patch b/gnu/packages/patches/sssd-system-directories.patch
index ce0dcf5d4d..cc37ac6024 100644
--- a/gnu/packages/patches/sssd-system-directories.patch
+++ b/gnu/packages/patches/sssd-system-directories.patch
@@ -2,19 +2,10 @@ Do not attempt to create $localstatedir and $sysconfdir (i.e., /var and /etc)
upon "make install".
diff --git a/Makefile.am b/Makefile.am
-index 0de53a2c8..51ad57bf1 100644
+index e780e8a14..afd2b0a49 100644
--- a/Makefile.am
+++ b/Makefile.am
-@@ -58,7 +58,7 @@ sssddatadir = $(datadir)/sssd
- sssdapiplugindir = $(sssddatadir)/sssd.api.d
- sssdtapscriptdir = $(sssddatadir)/systemtap
- krb5snippetsdir = $(sssddatadir)/krb5-snippets
--dbuspolicydir = $(sysconfdir)/dbus-1/system.d
-+dbuspolicydir = $(prefix)/etc/dbus-1/system.d
- dbusservicedir = $(datadir)/dbus-1/system-services
- sss_statedir = $(localstatedir)/lib/sss
- runstatedir = @runstatedir@
-@@ -85,7 +85,7 @@ pkgconfigdir = $(libdir)/pkgconfig
+@@ -84,7 +84,7 @@ pkgconfigdir = $(libdir)/pkgconfig
krb5rcachedir = @krb5rcachedir@
sudolibdir = @sudolibpath@
polkitdir = @polkitdir@
@@ -23,7 +14,7 @@ index 0de53a2c8..51ad57bf1 100644
systemtap_tapdir = @tapset_dir@
sssdkcmdatadir = $(datadir)/sssd-kcm
deskprofilepath = $(sss_statedir)/deskprofile
-@@ -5195,7 +5195,6 @@ installsssddirs::
+@@ -5378,7 +5378,6 @@ installsssddirs::
$(DESTDIR)$(bindir) \
$(DESTDIR)$(sbindir) \
$(DESTDIR)$(mandir) \
@@ -31,7 +22,7 @@ index 0de53a2c8..51ad57bf1 100644
$(DESTDIR)$(pluginpath) \
$(DESTDIR)$(libdir)/ldb \
$(DESTDIR)$(dbuspolicydir) \
-@@ -5205,24 +5204,12 @@ installsssddirs::
+@@ -5388,24 +5387,12 @@ installsssddirs::
$(DESTDIR)$(sssddatadir) \
$(DESTDIR)$(sudolibdir) \
$(DESTDIR)$(autofslibdir) \
@@ -56,7 +47,7 @@ index 0de53a2c8..51ad57bf1 100644
if HAVE_DOXYGEN
docs:
-@@ -5338,7 +5325,6 @@ if BUILD_SAMBA
+@@ -5523,7 +5510,6 @@ if BUILD_SAMBA
endif
if BUILD_KCM
$(MKDIR_P) $(DESTDIR)/$(sssdkcmdatadir)
diff --git a/gnu/packages/patches/texlive-hyph-utf8-no-byebug.patch b/gnu/packages/patches/texlive-hyph-utf8-no-byebug.patch
deleted file mode 100644
index fb29b76ef2..0000000000
--- a/gnu/packages/patches/texlive-hyph-utf8-no-byebug.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Description: Avoid dependency on byebug to reduce package closure
- significantly, see https://issues.guix.gnu.org/55997
-diff --git a/lib/tex/hyphen/language.rb b/lib/tex/hyphen/language.rb
-index 12831417..df6daa39 100644
---- a/lib/tex/hyphen/language.rb
-+++ b/lib/tex/hyphen/language.rb
-@@ -1,6 +1,5 @@
- require 'yaml'
- require 'hydra'
--require 'byebug'
-
- require_relative 'path'
-
diff --git a/gnu/packages/patches/u-boot-allow-disabling-openssl.patch b/gnu/packages/patches/u-boot-allow-disabling-openssl.patch
index 5f2856dbb4..5195a7a6f8 100644
--- a/gnu/packages/patches/u-boot-allow-disabling-openssl.patch
+++ b/gnu/packages/patches/u-boot-allow-disabling-openssl.patch
@@ -128,29 +128,28 @@ index 94b7685392..eec599b0ee 100644
datai = 0;
for (cfgi = 0; cfgi < cfgn; cfgi++) {
e = &image_cfg[cfgi];
-@@ -1552,9 +1568,11 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
+@@ -1624,10 +1640,12 @@ static void *image_create_v1(size_t *dataoff, struct image_tool_params *params,
&datai, delay);
}
+#if defined(CONFIG_KWB_SECURE)
- if (secure_hdr && add_secure_header_v1(params, ptr, payloadsz + headersz,
- headersz, image, secure_hdr))
+ if (secure_hdr && add_secure_header_v1(params, ptr + *dataoff, payloadsz,
+ image, headersz, secure_hdr))
return NULL;
+#endif
- *imagesz = headersz;
+ /* Calculate and set the header checksum */
+ main_hdr->checksum = image_checksum8(main_hdr, headersz);
--- a/tools/image-host.c
+++ b/tools/image-host.c
-@@ -14,10 +14,12 @@
+@@ -14,8 +14,10 @@
#include <image.h>
#include <version.h>
+#ifdef CONFIG_FIT_PRELOAD
#include <openssl/pem.h>
#include <openssl/evp.h>
-
- #define IMAGE_PRE_LOAD_PATH "/image/pre-load/sig"
+#endif
/**
diff --git a/gnu/packages/patches/u-boot-fix-u-boot-lib-build.patch b/gnu/packages/patches/u-boot-fix-u-boot-lib-build.patch
new file mode 100644
index 0000000000..233c437de6
--- /dev/null
+++ b/gnu/packages/patches/u-boot-fix-u-boot-lib-build.patch
@@ -0,0 +1,24 @@
+Submitted upstream (see:
+https://lists.denx.de/pipermail/u-boot/2023-July/521984.html)
+
+diff --git a/tools/u_boot_pylib/pyproject.toml b/tools/u_boot_pylib/pyproject.toml
+index 3f33caf6f8..037c5d629e 100644
+--- a/tools/u_boot_pylib/pyproject.toml
++++ b/tools/u_boot_pylib/pyproject.toml
+@@ -9,7 +9,7 @@ authors = [
+ { name="Simon Glass", email="sjg@chromium.org" },
+ ]
+ description = "U-Boot python library"
+-readme = "README.md"
++readme = "README.rst"
+ requires-python = ">=3.7"
+ classifiers = [
+ "Programming Language :: Python :: 3",
+@@ -20,3 +20,7 @@ classifiers = [
+ [project.urls]
+ "Homepage" = "https://u-boot.readthedocs.io"
+ "Bug Tracker" = "https://source.denx.de/groups/u-boot/-/issues"
++
++[tool.setuptools.packages.find]
++where = [".."]
++include = ["u_boot_pylib*"]
diff --git a/gnu/packages/patches/u-boot-infodocs-target.patch b/gnu/packages/patches/u-boot-infodocs-target.patch
deleted file mode 100644
index 5b21a99de3..0000000000
--- a/gnu/packages/patches/u-boot-infodocs-target.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-Upstream status: https://patchwork.ozlabs.org/project/uboot/list/?series=333259
-
-diff --git a/Makefile b/Makefile
-index de5746399a..597a8886c3 100644
---- a/Makefile
-+++ b/Makefile
-@@ -2372,7 +2372,7 @@ tcheck:
- # Documentation targets
- # ---------------------------------------------------------------------------
- DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
-- linkcheckdocs dochelp refcheckdocs
-+ linkcheckdocs dochelp refcheckdocs texinfodocs infodocs
- PHONY += $(DOC_TARGETS)
- $(DOC_TARGETS): scripts_basic FORCE
- $(Q)$(MAKE) $(build)=doc $@
-diff --git a/doc/Makefile b/doc/Makefile
-index f5de65e927..d0904a9f99 100644
---- a/doc/Makefile
-+++ b/doc/Makefile
-@@ -69,6 +69,14 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
- htmldocs:
- @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
-
-+texinfodocs:
-+ @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,texinfo,$(var),texinfo,$(var)))
-+
-+# Note: the 'info' Make target is generated by sphinx itself when
-+# running the texinfodocs target defined above.
-+infodocs: texinfodocs
-+ $(MAKE) -C $(BUILDDIR)/texinfo info
-+
- linkcheckdocs:
- @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
-
-@@ -109,6 +117,8 @@ cleandocs:
- dochelp:
- @echo ' U-Boot documentation in different formats from ReST:'
- @echo ' htmldocs - HTML'
-+ @echo ' texinfodocs - Texinfo'
-+ @echo ' infodocs - Info'
- @echo ' latexdocs - LaTeX'
- @echo ' pdfdocs - PDF'
- @echo ' epubdocs - EPUB'
-diff --git a/doc/conf.py b/doc/conf.py
-index 62c8d31270..3db70f80c1 100644
---- a/doc/conf.py
-+++ b/doc/conf.py
-@@ -449,7 +449,7 @@ for fn in os.listdir('.'):
- # One entry per manual page. List of tuples
- # (source start file, name, description, authors, manual section).
- man_pages = [
-- (master_doc, 'dasuboot', 'The U-Boot Documentation',
-+ (master_doc, 'u-boot', 'The U-Boot Documentation',
- [author], 1)
- ]
-
-@@ -463,8 +463,8 @@ man_pages = [
- # (source start file, target name, title, author,
- # dir menu entry, description, category)
- texinfo_documents = [
-- (master_doc, 'DasUBoot', 'The U-Boot Documentation',
-- author, 'DasUBoot', 'One line description of project.',
-+ (master_doc, 'u-boot', 'The U-Boot Documentation',
-+ author, 'U-Boot', 'Boot loader for embedded systems',
- 'Miscellaneous'),
- ]
-
-diff --git a/doc/media/Makefile b/doc/media/Makefile
-index b9b43a34c3..9b32258696 100644
---- a/doc/media/Makefile
-+++ b/doc/media/Makefile
-@@ -22,10 +22,11 @@ $(BUILDDIR)/linker_lists.h.rst: ${API}/linker_lists.h ${PARSER} $(SRC_DIR)/linke
-
- # Media build rules
-
--.PHONY: all html epub xml latex
-+.PHONY: all html texinfo epub xml latex
-
- all: $(IMGDOT) $(BUILDDIR) ${TARGETS}
- html: all
-+texinfo: all
- epub: all
- xml: all
- latex: $(IMGPDF) all
diff --git a/gnu/packages/patches/u-boot-patman-guix-integration.patch b/gnu/packages/patches/u-boot-patman-guix-integration.patch
deleted file mode 100644
index 3472656c99..0000000000
--- a/gnu/packages/patches/u-boot-patman-guix-integration.patch
+++ /dev/null
@@ -1,1244 +0,0 @@
-These changes correspond to commits 9ff7500ace..3154de3dd6 already merged to
-the u-boot-dm custodian repo (at
-https://source.denx.de/u-boot/custodians/u-boot-dm/-/commits/next), scheduled
-to be pulled after the next release.
-
-diff --git a/tools/patman/__init__.py b/tools/patman/__init__.py
-index c9d3e35052..1b98ec7fee 100644
---- a/tools/patman/__init__.py
-+++ b/tools/patman/__init__.py
-@@ -1,6 +1,6 @@
- # SPDX-License-Identifier: GPL-2.0+
-
- __all__ = ['checkpatch', 'command', 'commit', 'control', 'cros_subprocess',
-- 'func_test', 'get_maintainer', 'gitutil', 'main', 'patchstream',
-+ 'func_test', 'get_maintainer', 'gitutil', '__main__', 'patchstream',
- 'project', 'series', 'setup', 'settings', 'terminal',
- 'test_checkpatch', 'test_util', 'tools', 'tout']
-diff --git a/tools/patman/main.py b/tools/patman/__main__.py
-similarity index 89%
-rename from tools/patman/main.py
-rename to tools/patman/__main__.py
-index 8067a288ab..749e6348b6 100755
---- a/tools/patman/main.py
-+++ b/tools/patman/__main__.py
-@@ -7,6 +7,7 @@
- """See README for more information"""
-
- from argparse import ArgumentParser
-+import importlib.resources
- import os
- import re
- import sys
-@@ -19,6 +20,7 @@ if __name__ == "__main__":
-
- # Our modules
- from patman import control
-+from patman import func_test
- from patman import gitutil
- from patman import project
- from patman import settings
-@@ -53,7 +55,8 @@ parser.add_argument('-H', '--full-help', action='store_true', dest='full_help',
- default=False, help='Display the README file')
-
- subparsers = parser.add_subparsers(dest='cmd')
--send = subparsers.add_parser('send')
-+send = subparsers.add_parser(
-+ 'send', help='Format, check and email patches (default command)')
- send.add_argument('-i', '--ignore-errors', action='store_true',
- dest='ignore_errors', default=False,
- help='Send patches email even if patch errors are found')
-@@ -62,6 +65,12 @@ send.add_argument('-l', '--limit-cc', dest='limit', type=int, default=None,
- send.add_argument('-m', '--no-maintainers', action='store_false',
- dest='add_maintainers', default=True,
- help="Don't cc the file maintainers automatically")
-+send.add_argument(
-+ '--get-maintainer-script', dest='get_maintainer_script', type=str,
-+ action='store',
-+ default=os.path.join(gitutil.get_top_level(), 'scripts',
-+ 'get_maintainer.pl') + ' --norolestats',
-+ help='File name of the get_maintainer.pl (or compatible) script.')
- send.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
- default=False, help="Do a dry run (create but don't email patches)")
- send.add_argument('-r', '--in-reply-to', type=str, action='store',
-@@ -94,9 +103,11 @@ send.add_argument('--smtp-server', type=str,
-
- send.add_argument('patchfiles', nargs='*')
-
--test_parser = subparsers.add_parser('test', help='Run tests')
--test_parser.add_argument('testname', type=str, default=None, nargs='?',
-- help="Specify the test to run")
-+# Only add the 'test' action if the test data files are available.
-+if os.path.exists(func_test.TEST_DATA_DIR):
-+ test_parser = subparsers.add_parser('test', help='Run tests')
-+ test_parser.add_argument('testname', type=str, default=None, nargs='?',
-+ help="Specify the test to run")
-
- status = subparsers.add_parser('status',
- help='Check status of patches in patchwork')
-@@ -113,7 +124,7 @@ status.add_argument('-f', '--force', action='store_true',
- argv = sys.argv[1:]
- args, rest = parser.parse_known_args(argv)
- if hasattr(args, 'project'):
-- settings.Setup(gitutil, parser, args.project, '')
-+ settings.Setup(parser, args.project)
- args, rest = parser.parse_known_args(argv)
-
- # If we have a command, it is safe to parse all arguments
-@@ -160,11 +171,8 @@ elif args.cmd == 'send':
- fd.close()
-
- elif args.full_help:
-- tools.print_full_help(
-- os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
-- 'README.rst')
-- )
--
-+ with importlib.resources.path('patman', 'README.rst') as readme:
-+ tools.print_full_help(str(readme))
- else:
- # If we are not processing tags, no need to warning about bad ones
- if not args.process_tags:
-diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
-index d1b902dd96..012c0d895c 100644
---- a/tools/patman/checkpatch.py
-+++ b/tools/patman/checkpatch.py
-@@ -211,7 +211,7 @@ def check_patch(fname, verbose=False, show_types=False, use_tree=False):
- stdout: Full output of checkpatch
- """
- chk = find_check_patch()
-- args = [chk]
-+ args = [chk, '--u-boot', '--strict']
- if not use_tree:
- args.append('--no-tree')
- if show_types:
-diff --git a/tools/patman/control.py b/tools/patman/control.py
-index bf426cf7bc..38e98dab84 100644
---- a/tools/patman/control.py
-+++ b/tools/patman/control.py
-@@ -94,8 +94,8 @@ def check_patches(series, patch_files, run_checkpatch, verbose, use_tree):
-
-
- def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go,
-- ignore_bad_tags, add_maintainers, limit, dry_run, in_reply_to,
-- thread, smtp_server):
-+ ignore_bad_tags, add_maintainers, get_maintainer_script, limit,
-+ dry_run, in_reply_to, thread, smtp_server):
- """Email patches to the recipients
-
- This emails out the patches and cover letter using 'git send-email'. Each
-@@ -123,6 +123,8 @@ def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go,
- ignore_bad_tags (bool): True to just print a warning for unknown tags,
- False to halt with an error
- add_maintainers (bool): Run the get_maintainer.pl script for each patch
-+ get_maintainer_script (str): The script used to retrieve which
-+ maintainers to cc
- limit (int): Limit on the number of people that can be cc'd on a single
- patch or the cover letter (None if no limit)
- dry_run (bool): Don't actually email the patches, just print out what
-@@ -134,7 +136,7 @@ def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go,
- smtp_server (str): SMTP server to use to send patches (None for default)
- """
- cc_file = series.MakeCcFile(process_tags, cover_fname, not ignore_bad_tags,
-- add_maintainers, limit)
-+ add_maintainers, limit, get_maintainer_script)
-
- # Email the patches out (giving the user time to check / cancel)
- cmd = ''
-@@ -174,8 +176,8 @@ def send(args):
- email_patches(
- col, series, cover_fname, patch_files, args.process_tags,
- its_a_go, args.ignore_bad_tags, args.add_maintainers,
-- args.limit, args.dry_run, args.in_reply_to, args.thread,
-- args.smtp_server)
-+ args.get_maintainer_script, args.limit, args.dry_run,
-+ args.in_reply_to, args.thread, args.smtp_server)
-
- def patchwork_status(branch, count, start, end, dest_branch, force,
- show_comments, url):
-diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
-index 7b92bc67be..c25a47bdeb 100644
---- a/tools/patman/func_test.py
-+++ b/tools/patman/func_test.py
-@@ -6,7 +6,9 @@
-
- """Functional tests for checking that patman behaves correctly"""
-
-+import contextlib
- import os
-+import pathlib
- import re
- import shutil
- import sys
-@@ -28,6 +30,21 @@ from patman.test_util import capture_sys_output
- import pygit2
- from patman import status
-
-+PATMAN_DIR = pathlib.Path(__file__).parent
-+TEST_DATA_DIR = PATMAN_DIR / 'test/'
-+
-+
-+@contextlib.contextmanager
-+def directory_excursion(directory):
-+ """Change directory to `directory` for a limited to the context block."""
-+ current = os.getcwd()
-+ try:
-+ os.chdir(directory)
-+ yield
-+ finally:
-+ os.chdir(current)
-+
-+
- class TestFunctional(unittest.TestCase):
- """Functional tests for checking that patman behaves correctly"""
- leb = (b'Lord Edmund Blackadd\xc3\xabr <weasel@blackadder.org>'.
-@@ -57,8 +74,7 @@ class TestFunctional(unittest.TestCase):
- Returns:
- str: Full path to file in the test directory
- """
-- return os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
-- 'test', fname)
-+ return TEST_DATA_DIR / fname
-
- @classmethod
- def _get_text(cls, fname):
-@@ -200,6 +216,8 @@ class TestFunctional(unittest.TestCase):
- text = self._get_text('test01.txt')
- series = patchstream.get_metadata_for_test(text)
- cover_fname, args = self._create_patches_for_test(series)
-+ get_maintainer_script = str(pathlib.Path(__file__).parent.parent.parent
-+ / 'get_maintainer.pl') + ' --norolestats'
- with capture_sys_output() as out:
- patchstream.fix_patches(series, args)
- if cover_fname and series.get('cover'):
-@@ -207,7 +225,7 @@ class TestFunctional(unittest.TestCase):
- series.DoChecks()
- cc_file = series.MakeCcFile(process_tags, cover_fname,
- not ignore_bad_tags, add_maintainers,
-- None)
-+ None, get_maintainer_script)
- cmd = gitutil.email_patches(
- series, cover_fname, args, dry_run, not ignore_bad_tags,
- cc_file, in_reply_to=in_reply_to, thread=None)
-@@ -502,6 +520,37 @@ complicated as possible''')
- finally:
- os.chdir(orig_dir)
-
-+ def test_custom_get_maintainer_script(self):
-+ """Validate that a custom get_maintainer script gets used."""
-+ self.make_git_tree()
-+ with directory_excursion(self.gitdir):
-+ # Setup git.
-+ os.environ['GIT_CONFIG_GLOBAL'] = '/dev/null'
-+ os.environ['GIT_CONFIG_SYSTEM'] = '/dev/null'
-+ tools.run('git', 'config', 'user.name', 'Dummy')
-+ tools.run('git', 'config', 'user.email', 'dumdum@dummy.com')
-+ tools.run('git', 'branch', 'upstream')
-+ tools.run('git', 'branch', '--set-upstream-to=upstream')
-+ tools.run('git', 'add', '.')
-+ tools.run('git', 'commit', '-m', 'new commit')
-+
-+ # Setup patman configuration.
-+ with open('.patman', 'w', buffering=1) as f:
-+ f.write('[settings]\n'
-+ 'get_maintainer_script: dummy-script.sh\n'
-+ 'check_patch: False\n')
-+ with open('dummy-script.sh', 'w', buffering=1) as f:
-+ f.write('#!/usr/bin/env python\n'
-+ 'print("hello@there.com")\n')
-+ os.chmod('dummy-script.sh', 0x555)
-+
-+ # Finally, do the test
-+ with capture_sys_output():
-+ output = tools.run(PATMAN_DIR / 'patman', '--dry-run')
-+ # Assert the email address is part of the dry-run
-+ # output.
-+ self.assertIn('hello@there.com', output)
-+
- def test_tags(self):
- """Test collection of tags in a patchstream"""
- text = '''This is a patch
-diff --git a/tools/patman/get_maintainer.py b/tools/patman/get_maintainer.py
-index e1d15ff6ab..f7011be1e4 100644
---- a/tools/patman/get_maintainer.py
-+++ b/tools/patman/get_maintainer.py
-@@ -1,48 +1,61 @@
- # SPDX-License-Identifier: GPL-2.0+
- # Copyright (c) 2012 The Chromium OS Authors.
-+# Copyright (c) 2022 Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
- #
-
- import os
-+import shlex
-+import shutil
-
- from patman import command
-+from patman import gitutil
-
--def find_get_maintainer(try_list):
-- """Look for the get_maintainer.pl script.
-
-- Args:
-- try_list: List of directories to try for the get_maintainer.pl script
-+def find_get_maintainer(script_file_name):
-+ """Try to find where `script_file_name` is.
-
-- Returns:
-- If the script is found we'll return a path to it; else None.
-+ It searches in PATH and falls back to a path relative to the top
-+ of the current git repository.
- """
-- # Look in the list
-- for path in try_list:
-- fname = os.path.join(path, 'get_maintainer.pl')
-- if os.path.isfile(fname):
-- return fname
-+ get_maintainer = shutil.which(script_file_name)
-+ if get_maintainer:
-+ return get_maintainer
-+
-+ git_relative_script = os.path.join(gitutil.get_top_level(),
-+ script_file_name)
-+ if os.path.exists(git_relative_script):
-+ return git_relative_script
-
-- return None
-
--def get_maintainer(dir_list, fname, verbose=False):
-- """Run get_maintainer.pl on a file if we find it.
-+def get_maintainer(script_file_name, fname, verbose=False):
-+ """Run `script_file_name` on a file.
-
-- We look for get_maintainer.pl in the 'scripts' directory at the top of
-- git. If we find it we'll run it. If we don't find get_maintainer.pl
-- then we fail silently.
-+ `script_file_name` should be a get_maintainer.pl-like script that
-+ takes a patch file name as an input and return the email addresses
-+ of the associated maintainers to standard output, one per line.
-+
-+ If `script_file_name` does not exist we fail silently.
-
- Args:
-- dir_list: List of directories to try for the get_maintainer.pl script
-- fname: Path to the patch file to run get_maintainer.pl on.
-+ script_file_name: The file name of the get_maintainer.pl script
-+ (or compatible).
-+ fname: File name of the patch to process with get_maintainer.pl.
-
- Returns:
- A list of email addresses to CC to.
- """
-- get_maintainer = find_get_maintainer(dir_list)
-+ # Expand `script_file_name` into a file name and its arguments, if
-+ # any.
-+ cmd_args = shlex.split(script_file_name)
-+ file_name = cmd_args[0]
-+ arguments = cmd_args[1:]
-+
-+ get_maintainer = find_get_maintainer(file_name)
- if not get_maintainer:
- if verbose:
- print("WARNING: Couldn't find get_maintainer.pl")
- return []
-
-- stdout = command.output(get_maintainer, '--norolestats', fname)
-+ stdout = command.output(get_maintainer, *arguments, fname)
- lines = stdout.splitlines()
-- return [ x.replace('"', '') for x in lines ]
-+ return [x.replace('"', '') for x in lines]
-diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
-index ceaf2ce150..5e742102c2 100644
---- a/tools/patman/gitutil.py
-+++ b/tools/patman/gitutil.py
-@@ -2,21 +2,19 @@
- # Copyright (c) 2011 The Chromium OS Authors.
- #
-
--import re
- import os
--import subprocess
- import sys
-
- from patman import command
- from patman import settings
- from patman import terminal
--from patman import tools
-
- # True to use --no-decorate - we check this in setup()
- use_no_decorate = True
-
-+
- def log_cmd(commit_range, git_dir=None, oneline=False, reverse=False,
-- count=None):
-+ count=None):
- """Create a command to perform a 'git log'
-
- Args:
-@@ -49,6 +47,7 @@ def log_cmd(commit_range, git_dir=None, oneline=False, reverse=False,
- cmd.append('--')
- return cmd
-
-+
- def count_commits_to_branch(branch):
- """Returns number of commits between HEAD and the tracking branch.
-
-@@ -68,13 +67,14 @@ def count_commits_to_branch(branch):
- rev_range = '@{upstream}..'
- pipe = [log_cmd(rev_range, oneline=True)]
- result = command.run_pipe(pipe, capture=True, capture_stderr=True,
-- oneline=True, raise_on_error=False)
-+ oneline=True, raise_on_error=False)
- if result.return_code:
- raise ValueError('Failed to determine upstream: %s' %
- result.stderr.strip())
- patch_count = len(result.stdout.splitlines())
- return patch_count
-
-+
- def name_revision(commit_hash):
- """Gets the revision name for a commit
-
-@@ -91,6 +91,7 @@ def name_revision(commit_hash):
- name = stdout.split(' ')[1].strip()
- return name
-
-+
- def guess_upstream(git_dir, branch):
- """Tries to guess the upstream for a branch
-
-@@ -109,7 +110,7 @@ def guess_upstream(git_dir, branch):
- """
- pipe = [log_cmd(branch, git_dir=git_dir, oneline=True, count=100)]
- result = command.run_pipe(pipe, capture=True, capture_stderr=True,
-- raise_on_error=False)
-+ raise_on_error=False)
- if result.return_code:
- return None, "Branch '%s' not found" % branch
- for line in result.stdout.splitlines()[1:]:
-@@ -121,6 +122,7 @@ def guess_upstream(git_dir, branch):
- return name, "Guessing upstream as '%s'" % name
- return None, "Cannot find a suitable upstream for branch '%s'" % branch
-
-+
- def get_upstream(git_dir, branch):
- """Returns the name of the upstream for a branch
-
-@@ -135,10 +137,10 @@ def get_upstream(git_dir, branch):
- """
- try:
- remote = command.output_one_line('git', '--git-dir', git_dir, 'config',
-- 'branch.%s.remote' % branch)
-+ 'branch.%s.remote' % branch)
- merge = command.output_one_line('git', '--git-dir', git_dir, 'config',
-- 'branch.%s.merge' % branch)
-- except:
-+ 'branch.%s.merge' % branch)
-+ except Exception:
- upstream, msg = guess_upstream(git_dir, branch)
- return upstream, msg
-
-@@ -149,7 +151,8 @@ def get_upstream(git_dir, branch):
- return '%s/%s' % (remote, leaf), None
- else:
- raise ValueError("Cannot determine upstream branch for branch "
-- "'%s' remote='%s', merge='%s'" % (branch, remote, merge))
-+ "'%s' remote='%s', merge='%s'"
-+ % (branch, remote, merge))
-
-
- def get_range_in_branch(git_dir, branch, include_upstream=False):
-@@ -168,6 +171,7 @@ def get_range_in_branch(git_dir, branch, include_upstream=False):
- rstr = '%s%s..%s' % (upstream, '~' if include_upstream else '', branch)
- return rstr, msg
-
-+
- def count_commits_in_range(git_dir, range_expr):
- """Returns the number of commits in the given range.
-
-@@ -180,12 +184,13 @@ def count_commits_in_range(git_dir, range_expr):
- """
- pipe = [log_cmd(range_expr, git_dir=git_dir, oneline=True)]
- result = command.run_pipe(pipe, capture=True, capture_stderr=True,
-- raise_on_error=False)
-+ raise_on_error=False)
- if result.return_code:
- return None, "Range '%s' not found or is invalid" % range_expr
- patch_count = len(result.stdout.splitlines())
- return patch_count, None
-
-+
- def count_commits_in_branch(git_dir, branch, include_upstream=False):
- """Returns the number of commits in the given branch.
-
-@@ -201,6 +206,7 @@ def count_commits_in_branch(git_dir, branch, include_upstream=False):
- return None, msg
- return count_commits_in_range(git_dir, range_expr)
-
-+
- def count_commits(commit_range):
- """Returns the number of commits in the given range.
-
-@@ -215,6 +221,7 @@ def count_commits(commit_range):
- patch_count = int(stdout)
- return patch_count
-
-+
- def checkout(commit_hash, git_dir=None, work_tree=None, force=False):
- """Checkout the selected commit for this build
-
-@@ -231,10 +238,11 @@ def checkout(commit_hash, git_dir=None, work_tree=None, force=False):
- pipe.append('-f')
- pipe.append(commit_hash)
- result = command.run_pipe([pipe], capture=True, raise_on_error=False,
-- capture_stderr=True)
-+ capture_stderr=True)
- if result.return_code != 0:
- raise OSError('git checkout (%s): %s' % (pipe, result.stderr))
-
-+
- def clone(git_dir, output_dir):
- """Checkout the selected commit for this build
-
-@@ -243,10 +251,11 @@ def clone(git_dir, output_dir):
- """
- pipe = ['git', 'clone', git_dir, '.']
- result = command.run_pipe([pipe], capture=True, cwd=output_dir,
-- capture_stderr=True)
-+ capture_stderr=True)
- if result.return_code != 0:
- raise OSError('git clone: %s' % result.stderr)
-
-+
- def fetch(git_dir=None, work_tree=None):
- """Fetch from the origin repo
-
-@@ -263,6 +272,7 @@ def fetch(git_dir=None, work_tree=None):
- if result.return_code != 0:
- raise OSError('git fetch: %s' % result.stderr)
-
-+
- def check_worktree_is_available(git_dir):
- """Check if git-worktree functionality is available
-
-@@ -274,9 +284,10 @@ def check_worktree_is_available(git_dir):
- """
- pipe = ['git', '--git-dir', git_dir, 'worktree', 'list']
- result = command.run_pipe([pipe], capture=True, capture_stderr=True,
-- raise_on_error=False)
-+ raise_on_error=False)
- return result.return_code == 0
-
-+
- def add_worktree(git_dir, output_dir, commit_hash=None):
- """Create and checkout a new git worktree for this build
-
-@@ -290,10 +301,11 @@ def add_worktree(git_dir, output_dir, commit_hash=None):
- if commit_hash:
- pipe.append(commit_hash)
- result = command.run_pipe([pipe], capture=True, cwd=output_dir,
-- capture_stderr=True)
-+ capture_stderr=True)
- if result.return_code != 0:
- raise OSError('git worktree add: %s' % result.stderr)
-
-+
- def prune_worktrees(git_dir):
- """Remove administrative files for deleted worktrees
-
-@@ -305,7 +317,8 @@ def prune_worktrees(git_dir):
- if result.return_code != 0:
- raise OSError('git worktree prune: %s' % result.stderr)
-
--def create_patches(branch, start, count, ignore_binary, series, signoff = True):
-+
-+def create_patches(branch, start, count, ignore_binary, series, signoff=True):
- """Create a series of patches from the top of the current branch.
-
- The patch files are written to the current directory using
-@@ -321,9 +334,7 @@ def create_patches(branch, start, count, ignore_binary, series, signoff = True):
- Filename of cover letter (None if none)
- List of filenames of patch files
- """
-- if series.get('version'):
-- version = '%s ' % series['version']
-- cmd = ['git', 'format-patch', '-M' ]
-+ cmd = ['git', 'format-patch', '-M']
- if signoff:
- cmd.append('--signoff')
- if ignore_binary:
-@@ -341,9 +352,10 @@ def create_patches(branch, start, count, ignore_binary, series, signoff = True):
-
- # We have an extra file if there is a cover letter
- if series.get('cover'):
-- return files[0], files[1:]
-+ return files[0], files[1:]
- else:
-- return None, files
-+ return None, files
-+
-
- def build_email_list(in_list, tag=None, alias=None, warn_on_error=True):
- """Build a list of email addresses based on an input list.
-@@ -385,40 +397,43 @@ def build_email_list(in_list, tag=None, alias=None, warn_on_error=True):
- raw += lookup_email(item, alias, warn_on_error=warn_on_error)
- result = []
- for item in raw:
-- if not item in result:
-+ if item not in result:
- result.append(item)
- if tag:
- return ['%s %s%s%s' % (tag, quote, email, quote) for email in result]
- return result
-
-+
- def check_suppress_cc_config():
- """Check if sendemail.suppresscc is configured correctly.
-
- Returns:
- True if the option is configured correctly, False otherwise.
- """
-- suppresscc = command.output_one_line('git', 'config', 'sendemail.suppresscc',
-- raise_on_error=False)
-+ suppresscc = command.output_one_line(
-+ 'git', 'config', 'sendemail.suppresscc', raise_on_error=False)
-
- # Other settings should be fine.
- if suppresscc == 'all' or suppresscc == 'cccmd':
- col = terminal.Color()
-
- print((col.build(col.RED, "error") +
-- ": git config sendemail.suppresscc set to %s\n" % (suppresscc)) +
-- " patman needs --cc-cmd to be run to set the cc list.\n" +
-- " Please run:\n" +
-- " git config --unset sendemail.suppresscc\n" +
-- " Or read the man page:\n" +
-- " git send-email --help\n" +
-- " and set an option that runs --cc-cmd\n")
-+ ": git config sendemail.suppresscc set to %s\n"
-+ % (suppresscc)) +
-+ " patman needs --cc-cmd to be run to set the cc list.\n" +
-+ " Please run:\n" +
-+ " git config --unset sendemail.suppresscc\n" +
-+ " Or read the man page:\n" +
-+ " git send-email --help\n" +
-+ " and set an option that runs --cc-cmd\n")
- return False
-
- return True
-
-+
- def email_patches(series, cover_fname, args, dry_run, warn_on_error, cc_fname,
-- self_only=False, alias=None, in_reply_to=None, thread=False,
-- smtp_server=None):
-+ self_only=False, alias=None, in_reply_to=None, thread=False,
-+ smtp_server=None, get_maintainer_script=None):
- """Email a patch series.
-
- Args:
-@@ -435,6 +450,7 @@ def email_patches(series, cover_fname, args, dry_run, warn_on_error, cc_fname,
- thread: True to add --thread to git send-email (make
- all patches reply to cover-letter or first patch in series)
- smtp_server: SMTP server to use to send patches
-+ get_maintainer_script: File name of script to get maintainers emails
-
- Returns:
- Git command that was/would be run
-@@ -487,9 +503,10 @@ send --cc-cmd cc-fname" cover p1 p2'
- "git config sendemail.to u-boot@lists.denx.de")
- return
- cc = build_email_list(list(set(series.get('cc')) - set(series.get('to'))),
-- '--cc', alias, warn_on_error)
-+ '--cc', alias, warn_on_error)
- if self_only:
-- to = build_email_list([os.getenv('USER')], '--to', alias, warn_on_error)
-+ to = build_email_list([os.getenv('USER')], '--to',
-+ alias, warn_on_error)
- cc = []
- cmd = ['git', 'send-email', '--annotate']
- if smtp_server:
-@@ -565,7 +582,7 @@ def lookup_email(lookup_name, alias=None, warn_on_error=True, level=0):
- if not alias:
- alias = settings.alias
- lookup_name = lookup_name.strip()
-- if '@' in lookup_name: # Perhaps a real email address
-+ if '@' in lookup_name: # Perhaps a real email address
- return [lookup_name]
-
- lookup_name = lookup_name.lower()
-@@ -581,7 +598,7 @@ def lookup_email(lookup_name, alias=None, warn_on_error=True, level=0):
- return out_list
-
- if lookup_name:
-- if not lookup_name in alias:
-+ if lookup_name not in alias:
- msg = "Alias '%s' not found" % lookup_name
- if warn_on_error:
- print(col.build(col.RED, msg))
-@@ -589,11 +606,12 @@ def lookup_email(lookup_name, alias=None, warn_on_error=True, level=0):
- for item in alias[lookup_name]:
- todo = lookup_email(item, alias, warn_on_error, level + 1)
- for new_item in todo:
-- if not new_item in out_list:
-+ if new_item not in out_list:
- out_list.append(new_item)
-
- return out_list
-
-+
- def get_top_level():
- """Return name of top-level directory for this git repo.
-
-@@ -608,6 +626,7 @@ def get_top_level():
- """
- return command.output_one_line('git', 'rev-parse', '--show-toplevel')
-
-+
- def get_alias_file():
- """Gets the name of the git alias file.
-
-@@ -615,7 +634,7 @@ def get_alias_file():
- Filename of git alias file, or None if none
- """
- fname = command.output_one_line('git', 'config', 'sendemail.aliasesfile',
-- raise_on_error=False)
-+ raise_on_error=False)
- if not fname:
- return None
-
-@@ -625,6 +644,7 @@ def get_alias_file():
-
- return os.path.join(get_top_level(), fname)
-
-+
- def get_default_user_name():
- """Gets the user.name from .gitconfig file.
-
-@@ -634,6 +654,7 @@ def get_default_user_name():
- uname = command.output_one_line('git', 'config', '--global', 'user.name')
- return uname
-
-+
- def get_default_user_email():
- """Gets the user.email from the global .gitconfig file.
-
-@@ -643,17 +664,19 @@ def get_default_user_email():
- uemail = command.output_one_line('git', 'config', '--global', 'user.email')
- return uemail
-
-+
- def get_default_subject_prefix():
- """Gets the format.subjectprefix from local .git/config file.
-
- Returns:
- Subject prefix found in local .git/config file, or None if none
- """
-- sub_prefix = command.output_one_line('git', 'config', 'format.subjectprefix',
-- raise_on_error=False)
-+ sub_prefix = command.output_one_line(
-+ 'git', 'config', 'format.subjectprefix', raise_on_error=False)
-
- return sub_prefix
-
-+
- def setup():
- """Set up git utils, by reading the alias files."""
- # Check for a git alias file also
-@@ -666,6 +689,7 @@ def setup():
- use_no_decorate = (command.run_pipe([cmd], raise_on_error=False)
- .return_code == 0)
-
-+
- def get_head():
- """Get the hash of the current HEAD
-
-@@ -674,6 +698,7 @@ def get_head():
- """
- return command.output_one_line('git', 'show', '-s', '--pretty=format:%H')
-
-+
- if __name__ == "__main__":
- import doctest
-
-diff --git a/tools/patman/patman b/tools/patman/patman
-index 11a5d8e18a..5a427d1942 120000
---- a/tools/patman/patman
-+++ b/tools/patman/patman
-@@ -1 +1 @@
--main.py
-\ No newline at end of file
-+__main__.py
-\ No newline at end of file
-diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
-index 8c5c9cc2cc..6113962fb4 100644
---- a/tools/patman/patman.rst
-+++ b/tools/patman/patman.rst
-@@ -1,6 +1,7 @@
- .. SPDX-License-Identifier: GPL-2.0+
- .. Copyright (c) 2011 The Chromium OS Authors
- .. Simon Glass <sjg@chromium.org>
-+.. Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
- .. v1, v2, 19-Oct-11
- .. revised v3 24-Nov-11
- .. revised v4 Independence Day 2020, with Patchwork integration
-@@ -68,13 +69,28 @@ this once::
-
- git config sendemail.aliasesfile doc/git-mailrc
-
--For both Linux and U-Boot the 'scripts/get_maintainer.pl' handles figuring
--out where to send patches pretty well.
-+For both Linux and U-Boot the 'scripts/get_maintainer.pl' handles
-+figuring out where to send patches pretty well. For other projects,
-+you may want to specify a different script to be run, for example via
-+a project-specific `.patman` file::
-+
-+ # .patman configuration file at the root of some project
-+
-+ [settings]
-+ get_maintainer_script: etc/teams.scm get-maintainer
-+
-+The `get_maintainer_script` option corresponds to the
-+`--get-maintainer-script` argument of the `send` command. It is
-+looked relatively to the root of the current git repository, as well
-+as on PATH. It can also be provided arguments, as shown above. The
-+contract is that the script should accept a patch file name and return
-+a list of email addresses, one per line, like `get_maintainer.pl`
-+does.
-
- During the first run patman creates a config file for you by taking the default
- user name and email address from the global .gitconfig file.
-
--To add your own, create a file ~/.patman like this::
-+To add your own, create a file `~/.patman` like this::
-
- # patman alias file
-
-@@ -85,6 +101,12 @@ To add your own, create a file ~/.patman like this::
- wolfgang: Wolfgang Denk <wd@denx.de>
- others: Mike Frysinger <vapier@gentoo.org>, Fred Bloggs <f.bloggs@napier.net>
-
-+As hinted above, Patman will also look for a `.patman` configuration
-+file at the root of the current project git repository, which makes it
-+possible to override the `project` settings variable or anything else
-+in a project-specific way. The values of this "local" configuration
-+file take precedence over those of the "global" one.
-+
- Aliases are recursive.
-
- The checkpatch.pl in the U-Boot tools/ subdirectory will be located and
-@@ -680,6 +702,16 @@ them:
-
- $ tools/patman/patman test
-
-+Note that since the test suite depends on data files only available in
-+the git checkout, the `test` command is hidden unless `patman` is
-+invoked from the U-Boot git repository.
-+
-+Alternatively, you can run the test suite via Pytest:
-+
-+.. code-block:: bash
-+
-+ $ cd tools/patman && pytest
-+
- Error handling doesn't always produce friendly error messages - e.g.
- putting an incorrect tag in a commit may provide a confusing message.
-
-diff --git a/tools/patman/pytest.ini b/tools/patman/pytest.ini
-new file mode 100644
-index 0000000000..df3eb518d0
---- /dev/null
-+++ b/tools/patman/pytest.ini
-@@ -0,0 +1,2 @@
-+[pytest]
-+addopts = --doctest-modules
-diff --git a/tools/patman/series.py b/tools/patman/series.py
-index 3075378ac1..2eeeef71dc 100644
---- a/tools/patman/series.py
-+++ b/tools/patman/series.py
-@@ -235,7 +235,7 @@ class Series(dict):
- print(col.build(col.RED, str))
-
- def MakeCcFile(self, process_tags, cover_fname, warn_on_error,
-- add_maintainers, limit):
-+ add_maintainers, limit, get_maintainer_script):
- """Make a cc file for us to use for per-commit Cc automation
-
- Also stores in self._generated_cc to make ShowActions() faster.
-@@ -249,6 +249,8 @@ class Series(dict):
- True/False to call the get_maintainers to CC maintainers
- List of maintainers to include (for testing)
- limit: Limit the length of the Cc list (None if no limit)
-+ get_maintainer_script: The file name of the get_maintainer.pl
-+ script (or compatible).
- Return:
- Filename of temp file created
- """
-@@ -267,8 +269,9 @@ class Series(dict):
- if type(add_maintainers) == type(cc):
- cc += add_maintainers
- elif add_maintainers:
-- dir_list = [os.path.join(gitutil.get_top_level(), 'scripts')]
-- cc += get_maintainer.get_maintainer(dir_list, commit.patch)
-+
-+ cc += get_maintainer.get_maintainer(get_maintainer_script,
-+ commit.patch)
- for x in set(cc) & set(settings.bounces):
- print(col.build(col.YELLOW, 'Skipping "%s"' % x))
- cc = list(set(cc) - set(settings.bounces))
-diff --git a/tools/patman/settings.py b/tools/patman/settings.py
-index 903d6fcb0b..636983e32d 100644
---- a/tools/patman/settings.py
-+++ b/tools/patman/settings.py
-@@ -1,18 +1,18 @@
- # SPDX-License-Identifier: GPL-2.0+
- # Copyright (c) 2011 The Chromium OS Authors.
-+# Copyright (c) 2022 Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
- #
-
- try:
- import configparser as ConfigParser
--except:
-+except Exception:
- import ConfigParser
-
- import argparse
- import os
- import re
-
--from patman import command
--from patman import tools
-+from patman import gitutil
-
- """Default settings per-project.
-
-@@ -32,7 +32,8 @@ _default_settings = {
- },
- }
-
--class _ProjectConfigParser(ConfigParser.SafeConfigParser):
-+
-+class _ProjectConfigParser(ConfigParser.ConfigParser):
- """ConfigParser that handles projects.
-
- There are two main goals of this class:
-@@ -83,14 +84,14 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
- def __init__(self, project_name):
- """Construct _ProjectConfigParser.
-
-- In addition to standard SafeConfigParser initialization, this also loads
-- project defaults.
-+ In addition to standard ConfigParser initialization, this also
-+ loads project defaults.
-
- Args:
- project_name: The name of the project.
- """
- self._project_name = project_name
-- ConfigParser.SafeConfigParser.__init__(self)
-+ ConfigParser.ConfigParser.__init__(self)
-
- # Update the project settings in the config based on
- # the _default_settings global.
-@@ -102,31 +103,31 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
- self.set(project_settings, setting_name, setting_value)
-
- def get(self, section, option, *args, **kwargs):
-- """Extend SafeConfigParser to try project_section before section.
-+ """Extend ConfigParser to try project_section before section.
-
- Args:
-- See SafeConfigParser.
-+ See ConfigParser.
- Returns:
-- See SafeConfigParser.
-+ See ConfigParser.
- """
- try:
-- val = ConfigParser.SafeConfigParser.get(
-+ val = ConfigParser.ConfigParser.get(
- self, "%s_%s" % (self._project_name, section), option,
- *args, **kwargs
- )
- except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
-- val = ConfigParser.SafeConfigParser.get(
-+ val = ConfigParser.ConfigParser.get(
- self, section, option, *args, **kwargs
- )
- return val
-
- def items(self, section, *args, **kwargs):
-- """Extend SafeConfigParser to add project_section to section.
-+ """Extend ConfigParser to add project_section to section.
-
- Args:
-- See SafeConfigParser.
-+ See ConfigParser.
- Returns:
-- See SafeConfigParser.
-+ See ConfigParser.
- """
- project_items = []
- has_project_section = False
-@@ -134,7 +135,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
-
- # Get items from the project section
- try:
-- project_items = ConfigParser.SafeConfigParser.items(
-+ project_items = ConfigParser.ConfigParser.items(
- self, "%s_%s" % (self._project_name, section), *args, **kwargs
- )
- has_project_section = True
-@@ -143,7 +144,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
-
- # Get top-level items
- try:
-- top_items = ConfigParser.SafeConfigParser.items(
-+ top_items = ConfigParser.ConfigParser.items(
- self, section, *args, **kwargs
- )
- except ConfigParser.NoSectionError:
-@@ -155,6 +156,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
- item_dict.update(project_items)
- return {(item, val) for item, val in item_dict.items()}
-
-+
- def ReadGitAliases(fname):
- """Read a git alias file. This is in the form used by git:
-
-@@ -170,7 +172,7 @@ def ReadGitAliases(fname):
- print("Warning: Cannot find alias file '%s'" % fname)
- return
-
-- re_line = re.compile('alias\s+(\S+)\s+(.*)')
-+ re_line = re.compile(r'alias\s+(\S+)\s+(.*)')
- for line in fd.readlines():
- line = line.strip()
- if not line or line[0] == '#':
-@@ -190,7 +192,8 @@ def ReadGitAliases(fname):
-
- fd.close()
-
--def CreatePatmanConfigFile(gitutil, config_fname):
-+
-+def CreatePatmanConfigFile(config_fname):
- """Creates a config file under $(HOME)/.patman if it can't find one.
-
- Args:
-@@ -200,12 +203,12 @@ def CreatePatmanConfigFile(gitutil, config_fname):
- None
- """
- name = gitutil.get_default_user_name()
-- if name == None:
-+ if name is None:
- name = input("Enter name: ")
-
- email = gitutil.get_default_user_email()
-
-- if email == None:
-+ if email is None:
- email = input("Enter email: ")
-
- try:
-@@ -220,7 +223,8 @@ me: %s <%s>
- [bounces]
- nxp = Zhikang Zhang <zhikang.zhang@nxp.com>
- ''' % (name, email), file=f)
-- f.close();
-+ f.close()
-+
-
- def _UpdateDefaults(main_parser, config):
- """Update the given OptionParser defaults based on config.
-@@ -242,8 +246,8 @@ def _UpdateDefaults(main_parser, config):
- # Find all the parsers and subparsers
- parsers = [main_parser]
- parsers += [subparser for action in main_parser._actions
-- if isinstance(action, argparse._SubParsersAction)
-- for _, subparser in action.choices.items()]
-+ if isinstance(action, argparse._SubParsersAction)
-+ for _, subparser in action.choices.items()]
-
- # Collect the defaults from each parser
- defaults = {}
-@@ -270,8 +274,9 @@ def _UpdateDefaults(main_parser, config):
- # Set all the defaults and manually propagate them to subparsers
- main_parser.set_defaults(**defaults)
- for parser, pdefs in zip(parsers, parser_defaults):
-- parser.set_defaults(**{ k: v for k, v in defaults.items()
-- if k in pdefs })
-+ parser.set_defaults(**{k: v for k, v in defaults.items()
-+ if k in pdefs})
-+
-
- def _ReadAliasFile(fname):
- """Read in the U-Boot git alias file if it exists.
-@@ -298,6 +303,7 @@ def _ReadAliasFile(fname):
- if bad_line:
- print(bad_line)
-
-+
- def _ReadBouncesFile(fname):
- """Read in the bounces file if it exists
-
-@@ -311,6 +317,7 @@ def _ReadBouncesFile(fname):
- continue
- bounces.add(line.strip())
-
-+
- def GetItems(config, section):
- """Get the items from a section of the config.
-
-@@ -323,31 +330,50 @@ def GetItems(config, section):
- """
- try:
- return config.items(section)
-- except ConfigParser.NoSectionError as e:
-+ except ConfigParser.NoSectionError:
- return []
-- except:
-- raise
-
--def Setup(gitutil, parser, project_name, config_fname=''):
-+
-+def Setup(parser, project_name, config_fname=None):
- """Set up the settings module by reading config files.
-
-+ Unless `config_fname` is specified, a `.patman` config file local
-+ to the git repository is consulted, followed by the global
-+ `$HOME/.patman`. If none exists, the later is created. Values
-+ defined in the local config file take precedence over those
-+ defined in the global one.
-+
- Args:
-- parser: The parser to update
-+ parser: The parser to update.
- project_name: Name of project that we're working on; we'll look
- for sections named "project_section" as well.
-- config_fname: Config filename to read ('' for default)
-+ config_fname: Config filename to read. An error is raised if it
-+ does not exist.
- """
- # First read the git alias file if available
- _ReadAliasFile('doc/git-mailrc')
- config = _ProjectConfigParser(project_name)
-- if config_fname == '':
-+
-+ if config_fname and not os.path.exists(config_fname):
-+ raise Exception(f'provided {config_fname} does not exist')
-+
-+ if not config_fname:
- config_fname = '%s/.patman' % os.getenv('HOME')
-+ has_config = os.path.exists(config_fname)
-+
-+ git_local_config_fname = os.path.join(gitutil.get_top_level(), '.patman')
-+ has_git_local_config = os.path.exists(git_local_config_fname)
-
-- if not os.path.exists(config_fname):
-- print("No config file found ~/.patman\nCreating one...\n")
-- CreatePatmanConfigFile(gitutil, config_fname)
-+ # Read the git local config last, so that its values override
-+ # those of the global config, if any.
-+ if has_config:
-+ config.read(config_fname)
-+ if has_git_local_config:
-+ config.read(git_local_config_fname)
-
-- config.read(config_fname)
-+ if not (has_config or has_git_local_config):
-+ print("No config file found.\nCreating ~/.patman...\n")
-+ CreatePatmanConfigFile(config_fname)
-
- for name, value in GetItems(config, 'alias'):
- alias[name] = value.split(',')
-@@ -358,6 +384,7 @@ def Setup(gitutil, parser, project_name, config_fname=''):
-
- _UpdateDefaults(parser, config)
-
-+
- # These are the aliases we understand, indexed by alias. Each member is a list.
- alias = {}
- bounces = set()
-diff --git a/tools/patman/setup.py b/tools/patman/setup.py
-index 5643bf1503..2ff791da0f 100644
---- a/tools/patman/setup.py
-+++ b/tools/patman/setup.py
-@@ -7,6 +7,6 @@ setup(name='patman',
- scripts=['patman'],
- packages=['patman'],
- package_dir={'patman': ''},
-- package_data={'patman': ['README']},
-+ package_data={'patman': ['README.rst']},
- classifiers=['Environment :: Console',
- 'Topic :: Software Development'])
-diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py
-new file mode 100644
-index 0000000000..c768a2fc64
---- /dev/null
-+++ b/tools/patman/test_settings.py
-@@ -0,0 +1,67 @@
-+# SPDX-License-Identifier: GPL-2.0+
-+#
-+# Copyright (c) 2022 Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
-+#
-+
-+import argparse
-+import contextlib
-+import os
-+import sys
-+import tempfile
-+
-+from patman import settings
-+from patman import tools
-+
-+
-+@contextlib.contextmanager
-+def empty_git_repository():
-+ with tempfile.TemporaryDirectory() as tmpdir:
-+ os.chdir(tmpdir)
-+ tools.run('git', 'init', raise_on_error=True)
-+ yield tmpdir
-+
-+
-+@contextlib.contextmanager
-+def cleared_command_line_args():
-+ old_value = sys.argv[:]
-+ sys.argv = [sys.argv[0]]
-+ try:
-+ yield
-+ finally:
-+ sys.argv = old_value
-+
-+
-+def test_git_local_config():
-+ # Clearing the command line arguments is required, otherwise
-+ # arguments passed to the test running such as in 'pytest -k
-+ # filter' would be processed by _UpdateDefaults and fail.
-+ with cleared_command_line_args():
-+ with empty_git_repository():
-+ with tempfile.NamedTemporaryFile() as global_config:
-+ global_config.write(b'[settings]\n'
-+ b'project=u-boot\n')
-+ global_config.flush()
-+ parser = argparse.ArgumentParser()
-+ parser.add_argument('-p', '--project', default='unknown')
-+ subparsers = parser.add_subparsers(dest='cmd')
-+ send = subparsers.add_parser('send')
-+ send.add_argument('--no-check', action='store_false',
-+ dest='check_patch', default=True)
-+
-+ # Test "global" config is used.
-+ settings.Setup(parser, 'unknown', global_config.name)
-+ args, _ = parser.parse_known_args([])
-+ assert args.project == 'u-boot'
-+ send_args, _ = send.parse_known_args([])
-+ assert send_args.check_patch
-+
-+ # Test local config can shadow it.
-+ with open('.patman', 'w', buffering=1) as f:
-+ f.write('[settings]\n'
-+ 'project: guix-patches\n'
-+ 'check_patch: False\n')
-+ settings.Setup(parser, 'unknown', global_config.name)
-+ args, _ = parser.parse_known_args([])
-+ assert args.project == 'guix-patches'
-+ send_args, _ = send.parse_known_args([])
-+ assert not send_args.check_patch
diff --git a/gnu/packages/patches/u-boot-sifive-prevent-reloc-initrd-fdt.patch b/gnu/packages/patches/u-boot-sifive-prevent-reloc-initrd-fdt.patch
index a5b92e3e8f..858f42efe7 100644
--- a/gnu/packages/patches/u-boot-sifive-prevent-reloc-initrd-fdt.patch
+++ b/gnu/packages/patches/u-boot-sifive-prevent-reloc-initrd-fdt.patch
@@ -5,12 +5,12 @@ Index: u-boot-2021.07~rc4+dfsg/include/configs/sifive-unmatched.h
===================================================================
--- u-boot-2021.07~rc4+dfsg.orig/include/configs/sifive-unmatched.h
+++ u-boot-2021.07~rc4+dfsg/include/configs/sifive-unmatched.h
-@@ -62,6 +62,8 @@
+@@ -55,6 +55,8 @@
"name=system,size=-,bootable,type=${type_guid_gpt_system};"
- #define CONFIG_EXTRA_ENV_SETTINGS \
+ #define CFG_EXTRA_ENV_SETTINGS \
+ "fdt_high=0xffffffffffffffff\0" \
+ "initrd_high=0xffffffffffffffff\0" \
"kernel_addr_r=0x84000000\0" \
- "fdt_addr_r=0x88000000\0" \
- "scriptaddr=0x88100000\0" \
+ "kernel_comp_addr_r=0x88000000\0" \
+ "kernel_comp_size=0x4000000\0" \
diff --git a/gnu/packages/patches/zig-0.9-riscv-support.patch b/gnu/packages/patches/zig-0.9-riscv-support.patch
new file mode 100644
index 0000000000..372a68ea02
--- /dev/null
+++ b/gnu/packages/patches/zig-0.9-riscv-support.patch
@@ -0,0 +1,47 @@
+https://github.com/ziglang/zig/commit/ca3c4ff2d0afcdc8fe86e7e7b41a967c88779729
+From: Shupei Fan <dymarkfan@outlook.com>
+zig0: properly set llvm_cpu_names and llvm_cpu_features for riscv
+
+Bug: https://bugs.gentoo.org/851732
+
+--- a/src/stage1/zig0.cpp
++++ b/src/stage1/zig0.cpp
+@@ -160,6 +160,17 @@ static void get_native_target(ZigTarget *target) {
+ }
+ }
+
++static const char* get_baseline_llvm_cpu_name(ZigLLVM_ArchType arch) {
++ return "";
++}
++
++static const char* get_baseline_llvm_cpu_features(ZigLLVM_ArchType arch) {
++ switch (arch) {
++ case ZigLLVM_riscv64: return "+a,+c,+d,+m";
++ default: return "";
++ }
++}
++
+ static Error target_parse_triple(struct ZigTarget *target, const char *zig_triple, const char *mcpu,
+ const char *dynamic_linker)
+ {
+@@ -178,8 +189,8 @@ static Error target_parse_triple(struct ZigTarget *target, const char *zig_tripl
+ } else if (strcmp(mcpu, "baseline") == 0) {
+ target->is_native_os = false;
+ target->is_native_cpu = false;
+- target->llvm_cpu_name = "";
+- target->llvm_cpu_features = "";
++ target->llvm_cpu_name = get_baseline_llvm_cpu_name(target->arch);
++ target->llvm_cpu_features = get_baseline_llvm_cpu_features(target->arch);
+ } else {
+ const char *msg = "stage0 can't handle CPU/features in the target";
+ stage2_panic(msg, strlen(msg));
+@@ -220,6 +231,9 @@ static Error target_parse_triple(struct ZigTarget *target, const char *zig_tripl
+ const char *msg = "stage0 can't handle CPU/features in the target";
+ stage2_panic(msg, strlen(msg));
+ }
++
++ target->llvm_cpu_name = get_baseline_llvm_cpu_name(target->arch);
++ target->llvm_cpu_features = get_baseline_llvm_cpu_features(target->arch);
+ }
+
+ return ErrorNone;