code:
This patch is needed to build e2fsprogs, util-linux.

Taken from https://salsa.debian.org/glibc-team/glibc/-/blob/glibc-2.31/debian/patches/hurd-i386/tg-hurdsig-SA_SIGINFO.diff

From: Jeremie Koenig <jk@jk.fr.eu.org>
Subject: [PATCH] implement SA_SIGINFO signal handlers.

    52baaca Hurd signals: Copy bits/sigaction.h
    4232c66 Hurd signals: SA_SIGINFO support
    1831cfe Hurd signals: Use POSIX sigcodes

---
 hurd/hurd/signal.h                       |    5 +
 hurd/hurdfault.c                         |    2
 hurd/hurdinit.c                          |    2
 hurd/hurdsig.c                           |    6 -
 sysdeps/mach/hurd/bits/sigaction.h       |   86 +++++++++++++++++++++
 sysdeps/mach/hurd/i386/bits/sigcontext.h |    4
 sysdeps/mach/hurd/i386/exc2signal.c      |  123 +++++++++++++++++++-----------
 sysdeps/mach/hurd/i386/trampoline.c      |  125 ++++++++++++++++++++++++++++---
 sysdeps/mach/hurd/kill.c                 |    2
 sysdeps/mach/hurd/setitimer.c            |    2
 10 files changed, 293 insertions(+), 64 deletions(-)

Index: glibc-2.31/hurd/hurd/signal.h
===================================================================
--- glibc-2.31.orig/hurd/hurd/signal.h
+++ glibc-2.31/hurd/hurd/signal.h
@@ -290,6 +290,11 @@ extern int _hurd_raise_signal (struct hu
 extern void _hurd_exception2signal (struct hurd_signal_detail *detail,
 				    int *signo);

+/* Translate a Mach exception into a signal with a legacy sigcode.  */
+
+extern void _hurd_exception2signal_legacy (struct hurd_signal_detail *detail,
+					   int *signo);
+

 /* Make the thread described by SS take the signal described by SIGNO and
    DETAIL.  If the process is traced, this will in fact stop with a SIGNO
Index: glibc-2.31/hurd/hurdfault.c
===================================================================
--- glibc-2.31.orig/hurd/hurdfault.c
+++ glibc-2.31/hurd/hurdfault.c
@@ -70,7 +70,7 @@ _hurdsig_fault_catch_exception_raise (ma
      codes into a signal number and subcode.  */
   _hurd_exception2signal (&d, &signo);

-  return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preemptor, signo, d.code)
+  return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preemptor, signo, d.exc_subcode)
     ? 0 : EGREGIOUS;
 }

Index: glibc-2.31/hurd/hurdinit.c
===================================================================
--- glibc-2.31.orig/hurd/hurdinit.c
+++ glibc-2.31/hurd/hurdinit.c
@@ -177,7 +177,7 @@ _hurd_new_proc_init (char **argv,
     /* This process is "traced", meaning it should stop on signals or exec.
        We are all set up now to handle signals.  Stop ourselves, to inform
        our parent (presumably a debugger) that the exec has completed.  */
-    __msg_sig_post (_hurd_msgport, SIGTRAP, 0, __mach_task_self ());
+    __msg_sig_post (_hurd_msgport, SIGTRAP, TRAP_TRACE, __mach_task_self ());
 }

 #include <shlib-compat.h>
Index: glibc-2.31/hurd/hurdsig.c
===================================================================
--- glibc-2.31.orig/hurd/hurdsig.c
+++ glibc-2.31/hurd/hurdsig.c
@@ -730,7 +730,7 @@ post_signal (struct hurd_sigstate *ss,
       {				/* PE cannot be null.  */
 	do
 	  {
-	    if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->code))
+	    if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->exc_subcode))
 	      {
 		if (pe->preemptor)
 		  {
@@ -1374,7 +1374,7 @@ _S_msg_sig_post (mach_port_t me,
   if (err = signal_allowed (signo, refport))
     return err;

-  d.code = sigcode;
+  d.code = d.exc_subcode = sigcode;
   d.exc = 0;

   /* Post the signal to a global receiver thread (or mark it pending in
@@ -1403,7 +1403,7 @@ _S_msg_sig_post_untraced (mach_port_t me
   if (err = signal_allowed (signo, refport))
     return err;

-  d.code = sigcode;
+  d.code = d.exc_subcode = sigcode;
   d.exc = 0;

   /* Post the signal to the designated signal-receiving thread.  This will
Index: glibc-2.31/sysdeps/mach/hurd/bits/sigaction.h
===================================================================
--- /dev/null
+++ glibc-2.31/sysdeps/mach/hurd/bits/sigaction.h
@@ -0,0 +1,86 @@
+/* Copyright (C) 1991-2015 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _BITS_SIGACTION_H
+#define _BITS_SIGACTION_H 1
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
+#endif
+
+/* These definitions match those used by the 4.4 BSD kernel.
+   If the operating system has a `sigaction' system call that correctly
+   implements the POSIX.1 behavior, there should be a system-dependent
+   version of this file that defines `struct sigaction' and the `SA_*'
+   constants appropriately.  */
+
+/* Structure describing the action to be taken when a signal arrives.  */
+struct sigaction
+  {
+    /* Signal handler.  */
+#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
+    union
+      {
+	/* Used if SA_SIGINFO is not set.  */
+	__sighandler_t sa_handler;
+	/* Used if SA_SIGINFO is set.  */
+	void (*sa_sigaction) (int, siginfo_t *, void *);
+      }
+    __sigaction_handler;
+# define sa_handler	__sigaction_handler.sa_handler
+# define sa_sigaction	__sigaction_handler.sa_sigaction
+#else
+    __sighandler_t sa_handler;
+#endif
+
+    /* Additional set of signals to be blocked.  */
+    __sigset_t sa_mask;
+
+    /* Special flags.  */
+    int sa_flags;
+  };
+
+/* Bits in `sa_flags'.  */
+#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC
+# define SA_ONSTACK	0x0001	/* Take signal on signal stack.  */
+#endif
+#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
+# define SA_RESTART	0x0002	/* Restart syscall on signal return.  */
+# define SA_NODEFER	0x0010	/* Don't automatically block the signal when
+				    its handler is being executed.  */
+# define SA_RESETHAND	0x0004	/* Reset to SIG_DFL on entry to handler.  */
+#endif
+#define	SA_NOCLDSTOP	0x0008	/* Don't send SIGCHLD when children stop.  */
+#define SA_SIGINFO	0x0040	/* Signal handler with SA_SIGINFO args */
+
+#ifdef __USE_MISC
+# define SA_INTERRUPT	0	/* Historical no-op ("not SA_RESTART").  */
+
+/* Some aliases for the SA_ constants.  */
+# define SA_NOMASK    SA_NODEFER
+# define SA_ONESHOT   SA_RESETHAND
+# define SA_STACK     SA_ONSTACK
+#endif
+
+
+/* Values for the HOW argument to `sigprocmask'.  */
+#define	SIG_BLOCK	1	/* Block signals.  */
+#define	SIG_UNBLOCK	2	/* Unblock signals.  */
+#define	SIG_SETMASK	3	/* Set the set of blocked signals.  */
+
+#endif
Index: glibc-2.31/sysdeps/mach/hurd/i386/bits/sigcontext.h
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/i386/bits/sigcontext.h
+++ glibc-2.31/sysdeps/mach/hurd/i386/bits/sigcontext.h
@@ -97,6 +97,10 @@ struct sigcontext
 #define sc_ps	sc_efl

+/* The deprecated sigcode values below are passed as an extra, non-portable
+   argument to regular signal handlers.  You should use SA_SIGINFO handlers
+   instead, which use the standard POSIX signal codes.  */
+
 /* Codes for SIGFPE.  */
 #define FPE_INTOVF_TRAP		0x1 /* integer overflow */
 #define FPE_INTDIV_FAULT	0x2 /* integer divide by zero */
Index: glibc-2.31/sysdeps/mach/hurd/i386/exc2signal.c
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/i386/exc2signal.c
+++ glibc-2.31/sysdeps/mach/hurd/i386/exc2signal.c
@@ -23,8 +23,8 @@
 /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
    into a signal number and signal subcode.  */

-void
-_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
+static void
+exception2signal (struct hurd_signal_detail *detail, int *signo, int posix)
 {
   detail->error = 0;

@@ -36,44 +36,62 @@ _hurd_exception2signal (struct hurd_sign
       break;

     case EXC_BAD_ACCESS:
-      if (detail->exc_code == KERN_INVALID_ADDRESS
-	  || detail->exc_code == KERN_PROTECTION_FAILURE
-	  || detail->exc_code == KERN_WRITE_PROTECTION_FAILURE)
-	*signo = SIGSEGV;
-      else
-	*signo = SIGBUS;
-      detail->code = detail->exc_subcode;
+      switch (detail->exc_code)
+        {
+	case KERN_INVALID_ADDRESS:
+	case KERN_MEMORY_FAILURE:
+	  *signo = SIGSEGV;
+	  detail->code = posix ? SEGV_MAPERR : detail->exc_subcode;
+	  break;
+
+	case KERN_PROTECTION_FAILURE:
+	case KERN_WRITE_PROTECTION_FAILURE:
+	  *signo = SIGSEGV;
+	  detail->code = posix ? SEGV_ACCERR : detail->exc_subcode;
+	  break;
+
+	default:
+	  *signo = SIGBUS;
+	  detail->code = posix ? BUS_ADRERR : detail->exc_subcode;
+	  break;
+	}
       detail->error = detail->exc_code;
       break;

     case EXC_BAD_INSTRUCTION:
       *signo = SIGILL;
-      if (detail->exc_code == EXC_I386_INVOP)
-	detail->code = ILL_INVOPR_FAULT;
-      else if (detail->exc_code == EXC_I386_STKFLT)
-	detail->code = ILL_STACK_FAULT;
-      else
-	detail->code = 0;
+      switch (detail->exc_code)
+        {
+	case EXC_I386_INVOP:
+	  detail->code = posix ? ILL_ILLOPC : ILL_INVOPR_FAULT;
+	  break;
+
+	case EXC_I386_STKFLT:
+	  detail->code = posix ? ILL_BADSTK : ILL_STACK_FAULT;
+	  break;
+
+	default:
+	  detail->code = 0;
+	  break;
+	}
       break;

     case EXC_ARITHMETIC:
+      *signo = SIGFPE;
       switch (detail->exc_code)
 	{
 	case EXC_I386_DIV:	/* integer divide by zero */
-	  *signo = SIGFPE;
-	  detail->code = FPE_INTDIV_FAULT;
+	  detail->code = posix ? FPE_INTDIV : FPE_INTDIV_FAULT;
 	  break;

 	case EXC_I386_INTO:	/* integer overflow */
-	  *signo = SIGFPE;
-	  detail->code = FPE_INTOVF_TRAP;
+	  detail->code = posix ? FPE_INTOVF : FPE_INTOVF_TRAP;
 	  break;

 	  /* These aren't anywhere documented or used in Mach 3.0.  */
 	case EXC_I386_NOEXT:
 	case EXC_I386_EXTOVR:
 	default:
-	  *signo = SIGFPE;
 	  detail->code = 0;
 	  break;

@@ -82,51 +100,43 @@ _hurd_exception2signal (struct hurd_sign
 	     Give an error code corresponding to the first bit set.  */
 	  if (detail->exc_subcode & FPS_IE)
 	    {
-	      *signo = SIGILL;
-	      detail->code = ILL_FPEOPR_FAULT;
+	      /* NB: We used to send SIGILL here but we can't distinguish
+		 POSIX vs. legacy with respect to what signal we send.  */
+	      detail->code = posix ? FPE_FLTINV : 0 /*ILL_FPEOPR_FAULT*/;
 	    }
 	  else if (detail->exc_subcode & FPS_DE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTDNR_FAULT;
+	      detail->code = posix ? FPE_FLTUND : FPE_FLTDNR_FAULT;
 	    }
 	  else if (detail->exc_subcode & FPS_ZE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTDIV_FAULT;
+	      detail->code = posix ? FPE_FLTDIV : FPE_FLTDIV_FAULT;
 	    }
 	  else if (detail->exc_subcode & FPS_OE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTOVF_FAULT;
+	      detail->code = posix ? FPE_FLTOVF : FPE_FLTOVF_FAULT;
 	    }
 	  else if (detail->exc_subcode & FPS_UE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTUND_FAULT;
+	      detail->code = posix ? FPE_FLTUND : FPE_FLTUND_FAULT;
 	    }
 	  else if (detail->exc_subcode & FPS_PE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTINX_FAULT;
+	      detail->code = posix ? FPE_FLTRES : FPE_FLTINX_FAULT;
 	    }
 	  else
 	    {
-	      *signo = SIGFPE;
 	      detail->code = 0;
 	    }
 	  break;

 	  /* These two can only be arithmetic exceptions if we
-	     are in V86 mode, which sounds like emulation to me.
-	     (See Mach 3.0 i386/trap.c.)  */
+	     are in V86 mode.  (See Mach 3.0 i386/trap.c.)  */
 	case EXC_I386_EMERR:
-	  *signo = SIGFPE;
-	  detail->code = FPE_EMERR_FAULT;
+	  detail->code = posix ? 0 : FPE_EMERR_FAULT;
 	  break;
 	case EXC_I386_BOUND:
-	  *signo = SIGFPE;
-	  detail->code = FPE_EMBND_FAULT;
+	  detail->code = posix ? FPE_FLTSUB : FPE_EMBND_FAULT;
 	  break;
 	}
       break;
@@ -143,7 +153,7 @@ _hurd_exception2signal (struct hurd_sign
       if (detail->exc_code == EXC_I386_BOUND)
 	{
 	  *signo = SIGFPE;
-	  detail->code = FPE_SUBRNG_FAULT;
+	  detail->code = posix ? FPE_FLTSUB : FPE_SUBRNG_FAULT;
 	}
       else
 	{
@@ -154,13 +164,34 @@ _hurd_exception2signal (struct hurd_sign

     case EXC_BREAKPOINT:
       *signo = SIGTRAP;
-      if (detail->exc_code == EXC_I386_SGL)
-	detail->code = DBG_SINGLE_TRAP;
-      else if (detail->exc_code == EXC_I386_BPT)
-	detail->code = DBG_BRKPNT_FAULT;
-      else
-	detail->code = 0;
+      switch (detail->exc_code)
+        {
+	case EXC_I386_SGL:
+	  detail->code = posix ? TRAP_BRKPT : DBG_SINGLE_TRAP;
+	  break;
+
+	case EXC_I386_BPT:
+	  detail->code = posix ? TRAP_BRKPT : DBG_BRKPNT_FAULT;
+	  break;
+
+	default:
+	  detail->code = 0;
+	  break;
+	}
       break;
     }
 }
 libc_hidden_def (_hurd_exception2signal)
+
+void
+_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
+{
+  exception2signal (detail, signo, 1);
+}
+
+void
+_hurd_exception2signal_legacy (struct hurd_signal_detail *detail, int *signo)
+{
+  exception2signal (detail, signo, 0);
+}
+
Index: glibc-2.31/sysdeps/mach/hurd/i386/trampoline.c
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/i386/trampoline.c
+++ glibc-2.31/sysdeps/mach/hurd/i386/trampoline.c
@@ -19,13 +19,66 @@
 #include <hurd/signal.h>
 #include <hurd/userlink.h>
 #include <thread_state.h>
+#include <mach/exception.h>
 #include <mach/machine/eflags.h>
 #include <assert.h>
 #include <errno.h>
 #include "hurdfault.h"
 #include <intr-msg.h>
+#include <sys/ucontext.h>

+/* Fill in a siginfo_t structure for SA_SIGINFO-enabled handlers.  */
+static void fill_siginfo (siginfo_t *si, int signo,
+			  const struct hurd_signal_detail *detail,
+			  const struct machine_thread_all_state *state)
+{
+  si->si_signo = signo;
+  si->si_errno = detail->error;
+  si->si_code = detail->code;
+
+  /* XXX We would need a protocol change for sig_post to include
+   * this information.  */
+  si->si_pid = -1;
+  si->si_uid = -1;
+
+  /* Address of the faulting instruction or memory access.  */
+  if (detail->exc == EXC_BAD_ACCESS)
+    si->si_addr = (void *) detail->exc_subcode;
+  else
+    si->si_addr = (void *) state->basic.eip;
+
+  /* XXX On SIGCHLD, this should be the exit status of the child
+   * process.  We would need a protocol change for the proc server
+   * to send this information along with the signal.  */
+  si->si_status = 0;
+
+  si->si_band = 0;              /* SIGPOLL is not supported yet.  */
+  si->si_value.sival_int = 0;   /* sigqueue() is not supported yet.  */
+}
+
+/* Fill in a ucontext_t structure SA_SIGINFO-enabled handlers.  */
+static void fill_ucontext (ucontext_t *uc, const struct sigcontext *sc)
+{
+  uc->uc_flags = 0;
+  uc->uc_link = NULL;
+  uc->uc_sigmask = sc->sc_mask;
+  uc->uc_stack.ss_sp = (__ptr_t) sc->sc_esp;
+  uc->uc_stack.ss_size = 0;
+  uc->uc_stack.ss_flags = 0;
+
+  /* Registers.  */
+  memcpy (&uc->uc_mcontext.gregs[REG_GS], &sc->sc_gs,
+	  (REG_TRAPNO - REG_GS) * sizeof (int));
+  uc->uc_mcontext.gregs[REG_TRAPNO] = 0;
+  uc->uc_mcontext.gregs[REG_ERR] = 0;
+  memcpy (&uc->uc_mcontext.gregs[REG_EIP], &sc->sc_eip,
+	  (NGREG - REG_EIP) * sizeof (int));
+
+  /* XXX FPU state.  */
+  memset (&uc->uc_mcontext.fpregs, 0, sizeof (fpregset_t));
+}
+
 struct sigcontext *
 _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
 			int signo, struct hurd_signal_detail *detail,
@@ -43,15 +96,38 @@ _hurd_setup_sighandler (struct hurd_sigs
   struct
     {
       int signo;
-      long int sigcode;
-      struct sigcontext *scp;	/* Points to ctx, below.  */
+      union
+	{
+	  /* Extra arguments for traditional signal handlers */
+	  struct
+	    {
+	      long int sigcode;
+	      struct sigcontext *scp;       /* Points to ctx, below.  */
+	    } legacy;
+
+	  /* Extra arguments for SA_SIGINFO handlers */
+	  struct
+	    {
+	      siginfo_t *siginfop;          /* Points to siginfo, below.  */
+	      ucontext_t *uctxp;            /* Points to uctx, below.  */
+	    } posix;
+	};
       void *sigreturn_addr;
       void *sigreturn_returns_here;
       struct sigcontext *return_scp; /* Same; arg to sigreturn.  */
+
+      /* NB: sigreturn assumes link is next to ctx.  */
       struct sigcontext ctx;
       struct hurd_userlink link;
+      ucontext_t ucontext;
+      siginfo_t siginfo;
     } *stackframe;

+  /* sigaction for preemptors */
+  static const struct sigaction legacy_sigaction = {
+    .sa_flags = SA_RESTART
+  };
+
   if (ss->context)
     {
       /* We have a previous sigcontext that sigreturn was about
@@ -94,9 +170,13 @@ _hurd_setup_sighandler (struct hurd_sigs
      the SP on sigreturn.  */
     state->basic.uesp = state->basic.ecx;

-  /* XXX what if handler != action->handler (for instance, if a signal
-   * preemptor took over) ? */
   action = & _hurd_sigstate_actions (ss) [signo];
+  if ( (action->sa_flags & SA_SIGINFO)
+        && handler != (__sighandler_t) action->sa_sigaction
+   || !(action->sa_flags & SA_SIGINFO)
+        && handler != action->sa_handler)
+    /* A signal preemptor took over, use legacy semantic.  */
+    action = &legacy_sigaction;

   if ((action->sa_flags & SA_ONSTACK)
       && !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
@@ -140,15 +220,9 @@ _hurd_setup_sighandler (struct hurd_sigs
 	  = &stackframe->link.thread.next;
       ss->active_resources = &stackframe->link;

-      /* Set up the arguments for the signal handler.  */
-      stackframe->signo = signo;
-      stackframe->sigcode = detail->code;
-      stackframe->scp = stackframe->return_scp = scp = &stackframe->ctx;
-      stackframe->sigreturn_addr = &__sigreturn;
-      stackframe->sigreturn_returns_here = firewall; /* Crash on return.  */
-
       /* Set up the sigcontext from the current state of the thread.  */

+      scp = &stackframe->ctx;
       scp->sc_onstack = ss->sigaltstack.ss_flags & SS_ONSTACK ? 1 : 0;

       /* struct sigcontext is laid out so that starting at sc_gs mimics a
@@ -162,6 +236,35 @@ _hurd_setup_sighandler (struct hurd_sigs
 			      &state->fpu, &scp->sc_i386_float_state,
 			      sizeof (state->fpu));

+      /* Set up the arguments for the signal handler.  */
+      stackframe->signo = signo;
+      if (action->sa_flags & SA_SIGINFO)
+	{
+	  stackframe->posix.siginfop = &stackframe->siginfo;
+	  stackframe->posix.uctxp = &stackframe->ucontext;
+	  fill_siginfo (&stackframe->siginfo, signo, detail, state);
+	  fill_ucontext (&stackframe->ucontext, scp);
+	}
+      else
+	{
+	  if (detail->exc)
+	    {
+	      int nsigno;
+	      _hurd_exception2signal_legacy (detail, &nsigno);
+	      assert (nsigno == signo);
+	    }
+	  else
+	    detail->code = 0;
+
+	  stackframe->legacy.sigcode = detail->code;
+	  stackframe->legacy.scp = &stackframe->ctx;
+	}
+
+      /* Set up the bottom of the stack.  */
+      stackframe->sigreturn_addr = &__sigreturn;
+      stackframe->sigreturn_returns_here = firewall; /* Crash on return.  */
+      stackframe->return_scp = &stackframe->ctx;
+
       _hurdsig_end_catch_fault ();

       if (! ok)
Index: glibc-2.31/sysdeps/mach/hurd/kill.c
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/kill.c
+++ glibc-2.31/sysdeps/mach/hurd/kill.c
@@ -64,7 +64,7 @@ __kill (pid_t pid, int sig)
 	    {
 	      if (msgport != MACH_PORT_NULL)
 		/* Send a signal message to his message port.  */
-		return __msg_sig_post (msgport, sig, 0, refport);
+		return __msg_sig_post (msgport, sig, SI_USER, refport);

 	      /* The process has no message port.  Perhaps try direct
 		 frobnication of the task.  */
Index: glibc-2.31/sysdeps/mach/hurd/setitimer.c
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/setitimer.c
+++ glibc-2.31/sysdeps/mach/hurd/setitimer.c
@@ -105,7 +105,7 @@ timer_thread (void)
 	  __msg_sig_post_request (_hurd_msgport,
 				  _hurd_itimer_port,
 				  MACH_MSG_TYPE_MAKE_SEND_ONCE,
-				  SIGALRM, 0, __mach_task_self ());
+				  SIGALRM, SI_TIMER, __mach_task_self ());
 	  break;

 	case MACH_RCV_INTERRUPTED:
Index: glibc-2.31/sysdeps/mach/hurd/i386/sigcontextinfo.h
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/i386/sigcontextinfo.h
+++ glibc-2.31/sysdeps/mach/hurd/i386/sigcontextinfo.h
@@ -18,11 +18,10 @@
 #ifndef _SIGCONTEXTINFO_H
 #define _SIGCONTEXTINFO_H

-#define SIGCONTEXT struct sigcontext
 static inline uintptr_t
-sigcontext_get_pc (struct sigcontext ctx)
+sigcontext_get_pc (struct ucontext_t *ctx)
 {
-  return ctx.sc_eip;
+  return ctx->uc_mcontext.gregs[REG_EIP];
 }

 #endif


code:
diff -r -U3 a/sysdeps/unix/sysv/linux/powerpc/ldd-rewrite.sed b/sysdeps/unix/sysv/linux/powerpc/ldd-rewrite.sed
--- a/sysdeps/unix/sysv/linux/powerpc/ldd-rewrite.sed	1970-01-01 01:00:00.000000000 +0100
+++ b/sysdeps/unix/sysv/linux/powerpc/ldd-rewrite.sed	2020-02-29 00:15:41.080000000 +0100
@@ -11,5 +11,5 @@
 # this works for /lib64/ld64.so.x and /lib/ld.so.x as input
 s_lib64_lib_
 s_64\.so_\.so_
-s_^RTLDLIST=\(.*lib\)\(/[^/]*\)\(\.so\.[0-9.]*\)[[:blank:]]*$_RTLDLIST="\1\2\3 \164\264\3"_
+s_^RTLDLIST=\(.*lib\)\(/[^/]*\)\(\.so\.[0-9.]*\)[[:blank:]]*$_RTLDLIST="\1\2\3 \1\264\3"_

repo_name: maximed/guix

license: mit


code:
This patch allows us to use glibc's build system to build locales
in a package separate from glibc.

  1. Use 'localedef' from $PATH since we are not rebuilding it.
  2. Use '--no-archive' to avoid building the big locale archive, and
     because the already-built 'localedef' would want to write it
     to '/run/current-system/locale', which is not possible.
  3. Pass $(inst_complocaledir)/$$locale to install files in the right
     place, and because otherwise, 'localedef' fails with:
     "cannot write output files to `(null)'".

--- glibc-2.27/localedata/Makefile
+++ glibc-2.27/localedata/Makefile
@@ -199,7 +199,7 @@ INSTALL-SUPPORTED-LOCALES=$(addprefix install-, $(SUPPORTED-LOCALES))

 # Sometimes the whole collection of locale files should be installed.
 LOCALEDEF=I18NPATH=. GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
-$(rtld-prefix) $(common-objpfx)locale/localedef
+  localedef --no-archive
 install-locales: $(INSTALL-SUPPORTED-LOCALES)

 install-locales-dir:
@@ -224,7 +224,7 @@ $(INSTALL-SUPPORTED-LOCALES): install-locales-dir
 	input=`echo $$locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; \
 	$(LOCALEDEF) $$flags --alias-file=../intl/locale.alias \
 		     -i locales/$$input -f charmaps/$$charset \
-		     $(addprefix --prefix=,$(install_root)) $$locale \
+		     $(addprefix --prefix=,$(install_root)) $(inst_complocaledir)/$$locale \
 	&& echo ' done'; \

 tst-setlocale-ENV = LC_ALL=ja_JP.EUC-JP


code:
This patch allows us to use glibc's build system to build locales
in a package separate from glibc.

  1. Use 'localedef' from $PATH since we are not rebuilding it.
  2. Use '--no-archive' to avoid building the big locale archive, and
     because the already-built 'localedef' would want to write it
     to '/run/current-system/locale', which is not possible.
  3. Pass $(inst_complocaledir)/$$locale to install files in the right
     place, and because otherwise, 'localedef' fails with:
     "cannot write output files to `(null)'".

diff -ru glibc-2.29-old/localedata/Makefile glibc-2.29-new/localedata/Makefile
--- glibc-2.29-old/localedata/Makefile	2019-01-31 11:45:36.000000000 -0500
+++ glibc-2.29-new/localedata/Makefile	2019-07-03 22:48:35.662015071 -0400
@@ -385,7 +385,7 @@

 # Sometimes the whole collection of locale files should be installed.
 LOCALEDEF=I18NPATH=. GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
-$(rtld-prefix) $(common-objpfx)locale/localedef
+  localedef --no-archive
 install-locales: install-locale-archive

 # Create and install the locale-archive file.
@@ -414,7 +414,7 @@
 	input=`echo $$locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; \
 	$(LOCALEDEF) $$flags --alias-file=../intl/locale.alias \
 		     -i locales/$$input -f charmaps/$$charset \
-		     $(addprefix --prefix=,$(install_root)) $$locale \
+		     $(addprefix --prefix=,$(install_root)) $(inst_complocaledir)/$$locale \
 	&& echo ' done';
 endef


code:
This patch reinstates fallback code when the 'prlimit64' system call is
missing by reverting the relevant part of this upstream commit:

  commit 695d7d138eda449678a1650a8b8b58181033353f
  Author: Joseph Myers <joseph@codesourcery.com>
  Date:   Tue May 9 14:05:09 2017 +0000

      Assume prlimit64 is available.

The fallback code is useful on systems that lack 'prlimit64', such as the
2.6.32-on-steroid kernel found on RHEL 6:

  <https://lists.gnu.org/archive/html/guix-devel/2018-03/msg00349.html>

diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c
index 37c173286f..56af3c0646 100644
--- b/sysdeps/unix/sysv/linux/getrlimit64.c
+++ a/sysdeps/unix/sysv/linux/getrlimit64.c
@@ -35,7 +35,40 @@
 int
 __getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
 {
-  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits);
+#ifdef __NR_prlimit64
+  int res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits);
+  if (res == 0 || errno != ENOSYS)
+    return res;
+#endif
+
+/* The fallback code only makes sense if the platform supports either
+   __NR_ugetrlimit and/or __NR_getrlimit.  */
+#if defined (__NR_ugetrlimit) || defined (__NR_getrlimit)
+# ifndef __NR_ugetrlimit
+#  define __NR_ugetrlimit __NR_getrlimit
+# endif
+# if __RLIM_T_MATCHES_RLIM64_T
+#  define rlimits32 (*rlimits)
+# else
+  struct rlimit rlimits32;
+# endif
+
+  if (INLINE_SYSCALL_CALL (ugetrlimit, resource, &rlimits32) < 0)
+    return -1;
+
+# if !__RLIM_T_MATCHES_RLIM64_T
+  if (rlimits32.rlim_cur == RLIM_INFINITY)
+    rlimits->rlim_cur = RLIM64_INFINITY;
+  else
+    rlimits->rlim_cur = rlimits32.rlim_cur;
+  if (rlimits32.rlim_max == RLIM_INFINITY)
+    rlimits->rlim_max = RLIM64_INFINITY;
+  else
+    rlimits->rlim_max = rlimits32.rlim_max;
+# endif /* !__RLIM_T_MATCHES_RLIM64_T */
+#endif /* defined (__NR_ugetrlimit) || defined (__NR_getrlimit)  */
+
+  return 0;
 }
 libc_hidden_def (__getrlimit64)

diff --git a/sysdeps/unix/sysv/linux/setrlimit.c b/sysdeps/unix/sysv/linux/setrlimit.c
index 01812ac355..8773c78236 100644
--- b/sysdeps/unix/sysv/linux/setrlimit.c
+++ a/sysdeps/unix/sysv/linux/setrlimit.c
@@ -34,6 +34,7 @@
 int
 __setrlimit (enum __rlimit_resource resource, const struct rlimit *rlim)
 {
+# ifdef __NR_prlimit64
   struct rlimit64 rlim64;

   if (rlim->rlim_cur == RLIM_INFINITY)
@@ -45,7 +46,11 @@
   else
     rlim64.rlim_max = rlim->rlim_max;

-  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, &rlim64, NULL);
+  int res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, &rlim64, NULL);
+  if (res == 0 || errno != ENOSYS)
+    return res;
+# endif
+  return INLINE_SYSCALL_CALL (setrlimit, resource, rlim);
 }

 # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c
index 2dd129d99e..db1960fc18 100644
--- b/sysdeps/unix/sysv/linux/setrlimit64.c
+++ a/sysdeps/unix/sysv/linux/setrlimit64.c
@@ -36,7 +36,36 @@
 int
 __setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
 {
-  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
+  int res;
+
+#ifdef __NR_prlimit64
+  res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
+  if (res == 0 || errno != ENOSYS)
+    return res;
+#endif
+
+/* The fallback code only makes sense if the platform supports
+   __NR_setrlimit.  */
+#ifdef __NR_setrlimit
+# if !__RLIM_T_MATCHES_RLIM64_T
+  struct rlimit rlimits32;
+
+  if (rlimits->rlim_cur >= RLIM_INFINITY)
+    rlimits32.rlim_cur = RLIM_INFINITY;
+  else
+    rlimits32.rlim_cur = rlimits->rlim_cur;
+  if (rlimits->rlim_max >= RLIM_INFINITY)
+    rlimits32.rlim_max = RLIM_INFINITY;
+  else
+    rlimits32.rlim_max = rlimits->rlim_max;
+# else
+#  define rlimits32 (*rlimits)
+# endif
+
+  res = INLINE_SYSCALL_CALL (setrlimit, resource, &rlimits32);
+#endif
+
+  return res;
 }
 weak_alias (__setrlimit64, setrlimit64)


code:
This patch is taken from debian's glibc package (generate-supported.mk).
It install the localedata/SUPPORTED file of the glibc. This file lists
all the supported locales of the glibc.

diff --git a/localedata/Makefile b/localedata/Makefile
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -176,7 +176,8 @@
 else
 install-others := $(addprefix $(inst_i18ndir)/, \
 			      $(addsuffix .gz, $(charmaps)) \
-			      $(locales))
+			      $(locales)) \
+                   $(inst_i18ndir)/SUPPORTED
 endif

 tests: $(objdir)/iconvdata/gconv-modules
@@ -401,6 +402,14 @@

 include SUPPORTED

+$(inst_i18ndir)/SUPPORTED: SUPPORTED $(+force)
+	for locale in $(SUPPORTED-LOCALES); do \
+		[ $$locale = true ] && continue; \
+		echo $$locale | sed 's,/, ,' >> LOCALES; \
+	done
+	$(make-target-directory)
+	$(INSTALL_DATA) LOCALES $@
+
 INSTALL-SUPPORTED-LOCALE-ARCHIVE=$(addprefix install-archive-, $(SUPPORTED-LOCALES))
 INSTALL-SUPPORTED-LOCALE-FILES=$(addprefix install-files-, $(SUPPORTED-LOCALES))


code:
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.

--- a/locale/newlocale.c
+++ b/locale/newlocale.c
@@ -30,6 +30,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							      \
@@ -48,7 +49,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;

@@ -102,17 +102,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 ead030d..0c0e314 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -215,12 +215,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.  */
@@ -251,17 +304,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 8424a61..f925503 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -38,7 +38,7 @@ routines	:= strcat strchr strcmp strcoll strcpy strcspn		\
 		   swab strfry memfrob memmem rawmemchr strchrnul	\
 		   $(addprefix argz-,append count create ctsep next	\
 				     delete extract insert stringify	\
-				     addsep replace)			\
+				     addsep replace suffix)		\
 		   envz basename					\
 		   strcoll_l strxfrm_l string-inlines memrchr		\
 		   xpg-strerror strerror_l
diff --git a/string/argz-suffix.c b/string/argz-suffix.c
new file mode 100644
index 0000000..505b0f2
--- /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 bb62a31..d276a35 100644
--- a/string/argz.h
+++ b/string/argz.h
@@ -134,6 +134,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


code:
# HG changeset patch
# User Torbjorn Granlund <tege@gmplib.org>
# Date 1396602422 -7200
# Node ID 676e2d0f0e4dd301a7066079d2c9326c25c34a40
# Parent  0194a75b56b21a9196626430af86c5bd9110c42d
Conditionalise ARM asm on !__thumb__.

diff -r 0194a75b56b2 -r 676e2d0f0e4d mpn/generic/div_qr_1n_pi1.c
--- a/mpn/generic/div_qr_1n_pi1.c	Thu Apr 03 23:58:51 2014 +0200
+++ b/mpn/generic/div_qr_1n_pi1.c	Fri Apr 04 11:07:02 2014 +0200
@@ -130,7 +130,7 @@
 	     "%2" ((UDItype)(a0)), "r" ((UDItype)(b0)) __CLOBBER_CC)
 #endif

-#if defined (__arm__) && W_TYPE_SIZE == 32
+#if defined (__arm__) && !defined (__thumb__) && W_TYPE_SIZE == 32
 #define add_mssaaaa(m, sh, sl, ah, al, bh, bl)				\
   __asm__ (  "adds	%2, %5, %6\n\t"					\
 	     "adcs	%1, %3, %4\n\t"					\


code:
Skip a test that randomly fails on ARMv7: <http://bugs.gnu.org/21620>.

--- a/tests/mpz/reuse.c
+++ b/tests/mpz/reuse.c
@@ -213,6 +213,7 @@ main (int argc, char **argv)
   mpz_t bs;
   unsigned long bsi, size_range;

+  exit (77);					  /* skip */
   tests_start ();
   TESTS_REPS (reps, argv, argc);


code:
Description: Change GIFLIB_MINOR to allow matching with v5.2+
Source: https://savannah.gnu.org/patch/index.php?9873
Author: marius851000

diff --git a/libbase/GnashImageGif.cpp b/libbase/GnashImageGif.cpp
index 2ae5ddb..b87b1e7 100644
--- a/libbase/GnashImageGif.cpp
+++ b/libbase/GnashImageGif.cpp
@@ -120,7 +120,7 @@ GifInput::GifInput(std::shared_ptr<IOChannel> in)
 GifInput::~GifInput()
 {
     // Clean up allocated data.
-#if GIFLIB_MAJOR==5 && GIFLIB_MINOR==1
+#if GIFLIB_MAJOR==5 && GIFLIB_MINOR!=0
 	DGifCloseFile(_gif, 0);
 #else
 	DGifCloseFile(_gif);


code:
This patch adds a "guix gc" button to the low disk space notification
that 'gsd-housekeeping' emits.

diff --git a/plugins/housekeeping/gsd-disk-space.c b/plugins/housekeeping/gsd-disk-space.c
index bd3437e..89027d8 100644
--- a/plugins/housekeeping/gsd-disk-space.c
+++ b/plugins/housekeeping/gsd-disk-space.c
@@ -546,6 +546,21 @@ empty_trash_callback (NotifyNotification *n,
         notify_notification_close (n, NULL);
 }

+static void
+guix_gc_callback (NotifyNotification *n,
+                  const char         *action)
+{
+        const gchar *argv[] = { "guix", "gc", NULL };
+
+        g_assert (action != NULL);
+        g_assert (strcmp (action, "run-guix-gc") == 0);
+
+        g_spawn_async (NULL, (gchar **) argv, NULL, G_SPAWN_SEARCH_PATH,
+                       NULL, NULL, NULL, NULL);
+
+        notify_notification_close (n, NULL);
+}
+
 static void
 on_notification_closed (NotifyNotification *n)
 {
@@ -591,6 +606,13 @@ ldsm_notify (const char *summary,
                                                 g_free);
         }

+        notify_notification_add_action (notification,
+                                        "run-guix-gc",
+                                        _("Collect Unused Guix Items"),
+                                        (NotifyActionCallback) guix_gc_callback,
+                                        NULL,
+                                        NULL);
+
         has_trash = ldsm_mount_has_trash (mount_path);

         if (has_trash) {


code:
From 05b7aec747282f62212b605249d518280ff80059 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Mon, 27 Jul 2020 10:58:22 -0400
Subject: [PATCH] loginDialog: Reset auth prompt on vt switch before fade in

At the moment, if a user switches to the login screen vt,
the login screen fades in whatever was on screen prior, and
then does a reset.

It makes more sense to reset first, so we fade in what the
user is going to interact with instead of what they interacted
with before.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2997
---
 js/gdm/loginDialog.js | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index c3f90dc58..6b35ebb16 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -920,16 +920,15 @@ var LoginDialog = GObject.registerClass({
         if (this.opacity == 255 && this._authPrompt.verificationStatus == AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
             return;

+        if (this._authPrompt.verificationStatus !== AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
+            this._authPrompt.reset();
+
         this._bindOpacity();
         this.ease({
             opacity: 255,
             duration: _FADE_ANIMATION_TIME,
             mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-            onComplete: () => {
-                if (this._authPrompt.verificationStatus != AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
-                    this._authPrompt.reset();
-                this._unbindOpacity();
-            }
+            onComplete: () => this._unbindOpacity(),
         });
     }

--
2.30.1


code:
This test seems to require a D-Bus connection not available in the build
environment.

diff -ur /tmp/guix-build-gnome-shell-3.34.2.drv-0/gnome-shell-3.34.2/src/st/meson.build b/src/st/meson.build
--- /tmp/guix-build-gnome-shell-3.34.2.drv-0/gnome-shell-3.34.2/src/st/meson.build	1969-12-31 19:00:00.000000000 -0500
+++ b/src/st/meson.build	2019-12-23 00:46:14.721198022 -0500
@@ -132,18 +132,6 @@
   sources: st_enums[1]
 )

-test_theme = executable('test-theme',
-  sources: 'test-theme.c',
-  c_args: st_cflags,
-  dependencies: [mutter_dep, gtk_dep],
-  build_rpath: mutter_typelibdir,
-  link_with: libst
-)
-
-test('CSS styling support', test_theme,
-  workdir: meson.current_source_dir()
-)
-
 libst_gir = gnome.generate_gir(libst,
   sources: st_gir_sources,
   nsversion: '1.0',


code:
Adjust GNOME-Shell so that it uses a Guix theme by default.

Patch by Ludovic Courtès <ludo@gnu.org>.

diff -ur a/data/gnome-shell-theme.gresource.xml b/data/gnome-shell-theme.gresource.xml
--- a/data/gnome-shell-theme.gresource.xml	2019-12-11 15:06:31.000000000 -0500
+++ b/data/gnome-shell-theme.gresource.xml	2019-12-21 00:31:55.895866241 -0500
@@ -19,6 +19,8 @@
     <file>no-events.svg</file>
     <file>no-notifications.svg</file>
     <file>noise-texture.png</file>
+    <file>guix-background.png</file>
+    <file>guix-logo.png</file>
     <file>pad-osd.css</file>
     <file alias="icons/pointer-double-click-symbolic.svg">pointer-double-click-symbolic.svg</file>
     <file alias="icons/pointer-drag-symbolic.svg">pointer-drag-symbolic.svg</file>
diff -ur a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss
--- a/data/theme/gnome-shell-sass/_common.scss	2019-12-11 15:06:31.000000000 -0500
+++ b/data/theme/gnome-shell-sass/_common.scss	2019-12-21 00:33:49.495832135 -0500
@@ -1994,7 +1994,16 @@
   }
 }

-  .login-dialog-logo-bin { padding: 24px 0px; }
+  .login-dialog-logo-bin {
+      /* Make it a bit narrower than .login-dialog-user-list.  */
+      width: 12em;
+      height: 8em;
+      background: url(resource:///org/gnome/shell/theme/guix-logo.png);
+      background-color: transparent;
+      background-repeat: no-repeat;
+      background-size: contain;
+      background-position: center; }
+
   .login-dialog-banner { color: darken($osd_fg_color,10%); }
   .login-dialog-button-box { spacing: 5px; }
   .login-dialog-message-warning { color: $warning_color; }
@@ -2143,9 +2152,10 @@
 }

 #lockDialogGroup {
-  background: lighten(#2e3436, 8%) url(resource:///org/gnome/shell/theme/noise-texture.png);
-  background-repeat: repeat;
-}
+  background: lighten(#2e3436, 8%) url(resource:///org/gnome/shell/theme/guix-background.png);
+  background-repeat: no-repeat;
+  background-size: cover;
+  background-position: center; }

 #screenShieldNotifications {
   StButton#vhandle, StButton#hhandle {


code:
From: Emmanuele Bassi <ebassi@gnome.org>

See also: https://gitlab.gnome.org/GNOME/gnome-todo/commit/6cdabc4dd0c6c804a093b94c269461ce376fed4f
--- gnome-todo-3.28.1/plugins/eds/gtd-eds-autoptr.h.orig	2020-05-06 14:20:49.589902539 +0200
+++ gnome-todo-3.28.1/plugins/eds/gtd-eds-autoptr.h	2020-05-06 14:20:54.593919721 +0200
@@ -25,4 +25,3 @@
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ECalComponent, g_object_unref);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ECalComponentId, e_cal_component_free_id);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ECalClient, g_object_unref);
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (ESource, g_object_unref);


code:
Gnome-tweaks does not look at GSETTINGS_SCHEMA_PATH or XDG_DATA_DIRS, it
assumes that schemas are installed in one global directory
(GSETTINGS_SCHEMA_DIR/gsettingsschemadir).

Guix/GuixSD uses a different directory for every gir package and has
packages pick-up files using XDG_DATA_DIRS.

Upstream ticket: https://bugzilla.gnome.org/show_bug.cgi?id=764537
janneke@gnu.org

--- gnome-tweak-3.18.1.orig/gtweak/gsettings.py	2015-04-08 15:21:32.000000000 +0200
+++ gnome-tweak-tool-3.18.1/gtweak/gsettings.py	2016-04-03 11:26:38.658482704 +0200
@@ -16,7 +16,8 @@
 # along with gnome-tweak-tool.  If not, see <http://www.gnu.org/licenses/>.

 import logging
-import os.path
+import os
+import sys
 import xml.dom.minidom
 import gettext

@@ -31,6 +32,13 @@
 class GSettingsMissingError(Exception):
     pass

+def file_from_path(path, file_name):
+    for dir in path:
+        f = os.path.join(dir, file_name)
+        if os.path.exists(f):
+            return f
+    return None
+
 class _GSettingsSchema:
     def __init__(self, schema_name, schema_dir=None, schema_filename=None, **options):
         if not schema_dir:
@@ -38,9 +46,14 @@
         if not schema_filename:
             schema_filename = schema_name + ".gschema.xml"

+        schema_prefix = os.path.join('glib-2.0', 'schemas')
         schema_path = os.path.join(schema_dir, schema_filename)
         if not os.path.exists(schema_path):
-            logging.critical("Could not find schema %s" % schema_path)
+            schema_path = file_from_path(os.environ.get ('GSETTINGS_SCHEMA_PATH', '').split(os.path.pathsep), schema_filename)
+        if not (schema_path and os.path.exists(schema_path)):
+            schema_path = file_from_path(os.environ.get ('XDG_DATA_DIRS', '').split(os.path.pathsep), os.path.join(schema_prefix, schema_filename))
+        if not (schema_path and os.path.exists(schema_path)):
+            logging.critical("Could not find schema %s" % schema_filename)
             assert(False)

         self._schema_name = schema_name


code:
Make GnuPG automatically find a pinentry installed by Guix. Try using
$HOME or, if that variable is not set, use the system password database,
or fall back to looking in "/".

More information:

https://bugs.gnu.org/24076

diff --git a/common/homedir.c b/common/homedir.c
index 4b6e46e88..f7ae68ba5 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -33,6 +33,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <pwd.h>

 #ifdef HAVE_W32_SYSTEM
 #include <winsock2.h>   /* Due to the stupid mingw64 requirement to
@@ -67,6 +68,10 @@
  * gnupg_homedir and gnupg_set_homedir.  Malloced.  */
 static char *the_gnupg_homedir;

+/* The user's home directory. Used in Guix to help GnuPG find the
+ * pinentry. */
+static char *the_user_homedir;
+
 /* Flag indicating that home directory is not the default one.  */
 static byte non_default_homedir;

@@ -509,6 +514,25 @@ gnupg_homedir (void)
   return the_gnupg_homedir;
 }

+/* Return the user's home directory */
+const char *
+user_homedir (void)
+{
+  const char *dir;
+  dir = getenv("HOME");
+  if (dir == NULL)
+    {
+       struct passwd *pw = NULL;
+       pw = getpwuid (getuid ());
+       if (pw != NULL)
+         dir = pw->pw_dir;
+       else
+         dir = "/";
+    }
+  if (!the_user_homedir)
+    the_user_homedir = make_absfilename (dir, NULL);
+  return the_user_homedir;
+}

 /* Return whether the home dir is the default one.  */
 int
@@ -971,6 +995,7 @@ get_default_pinentry_name (int reset)
   } names[] = {
     /* The first entry is what we return in case we found no
        other pinentry.  */
+    { user_homedir, "/.guix-profile/bin/pinentry" },
     { gnupg_bindir, DIRSEP_S "pinentry" EXEEXT_S },
 #ifdef HAVE_W32_SYSTEM
     /* Try Gpg4win directory (with bin and without.) */


code:
From 15beb4b193b2714d88107e7dffca781798684e7e Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@gnu.org>
Date: Fri, 29 Jan 2021 14:06:05 +0100
Subject: [PATCH 1/2] key_share: avoid use-after-free around realloc

Signed-off-by: Daiki Ueno <ueno@gnu.org>
---
 lib/ext/key_share.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/lib/ext/key_share.c b/lib/ext/key_share.c
index ab8abf8fe..a8c4bb5cf 100644
--- a/lib/ext/key_share.c
+++ b/lib/ext/key_share.c
@@ -664,14 +664,14 @@ key_share_send_params(gnutls_session_t session,
 {
 	unsigned i;
 	int ret;
-	unsigned char *lengthp;
-	unsigned int cur_length;
 	unsigned int generated = 0;
 	const gnutls_group_entry_st *group;
 	const version_entry_st *ver;

 	/* this extension is only being sent on client side */
 	if (session->security_parameters.entity == GNUTLS_CLIENT) {
+		unsigned int length_pos;
+
 		ver = _gnutls_version_max(session);
 		if (unlikely(ver == NULL || ver->key_shares == 0))
 			return 0;
@@ -679,16 +679,13 @@ key_share_send_params(gnutls_session_t session,
 		if (!have_creds_for_tls13(session))
 			return 0;

-		/* write the total length later */
-		lengthp = &extdata->data[extdata->length];
+		length_pos = extdata->length;

 		ret =
 		    _gnutls_buffer_append_prefix(extdata, 16, 0);
 		if (ret < 0)
 			return gnutls_assert_val(ret);

-		cur_length = extdata->length;
-
 		if (session->internals.hsk_flags & HSK_HRR_RECEIVED) { /* we know the group */
 			group = get_group(session);
 			if (unlikely(group == NULL))
@@ -736,7 +733,8 @@ key_share_send_params(gnutls_session_t session,
 		}

 		/* copy actual length */
-		_gnutls_write_uint16(extdata->length - cur_length, lengthp);
+		_gnutls_write_uint16(extdata->length - length_pos - 2,
+				     &extdata->data[length_pos]);

 	} else { /* server */
 		ver = get_version(session);
--
2.30.2


code:
From 75a937d97f4fefc6f9b08e3791f151445f551cb3 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@gnu.org>
Date: Fri, 29 Jan 2021 14:06:23 +0100
Subject: [PATCH 2/2] pre_shared_key: avoid use-after-free around realloc

Signed-off-by: Daiki Ueno <ueno@gnu.org>
---
 lib/ext/pre_shared_key.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/ext/pre_shared_key.c b/lib/ext/pre_shared_key.c
index a042c6488..380bf39ed 100644
--- a/lib/ext/pre_shared_key.c
+++ b/lib/ext/pre_shared_key.c
@@ -267,7 +267,7 @@ client_send_params(gnutls_session_t session,
 	size_t spos;
 	gnutls_datum_t username = {NULL, 0};
 	gnutls_datum_t user_key = {NULL, 0}, rkey = {NULL, 0};
-	gnutls_datum_t client_hello;
+	unsigned client_hello_len;
 	unsigned next_idx;
 	const mac_entry_st *prf_res = NULL;
 	const mac_entry_st *prf_psk = NULL;
@@ -428,8 +428,7 @@ client_send_params(gnutls_session_t session,
 	assert(extdata->length >= sizeof(mbuffer_st));
 	assert(ext_offset >= (ssize_t)sizeof(mbuffer_st));
 	ext_offset -= sizeof(mbuffer_st);
-	client_hello.data = extdata->data+sizeof(mbuffer_st);
-	client_hello.size = extdata->length-sizeof(mbuffer_st);
+	client_hello_len = extdata->length-sizeof(mbuffer_st);

 	next_idx = 0;

@@ -440,6 +439,11 @@ client_send_params(gnutls_session_t session,
 	}

 	if (prf_res && rkey.size > 0) {
+		gnutls_datum_t client_hello;
+
+		client_hello.data = extdata->data+sizeof(mbuffer_st);
+		client_hello.size = client_hello_len;
+
 		ret = compute_psk_binder(session, prf_res,
 					 binders_len, binders_pos,
 					 ext_offset, &rkey, &client_hello, 1,
@@ -474,6 +478,11 @@ client_send_params(gnutls_session_t session,
 	}

 	if (prf_psk && user_key.size > 0 && info) {
+		gnutls_datum_t client_hello;
+
+		client_hello.data = extdata->data+sizeof(mbuffer_st);
+		client_hello.size = client_hello_len;
+
 		ret = compute_psk_binder(session, prf_psk,
 					 binders_len, binders_pos,
 					 ext_offset, &user_key, &client_hello, 0,
--
2.30.2


code:
Not sent upstream.

From e23de62e28f64599148ff06e439fac116a391299 Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
Date: Fri, 10 Apr 2020 07:24:48 +0200
Subject: [PATCH] guile: Cross build fix.

To cross-build, both the host guile and the native guile-for-build
must be available.  If the native guile is not available, no snarfing
is done and the guile cross build is skipped.

During the cross-build gnutls.scm does not load when compliling
extra.scm, becase of missing definitions from guile-gnutls-v-2.

* guile/modules/gnutls.in (protocol/ssl-3 protocol/tls-1.0,
protocol/tls-1.1, credentials/anonymous, cipher/rijndael-256-cbc,
cipher/rijndael-128-cbc, cipher/rijndael-cbc, cipher/arcfour-128,
certificate-verify/allow-any-x509-v1-ca-certificate,
certificate-verify/allow-x509-v1-ca-certificate): Define to #f
initially.  When "GNUTLS_GUILE_CROSS_COMPILING" not set, set! to value
from "guile-gnutls-v-2" load-extension C module.
---
 guile/modules/gnutls.in | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/guile/modules/gnutls.in b/guile/modules/gnutls.in
index 6461c404a..954e315de 100644
--- a/guile/modules/gnutls.in
+++ b/guile/modules/gnutls.in
@@ -564,22 +564,36 @@ This defines 'variable' as an alias for 'alias', and emits a warning when
                    (identifier? #'id)
                    #'alias))))))))))

-
 ;; Renaming.
-(define protocol/ssl-3 protocol/ssl3)
-(define protocol/tls-1.0 protocol/tls1-0)
-(define protocol/tls-1.1 protocol/tls1-1)
+(define protocol/ssl-3 #f)
+(define protocol/tls-1.0 #f)
+(define protocol/tls-1.1 #f)

 ;; Aliases.
-(define credentials/anonymous   credentials/anon)
-(define cipher/rijndael-256-cbc cipher/aes-256-cbc)
-(define cipher/rijndael-128-cbc cipher/aes-128-cbc)
-(define cipher/rijndael-cbc     cipher/aes-128-cbc)
-(define cipher/arcfour-128      cipher/arcfour)
-(define certificate-verify/allow-any-x509-v1-ca-certificate
-  certificate-verify/allow-any-x509-v1-ca-crt)
-(define certificate-verify/allow-x509-v1-ca-certificate
-  certificate-verify/allow-x509-v1-ca-crt)
+(define credentials/anonymous   #f)
+(define cipher/rijndael-256-cbc #f)
+(define cipher/rijndael-128-cbc #f)
+(define cipher/rijndael-cbc     #f)
+(define cipher/arcfour-128      #f)
+(define certificate-verify/allow-any-x509-v1-ca-certificate #f)
+(define certificate-verify/allow-x509-v1-ca-certificate #f)
+
+(unless (getenv "GNUTLS_GUILE_CROSS_COMPILING")
+  ;; Renaming.
+  (set! protocol/ssl-3 protocol/ssl3)
+  (set! protocol/tls-1.0 protocol/tls1-0)
+  (set! protocol/tls-1.1 protocol/tls1-1)
+
+  ;; Aliases.
+  (set! credentials/anonymous   credentials/anon)
+  (set! cipher/rijndael-256-cbc cipher/aes-256-cbc)
+  (set! cipher/rijndael-128-cbc cipher/aes-128-cbc)
+  (set! cipher/rijndael-cbc     cipher/aes-128-cbc)
+  (set! cipher/arcfour-128      cipher/arcfour)
+  (set! certificate-verify/allow-any-x509-v1-ca-certificate
+    certificate-verify/allow-any-x509-v1-ca-crt)
+  (set! certificate-verify/allow-x509-v1-ca-certificate
+    certificate-verify/allow-x509-v1-ca-crt))

 ;; Deprecated OpenPGP bindings.
 (define-deprecated certificate-type/openpgp)
--
2.26.0


code:
Version 3.5.11 added a test to check that the default trust store is readable.
It does not exist in the build environment, so pretend everything is fine.

diff a/tests/trust-store.c b/tests/trust-store.c
--- a/tests/trust-store.c
+++ b/tests/trust-store.c
@@ -61,7 +61,7 @@
 	} else if (ret < 0) {
 		fail("error loading system trust store: %s\n", gnutls_strerror(ret));
 	} else if (ret == 0) {
-		fail("no certificates were found in system trust store!\n");
+		success("no trust store in the Guix build environment!\n");
 	}

 	gnutls_certificate_free_credentials(x509_cred);


code:
Make library/header paths visible to cmd/go script tests, which is necessary for
cgo/gccgo tests to work correctly

diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go
index dfaa40548e..9d0f0e9bcd 100644
--- a/src/cmd/go/script_test.go
+++ b/src/cmd/go/script_test.go
@@ -100,6 +100,10 @@ const (
 var extraEnvKeys = []string{
 	"SYSTEMROOT",         // must be preserved on Windows to find DLLs; golang.org/issue/25210
 	"WINDIR",             // must be preserved on Windows to be able to run PowerShell command; golang.org/issue/30711
+	"CPATH",
+	"C_INCLUDE_PATH",
+	"CPLUS_INCLUDE_PATH",
+	"LIBRARY_PATH",
 	"LD_LIBRARY_PATH",    // must be preserved on Unix systems to find shared libraries
 	"CC",                 // don't lose user settings when invoking cgo
 	"GO_TESTING_GOTOOLS", // for gccgo testing


code:
Skip a GC test known to be flaky:

  https://issues.guix.gnu.org/issue/37425
  https://github.com/golang/go/issues/27636

--- go/src/runtime/gc_test.go	2019-09-16 23:10:18.200680387 +0200
+++ go/src/runtime/gc_test.go	2019-09-16 23:11:50.324360646 +0200
@@ -27,6 +27,9 @@ func TestGcSys(t *testing.T) {
 	if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" {
 		t.Skip("skipping test; GOOS=linux GOARCH=arm64 https://github.com/golang/go/issues/27636")
 	}
+	if runtime.GOOS == "linux" {
+		t.Skip("skipping test; GOOS=linux https://issues.guix.gnu.org/issue/37425")
+	}
 	got := runTestProg(t, "testprog", "GCSys")
 	want := "OK\n"
 	if got != want {


code:
# Names of libraries included in typelib files are opened by dlopen.  Here we
# add the full path.
#
# This patch was provided by Luca Bruno <lucabru@src.gnome.org>  for
# 'gobject-introspection' 1.40.0 in Nix.
#
# It has since been updated to work with newer versions of
# gobject-introspection.
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -95,6 +95,39 @@ def get_windows_option_group(parser):
     return group

+def _get_default_fallback_libpath():
+    # Newer multiple-output-optimized stdenv has an environment variable
+    # $outputLib which in turn specifies another variable which then is used as
+    # the destination for the library contents (${!outputLib}/lib).
+    store_path = os.environ.get(os.environ.get("outputLib")) if "outputLib" in os.environ else None
+    if store_path is None:
+        outputs = os.environ.get("outputs", "out").split()
+        if "lib" in outputs:
+            # For multiple output derivations let's try whether there is a $lib
+            # environment variable and use that as the base store path.
+            store_path = os.environ.get("lib")
+        elif "out" in outputs:
+            # Otherwise we have a single output derivation, so the libraries
+            # most certainly will end up in "$out/lib".
+            store_path = os.environ.get("out")
+
+    if store_path is not None:
+        # Even if we have a $lib as output, there still should be a $lib/lib
+        # directory.
+        return os.path.join(store_path, 'lib')
+    else:
+        # If we haven't found a possible scenario, let's return an empty string
+        # so that the shared library won't be prepended with a path.
+        #
+        # Note that this doesn't mean that all hope is lost, because after all
+        # we can still use --fallback-library-path to set one.
+        #
+        # Also, we're not returning None, because that would make it very
+        # difficult to disable adding fallback paths altogether using something
+        # like: --fallback-library-path=""
+        return ""
+
+
 def _get_option_parser():
     parser = optparse.OptionParser('%prog [options] sources',
                                    version='%prog ' + giscanner.__version__)
@@ -205,6 +238,10 @@ match the namespace prefix.""")
     parser.add_option("", "--filelist",
                       action="store", dest="filelist", default=[],
                       help="file containing headers and sources to be scanned")
+    parser.add_option("", "--fallback-library-path",
+                      action="store", dest="fallback_libpath",
+                      default=_get_default_fallback_libpath(),
+                      help="Path to prepend to unknown shared libraries")

     group = get_preprocessor_option_group(parser)
     parser.add_option_group(group)
--- a/giscanner/shlibs.py
+++ b/giscanner/shlibs.py
@@ -57,6 +57,14 @@ def _ldd_library_pattern(library_name):
     $""" % re.escape(library_name), re.VERBOSE)

+def _ldd_library_guix_pattern(library_name):
+    store_dir = re.escape(
+      os.environ.get("NIX_STORE", default="/gnu/store")
+    )
+    pattern = r'(%s(?:/[^/]*)+lib%s[^A-Za-z0-9_-][^\s\(\)]*)'
+    return re.compile(pattern % (store_dir, re.escape(library_name)))
+
+
 # This is a what we do for non-la files. We assume that we are on an
 # ELF-like system where ldd exists and the soname extracted with ldd is
 # a filename that can be opened with dlopen().
@@ -106,7 +112,8 @@ def _resolve_non_libtool(options, binary, libraries):
             output = output.decode("utf-8", "replace")

         shlibs = resolve_from_ldd_output(libraries, output)
-        return list(map(sanitize_shlib_path, shlibs))
+        fallback_libpath = options.fallback_libpath or "";
+        return list(map(lambda p: os.path.join(fallback_libpath, p), map(sanitize_shlib_path, shlibs)))

 def sanitize_shlib_path(lib):
@@ -115,19 +122,18 @@ def sanitize_shlib_path(lib):
     # In case we get relative paths on macOS (like @rpath) then we fall
     # back to the basename as well:
     # https://gitlab.gnome.org/GNOME/gobject-introspection/issues/222
-    if sys.platform == "darwin":
-        if not os.path.isabs(lib):
-            return os.path.basename(lib)
-        return lib
-    else:
+
+    # Always use absolute paths if available
+    if not os.path.isabs(lib):
         return os.path.basename(lib)
+    return lib

 def resolve_from_ldd_output(libraries, output):
     patterns = {}
     for library in libraries:
         if not os.path.isfile(library):
-            patterns[library] = _ldd_library_pattern(library)
+            patterns[library] = (_ldd_library_pattern(library), _ldd_library_guix_pattern(library))
     if len(patterns) == 0:
         return []

@@ -139,8 +145,12 @@ def resolve_from_ldd_output(libraries, output):
         if line.endswith(':'):
             continue
         for word in line.split():
-            for library, pattern in patterns.items():
-                m = pattern.match(word)
+            for library, (pattern, guix_pattern) in patterns.items():
+                store_dir = os.environ.get("NIX_STORE", default="/gnu/store")
+                if line.find(store_dir) != -1:
+                    m = guix_pattern.match(word)
+                else:
+                    m = pattern.match(word)
                 if m:
                     del patterns[library]
                     shlibs.append(m.group())

--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -111,17 +111,11 @@ def extract_libtool_shlib(la_file):
     if dlname is None:
         return None

-    # Darwin uses absolute paths where possible; since the libtool files never
-    # contain absolute paths, use the libdir field
-    if platform.system() == 'Darwin':
-        dlbasename = os.path.basename(dlname)
-        libdir = _extract_libdir_field(la_file)
-        if libdir is None:
-            return dlbasename
-        return libdir + '/' + dlbasename
-    # From the comments in extract_libtool(), older libtools had
-    # a path rather than the raw dlname
-    return os.path.basename(dlname)
+    dlbasename = os.path.basename(dlname)
+    libdir = _extract_libdir_field(la_file)
+    if libdir is None:
+        return dlbasename
+    return libdir + '/' + dlbasename

 def extract_libtool(la_file):
--- a/tests/scanner/test_shlibs.py
+++ b/tests/scanner/test_shlibs.py
@@ -40,6 +64,7 @@ class TestLddParser(unittest.TestCase):

         self.assertEqual(
             sanitize_shlib_path('/foo/bar'),
-            '/foo/bar' if sys.platform == 'darwin' else 'bar')
+            # Always use an absolute filename for Guix
+            '/foo/bar')

     def test_unresolved_library(self):
output = ''


code:
Use gcc as the default C compiler if CC is not set.

diff -ru gobject-introspection-1.58.1.orig/giscanner/__init__.py gobject-introspection-1.58.1/giscanner/__init__.py
--- gobject-introspection-1.58.1.orig/giscanner/__init__.py	1970-01-01 01:00:00.000000000 +0100
+++ gobject-introspection-1.58.1/giscanner/__init__.py	2018-12-03 13:33:28.788971299 +0100
@@ -22,6 +22,8 @@
 builddir = os.environ.get('UNINSTALLED_INTROSPECTION_BUILDDIR')
 if builddir is not None:
     __path__.append(os.path.join(builddir, 'giscanner'))
+if not 'CC' in os.environ:
+    os.environ['CC'] = 'gcc'
 try:
     from ._version import __version__
 except ImportError:


code:
--- a/girepository/gitypelib.c.orig
+++ b/girepository/gitypelib.c
@@ -2296,7 +2296,22 @@ _g_typelib_do_dlopen (GITypelib *typelib)
         {
           GModule *module;

+          /* 'gobject-introspection' doesn't store the path of shared
+             libraries into '.typelib' and '.gir' files.  Shared
+             libraries are searched for in the dynamic linker search
+             path.  In Guix we patch 'gobject-introspection' such that
+             it stores the absolute path of shared libraries in
+             '.typelib' and '.gir' files.  Here, in order to minimize
+             side effects, we make sure that if the library is not
+             found at the indicated path location, we try with just
+             the basename and the system dynamic library
+             infrastructure, as per default behaviour of the
+             library. */
           module = load_one_shared_library (shlibs[i]);
+          if (module == NULL && g_path_is_absolute (shlibs[i]))
+            {
+              module = load_one_shared_library (g_basename(shlibs[i]));
+            }

           if (module == NULL)
             {


code:
Fix building of GPM with glibc 2.26:

https://bugs.gentoo.org/629774

Patches copied from Gentoo:

https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-libs/gpm/files/gpm-1.20.7-glibc-2.26.patch?id=1618968c56caf7f8c08823908d88dc49bb8f7649
https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-libs/gpm/files/gpm-1.20.7-sysmacros.patch?id=1618968c56caf7f8c08823908d88dc49bb8f7649

--- a/src/prog/gpm-root.y	2012-10-26 17:21:38.000000000 -0400
+++ b/src/prog/gpm-root.y	2017-09-07 20:39:51.933264063 -0400
@@ -1197,7 +1197,7 @@
    /* reap your zombies */
    childaction.sa_handler=reap_children;
 #if defined(__GLIBC__)
-   __sigemptyset(&childaction.sa_mask);
+   sigemptyset(&childaction.sa_mask);
 #else /* __GLIBC__ */
    childaction.sa_mask=0;
 #endif /* __GLIBC__ */
From b350aee4ea5785a75cb6ad770f6b768c506ebb70 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Mon, 14 Mar 2016 15:39:54 -0400
Subject: [PATCH] fix building w/newer glibc

Linux C libraries are looking to disentangle sysmacros.h from the
sys/types.h include, so make sure we pull in the header when it is
found.
---
 src/daemon/open_console.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/daemon/open_console.c b/src/daemon/open_console.c
index 4d6c0af..6dd43e6 100644
--- a/src/daemon/open_console.c
+++ b/src/daemon/open_console.c
@@ -24,6 +24,10 @@
 #include <sys/types.h>              /* major()           */
 #include <sys/ioctl.h>              /* ioctl             */

+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>          /* major() w/newer glibc */
+#endif
+
 /* Linux specific (to be outsourced in gpm2 */
 #include <linux/serial.h>           /* for serial console check */
 #include <asm/ioctls.h>            /* for serial console check */
--
2.6.2


code:
Description: Modify the default value for check_on_startup to false.
 This prevents an privacy/information disclosure unless the user
 explicitly opts-in for the update check.
Forwarded: not-needed
Origin: vendor
Author: tony mancill <tmancill@debian.org>

--- a/src/gpodder/config.py
+++ b/src/gpodder/config.py
@@ -93,7 +93,7 @@

     # Software updates from gpodder.org
     'software_update': {
-        'check_on_startup': True,  # check for updates on start
+        'check_on_startup': False,  # check for updates on start
         'last_check': 0,  # unix timestamp of last update check
         'interval': 5,  # interval (in days) to check for updates
     },


code:
https://github.com/gpsbabel/gpsbabel/commit/465a74194d53acea5c8d74c5cf3cb2940546ec92.patch
Can be removed next release

From 465a74194d53acea5c8d74c5cf3cb2940546ec92 Mon Sep 17 00:00:00 2001
From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
Date: Fri, 7 Aug 2020 11:29:22 -0600
Subject: [PATCH] fix i386 regression error with engima. (#620)

this was motivated by the test failure seen at
https://buildd.debian.org/status/fetch.php?pkg=gpsbabel&arch=i386&ver=1.7.0%2Bds-4&stamp=1596794554&raw=0
---
 enigma.cc | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/enigma.cc b/enigma.cc
index 850f27b4e..32fea92d6 100644
--- a/enigma.cc
+++ b/enigma.cc
@@ -21,9 +21,16 @@

  */

+#include <cmath>           // for fabs, lround
+#include <cstdint>         // for int32_t, uint8_t, uint32_t
+#include <cstdlib>         // for abs
+#include <cstring>         // for strlen, memcpy, memset
+
+#include <QtCore/QString>  // for QString
+
 #include "defs.h"
-#include <cmath>
-#include <cstdlib>
+#include "gbfile.h"        // for gbfclose, gbfopen_le, gbfread, gbfwrite, gbfile
+

 #define MYNAME "Enigma binary route and waypoint file format"

@@ -177,7 +184,7 @@ enigma_waypt_disp(const Waypoint* wpt)
   le_write32(&ewpt.longitude, decToEnigmaPosition(wpt->longitude));
   ewpt.waypoint_type = WTYPE_WAYPOINT;
   if (wpt->altitude != unknown_alt) {
-    le_write32(&ewpt.data.wp_altitude, METERS_TO_FEET(wpt->altitude) + 1000);
+    le_write32(&ewpt.data.wp_altitude, lround(METERS_TO_FEET(wpt->altitude)) + 1000);
   }
   if (wpt->shortname != nullptr) {
     ewpt.shortname_len = (uint8_t) min(6, strlen(CSTRc(wpt->shortname)));


code:
Taken from nixpkgs, see
grantleetheme: merge themes across multiple prefixes
<https://github.com/NixOS/nixpkgs/commits/master/pkgs/applications/kde/grantleetheme/grantlee-merge-theme-dirs.patch>

diff --git a/src/grantleetheme.cpp b/src/grantleetheme.cpp
index 27d5bc8..8d43140 100644
--- a/src/grantleetheme.cpp
+++ b/src/grantleetheme.cpp
@@ -46,7 +46,7 @@ ThemePrivate::ThemePrivate(const ThemePrivate &other)
     , description(other.description)
     , name(other.name)
     , dirName(other.dirName)
-    , absolutePath(other.absolutePath)
+    , absolutePaths(other.absolutePaths)
     , author(other.author)
     , email(other.email)
     , loader(other.loader)
@@ -64,12 +64,15 @@ void ThemePrivate::setupEngine()

 void ThemePrivate::setupLoader()
 {
-    // Get the parent dir with themes, we set the theme directory separately
-    QDir dir(absolutePath);
-    dir.cdUp();
+    QStringList templateDirs;
+    for (const QString& path : absolutePaths) {
+        QDir dir(path);
+        dir.cdUp();
+        templateDirs << dir.absolutePath();
+    }

     loader = QSharedPointer<GrantleeTheme::QtResourceTemplateLoader>::create();
-    loader->setTemplateDirs({ dir.absolutePath() });
+    loader->setTemplateDirs(templateDirs);
     loader->setTheme(dirName);

     if (!sEngine) {
@@ -121,7 +124,7 @@ Theme::Theme(const QString &themePath, const QString &dirName, const QString &de
     KConfigGroup group(&config, QStringLiteral("Desktop Entry"));
     if (group.isValid()) {
         d->dirName = dirName;
-        d->absolutePath = themePath;
+        d->absolutePaths = QStringList(themePath);
         d->name = group.readEntry("Name", QString());
         d->description = group.readEntry("Description", QString());
         d->themeFileName = group.readEntry("FileName", QString());
@@ -140,7 +143,7 @@ Theme::~Theme()

 bool Theme::operator==(const Theme &other) const
 {
-    return isValid() && other.isValid() && d->absolutePath == other.absolutePath();
+    return isValid() && other.isValid() && d->absolutePaths == other.absolutePaths();
 }

 Theme &Theme::operator=(const Theme &other)
@@ -184,7 +187,15 @@ QString Theme::dirName() const

 QString Theme::absolutePath() const
 {
-    return d->absolutePath;
+    if (! d->absolutePaths.isEmpty()) {
+      return d->absolutePaths.first();
+    };
+    return QString();
+}
+
+QStringList Theme::absolutePaths() const
+{
+    return d->absolutePaths;
 }

 QString Theme::author() const
@@ -223,6 +231,13 @@ QString Theme::render(const QString &templateName, const QVariantHash &data, con
     return result;
 }

+void Theme::addThemeDir(const QString& path)
+{
+    QDir dir(path);
+    dir.cdUp();
+    d->absolutePaths << dir.absolutePath();
+}
+
 void Theme::addPluginPath(const QString &path)
 {
     if (!ThemePrivate::sEngine) {
diff --git a/src/grantleetheme.h b/src/grantleetheme.h
index a25c27b..be38299 100644
--- a/src/grantleetheme.h
+++ b/src/grantleetheme.h
@@ -48,11 +48,14 @@ public:
     Q_REQUIRED_RESULT QStringList displayExtraVariables() const;
     Q_REQUIRED_RESULT QString dirName() const;
     Q_REQUIRED_RESULT QString absolutePath() const;
+    Q_REQUIRED_RESULT QStringList absolutePaths() const;
     Q_REQUIRED_RESULT QString author() const;
     Q_REQUIRED_RESULT QString authorEmail() const;

     Q_REQUIRED_RESULT QString render(const QString &templateName, const QVariantHash &data, const QByteArray &applicationDomain = QByteArray());

+    void addThemeDir(const QString&);
+
     static void addPluginPath(const QString &path);

 private:
diff --git a/src/grantleetheme_p.h b/src/grantleetheme_p.h
index eb73dcb..00510e9 100644
--- a/src/grantleetheme_p.h
+++ b/src/grantleetheme_p.h
@@ -43,7 +43,7 @@ public:
     QString description;
     QString name;
     QString dirName;
-    QString absolutePath;
+    QStringList absolutePaths;
     QString author;
     QString email;

diff --git a/src/grantleethememanager.cpp b/src/grantleethememanager.cpp
index 606d717..dc99041 100644
--- a/src/grantleethememanager.cpp
+++ b/src/grantleethememanager.cpp
@@ -125,25 +125,18 @@ public:

         for (const QString &directory : qAsConst(themesDirectories)) {
             QDirIterator dirIt(directory, QStringList(), QDir::AllDirs | QDir::NoDotAndDotDot);
-            QStringList alreadyLoadedThemeName;
             while (dirIt.hasNext()) {
                 dirIt.next();
                 const QString dirName = dirIt.fileName();
                 GrantleeTheme::Theme theme = q->loadTheme(dirIt.filePath(), dirName, defaultDesktopFileName);
                 if (theme.isValid()) {
                     QString themeName = theme.name();
-                    if (alreadyLoadedThemeName.contains(themeName)) {
-                        int i = 2;
-                        const QString originalName(theme.name());
-                        while (alreadyLoadedThemeName.contains(themeName)) {
-                            themeName = originalName + QStringLiteral(" (%1)").arg(i);
-                            ++i;
-                        }
-                        theme.d->name = themeName;
+                    QMap<QString, GrantleeTheme::Theme>::iterator i = themes.find(dirName);
+                    if (i != themes.end()) {
+                        i.value().addThemeDir(dirIt.filePath());
+                    } else {
+                        themes.insert(dirName, theme);
                     }
-                    alreadyLoadedThemeName << themeName;
-                    themes.insert(dirName, theme);
-                    //qDebug()<<" theme.name()"<<theme.name();
                 }
             }
             watch->addDir(directory);
@@ -366,7 +359,7 @@ QString ThemeManager::pathFromThemes(const QString &themesRelativePath, const QS
                 GrantleeTheme::Theme theme = loadTheme(dirIt.filePath(), dirName, defaultDesktopFileName);
                 if (theme.isValid()) {
                     if (dirName == themeName) {
-                        return theme.absolutePath();
+                        return theme.absolutePaths().first();
                     }
                 }
             }


code:
Fix CVE-2020-18032:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=2020-18032
https://gitlab.com/graphviz/graphviz/-/issues/1700

Patch copied from upstream source repository:

https://gitlab.com/graphviz/graphviz/-/commit/784411ca3655c80da0f6025ab20634b2a6ff696b

From 784411ca3655c80da0f6025ab20634b2a6ff696b Mon Sep 17 00:00:00 2001
From: Matthew Fernandez <matthew.fernandez@gmail.com>
Date: Sat, 25 Jul 2020 19:31:01 -0700
Subject: [PATCH] fix: out-of-bounds write on invalid label

When the label for a node cannot be parsed (due to it being malformed), it falls
back on the symbol name of the node itself. I.e. the default label the node
would have had if it had no label attribute at all. However, this is applied by
dynamically altering the node's label to "\N", a shortcut for the symbol name of
the node. All of this is fine, however if the hand written label itself is
shorter than the literal string "\N", not enough memory would have been
allocated to write "\N" into the label text.

Here we account for the possibility of error during label parsing, and assume
that the label text may need to be overwritten with "\N" after the fact. Fixes
issue #1700.
---
 lib/common/shapes.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/common/shapes.c b/lib/common/shapes.c
index 0a0635fc3..9dca9ba6e 100644
--- a/lib/common/shapes.c
+++ b/lib/common/shapes.c
@@ -3546,9 +3546,10 @@ static void record_init(node_t * n)
     reclblp = ND_label(n)->text;
     len = strlen(reclblp);
     /* For some forgotten reason, an empty label is parsed into a space, so
-     * we need at least two bytes in textbuf.
+     * we need at least two bytes in textbuf, as well as accounting for the
+     * error path involving "\\N" below.
      */
-    len = MAX(len, 1);
+    len = MAX(MAX(len, 1), (int)strlen("\\N"));
     textbuf = N_NEW(len + 1, char);
     if (!(info = parse_reclbl(n, flip, TRUE, textbuf))) {
 	agerr(AGERR, "bad label format %s\n", ND_label(n)->text);
--
2.31.1


code:
Skip this performance regression test.

The test measures things on the order of 20ms.  On a loaded machine, we
have seen enough variation that the test would fail.

--- grep-2.22/tests/long-pattern-perf	2016-01-03 12:52:38.491575007 +0100
+++ grep-2.22/tests/long-pattern-perf	2016-01-03 12:53:39.768464687 +0100
@@ -16,6 +16,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

+exit 77
 . "${srcdir=.}/init.sh"; path_prepend_ ../src

 fail=0


code:
python-admiral doesn't have a license
https://github.com/nspies/admiral/issues/3

diff --git a/setup.py b/setup.py
index 692b6a0..568f381 100755
--- a/setup.py
+++ b/setup.py
@@ -20,7 +20,7 @@ setup(
         'console_scripts' : ["grocsvs = grocsvs.main:main"]
     },

-    install_requires = ["admiral", "h5py", "networkx>=2.0", "pandas", "pybedtools",
+    install_requires = ["h5py", "networkx>=2.0", "pandas", "pybedtools",
                         "pyfaidx", "pysam>=0.10.0", "scipy", "ipython-cluster-helper",
                         "pygraphviz", "psutil"],

diff --git a/src/grocsvs/jobmanagers.py b/src/grocsvs/jobmanagers.py
index 6da0b58..112d7ff 100755
--- a/src/grocsvs/jobmanagers.py
+++ b/src/grocsvs/jobmanagers.py
@@ -41,34 +41,3 @@ class MultiprocessingCluster(Cluster):
         pool = multiprocessing.Pool(processes=self.processes)
         return pool.map_async(fn, args).get(999999)

-
-class AdmiralCluster(Cluster):
-    def map(self, fn, args):
-        from admiral import jobmanagers, remote
-
-        cluster_options = self.cluster_settings.cluster_options.copy()
-
-        scheduler = cluster_options.pop("scheduler")
-
-        jobmanager_class = jobmanagers.get_jobmanager(scheduler)
-        jobmanager = jobmanager_class(
-            batch_dir=self.batch_dir, log_dir=self.batch_dir)
-
-
-        if not "mem" in cluster_options:
-            cluster_options["mem"] = "16g"
-        if not "time" in cluster_options:
-            cluster_options["time"] = "12h"
-
-        jobs = []
-        #for i, arg in enumerate(args):
-
-        job_name = args[0].__class__.__name__
-        args = [[arg] for arg in args]
-        job = remote.run_remote(fn, jobmanager, job_name, args=args,
-                                array=True, overwrite=True, **cluster_options)
-
-        result = jobmanagers.wait_for_jobs([job], wait=5, progress=True)
-
-        if not result:
-            raise Exception("Some chunks failed to complete")
diff --git a/src/grocsvs/pipeline.py b/src/grocsvs/pipeline.py
index ab1bb2d..350976f 100755
--- a/src/grocsvs/pipeline.py
+++ b/src/grocsvs/pipeline.py
@@ -8,8 +8,7 @@ from grocsvs import utilities
 def make_jobmanager(jobmanager_settings, processes, batch_dir):
     jobmanager_classes = {"IPCluster":jobmanagers.IPCluster,
                           "local":    jobmanagers.LocalCluster,
-                          "multiprocessing": jobmanagers.MultiprocessingCluster,
-                          "admiral": jobmanagers.AdmiralCluster}
+                          "multiprocessing": jobmanagers.MultiprocessingCluster}

     cls = jobmanager_classes[jobmanager_settings.cluster_type]
     return cls(processes, jobmanager_settings, batch_dir)


code:
Unbundling tinyxml2 from gromacs and using our own, which is newer, broke gromacs
build.

This patch fixes three issues:

- cmake now errors out if using multiple target_link_libraries with mixed styles
  of signatures.

- Error handling API changed, fix the testutils/refdata_xml.cpp code by using the
  new API: document.ErrorStr() & tinyxml2::XML_SUCCESS.

Those fixes will be submitted for inclusion to upstream, but may not be suitable
there as long as they still keep the old version bundled.

First hunk has already been requested for merging. Third is in discussion. Second
will only be sent if third is OK'ed.

diff -ruN gromacs-2020.2/src/testutils/CMakeLists.txt gromacs-2020.2-fixed/src/testutils/CMakeLists.txt
--- gromacs-2020.2/src/testutils/CMakeLists.txt 2020-04-30 18:33:44.000000000 +0200
+++ gromacs-2020.2-fixed/src/testutils/CMakeLists.txt   2020-05-01 22:52:16.356000000 +0200
@@ -73,7 +73,7 @@

 if(HAVE_TINYXML2)
     include_directories(SYSTEM ${TinyXML2_INCLUDE_DIR})
-    target_link_libraries(testutils ${TinyXML2_LIBRARIES})
+    target_link_libraries(testutils PRIVATE ${TinyXML2_LIBRARIES})
 else()
     include_directories(BEFORE SYSTEM "../external/tinyxml2")
 endif()
diff -ruN gromacs-2020.2/src/testutils/refdata_xml.cpp gromacs-2020.2-fixed/src/testutils/refdata_xml.cpp
--- gromacs-2020.2/src/testutils/refdata_xml.cpp        2020-04-30 18:33:44.000000000 +0200
+++ gromacs-2020.2-fixed/src/testutils/refdata_xml.cpp  2020-05-01 23:17:09.556000000 +0200
@@ -206,21 +206,12 @@
     document.LoadFile(path.c_str());
     if (document.Error())
     {
-        const char* errorStr1 = document.GetErrorStr1();
-        const char* errorStr2 = document.GetErrorStr2();
+        const char* errorStr = document.ErrorStr();
         std::string errorString("Error was ");
-        if (errorStr1)
-        {
-            errorString += errorStr1;
-        }
-        if (errorStr2)
-        {
-            errorString += errorStr2;
-        }
-        if (!errorStr1 && !errorStr2)
-        {
+        if (errorStr)
+            errorString += errorStr;
+        else
             errorString += "not specified.";
-        }
         GMX_THROW(TestException("Reference data not parsed successfully: " + path + "\n."
                                 + errorString + "\n"));
     }
@@ -371,7 +362,7 @@
     XMLElementPtr rootElement = createRootElement(&document);
     createChildElements(rootElement, rootEntry);

-    if (document.SaveFile(path.c_str()) != tinyxml2::XML_NO_ERROR)
+    if (document.SaveFile(path.c_str()) != tinyxml2::XML_SUCCESS)
     {
         GMX_THROW(TestException("Reference data saving failed in " + path));
     }


code:
From 3dbdc68093e90f0ef9b77b70490d8e0b1dcfbf8f Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Sun, 17 Sep 2017 21:08:45 +0200
Subject: [PATCH] Add ExceptionUtilsGenerator.java.

A gradle task (in gradle/utils.gradle) is normally used to generate an
ExceptionUtils class. Since gradle depends on groovy, we cannot use it, so
we copy the code from the gradle task to a new file. Running this file then
generates the required class.
---
 .../codehaus/groovy/ExceptionUtilsGenerator.java   | 75 ++++++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 config/ant/src/org/codehaus/groovy/ExceptionUtilsGenerator.java

diff --git a/config/ant/src/org/codehaus/groovy/ExceptionUtilsGenerator.java b/config/ant/src/org/codehaus/groovy/ExceptionUtilsGenerator.java
new file mode 100644
index 0000000..41f006d
--- /dev/null
+++ b/config/ant/src/org/codehaus/groovy/ExceptionUtilsGenerator.java
@@ -0,0 +1,75 @@
+package org.codehaus.groovy;
+
+import org.objectweb.asm.*;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.logging.Logger;
+
+public class ExceptionUtilsGenerator implements Opcodes {
+    private final static Logger LOGGER = Logger.getLogger(ExceptionUtilsGenerator.class.getName());
+
+    public static void main(String... args) {
+        if (args==null || args.length==0) {
+            throw new IllegalArgumentException("You must specify at least one file");
+        }
+
+        ClassWriter cw = new ClassWriter(0);
+        MethodVisitor mv;
+
+        cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "org/codehaus/groovy/runtime/ExceptionUtils", null, "java/lang/Object", null);
+
+        cw.visitSource("ExceptionUtils.java", null);
+
+        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+        mv.visitCode();
+        Label l0 = new Label();
+        mv.visitLabel(l0);
+        mv.visitLineNumber(18, l0);
+        mv.visitVarInsn(ALOAD, 0);
+        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
+        mv.visitInsn(RETURN);
+        Label l1 = new Label();
+        mv.visitLabel(l1);
+        mv.visitLocalVariable("this", "Lorg/codehaus/groovy/runtime/ExceptionUtils;", null, l0, l1, 0);
+        mv.visitMaxs(1, 1);
+        mv.visitEnd();
+
+        mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "sneakyThrow", "(Ljava/lang/Throwable;)V", null, null);
+        mv.visitCode();
+        Label l2 = new Label();
+        mv.visitLabel(l2);
+        mv.visitLineNumber(20, l2);
+        mv.visitVarInsn(ALOAD, 0);
+        mv.visitInsn(ATHROW);
+        Label l3 = new Label();
+        mv.visitLabel(l3);
+        mv.visitLocalVariable("e", "Ljava/lang/Throwable;", null, l2, l3, 0);
+        mv.visitMaxs(1, 1);
+        mv.visitEnd();
+
+        cw.visitEnd();
+
+        LOGGER.info("Generating ExceptionUtils");
+        byte[] bytes = cw.toByteArray();
+        for (String classFilePath : args) {
+            File classFile = new File(classFilePath);
+            if (classFile.getParentFile().exists() || classFile.getParentFile().mkdirs()) {
+                try {
+                    if (classFile.exists()) {
+                        classFile.delete();
+                    }
+                    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(classFile));
+                    bos.write(bytes);
+                    bos.close();
+                } catch (IOException e) {
+                    LOGGER.warning("Unable to write file "+classFile);
+                }
+            } else {
+                LOGGER.warning("Unable to create directory "+classFile.getParentFile());
+            }
+        }
+	}
+}
--
2.14.1


code:
Change 'grub-mkrescue' to honor the 'GRUB_FAT_SERIAL_NUMBER'
environment variable.  That way, the caller can specify a fixed
serial number (instead of the randomly chosen one) to create EFI
images (the 'efi.img' file) that are reproducible bit-for-bit.

Patch by Ludovic Courtès <ludo@gnu.org>.
Mangled (for GRUB 2.04) by Tobias Geerinckx-Rice <me@tobias.gr>.

--- grub-2.04/util/grub-mkrescue.c	2019-05-20 13:01:11.000000000 +0200
+++ grub-2.04/util/grub-mkrescue.c	2019-07-08 23:57:36.912104652 +0200
@@ -809,8 +809,15 @@
       free (efidir_efi_boot);

       efiimgfat = grub_util_path_concat (2, iso9660_dir, "efi.img");
-      rv = grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2880", "-L", "16", "-i",
-	    efiimgfat, "::", NULL });
+
+      const char *fat_serial_number = getenv ("GRUB_FAT_SERIAL_NUMBER");
+      const char *mformat_args[] =
+       { "mformat", "-C", "-f", "2880", "-L", "16",
+         fat_serial_number != NULL ? "-N" : "-C",
+         fat_serial_number != NULL ? fat_serial_number : "-C",
+         "-i", efiimgfat, "::", NULL };
+
+      rv = grub_util_exec (mformat_args);
       if (rv != 0)
 	grub_util_error ("`%s` invocation failed\n", "mformat");
       rv = grub_util_exec ((const char * []) { "mcopy", "-s", "-i", efiimgfat, efidir_efi, "::/", NULL });


code:
This patch is taken from OpenWrt, see:

https://github.com/openwrt/openwrt/blob/master/package/boot/grub2/patches/100-grub_setup_root.patch

nckx changed `char *root' to lazily pacify -Werror=discarded-qualifiers.

It allows to use grub-bios-setup on a raw disk-images, without root permissions.

--- a/include/grub/util/install.h
+++ b/include/grub/util/install.h
@@ -198,13 +198,13 @@ grub_install_get_image_target (const char *arg);
 void
 grub_util_bios_setup (const char *dir,
 		      const char *boot_file, const char *core_file,
-		      const char *dest, int force,
+		      char *root, const char *dest, int force,
 		      int fs_probe, int allow_floppy,
 		      int add_rs_codes, int warn_short_mbr_gap);
 void
 grub_util_sparc_setup (const char *dir,
 		       const char *boot_file, const char *core_file,
-		       const char *dest, int force,
+		       char *root, const char *dest, int force,
 		       int fs_probe, int allow_floppy,
 		       int add_rs_codes, int warn_short_mbr_gap);

diff --git a/util/grub-install.c b/util/grub-install.c
index 0fbe7f78c..7f06aa1e3 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -1721,7 +1721,7 @@ main (int argc, char *argv[])
 	if (install_bootsector)
 	  {
 	    grub_util_bios_setup (platdir, "boot.img", "core.img",
-				  install_drive, force,
+				  NULL, install_drive, force,
 				  fs_probe, allow_floppy, add_rs_codes,
 				  !grub_install_is_short_mbrgap_supported ());

@@ -1752,7 +1752,7 @@ main (int argc, char *argv[])
 	if (install_bootsector)
 	  {
 	    grub_util_sparc_setup (platdir, "boot.img", "core.img",
-				   install_drive, force,
+				   NULL, install_drive, force,
 				   fs_probe, allow_floppy,
 				   0 /* unused */, 0 /* unused */ );

diff --git a/util/grub-setup.c b/util/grub-setup.c
index 1783224dd..48cde4950 100644
--- a/util/grub-setup.c
+++ b/util/grub-setup.c
@@ -87,6 +87,8 @@ static struct argp_option options[] = {
    N_("install even if problems are detected"), 0},
   {"skip-fs-probe",'s',0,      0,
    N_("do not probe for filesystems in DEVICE"), 0},
+  {"root-device", 'r', N_("DEVICE"), 0,
+   N_("use DEVICE as the root device"), 0},
   {"verbose",     'v', 0,      0, N_("print verbose messages."), 0},
   {"allow-floppy", 'a', 0,      0,
    /* TRANSLATORS: The potential breakage isn't limited to floppies but it's
@@ -130,6 +132,7 @@ struct arguments
   char *core_file;
   char *dir;
   char *dev_map;
+  char *root_dev;
   int  force;
   int  fs_probe;
   int allow_floppy;
@@ -178,6 +181,13 @@ argp_parser (int key, char *arg, struct argp_state *state)
         arguments->dev_map = xstrdup (arg);
         break;

+      case 'r':
+        if (arguments->root_dev)
+          free (arguments->root_dev);
+
+        arguments->root_dev = xstrdup (arg);
+        break;
+
       case 'f':
         arguments->force = 1;
         break;
@@ -313,7 +323,7 @@ main (int argc, char *argv[])
   GRUB_SETUP_FUNC (arguments.dir ? : DEFAULT_DIRECTORY,
 		   arguments.boot_file ? : DEFAULT_BOOT_FILE,
 		   arguments.core_file ? : DEFAULT_CORE_FILE,
-		   dest_dev, arguments.force,
+		   arguments.root_dev, dest_dev, arguments.force,
 		   arguments.fs_probe, arguments.allow_floppy,
 		   arguments.add_rs_codes, 0);

diff --git a/util/setup.c b/util/setup.c
index da5f2c07f..193745a9c 100644
--- a/util/setup.c
+++ b/util/setup.c
@@ -252,14 +252,13 @@ identify_partmap (grub_disk_t disk __attribute__ ((unused)),
 void
 SETUP (const char *dir,
        const char *boot_file, const char *core_file,
-       const char *dest, int force,
+       char *root, const char *dest, int force,
        int fs_probe, int allow_floppy,
        int add_rs_codes __attribute__ ((unused)), /* unused on sparc64 */
        int warn_small)
 {
   char *core_path;
   char *boot_img, *core_img, *boot_path;
-  char *root = 0;
   size_t boot_size, core_size;
   grub_uint16_t core_sectors;
   grub_device_t root_dev = 0, dest_dev, core_dev;
@@ -311,7 +310,10 @@ SETUP (const char *dir,

   core_dev = dest_dev;

-  {
+  if (root)
+    root_dev = grub_device_open(root);
+
+  if (!root_dev) {
     char **root_devices = grub_guess_root_devices (dir);
     char **cur;
     int found = 0;
@@ -324,6 +326,8 @@ SETUP (const char *dir,
 	char *drive;
 	grub_device_t try_dev;

+	if (root_dev)
+	  break;
 	drive = grub_util_get_grub_dev (*cur);
 	if (!drive)
 	  continue;


code:
Somehow, Aspell 0.60.6.1 and aspell-dict-en-2016.11.20-0 don't consider
this a valid spelling.  Skip it.

TODO: Migrate to using hunspell. According to upstream, this bug won't be fixed.
See https://bugzilla.gnome.org/show_bug.cgi?id=772406.
--- a/testsuite/test-checker.c	2017-03-24 09:50:50.000000000 -0400
+++ b/testsuite/test-checker.c	2017-06-15 21:47:07.116173895 -0400
@@ -105,10 +105,11 @@
 	 * be considered deprecated, it is better to use hunspell, so WONTFIX.
 	 * For more details, see:
 	 * https://bugzilla.gnome.org/show_bug.cgi?id=772406
+	 *
+	 * correctly_spelled = gspell_checker_check_word (checker, "spell-checking", -1, &error);
+	 * g_assert_no_error (error);
+	 * g_assert (correctly_spelled);
 	 */
-	correctly_spelled = gspell_checker_check_word (checker, "spell-checking", -1, &error);
-	g_assert_no_error (error);
-	g_assert (correctly_spelled);

 	correctly_spelled = gspell_checker_check_word (checker, "nrst-auie", -1, &error);
 	g_assert_no_error (error);


code:
Fix a stack corruption when handling files with more than 64 audio
channels:

https://gstreamer.freedesktop.org/security/sa-2021-0005.html

Patch copied from upstream source repository:

https://gitlab.freedesktop.org/gstreamer/gst-libav/-/commit/dcea8baa14a5fc3b796d876baaf2f238546ba2b1

diff --git a/ext/libav/gstavcodecmap.c b/ext/libav/gstavcodecmap.c
index b5be4bb7a5f2712f78383da9319754a8849e3307..be22f22cf5c7c7b22b13e44b10999adaacbcca2b 100644
--- a/ext/libav/gstavcodecmap.c
+++ b/ext/libav/gstavcodecmap.c
@@ -102,7 +102,7 @@ gst_ffmpeg_channel_layout_to_gst (guint64 channel_layout, gint channels,
   guint nchannels = 0;
   gboolean none_layout = FALSE;

-  if (channel_layout == 0) {
+  if (channel_layout == 0 || channels > 64) {
     nchannels = channels;
     none_layout = TRUE;
   } else {
@@ -163,7 +163,7 @@ gst_ffmpeg_channel_layout_to_gst (guint64 channel_layout, gint channels,
     } else {
       guint i;

-      for (i = 0; i < nchannels; i++)
+      for (i = 0; i < nchannels && i < 64; i++)
         pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
     }
   }