code:
From: Markus Koschany <apo@gambaru.de>
Date: Sun, 3 Aug 2014 22:50:46 +0200
Subject: missing separators

Bug: https://bugs.debian.org/750082

---
 src/Makefile.am  | 14 +++++++-------
 src/Makefile.in  | 14 +++++++-------
 test/Makefile.am |  2 +-
 test/Makefile.in |  2 +-
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index fbd7e8f..96768d3 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,7 +29,7 @@ Script.cpp \
 StateBehavior.cpp \
 Table.cpp

-dnl libemilia_pin_la_SOURCES = $(libemilia_pin_a_SOURCES)
+# libemilia_pin_la_SOURCES = $(libemilia_pin_a_SOURCES)

 pininclude_HEADERS = \
 ArmBehavior.h \
@@ -56,10 +56,10 @@ Table.h
 # libemilia_pin.a libemilia_addon.a  libemilia_base.a libltdlc.a
 wpinball.exe:  ${pinball_OBJECTS} ${pinball_DEPENDENCIES}
 	${GCCLOCALDIR}g++ -g -W -Wall -O2 -o$@ $^ \
- -lSDL_mixer -lvorbisfile -lvorbis -logg -lsmpeg \
- -lSDL_image -lSDLmain -lSDL \
- -lglu32 -lopengl32 -ljpeg -lpng  \
- -lwinmm -luser32 -lgdi32 -ldxguid   \
- -lmingw32 -lSDLmain -lSDL  -mwindows \
- -L${GCCLOCALDIR}../lib
+	-lSDL_mixer -lvorbisfile -lvorbis -logg -lsmpeg \
+	-lSDL_image -lSDLmain -lSDL \
+	-lglu32 -lopengl32 -ljpeg -lpng \
+	-lwinmm -luser32 -lgdi32 -ldxguid \
+	-lmingw32 -lSDLmain -lSDL  -mwindows \
+	-L${GCCLOCALDIR}../lib
 # !-rzr : # have to solve it later # -lstdc++
diff --git a/src/Makefile.in b/src/Makefile.in
index ea7651b..8e95cd6 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -505,7 +505,7 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am \
 	uninstall-pinincludeHEADERS uninstall-pinlibLIBRARIES

-dnl libemilia_pin_la_SOURCES = $(libemilia_pin_a_SOURCES)
+	dnl libemilia_pin_la_SOURCES = $(libemilia_pin_a_SOURCES)

 # !+rzr : This trick workaround a bad generated rule (under Linux mingw32)
 # src/ litool returns:  -L/usr/local//lib /usr/lib/libjpeg.so
@@ -514,12 +514,12 @@ dnl libemilia_pin_la_SOURCES = $(libemilia_pin_a_SOURCES)
 # libemilia_pin.a libemilia_addon.a  libemilia_base.a libltdlc.a
 wpinball.exe:  ${pinball_OBJECTS} ${pinball_DEPENDENCIES}
 	${GCCLOCALDIR}g++ -g -W -Wall -O2 -o$@ $^ \
- -lSDL_mixer -lvorbisfile -lvorbis -logg -lsmpeg \
- -lSDL_image -lSDLmain -lSDL \
- -lglu32 -lopengl32 -ljpeg -lpng  \
- -lwinmm -luser32 -lgdi32 -ldxguid   \
- -lmingw32 -lSDLmain -lSDL  -mwindows \
- -L${GCCLOCALDIR}../lib
+	-lSDL_mixer -lvorbisfile -lvorbis -logg -lsmpeg \
+	-lSDL_image -lSDLmain -lSDL \
+	-lglu32 -lopengl32 -ljpeg -lpng \
+	-lwinmm -luser32 -lgdi32 -ldxguid \
+	-lmingw32 -lSDLmain -lSDL  -mwindows \
+	-L${GCCLOCALDIR}../lib
 # !-rzr : # have to solve it later # -lstdc++
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/test/Makefile.am b/test/Makefile.am
index d87cf34..ea3ffc9 100755
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -4,7 +4,7 @@ testlibdir = $(EM_LIBDIR)
 testdatadir = $(pkgdatadir)

 noinst_PROGRAMS = scale simple light texture load explode collision signal billboard font thread menu joy sound trans math misc varray unittest
-dnl noinst_PROGRAMS = unittest
+# noinst_PROGRAMS = unittest

 INCLUDES = -I../base -I../addon -I../src @INCLTDL@
 LDADD = ../src/libemilia_pin.a ../addon/libemilia_addon.a ../base/libemilia_base.a @LIBLTDL@
diff --git a/test/Makefile.in b/test/Makefile.in
index 6ba2646..47654dc 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -621,7 +621,7 @@ uninstall-am: uninstall-info-am uninstall-testlibLTLIBRARIES
 	mostlyclean-generic mostlyclean-libtool tags uninstall \
 	uninstall-am uninstall-info-am uninstall-testlibLTLIBRARIES

-dnl noinst_PROGRAMS = unittest
+# noinst_PROGRAMS = unittest
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:


code:
Fixes error during make:

"No rule to make target '../src/libemilia_pin.a', needed by 'pinball'.  Stop."

--- pinball-0.3.1/src/Makefile.in	2003-12-10 05:34:47.000000000 -0600
+++ pinball-0.3.1/src/Makefile.in	2016-01-31 22:29:13.134519889 -0600
@@ -116,7 +116,7 @@

 INCLUDES = -I../base -I../addon @INCLTDL@

-pinball_LDADD = ../src/libemilia_pin.a ../addon/libemilia_addon.a ../base/libemilia_base.a @LIBLTDL@
+pinball_LDADD = libemilia_pin.a ../addon/libemilia_addon.a ../base/libemilia_base.a @LIBLTDL@
 pinball_LDFLAGS = -export-dynamic

 pinball_SOURCES = Pinball.cpp
@@ -174,7 +174,7 @@

 am_pinball_OBJECTS = Pinball.$(OBJEXT)
 pinball_OBJECTS = $(am_pinball_OBJECTS)
-pinball_DEPENDENCIES = ../src/libemilia_pin.a ../addon/libemilia_addon.a \
+pinball_DEPENDENCIES = libemilia_pin.a ../addon/libemilia_addon.a \
 	../base/libemilia_base.a

 DEFS = @DEFS@

license: mit


code:
--- pinball-0.3.1/configure.ac	2010-01-14 17:26:25.000000000 +0100
+++ pinball-0.3.1/configure.ac	2010-01-14 17:26:25.000000000 +0100
@@ -22,14 +22,12 @@
 [  --with-cxxflags=CXXFLAGS        use CXXFLAGS as compile time arguments.],
     [CXXFLAGS=$with_cxxflags; export CXXFLAGS])

-AC_CONFIG_SUBDIRS(libltdl)
-
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_CXX
 AC_PROG_INSTALL
 AC_LIBTOOL_DLOPEN
-AC_LIBLTDL_CONVENIENCE
+LTDL_INIT
 AC_PROG_LIBTOOL

 AC_SUBST(INCLTDL)


code:
Do not assume the SDL_image and SLD_mixer libraries are installed at the same
prefix reported by sdl-config, but instead get flags from the pkg-config files
installed with these libraries.

--- a/SConscript	2011-12-24 15:46:47.000000000 -0600
+++ b/SConscript	2014-06-12 21:20:45.702668330 -0500
@@ -199,7 +199,13 @@
                 self.fatal_error += "  * library 'png' not found\n"

     def configure_sdl(self):
-        if self.conf.CheckMyProgram('sdl-config'):
+        if self.conf.CheckMyProgram('pkg-config'):
+            self.conf.env.ParseConfig("pkg-config --cflags --libs sdl")
+            for sdllib in ['image', 'mixer']:
+                self.conf.env.ParseConfig("pkg-config --cflags --libs SDL_%s" % sdllib)
+                if not self.conf.CheckSDLLib(sdllib):
+                    self.fatal_error += "  * SDL library '%s' not found\n" % sdllib
+        elif self.conf.CheckMyProgram('sdl-config'):
             self.conf.env.ParseConfig("sdl-config  --cflags --libs | sed 's/-I/-isystem/g'")
             for sdllib in ['image', 'mixer']:
                 if not self.conf.CheckSDLLib(sdllib):


code:
See https://github.com/jaymzh/pius/pull/96

commit 4dba0bf75ab351969622f7b9c38484657411a528
Author: Martin Kletzander <nert.pinx+github@gmail.com>
Date:   Thu May 17 17:55:27 2018 +0200

    Don't fail on ENCRYPTION_COMPLIANCE_MODE line from too new GnuPG (#96)

    GnuPG started printing information about encryption compliance in [commit
    f31dc2540acf](https://dev.gnupg.org/rGf31dc2540acf7cd7f09fd94658e815822222bfcb)
    and since then signing with pius fails.

    Closes #95

    Signed-off-by: Martin Kletzander <nert.pinx@gmail.com>

diff --git a/libpius/signer.py b/libpius/signer.py
index 3c7262f..13013bb 100644
--- a/libpius/signer.py
+++ b/libpius/signer.py
@@ -45,6 +45,7 @@ class PiusSigner(object):
   GPG_PINENTRY_LAUNCHED = '[GNUPG:] PINENTRY_LAUNCHED'
   GPG_KEY_CONSIDERED = '[GNUPG:] KEY_CONSIDERED'
   GPG_WARN_VERSION = '[GNUPG:] WARNING server_version_mismatch'
+  GPG_ENC_COMPLIANT_MODE = '[GNUPG:] ENCRYPTION_COMPLIANCE_MODE'

   def __init__(self, signer, force_signer, mode, keyring, gpg_path, tmpdir,
                outdir, encrypt_outfiles, mail, mailer, verbose, sort_keyring,
@@ -431,6 +432,9 @@ class PiusSigner(object):
       if PiusSigner.GPG_ENC_BEG in line:
         debug('Got GPG_ENC_BEG')
         continue
+      elif PiusSigner.GPG_ENC_COMPLIANT_MODE in line:
+        debug('Got ENCRYPTION_COMPLIANCE_MODE')
+        continue
       elif PiusSigner.GPG_ENC_END in line:
         debug('Got GPG_ENC_END')
         break


code:
Fix CVE-2016-5296: Heap-buffer-overflow WRITE in rasterize_edges_1
Adapted for upstream pixman based on:

  https://hg.mozilla.org/releases/mozilla-esr45/rev/5e39c1c2fded

--- pixman-0.34.0/pixman/pixman-edge-imp.h.orig	2015-06-30 05:48:31.000000000 -0400
+++ pixman-0.34.0/pixman/pixman-edge-imp.h	2016-11-16 01:09:34.046335106 -0500
@@ -55,8 +55,9 @@
 	 *
 	 * (The AA case does a similar  adjustment in RENDER_SAMPLES_X)
 	 */
-	lx += X_FRAC_FIRST(1) - pixman_fixed_e;
-	rx += X_FRAC_FIRST(1) - pixman_fixed_e;
+	/* we cast to unsigned to get defined behaviour for overflow */
+	lx = (unsigned)lx + X_FRAC_FIRST(1) - pixman_fixed_e;
+	rx = (unsigned)rx + X_FRAC_FIRST(1) - pixman_fixed_e;
 #endif
 	/* clip X */
 	if (lx < 0)


code:
GCC rightfully complains about redefined variables, as iterator declarations
appear inside loops with a loop variable of the same name.

This patch has been sent upstream.

--- a/sets.cpp	2015-06-25 11:22:08.252821681 +0200
+++ b/sets.cpp	2015-06-25 11:22:23.239187985 +0200
@@ -768,11 +768,11 @@
       //////////////////////////////////////////////
       // Reset original missing status

-      vector<Individual*>::iterator i = PP->sample.begin();
-      while ( i != PP->sample.end() )
+      vector<Individual*>::iterator it = PP->sample.begin();
+      while ( it != PP->sample.end() )
 	{
-	  (*i)->missing = (*i)->flag;
-	  ++i;
+	  (*it)->missing = (*it)->flag;
+	  ++it;
 	}

       ////////////////////////////////////////////////

--- a/elf.cpp	2009-10-10 18:00:21.000000000 +0200
+++ b/elf.cpp	2015-06-25 11:34:06.136835756 +0200
@@ -1175,10 +1175,10 @@
 	  << setw(8) << gcnt << " "
 	  << setw(8) << (double)cnt / (double)gcnt << "\n";

-      map<int,int>::iterator i = chr_cnt.begin();
-      while ( i != chr_cnt.end() )
+      map<int,int>::iterator it = chr_cnt.begin();
+      while ( it != chr_cnt.end() )
 	{
-	  int c = i->first;
+	  int c = it->first;
 	  int x = chr_cnt.find( c )->second;
 	  int y = chr_gcnt.find( c )->second;

@@ -1189,7 +1189,7 @@
 	      << setw(8) << y << " "
 	      << setw(8) << (double)x / (double)y << "\n";

-	  ++i;
+	  ++it;
 	}

     }

--- plink-1.07-src/idhelp.cpp	2009-10-10 18:00:22.000000000 +0200
+++ plink-1.07-src/idhelp.cpp.patched	2015-06-25 11:37:39.387204086 +0200
@@ -772,12 +772,12 @@
       for (int j = 0 ; j < jointField.size(); j++ )
 	{
 	  set<IDField*> & jf = jointField[j];
-	  set<IDField*>::iterator j = jf.begin();
+	  set<IDField*>::iterator jit = jf.begin();
 	  PP->printLOG(" { ");
-	  while ( j != jf.end() )
+	  while ( jit != jf.end() )
 	    {
-	      PP->printLOG( (*j)->name + " " );
-	      ++j;
+	      PP->printLOG( (*jit)->name + " " );
+	      ++jit;
 	    }
 	  PP->printLOG(" }");
 	}


code:
This patch is borrowed from Debian's patches for plink

Author: Peter Green <plugwash@p10link.net>
Puropose: Fallback to endian.h if all else fails on 64bit machines
Closes: #528659
Forwarded: Shaun Purcell <plink@chgr.mgh.harvard.edu>
License: same as plink itself.
===================================================================
--- plink-1.06.orig/Rsrv.h	2009-05-15 03:35:29.000000000 +0100
+++ plink-1.06/Rsrv.h	2009-05-15 03:35:41.000000000 +0100
@@ -313,7 +313,18 @@
 #define __BIG_ENDIAN__ 1
 #define SWAPEND 1
 #elif ! defined Win32 /* Windows is little-endian is most cases, anywhere else we're stuck */
-#error "Cannot determine endianness. Make sure config.h is included or __{BIG|LITTLE}_ENDIAN__ is defined ."
+  //try endian.h before we finally bail out
+  #include <endian.h>
+  #if __BYTE_ORDER == __LITTLE_ENDIAN
+    #warning using little endian based on information from endian.h
+    #define __LITTLE_ENDIAN__ 1
+  #elif __BYTE_ORDER == __BIG_ENDIAN
+    #warning using big endian based on information from endian.h
+    #define __BIG_ENDIAN__ 1
+    #define SWAPEND 1
+  #else
+    #error "Cannot determine endianness. Make sure config.h is included or __{BIG|LITTLE}_ENDIAN__ is defined ."
+  #endif
 #endif

 /* FIXME: all the mess below needs more efficient implementation - the current one is so messy to work around alignment problems on some platforms like Sun and HP 9000 */


code:
Use the `png_jmpbuf' accessor, as recommended since libpng 1.4.0:
http://www.libpng.org/pub/png/src/libpng-1.2.x-to-1.4.x-summary.txt .

--- plotutils-2.6/libplot/z_write.c	2013-07-12 17:19:12.000000000 +0200
+++ plotutils-2.6/libplot/z_write.c	2013-07-12 17:19:07.000000000 +0200
@@ -164,7 +164,7 @@ _pl_z_maybe_output_image (S___(Plotter *
     }

   /* cleanup after libpng errors (error handler does a longjmp) */
-  if (setjmp (png_ptr->jmpbuf))
+  if (setjmp (png_jmpbuf (png_ptr)))
     {
       png_destroy_write_struct (&png_ptr, (png_info **)NULL);
       return -1;
@@ -444,7 +444,7 @@ _our_error_fn_stdio (png_struct *png_ptr
 #endif
     }

-  longjmp (png_ptr->jmpbuf, 1);
+  longjmp (png_jmpbuf (png_ptr), 1);
 }

 static void


code:
Description: Add features needed to make portmixer work with audacity.
Author: Audacity Team
Last-Update: 2011-12-07

See <http://music.columbia.edu/pipermail/portaudio/2015-March/016611.html>.

--- a/include/pa_win_ds.h
+++ b/include/pa_win_ds.h
@@ -89,6 +89,21 @@

 }PaWinDirectSoundStreamInfo;

+/** Retrieve the GUID of the input device.
+
+ @param stream The stream to query.
+
+ @return A pointer to the GUID, or NULL if none.
+*/
+LPGUID PaWinDS_GetStreamInputGUID( PaStream* s );
+
+/** Retrieve the GUID of the output device.
+
+ @param stream The stream to query.
+
+ @return A pointer to the GUID, or NULL if none.
+*/
+LPGUID PaWinDS_GetStreamOutputGUID( PaStream* s );

 #ifdef __cplusplus
--- a/include/portaudio.h
+++ b/include/portaudio.h
@@ -1146,6 +1146,15 @@
 signed long Pa_GetStreamWriteAvailable( PaStream* stream );

+/** Retrieve the host type handling an open stream.
+
+ @return Returns a non-negative value representing the host API type
+ handling an open stream or, a PaErrorCode (which are always negative)
+ if PortAudio is not initialized or an error is encountered.
+*/
+PaHostApiTypeId Pa_GetStreamHostApiType( PaStream* stream );
+
+
 /* Miscellaneous utilities */

--- /dev/null
+++ b/include/pa_unix_oss.h
@@ -0,0 +1,104 @@
+#ifndef PA_UNIX_OSS_H
+#define PA_UNIX_OSS_H
+
+/*
+ * $Id: portaudio.patch,v 1.10 2009-06-30 04:52:59 llucius Exp $
+ * PortAudio Portable Real-Time Audio Library
+ * OSS-specific extensions
+ *
+ * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** @file
+ * OSS-specific PortAudio API extension header file.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const char *PaOSS_GetStreamInputDevice( PaStream *s );
+
+const char *PaOSS_GetStreamOutputDevice( PaStream *s );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+#ifndef PA_UNIX_OSS_H
+#define PA_UNIX_OSS_H
+
+/*
+ * $Id: portaudio.patch,v 1.10 2009-06-30 04:52:59 llucius Exp $
+ * PortAudio Portable Real-Time Audio Library
+ * OSS-specific extensions
+ *
+ * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** @file
+ * OSS-specific PortAudio API extension header file.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const char *PaOSS_GetStreamInputDevice( PaStream *s );
+
+const char *PaOSS_GetStreamOutputDevice( PaStream *s );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- a/src/common/pa_front.c
+++ b/src/common/pa_front.c
@@ -1216,8 +1216,10 @@
                                   hostApiInputParametersPtr, hostApiOutputParametersPtr,
                                   sampleRate, framesPerBuffer, streamFlags, streamCallback, userData );

-    if( result == paNoError )
+    if( result == paNoError ) {
         AddOpenStream( *stream );
+        PA_STREAM_REP(*stream)->hostApiType = hostApi->info.type;
+    }

     PA_LOGAPI(("Pa_OpenStream returned:\n" ));
@@ -1729,6 +1731,32 @@
     return result;
 }

+PaHostApiTypeId Pa_GetStreamHostApiType( PaStream* stream )
+{
+    PaError error = PaUtil_ValidateStreamPointer( stream );
+    PaHostApiTypeId result;
+
+#ifdef PA_LOG_API_CALLS
+    PaUtil_DebugPrint("Pa_GetStreamHostApiType called:\n" );
+    PaUtil_DebugPrint("\tPaStream* stream: 0x%p\n", stream );
+#endif
+
+    if( error == paNoError )
+    {
+        result = PA_STREAM_REP(stream)->hostApiType;
+    }
+    else
+    {
+        result = (PaHostApiTypeId) error;
+    }
+
+#ifdef PA_LOG_API_CALLS
+    PaUtil_DebugPrint("Pa_GetStreamHostApiType returned:\n" );
+    PaUtil_DebugPrint("\tPaError: %d ( %s )\n\n", result, Pa_GetErrorText( result ) );
+#endif
+
+    return result;
+}

 PaError Pa_GetSampleSize( PaSampleFormat format )
 {
--- a/src/common/pa_stream.c
+++ b/src/common/pa_stream.c
@@ -93,6 +93,8 @@
     streamRepresentation->streamInfo.inputLatency = 0.;
     streamRepresentation->streamInfo.outputLatency = 0.;
     streamRepresentation->streamInfo.sampleRate = 0.;
+
+    streamRepresentation->hostApiType = 0;
 }

--- a/src/common/pa_stream.h
+++ b/src/common/pa_stream.h
@@ -152,6 +152,7 @@
     PaStreamFinishedCallback *streamFinishedCallback;
     void *userData;
     PaStreamInfo streamInfo;
+    PaHostApiTypeId hostApiType;
 } PaUtilStreamRepresentation;

--- a/src/hostapi/coreaudio/pa_mac_core_blocking.c
+++ b/src/hostapi/coreaudio/pa_mac_core_blocking.c
@@ -66,6 +66,9 @@
 #ifdef MOSX_USE_NON_ATOMIC_FLAG_BITS
 # define OSAtomicOr32( a, b ) ( (*(b)) |= (a) )
 # define OSAtomicAnd32( a, b ) ( (*(b)) &= (a) )
+#elif MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3
+# define OSAtomicOr32( a, b ) BitOrAtomic( a, (UInt32 *) b )
+# define OSAtomicAnd32( a, b ) BitAndAtomic( a, (UInt32 *) b )
 #else
 # include <libkern/OSAtomic.h>
 #endif
--- a/src/hostapi/alsa/pa_linux_alsa.c
+++ b/src/hostapi/alsa/pa_linux_alsa.c
@@ -611,6 +611,7 @@
     StreamDirection streamDir;

     snd_pcm_channel_area_t *channelAreas;  /* Needed for channel adaption */
+    int card;
 } PaAlsaStreamComponent;

 /* Implementation specific stream structure */
@@ -1806,6 +1807,7 @@
 {
     PaError result = paNoError;
     PaSampleFormat userSampleFormat = params->sampleFormat, hostSampleFormat = paNoError;
+    snd_pcm_info_t* pcmInfo;
     assert( params->channelCount > 0 );

     /* Make sure things have an initial value */
@@ -1826,6 +1828,9 @@
     self->device = params->device;

     PA_ENSURE( AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm ) );
+
+    snd_pcm_info_alloca( &pcmInfo );
+    self->card = snd_pcm_info_get_card( pcmInfo );
     self->nfds = alsa_snd_pcm_poll_descriptors_count( self->pcm );

     PA_ENSURE( hostSampleFormat = PaUtil_SelectClosestAvailableFormat( GetAvailableFormats( self->pcm ), userSampleFormat ) );
@@ -4519,9 +4524,7 @@
     /* XXX: More descriptive error? */
     PA_UNLESS( stream->capture.pcm, paDeviceUnavailable );

-    alsa_snd_pcm_info_alloca( &pcmInfo );
-    PA_ENSURE( alsa_snd_pcm_info( stream->capture.pcm, pcmInfo ) );
-    *card = alsa_snd_pcm_info_get_card( pcmInfo );
+    *card = stream->capture.card;

 error:
     return result;
@@ -4537,9 +4540,7 @@
     /* XXX: More descriptive error? */
     PA_UNLESS( stream->playback.pcm, paDeviceUnavailable );

-    alsa_snd_pcm_info_alloca( &pcmInfo );
-    PA_ENSURE( alsa_snd_pcm_info( stream->playback.pcm, pcmInfo ) );
-    *card = alsa_snd_pcm_info_get_card( pcmInfo );
+    *card = stream->playback.card;

 error:
     return result;
--- a/src/hostapi/oss/pa_unix_oss.c
+++ b/src/hostapi/oss/pa_unix_oss.c
@@ -2028,3 +2028,26 @@
 #endif
 }

+const char *PaOSS_GetStreamInputDevice( PaStream* s )
+{
+    PaOssStream *stream = (PaOssStream*)s;
+
+    if( stream->capture )
+    {
+      return stream->capture->devName;
+    }
+
+   return NULL;
+}
+
+const char *PaOSS_GetStreamOutputDevice( PaStream* s )
+{
+    PaOssStream *stream = (PaOssStream*)s;
+
+    if( stream->playback )
+    {
+      return stream->playback->devName;
+    }
+
+   return NULL;
+}
--- a/configure.in
+++ b/configure.in
@@ -365,6 +365,7 @@
                    DLL_LIBS="$DLL_LIBS -lossaudio"
                    LIBS="$LIBS -lossaudio"
            fi
+           INCLUDES="$INCLUDES pa_unix_oss.h"
            AC_DEFINE(PA_USE_OSS,1)
         fi


code:
We took this patch from Gentoo to break apart the portmidi build, so that we
can disable the Java parts and cleanly disable the tests which fail to link
(possibly because they are linked before “-lportmidi” is available).  The
patch was downloaded from here:

https://gitweb.gentoo.org/repo/gentoo.git/plain/media-libs/portmidi/files/portmidi-217-cmake.patch?id=56bd759df1d0c750a065b8c845e93d5dfa6b549d

--- portmidi/CMakeLists.txt
+++ portmidi/CMakeLists.txt
@@ -9,12 +9,11 @@
   set(CMAKE_BUILD_TYPE Release CACHE STRING
       "Semicolon-separate list of supported configuration types")
   # set default directories but don't override cached values...
-  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CACHEFILE_DIR}/${CMAKE_BUILD_TYPE}
+  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
       CACHE STRING "libraries go here")
-  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CACHEFILE_DIR}/${CMAKE_BUILD_TYPE}
+  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
       CACHE STRING "libraries go here")
-  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
-      ${CMAKE_CACHEFILE_DIR}/${CMAKE_BUILD_TYPE}
+  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
       CACHE STRING "executables go here")

 else(UNIX)
@@ -68,10 +67,20 @@
 include_directories(pm_common porttime)
 add_subdirectory(pm_common)

-add_subdirectory(pm_test)
+option(PORTMIDI_ENABLE_JAVA "Enable Java bindings support" ON)
+option(PORTMIDI_ENABLE_STATIC "Build and install static libraries" OFF)
+option(PORTMIDI_ENABLE_TEST "Build test programs" ON)
+
+if(PORTMIDI_ENABLE_TEST)
+  add_subdirectory(pm_test)
+endif(PORTMIDI_ENABLE_TEST)

 add_subdirectory(pm_dylib)

 # Cannot figure out how to make an xcode Java application with CMake
-add_subdirectory(pm_java)
+if(PORTMIDI_ENABLE_JAVA)
+  set(JAR_INSTALL_DIR share/java
+      CACHE STRING "Define directory name for jar installation")
+  add_subdirectory(pm_java)
+endif(PORTMIDI_ENABLE_JAVA)

--- portmidi/pm_common/CMakeLists.txt
+++ portmidi/pm_common/CMakeLists.txt
@@ -44,9 +44,6 @@

 # first include the appropriate system-dependent file:
 if(UNIX)
-  # add the -g switch for Linux and Mac OS X (not used in Win32)
-  set (CMAKE_C_FLAGS_DEBUG "-g ${CMAKE_C_FLAGS_DEBUG}"
-       CACHE STRING "enable extra checks for debugging" FORCE)
   if(APPLE)
     set(MACSRC pmmacosxcm pmmac readbinaryplist finddefault)
     prepend_path(LIBSRC ../pm_mac/ ${MACSRC})
@@ -62,19 +59,23 @@
                              ${COREMIDI_LIB} ${CORESERVICES_LIB}
         CACHE INTERNAL "")

-    set(JAVAVM_LIB "${FRAMEWORK_PATH}/JavaVM.framework")
-    set(JAVA_INCLUDE_PATHS ${JAVAVM_LIB}/Headers)
+    if(PORTMIDI_ENABLE_JAVA)
+      set(JAVAVM_LIB "${FRAMEWORK_PATH}/JavaVM.framework")
+      set(JAVA_INCLUDE_PATHS ${JAVAVM_LIB}/Headers)
+    endif(PORTMIDI_ENABLE_JAVA)
     message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
   else(APPLE)
     # LINUX settings...
-    include(FindJNI)
-    message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
-    message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
-    message(STATUS "JAVA_INCLUDE_PATH2 is " ${JAVA_INCLUDE_PATH2})
-    message(STATUS "JAVA_JVM_LIBRARY is " ${JAVA_JVM_LIBRARY})
-    set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
-    # libjvm.so is found relative to JAVA_INCLUDE_PATH:
-    set(JAVAVM_LIB ${JAVA_JVM_LIBRARY}/libjvm.so)
+    if(PORTMIDI_ENABLE_JAVA)
+      include(FindJNI)
+      message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
+      message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
+      message(STATUS "JAVA_INCLUDE_PATH2 is " ${JAVA_INCLUDE_PATH2})
+      message(STATUS "JAVA_JVM_LIBRARY is " ${JAVA_JVM_LIBRARY})
+      set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
+      # libjvm.so is found relative to JAVA_INCLUDE_PATH:
+      set(JAVAVM_LIB ${JAVA_JVM_LIBRARY}/libjvm.so)
+    endif(PORTMIDI_ENABLE_JAVA)

     set(LINUXSRC pmlinuxalsa pmlinux finddefault)
     prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
@@ -88,10 +89,12 @@
     # /MD is multithread DLL, /MT is multithread. Change to static:
     include(../pm_win/static.cmake)

-    include(FindJNI)
+    if(PORTMIDI_ENABLE_JAVA)
+      include(FindJNI)

-    set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
-    # message(STATUS "JAVA_INCLUDE_PATHS: " ${JAVA_INCLUDE_PATHS})
+      set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
+      # message(STATUS "JAVA_INCLUDE_PATHS: " ${JAVA_INCLUDE_PATHS})
+    endif(PORTMIDI_ENABLE_JAVA)

     set(WINSRC pmwin pmwinmm)
     prepend_path(LIBSRC ../pm_win/ ${WINSRC})
@@ -99,29 +102,43 @@
     set(PM_NEEDED_LIBS winmm.lib)
   endif(WIN32)
 endif(UNIX)
-set(JNI_EXTRA_LIBS ${PM_NEEDED_LIBS} ${JAVA_JVM_LIBRARY})
+
+if(PORTMIDI_ENABLE_JAVA)
+  set(JNI_EXTRA_LIBS ${PM_NEEDED_LIBS} ${JAVA_JVM_LIBRARY})
+endif(PORTMIDI_ENABLE_JAVA)

 # this completes the list of library sources by adding shared code
 list(APPEND LIBSRC pmutil portmidi)

 # now add the shared files to make the complete list of library sources
-add_library(portmidi-static ${LIBSRC})
-set_target_properties(portmidi-static PROPERTIES OUTPUT_NAME "portmidi_s")
-target_link_libraries(portmidi-static ${PM_NEEDED_LIBS})
-
-# define the jni library
-include_directories(${JAVA_INCLUDE_PATHS})
-
-set(JNISRC ${LIBSRC} ../pm_java/pmjni/pmjni.c)
-add_library(pmjni SHARED ${JNISRC})
-target_link_libraries(pmjni ${JNI_EXTRA_LIBS})
-set_target_properties(pmjni PROPERTIES EXECUTABLE_EXTENSION "jnilib")
+if(PORTMIDI_ENABLE_STATIC)
+  add_library(portmidi-static ${LIBSRC})
+  set_target_properties(portmidi-static PROPERTIES OUTPUT_NAME "portmidi")
+  target_link_libraries(portmidi-static ${PM_NEEDED_LIBS})
+endif(PORTMIDI_ENABLE_STATIC)
+
+if(PORTMIDI_ENABLE_JAVA)
+  # define the jni library
+  include_directories(${JAVA_INCLUDE_PATHS})
+
+  set(JNISRC ${LIBSRC} ../pm_java/pmjni/pmjni.c)
+  add_library(pmjni SHARED ${JNISRC})
+  target_link_libraries(pmjni ${JNI_EXTRA_LIBS})
+  set_target_properties(pmjni PROPERTIES EXECUTABLE_EXTENSION "jnilib")
+endif(PORTMIDI_ENABLE_JAVA)

 # install the libraries (Linux and Mac OS X command line)
 if(UNIX)
-  INSTALL(TARGETS portmidi-static pmjni
-    LIBRARY DESTINATION /usr/local/lib
-    ARCHIVE DESTINATION /usr/local/lib)
+  if(PORTMIDI_ENABLE_STATIC)
+    INSTALL(TARGETS portmidi-static
+      LIBRARY DESTINATION lib${LIB_SUFFIX}
+      ARCHIVE DESTINATION lib${LIB_SUFFIX})
+  endif(PORTMIDI_ENABLE_STATIC)
+  if(PORTMIDI_ENABLE_JAVA)
+    INSTALL(TARGETS pmjni
+      LIBRARY DESTINATION lib${LIB_SUFFIX}
+      ARCHIVE DESTINATION lib${LIB_SUFFIX})
+  endif(PORTMIDI_ENABLE_JAVA)
 # .h files installed by pm_dylib/CMakeLists.txt, so don't need them here
 #  INSTALL(FILES portmidi.h ../porttime/porttime.h
 #    DESTINATION /usr/local/include)
--- portmidi/pm_dylib/CMakeLists.txt
+++ portmidi/pm_dylib/CMakeLists.txt
@@ -39,9 +39,6 @@

 # first include the appropriate system-dependent file:
 if(UNIX)
-  # add the -g switch for Linux and Mac OS X (not used in Win32)
-  set (CMAKE_C_FLAGS_DEBUG "-g ${CMAKE_C_FLAGS_DEBUG}"
-       CACHE STRING "enable extra checks for debugging" FORCE)
   if(APPLE)
     set(MACSRC pmmacosxcm pmmac readbinaryplist finddefault)
     prepend_path(LIBSRC ../pm_mac/ ${MACSRC})
@@ -63,7 +60,8 @@
     message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
   else(APPLE)
     # LINUX settings...
-    include(FindJNI)
+    if(PORTMIDI_ENABLE_JAVA)
+      include(FindJNI)
     # message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
     # message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
     # note: should use JAVA_JVM_LIB_PATH, but it is not set properly
@@ -75,11 +73,8 @@
     # JAVA_INCLUDE_PATH2; if no, then we need to make both JAVA_INCLUDE_PATH
     # and JAVA_INCLUDE_PATH2 set by user (will need clear documentation
     # because JAVA_INCLUDE_PATH2 is pretty obscure)
-    set(JAVA_INCLUDE_PATH  ${JAVA_INCLUDE_PATH-UNKNOWN}
-        CACHE STRING "where to find Java SDK include directory")
-    set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH}/linux)
-    # libjvm.so is found relative to JAVA_INCLUDE_PATH:
-    set(JAVAVM_LIB ${JAVA_INCLUDE_PATH}/../jre/lib/i386/client/libjvm.so)
+      set(JAVAVM_LIB ${JAVA_JVM_LIBRARY})
+    endif(PORTMIDI_ENABLE_JAVA)

     set(LINUXSRC pmlinuxalsa pmlinux finddefault)
     prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
@@ -91,13 +86,15 @@
   if(WIN32)
     # /MDd is multithread debug DLL, /MTd is multithread debug
     # /MD is multithread DLL, /MT is multithread
-
-    include(FindJNI)
-    # note: should use JAVA_JVM_LIB_PATH, but it is not set properly
-    set(JAVAVM_LIB ${JAVA_INCLUDE_PATH}/../lib/jvm.lib)

-    set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
-    # message(STATUS "JAVA_INCLUDE_PATHS: " ${JAVA_INCLUDE_PATHS})
+    if(PORTMIDI_ENABLE_JAVA)
+      include(FindJNI)
+      # note: should use JAVA_JVM_LIB_PATH, but it is not set properly
+      set(JAVAVM_LIB ${JAVA_INCLUDE_PATH}/../lib/jvm.lib)
+
+      set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
+      # message(STATUS "JAVA_INCLUDE_PATHS: " ${JAVA_INCLUDE_PATHS})
+    endif(PORTMIDI_ENABLE_JAVA)

     set(WINSRC pmwin pmwinmm)
     prepend_path(LIBSRC ../pm_win/ ${WINSRC})
@@ -106,7 +103,10 @@
     # message(STATUS "JAVAVM_LIB: " ${JAVAVM_LIB})
   endif(WIN32)
 endif(UNIX)
+
+if(PORTMIDI_ENABLE_JAVA)
 set(JNI_EXTRA_LIBS ${PM_NEEDED_LIBS} ${JAVAVM_LIB})
+endif(PORTMIDI_ENABLE_JAVA)

 # this completes the list of library sources by adding shared code
 set(SHARED_FILES pmutil portmidi)
@@ -120,8 +120,8 @@
 # install the libraries (Linux and Mac OS X command line)
 if(UNIX)
   INSTALL(TARGETS portmidi-dynamic
-    LIBRARY DESTINATION /usr/local/lib
-    ARCHIVE DESTINATION /usr/local/lib)
+    LIBRARY DESTINATION lib${LIB_SUFFIX}
+    ARCHIVE DESTINATION lib${LIB_SUFFIX})
   INSTALL(FILES ../pm_common/portmidi.h ../porttime/porttime.h
-    DESTINATION /usr/local/include)
+    DESTINATION include)
 endif(UNIX)
--- portmidi/pm_java/CMakeLists.txt
+++ portmidi/pm_java/CMakeLists.txt
@@ -5,43 +5,24 @@
     # java not dealt with in CMake -- see pm_mac/pm_mac.xcodeproj
   else(APPLE)
     # linux
-    set(JPORTMIDICLASS JPortMidi.class JPortMidiException.class
-    		       JPortMidiApi.class)
-    set(PMDEFAULTSCLASS PmDefaultsFrame.class PmDefaults.class)
-    prepend_path(JPORTMIDICLASS2 jportmidi/ ${JPORTMIDICLASS})
-    prepend_path(PMDEFAULTSCLASS2 pmdefaults/ ${PMDEFAULTSCLASS})
-    set(PMDEFAULTS_ALL_CLASSES ${JPORTMIDICLASS2} ${PMDEFAULTSCLASS2})
-    # message(STATUS "PMDEFAULTS_ALL_CLASSES is " ${PMDEFAULTS_ALL_CLASSES})
-    add_custom_command(OUTPUT pmdefaults/PmDefaultsFrame.class
-        COMMAND javac -classpath . pmdefaults/PmDefaultsFrame.java
-	MAIN_DEPENDENCY pmdefaults/PmDefaultsFrame.java
-	DEPENDS pmdefaults/PmDefaults.java
-	WORKING_DIRECTORY pm_java)
-    add_custom_command(OUTPUT pmdefaults/PmDefaults.class
-        COMMAND javac -classpath . pmdefaults/PmDefaults.java
-	MAIN_DEPENDENCY pmdefaults/PmDefaults.java
-	DEPENDS pmdefaults/PmDefaultsFrame.java
-	WORKING_DIRECTORY pm_java)
-    add_custom_command(OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar
-        COMMAND	cp pmdefaults/portmusic_logo.png .
-        COMMAND	jar cmf pmdefaults/manifest.txt pmdefaults.jar
-		pmdefaults/*.class portmusic_logo.png jportmidi/*.class
-  	COMMAND chmod +x pmdefaults/pmdefaults
-	COMMAND cp pmdefaults/pmdefaults ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-	COMMAND mv pmdefaults.jar ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-	COMMAND rm portmusic_logo.png
-	MAIN_DEPENDENCY pmdefaults/PmDefaults.class
-	DEPENDS ${PMDEFAULTS_ALL_CLASSES}
-	WORKING_DIRECTORY pm_java)
-    add_custom_target(pmdefaults_target ALL
-        DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar)
-    # message(STATUS "add_custom_target: pmdefaults.jar")
+	set(JAVA_CLASSES jportmidi pmdefaults)
+	add_custom_command(OUTPUT ${JAVA_CLASSES}
+		COMMAND javac -d ${CMAKE_CURRENT_BINARY_DIR} jportmidi/*.java pmdefaults/*.java
+		WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+	add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pmdefaults.jar
+		DEPENDS ${JAVA_CLASSES}
+		COMMAND jar cmf pmdefaults/manifest.txt ${CMAKE_CURRENT_BINARY_DIR}/pmdefaults.jar
+		-C pmdefaults portmusic_logo.png -C ${CMAKE_CURRENT_BINARY_DIR} jportmidi
+		-C ${CMAKE_CURRENT_BINARY_DIR} pmdefaults
+		WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+	add_custom_target(pmdefaults.jar ALL
+		DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pmdefaults.jar)

     # install the libraries (Linux only)
-    INSTALL(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar
-      DESTINATION /usr/share/java)
-    INSTALL(PROGRAMS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults
-      DESTINATION /usr/local/bin)
+    INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pmdefaults.jar
+      DESTINATION ${JAR_INSTALL_DIR})
+    INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/pmdefaults/pmdefaults
+      DESTINATION bin)
   endif(APPLE)
 endif(UNIX)
 # In windows, use pm_java/make.bat
--- portmidi/pm_test/CMakeLists.txt
+++ portmidi/pm_test/CMakeLists.txt
@@ -12,8 +12,8 @@

 macro(make_a_test name)
   add_executable(${name} ${name}.c)
-  target_link_libraries(${name} portmidi-static ${PM_NEEDED_LIBS})
-  add_dependencies(${name} portmidi-static)
+  target_link_libraries(${name} portmidi ${PM_NEEDED_LIBS})
+  add_dependencies(${name} portmidi)
 endmacro(make_a_test)

 make_a_test(test)


code:
This relaxes the comparison threshold between the reference data
and the bitmaps produced by Ghostscript interpreting the vectorized
image.  Apparently the threshold has become too low with the switch
to from Ghostscript 2.21 to 2.22.

--- potrace-1.15/check/postscript-check.sh	2018-01-06 19:47:26.194900686 +0100
+++ potrace-1.15/check/postscript-check.sh	2018-01-06 19:51:35.937503739 +0100
@@ -70,15 +70,15 @@ if test $? -ne 0; then
     echo "Something is wrong with $GS; skipping this test" >& 2
     exit 77
 fi
-actiondiff "$TMP2" "$REFDATA" 1000
+actiondiff "$TMP2" "$REFDATA" 1500

 action $POTRACE -r50 -p -L 0 -B 0 --opaque -o "$TMP1" "$DATA"
 action "$GS" -q -dNOPAUSE -sDEVICE=pbmraw -g460x394 -r100x100 -sOutputFile="$TMP2" -- "$TMP1"
-actiondiff "$TMP2" "$REFDATA" 1200
+actiondiff "$TMP2" "$REFDATA" 1500

 action $POTRACE -r50 -p -L 0 -B 0 -A 160 -o "$TMP1" "$DATA"
 action "$GS" -q -dNOPAUSE -sDEVICE=pbmraw -g568x528 -r100x100 -sOutputFile="$TMP2" -- "$TMP1"
-actiondiff "$TMP2" "$REFDATAROT" 1200
+actiondiff "$TMP2" "$REFDATAROT" 1500

 action rm -f "$TMP1"
 action rm -f "$TMP2"

--- potrace-1.15/check/pdf-check.sh	2018-01-06 19:47:28.698886663 +0100
+++ potrace-1.15/check/pdf-check.sh	2018-01-06 20:54:14.895460329 +0100
@@ -72,15 +72,15 @@ if test $? -ne 0 -o ! -f "$TMP2"; then
     echo "GS does not understand PDF; skipping this test" >& 2
     exit 77
 fi
-actiondiff "$TMP2" "$REFDATA" 1000
+actiondiff "$TMP2" "$REFDATA" 1500

 action $POTRACE -r50 -p -L 0 -B 0 --opaque -b pdf -o "$TMP1" "$DATA"
 action "$GS" -q -dNOPAUSE -sDEVICE=pbmraw -g460x394 -r100x100 -sOutputFile="$TMP2" -- "$TMP1"
-actiondiff "$TMP2" "$REFDATA" 1200
+actiondiff "$TMP2" "$REFDATA" 1500

 action $POTRACE -r50 -p -L 0 -B 0 -A 160 -b pdf -o "$TMP1" "$DATA"
 action "$GS" -q -dNOPAUSE -sDEVICE=pbmraw -g568x528 -r100x100 -sOutputFile="$TMP2" -- "$TMP1"
-actiondiff "$TMP2" "$REFDATAROT" 1200
+actiondiff "$TMP2" "$REFDATAROT" 1500

 action rm -f "$TMP1"
 action rm -f "$TMP2"

Diff finished.  Sat Jan  6 20:54:50 2018


code:
Fixes CVE-2014-3618 (heap overflow in formisc.c allowing denial of
service and potential remote execution of arbitrary code).
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3618

Source:
http://seclists.org/oss-sec/2014/q3/495

Adopted by Debian as patch '27':
https://sources.debian.net/src/procmail/3.22-25/debian/patches/27/

--- a/src/formisc.c
+++ b/src/formisc.c
@@ -84,12 +84,11 @@
 	case '"':*target++=delim='"';start++;
       }
      ;{ int i;
-	do
+	while(*start)
 	   if((i= *target++= *start++)==delim)	 /* corresponding delimiter? */
 	      break;
 	   else if(i=='\\'&&*start)		    /* skip quoted character */
 	      *target++= *start++;
-	while(*start);						/* anything? */
       }
      hitspc=2;
    }


code:
Fix CVE-2017-16844:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-16844
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=876511

Patch copied from Debian procmail package 3.22-26:

http://http.debian.net/debian/pool/main/p/procmail/procmail_3.22-26.debian.tar.xz

From: Santiago Vila <sanvila@debian.org>
Subject: Fix heap-based buffer overflow in loadbuf()
Bug-Debian: http://bugs.debian.org/876511
X-Debian-version: 3.22-26

--- a/src/formisc.c
+++ b/src/formisc.c
@@ -103,7 +103,7 @@
 }
 							    /* append to buf */
 void loadbuf(text,len)const char*const text;const size_t len;
-{ if(buffilled+len>buflen)			  /* buf can't hold the text */
+{ while(buffilled+len>buflen)			  /* buf can't hold the text */
      buf=realloc(buf,buflen+=Bsize);
   tmemmove(buf+buffilled,text,len);buffilled+=len;
 }


code:
Rename getline() to procmail_getline() to avoid namespace clash with
POSIX getline(). Fixes FTBFS.

Copied from Debian:
http://sources.debian.net/src/procmail/3.22-24/debian/patches/24/

References:
http://bugs.debian.org/549426

--- a/src/fields.c
+++ b/src/fields.c
@@ -110,16 +110,16 @@
 		    /* try and append one valid field to rdheader from stdin */
 int readhead P((void))
 { int idlen;
-  getline();
+  procmail_getline();
   if((idlen=breakfield(buf,buffilled))<=0) /* not the start of a valid field */
      return 0;
   if(idlen==STRLEN(FROM)&&eqFrom_(buf))			/* it's a From_ line */
    { if(rdheader)
 	return 0;			       /* the From_ line was a fake! */
-     for(;buflast=='>';getline());	    /* gather continued >From_ lines */
+     for(;buflast=='>';procmail_getline());	    /* gather continued >From_ lines */
    }
   else
-     for(;;getline())		      /* get the rest of the continued field */
+     for(;;procmail_getline())		      /* get the rest of the continued field */
       { switch(buflast)			     /* will this line be continued? */
 	 { case ' ':case '\t':				  /* yep, it sure is */
 	      continue;
--- a/src/formail.c
+++ b/src/formail.c
@@ -819,7 +819,7 @@
       { if(split)		       /* gobble up the next start separator */
 	 { buffilled=0;
 #ifdef sMAILBOX_SEPARATOR
-	   getline();buffilled=0;		 /* but only if it's defined */
+	   procmail_getline();buffilled=0;		 /* but only if it's defined */
 #endif
 	   if(buflast!=EOF)					   /* if any */
 	      goto splitit;
--- a/src/formisc.c
+++ b/src/formisc.c
@@ -115,7 +115,7 @@
   buf[buffilled++]=c;
 }

-int getline P((void))			   /* read a newline-terminated line */
+int procmail_getline P((void))			   /* read a newline-terminated line */
 { if(buflast==EOF)			 /* at the end of our Latin already? */
    { loadchar('\n');					  /* fake empty line */
      return EOF;					  /* spread the word */
--- a/src/formisc.h
+++ b/src/formisc.h
@@ -17,4 +17,4 @@
 char*
  skipwords P((char*start));
 int
- getline P((void));
+ procmail_getline P((void));


code:
The test suite of PRoot makes many FHS assumptions, such as assuming
that /bin, /bin/true, and /usr exist.  This patch fixes these assumptions.

--- source/tests/GNUmakefile	2017-05-11 15:26:36.899115484 +0200
+++ source/tests/GNUmakefile	2017-05-11 15:26:46.143063166 +0200
@@ -121,7 +121,7 @@ $(ROOTFS_DIR):
 setup: $(ROOTFS_BIN)

 $(ROOTFS)/bin/abs-true:
-	@ln -fs /bin/true $@
+	@ln -fs `which true`  $@

 $(ROOTFS)/bin/rel-true:
 	@ln -fs ./true $@

--- source/tests/test-d2175fc3.sh	2017-05-11 15:36:53.727617010 +0200
+++ source/tests/test-d2175fc3.sh	2017-05-11 15:37:10.155523637 +0200
@@ -2,8 +2,8 @@ if [ ! -x  ${ROOTFS}/bin/readlink ] || [
     exit 125;
 fi

-${PROOT} -r ${ROOTFS} /bin/readlink /bin/abs-true | grep '^/bin/true$'
+${PROOT} -r ${ROOTFS} /bin/readlink /bin/abs-true | grep "`which true`"
 ${PROOT} -r ${ROOTFS} /bin/readlink /bin/rel-true | grep '^\./true$'

-${PROOT} -b /:/host-rootfs -r ${ROOTFS} /bin/readlink /bin/abs-true | grep '^/bin/true$'
+${PROOT} -b /:/host-rootfs -r ${ROOTFS} /bin/readlink /bin/abs-true | grep "`which true`"
 ${PROOT} -b /:/host-rootfs -r ${ROOTFS} /bin/readlink /bin/rel-true | grep '^./true$'

--- source/tests/test-d1be631a.sh	2017-05-11 15:41:36.458008715 +0200
+++ source/tests/test-d1be631a.sh	2017-05-11 15:41:38.921994686 +0200
@@ -1,4 +1,4 @@
-if [ -z `which mknod`] || [ `id -u` -eq 0 ]; then
+if [ -z `which mknod` ] || [ `id -u` -eq 0 ]; then
     exit 125;
 fi

--- source/tests/test-5bed7141.c	2017-05-11 15:34:23.088472743 +0200
+++ source/tests/test-5bed7141.c	2017-05-11 15:34:27.052450235 +0200
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);

 	case 0: /* child */
-		status = chdir("/usr");
+		status = chdir("/gnu");
 		if (status < 0) {
 			perror("chdir");
 			exit(EXIT_FAILURE);

--- a/tests/test-092c5e26.sh
+++ b/tests/test-092c5e26.sh
@@ -24,7 +24,7 @@ fi

 unset LD_LIBRARY_PATH

-env PROOT_FORCE_FOREIGN_BINARY=1 PATH=/tmp:/bin:/usr/bin ${PROOT} -r ${ROOTFS} -q echo ${TMP} | grep "^-U LD_LIBRARY_PATH ${EXTRA}-0 /bin/argv0 /bin/argv0 ${TMP_ABS}$"
+env PROOT_FORCE_FOREIGN_BINARY=1 PATH=/tmp:/bin:/usr/bin:$(dirname $(which echo)) ${PROOT} -r ${ROOTFS} -q echo ${TMP} | grep "^-U LD_LIBRARY_PATH ${EXTRA}-0 /bin/argv0 /bin/argv0 ${TMP_ABS}$"
 env PROOT_FORCE_FOREIGN_BINARY=1 ${PROOT} -r ${ROOTFS} -q echo ${TMP_ABS} | grep "^-U LD_LIBRARY_PATH ${EXTRA}-0 /bin/argv0 /bin/argv0 ${TMP_ABS}$"

 cat > ${ROOTFS}/${TMP_ABS} <<EOF
@@ -34,7 +34,7 @@ chmod +x ${ROOTFS}/${TMP_ABS}

 # Valgrind prepends "/bin/sh" in front of foreign binaries.
 if ! $(echo ${PROOT} | grep -q valgrind); then
-    env PATH=/tmp:/bin:/usr/bin ${PROOT} -r ${ROOTFS} -q echo ${TMP} | grep "^-U LD_LIBRARY_PATH -0 ${TMP} ${TMP_ABS}$"
+    env PATH=/tmp:/bin:/usr/bin:$(dirname $(which echo)) ${PROOT} -r ${ROOTFS} -q echo ${TMP} | grep "^-U LD_LIBRARY_PATH -0 ${TMP} ${TMP_ABS}$"
     ${PROOT} -r ${ROOTFS} -q echo ${TMP_ABS}                | grep "^-U LD_LIBRARY_PATH -0 ${TMP_ABS} ${TMP_ABS}$"
 fi

diff --git a/tests/test-5467b986.sh b/tests/test-5467b986.sh
index c6ac71a..f616f1e 100644
--- a/tests/test-5467b986.sh
+++ b/tests/test-5467b986.sh
@@ -30,8 +30,8 @@ ${PROOT} -v -1 -b /tmp:/b -b /tmp:/a -r ${ROOTFS} fchdir_getcwd /b | grep '^/[ab
 ! ${PROOT} -w /bin -r ${ROOTFS} fchdir_getcwd true
 [ $? -eq 0 ]

-${PROOT} -v -1 -w /usr -r / ${ROOTFS}/bin/chdir_getcwd share  | grep '^/usr/share$'
-${PROOT} -v -1 -w /usr -r / ${ROOTFS}/bin/fchdir_getcwd share | grep '^/usr/share$'
+${PROOT} -v -1 -w /gnu -r / ${ROOTFS}/bin/chdir_getcwd store  | grep '^/gnu/store$'
+${PROOT} -v -1 -w /gnu -r / ${ROOTFS}/bin/fchdir_getcwd store | grep '^/gnu/store$'

-(cd /; ${PROOT} -v -1 -w usr -r / ${ROOTFS}/bin/chdir_getcwd share  | grep '^/usr/share$')
-(cd /; ${PROOT} -v -1 -w usr -r / ${ROOTFS}/bin/fchdir_getcwd share | grep '^/usr/share$')
+(cd /; ${PROOT} -v -1 -w gnu -r / ${ROOTFS}/bin/chdir_getcwd store  | grep '^/gnu/store$')
+(cd /; ${PROOT} -v -1 -w gnu -r / ${ROOTFS}/bin/fchdir_getcwd store | grep '^/gnu/store$')

--- a/tests/test-c15999f9.sh
+++ b/tests/test-c15999f9.sh
@@ -5,7 +5,7 @@ fi
 TMP=/tmp/$(mcookie)
 mkdir ${TMP}

-${PROOT} -b /bin/true:${TMP}/true /bin/true
+${PROOT} -b `which true`:${TMP}/true `which true`
 ! test -e ${TMP}/true
 [ $? -eq 0 ]


code:
Use 'uname -m', which in practice returns the processor architecture.

--- psm-3.3/buildflags.mak~	2014-08-20 21:00:18.000000000 +0100
+++ psm-3.3/buildflags.mak	2017-10-22 12:02:12.855291447 +0100
@@ -38,7 +38,7 @@
 endif

 export os ?= $(shell uname -s | tr '[A-Z]' '[a-z]')
-export arch := $(shell uname -p | sed -e 's,\(i[456]86\|athlon$$\),i386,')
+export arch := $(shell uname -m | sed -e 's,\(i[456]86\|athlon$$\),i386,')

 CC ?= gcc


code:
Add missing flags.

--- psm-3.3/ipath/Makefile~	1970-01-01 01:00:00.000000000 +0100
+++ psm-3.3/ipath/Makefile	2017-10-22 15:10:10.269177711 +0100
@@ -73,7 +73,7 @@
 ${TARGLIB}.so.${MAJOR}.${MINOR}: ${${TARGLIB}-objs}
 	date +'static __attribute__ ((unused)) char __psc_infinipath_revision[] ="$$""Date: %F %R ${rpm_extra_description}InfiniPath $$";' > _revision.c
 	$(CC) -c $(BASECFLAGS) $(INCLUDES) _revision.c -o _revision.o
-	$(CC) -o $@ -Wl,-soname=${TARGLIB}.so.${MAJOR} -shared \
+	$(CC) -o $@ -Wl,-soname=${TARGLIB}.so.${MAJOR} $(LDFLAGS) -shared \
 		-Wl,--unique='*fastpath*' \
 		${${TARGLIB}-objs} _revision.o $(LDFLAGS) $(if $(MIC:0=),$(SCIF_LINK_FLAGS))


code:
Remove timestamp to support reproducible builds.

--- psm-3.3/Makefile~	1970-01-01 01:00:00.000000000 +0100
+++ psm-3.3/Makefile	2017-10-22 15:32:11.736949002 +0100
@@ -326,7 +326,7 @@
 # file around.  Generate it such that the ident command can find it
 # and strings -a | grep InfiniPath does a reasonable job as well.
 ${TARGLIB}.so.${MAJOR}.${MINOR}: ${${TARGLIB}-objs}
-	date +'char psmi_infinipath_revision[] ="$$""Date: %F %R ${rpm_extra_description}InfiniPath $$";' > ${lib_build_dir}/_revision.c
+	echo 'char psmi_infinipath_revision[] ="$$""Date: 1970-01-01 00:00 ${rpm_extra_description}InfiniPath $$";' > ${lib_build_dir}/_revision.c
 	$(CC) -c $(BASECFLAGS) $(INCLUDES) _revision.c -o _revision.o
 	$(CC) $(LDFLAGS) -o $@ -Wl,-soname=${TARGLIB}.so.${MAJOR} -shared -Wl,--unique='*fastpath*' \
 		${${TARGLIB}-objs} _revision.o -L$(build_dir)/ipath $(LDLIBS)


code:
Avoid signed overflow during mult-s16-test which intermittently
failed.

Patch by Mark H Weaver <mhw@netris.org>.

--- pulseaudio-5.0/src/tests/mult-s16-test.c.orig	2014-01-23 13:57:55.000000000 -0500
+++ pulseaudio-5.0/src/tests/mult-s16-test.c	2014-10-24 03:13:46.464661815 -0400
@@ -55,7 +55,7 @@
 START_TEST (mult_s16_test) {
     int16_t samples[SAMPLES];
     int32_t volumes[SAMPLES];
-    int32_t sum1 = 0, sum2 = 0;
+    uint32_t sum1 = 0, sum2 = 0;
     int i;

     pa_random(samples, sizeof(samples));


code:
Increase the timeout on 'cpu-mix-test' to accommodate slower machines.

--- pulseaudio-6.0/src/tests/cpu-mix-test.c.ORIG	2015-02-12 09:10:35.000000000 -0500
+++ pulseaudio-6.0/src/tests/cpu-mix-test.c	2015-03-31 13:45:05.316878322 -0400
@@ -212,7 +212,7 @@
 #if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
     tcase_add_test(tc, mix_neon_test);
 #endif
-    tcase_set_timeout(tc, 120);
+    tcase_set_timeout(tc, 240);
     suite_add_tcase(s, tc);

     sr = srunner_create(s);


code:
In case of 'AttributeError', 'value' is None, so do not try to
access it.
Submitted upstream.

--- pybugz-0.6.11/bugz.py	2006-09-02 14:35:37.000000000 +0200
+++ pybugz-0.6.11/bugz.py	2014-05-05 16:02:20.000000000 +0200
@@ -1249,9 +1254,9 @@ class PrettyBugz(Bugz):
         for field, name in FIELDS + MORE_FIELDS:
             try:
                 value = result.find('//%s' % field).text
+                print '%-12s: %s' % (name, value.encode(self.enc))
             except AttributeError:
                 continue
-            print '%-12s: %s' % (name, value.encode(self.enc))

         # Print out the cc'ed people
         cced = result.findall('.//cc')


code:
Gracefully deal with 'stty size' failures.
Submitted upstream.

--- pybugz-0.6.11/bugz.py	2006-09-02 14:35:37.000000000 +0200
+++ pybugz-0.6.11/bugz.py	2014-05-05 15:17:03.000000000 +0200
@@ -288,7 +288,12 @@ def get_cols():
     stty = which('stty')
     if stty:
         row_cols = commands.getoutput("%s size" % stty)
-        rows, cols = map(int, row_cols.split())
+        try:
+            rows, cols = map(int, row_cols.split())
+        except:
+            # In some cases 'stty size' will just fail with
+            # "Inappropriate ioctl for device".
+            cols = DEFAULT_NUM_COLS
         return cols
     else:
         return DEFAULT_NUM_COLS


code:
These tests require a gpg agent to run, and are difficult to get to work right
in Guix's environment.  For more details, see:
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=713074
  https://bugs.launchpad.net/pygpgme/+bug/999949

--- pygpgme-0.3/tests/test_encrypt_decrypt.py	2012-02-28 19:10:28.000000000 -0800
+++ pygpgme-0.3/tests/test_encrypt_decrypt.py	2016-02-05 10:21:58.966685384 -0800
@@ -125,7 +125,7 @@
         ctx.decrypt(ciphertext, plaintext)
         self.assertEqual(plaintext.getvalue(), b'Hello World\n')

-    def test_encrypt_symmetric(self):
+    def skip_test_encrypt_symmetric(self):
         plaintext = BytesIO(b'Hello World\n')
         ciphertext = BytesIO()
         def passphrase(uid_hint, passphrase_info, prev_was_bad, fd):

--- pygpgme-0.3/tests/test_passphrase.py	2012-02-28 19:04:17.000000000 -0800
+++ pygpgme-0.3/tests/test_passphrase.py	2016-02-05 10:21:47.990630956 -0800
@@ -30,7 +30,7 @@

     import_keys = ['passphrase.pub', 'passphrase.sec']

-    def test_sign_without_passphrase_cb(self):
+    def skip_test_sign_without_passphrase_cb(self):
         ctx = gpgme.Context()
         key = ctx.get_key('EFB052B4230BBBC51914BCBB54DCBBC8DBFB9EB3')
         ctx.signers = [key]
@@ -51,7 +51,7 @@
         self.prev_was_bad = prev_was_bad
         os.write(fd, b'test\n')

-    def test_sign_with_passphrase_cb(self):
+    def skip_test_sign_with_passphrase_cb(self):
         ctx = gpgme.Context()
         key = ctx.get_key('EFB052B4230BBBC51914BCBB54DCBBC8DBFB9EB3')
         ctx.signers = [key]


code:
Have configure.py modify internal variables depending on the --qml-plugindir
configure option.
diff -u PyQt-gpl-5.4.alt/configure.py PyQt-gpl-5.4/configure.py
--- PyQt-gpl-5.4.alt/configure.py	2015-01-25 17:27:50.000000000 +0100
+++ PyQt-gpl-5.4/configure.py	2015-01-25 17:56:41.000000000 +0100
@@ -904,6 +904,9 @@
         if opts.pyuicinterpreter is not None:
             self.pyuic_interpreter = opts.pyuicinterpreter

+        if opts.qmlplugindir is not None:
+            self.qml_plugin_dir = opts.qmlplugindir
+
         if opts.qsciapidir is not None:
             self.qsci_api_dir = opts.qsciapidir


code:
https://sources.debian.org/data/main/p/pyqt5/5.11.2+dfsg-1/debian/patches/public_sip.diff

From: Dmitry Shachnev <mitya57@debian.org>
Date: Tue, 3 Jul 2018 09:46:42 +0300
Subject: Use the public version of sip module

Per https://www.debian.org/doc/debian-policy/#convenience-copies-of-code.
---
 configure.py | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/configure.py b/configure.py
index 7c48136..ca23f93 100644
--- a/configure.py
+++ b/configure.py
@@ -642,15 +642,6 @@ class TargetConfiguration:
                     "Unable to import enum.  Please install the enum34 "
                     "package from PyPI.")

-        # Check there is a private copy of the sip module already installed.
-        try:
-            from PyQt5 import sip
-        except ImportError:
-            error(
-                    "Unable to import PyQt5.sip.  Make sure you have "
-                    "configured SIP to create a private copy of the sip "
-                    "module.")
-
         # Get the details of the Python interpreter library.
         py_major = self.py_version >> 16
         py_minor = (self.py_version >> 8) & 0x0ff
@@ -2438,7 +2429,7 @@ def get_sip_flags(target_config):
     the target configuration.
     """

-    sip_flags = ['-n', 'PyQt5.sip']
+    sip_flags = ['-n', 'sip']

     # If we don't check for signed interpreters, we exclude the 'VendorID'
     # feature
@@ -2914,14 +2905,6 @@ def check_sip(target_config):
     target_config is the target configuration.
     """

-    # Check there is a private copy of the sip module already installed.
-    try:
-        from PyQt5 import sip
-    except ImportError:
-        error(
-                "Unable to import PyQt5.sip.  Make sure you have configured "
-                "SIP to create a private copy of the sip module.")
-
     if target_config.sip is None:
         error(
                 "Make sure you have a working sip on your PATH or use the "


code:
Always provide the same date and time in 'Py_GetBuildInfo'.
This is the information shown at the REPL and in 'sys.version'.
We cannot pass it in CPPFLAGS due to whitespace in the DATE string.

--- a/Modules/getbuildinfo.c
+++ b/Modules/getbuildinfo.c
@@ -4,6 +4,10 @@
 #include <stdio.h>
 #endif

+/* Deterministic date and time.  */
+#define DATE "Jan  1 1970"
+#define TIME "00:00:01"
+
 #ifndef DATE
 #ifdef __DATE__
 #define DATE __DATE__


code:
SIGINT is ignored in the Guix build environment.

--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -399,6 +399,8 @@
         output = self.run_tests('--fromfile', filename)
         self.check_executed_tests(output, tests)

+    @unittest.skipIf(True,
+        "KeyboardInterrupts do not work in the build environment")
     def test_interrupted(self):
         code = TEST_INTERRUPTED
         test = self.create_test('sigint', code=code)
@@ -416,6 +418,8 @@
                  % (self.TESTNAME_REGEX, len(tests)))
         self.check_line(output, regex)

+    @unittest.skipIf(True,
+        "KeyboardInterrupts do not work in the build environment")
     def test_slow_interrupted(self):
         # Issue #25373: test --slowest with an interrupted test
         code = TEST_INTERRUPTED


code:
Make sure the build system honors C_INCLUDE_PATH and LIBRARY_PATH when
looking for headers and libraries.

--- Python-2.7.10/setup.py	2015-10-07 18:33:18.125153186 +0200
+++ Python-2.7.10/setup.py	2015-10-07 18:33:47.497347552 +0200
@@ -526,6 +526,10 @@ class PyBuildExt(build_ext):
             inc_dirs += ['/system/include', '/atheos/autolnk/include']
             inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)

+        # Always honor these variables.
+        lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep)
+        inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)
+
         # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb)
         if host_platform in ['osf1', 'unixware7', 'openunix8']:
             lib_dirs += ['/usr/ccs/lib']


code:
Add all /gnu/store/ prefixes found in PYTHONPATH to the prefixes where
site-packages (and .pth files) are searched.

*** Python-2.7.11/Lib/site.py.orig	2016-10-17 23:27:23.746149690 +0200
--- Python-2.7.11/Lib/site.py	2016-10-17 23:44:51.930871644 +0200
***************
*** 65,70 ****
--- 65,82 ----

  # Prefixes for site-packages; add additional prefixes like /usr/local here
  PREFIXES = [sys.prefix, sys.exec_prefix]
+ # Guix: Add all /gnu/store-paths in PYTHONPATH--these are all
+ # "prefixes".  This is required to search .pth files in all python
+ # packages contained in /gnu/store which is required to make
+ # .pth-defined namespace packages work.
+ # This is necessary if the packages are not merged into a single
+ # `site-packages` directory (like when using `guix environment`) but
+ # listed in PYTHONPATH (like when running `guix build`).
+ for p in sys.path:
+     if p.startswith('/gnu/store/'):
+         PREFIXES.append(p[:p.find('/', 44)]) # find first pathsep after hash
+ del p
+
  # Enable per user site-packages directory
  # set it to False to disable the feature or True to force the feature
  ENABLE_USER_SITE = None


code:
Honor the 'SOURCE_DATE_EPOCH' environment variable to allow for
determinitic builds.

--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -105,7 +105,10 @@ def compile(file, cfile=None, dfile=None, doraise=False):
     """
     with open(file, 'U') as f:
         try:
-            timestamp = long(os.fstat(f.fileno()).st_mtime)
+            if 'SOURCE_DATE_EPOCH' in os.environ:
+                timestamp = long(os.environ['SOURCE_DATE_EPOCH'])
+            else:
+                timestamp = long(os.fstat(f.fileno()).st_mtime)
         except AttributeError:
             timestamp = long(os.stat(file).st_mtime)
         codestring = f.read()
diff --git a/Python/import.c b/Python/import.c
index e47ce63..7eecf9c 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -945,6 +945,11 @@ write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat, t
     /* Now write the true mtime (as a 32-bit field) */
     fseek(fp, 4L, 0);
     assert(mtime <= 0xFFFFFFFF);
+    if (Py_GETENV("SOURCE_DATE_EPOCH") != NULL) {
+	const char *epoch = Py_GETENV("SOURCE_DATE_EPOCH");
+	mtime = atoi(epoch);
+    }
+
     PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION);
     fflush(fp);
     fclose(fp);


code:
Always provide the same date and time in 'Py_GetBuildInfo'.
This is the information shown at the REPL and in 'sys.version'.
We cannot pass it in CPPFLAGS due to whitespace in the DATE string.

--- Modules/getbuildinfo.c
+++ Modules/getbuildinfo.c
@@ -4,6 +4,10 @@
 #include <stdio.h>
 #endif

+/* Deterministic date and time.  */
+#define DATE "Jan  1 1970"
+#define TIME "00:00:01"
+
 #ifndef DATE
 #ifdef __DATE__
 #define DATE __DATE__


code:
Additional test fixes which affect Python 3.5 (and presumably later) but not
prior revisions of Python.

--- Lib/test/test_pathlib.py     2014-03-01 03:02:36.088311000 +0100
+++ Lib/test/test_pathlib.py     2014-03-01 04:56:37.768311000 +0100
@@ -2132,8 +2132,7 @@
         self.assertEqual(given, expect)
         self.assertEqual(set(p.rglob("FILEd*")), set())

-    @unittest.skipUnless(hasattr(pwd, 'getpwall'),
-                         'pwd module does not expose getpwall()')
+    @unittest.skipIf(True, "Guix builder home is '/' which causes trouble for these tests")
     def test_expanduser(self):
         P = self.cls
         support.import_module('pwd')
--- Lib/test/test_tarfile.py        2016-02-24 19:22:52.597208055 +0000
+++ Lib/test/test_tarfile.py     2016-02-24 20:50:48.941950135 +0000
@@ -2305,11 +2305,14 @@
     try:
         import pwd, grp
     except ImportError:
         return False
-    if pwd.getpwuid(0)[0] != 'root':
-        return False
-    if grp.getgrgid(0)[0] != 'root':
+    try:
+        if pwd.getpwuid(0)[0] != 'root':
+            return False
+        if grp.getgrgid(0)[0] != 'root':
+            return False
+    except KeyError:
         return False
     return True

--- Lib/test/test_asyncio/test_base_events.py
+++ Lib/test/test_asyncio/test_base_events.py
@@ -1216,6 +1216,8 @@
         self._test_create_connection_ip_addr(m_socket, False)

     @patch_socket
+    @unittest.skipUnless(support.is_resource_enabled('network'),
+                         'network is not enabled')
     def test_create_connection_service_name(self, m_socket):
         m_socket.getaddrinfo = socket.getaddrinfo
         sock = m_socket.socket.return_value

--- Lib/test/test_pdb.py.org    2017-03-12 03:09:01.991856701 +0100
+++ Lib/test/test_pdb.py        2017-03-12 03:26:17.742572869 +0100

For some reason, KeyboardInterrupts do not work in the build
environment (lack of controlling TTY?). Just change the expected
outcome. Unfortunately, this will make it fail for users running
`python -m test test_pdb test_pdb` interactively.

@@ -928,11 +928,11 @@
     > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
     -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
     (Pdb) continue
-    pdb 1: <built-in function default_int_handler>
+    pdb 1: Handlers.SIG_IGN
     > <doctest test.test_pdb.test_pdb_issue_20766[0]>(5)test_function()
     -> sess.set_trace(sys._getframe())
     (Pdb) continue
-    pdb 2: <built-in function default_int_handler>
+    pdb 2: Handlers.SIG_IGN
     """

 class PdbTestCase(unittest.TestCase):
--- Lib/test/test_socket.py
+++ Lib/test/test_socket.py
@@ -802,6 +802,8 @@
         if not fqhn in all_host_names:
             self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))

+    @unittest.skipUnless(support.is_resource_enabled('network'),
+                         'network is not enabled')
     def test_host_resolution(self):
         for addr in [support.HOST, '10.0.0.1', '255.255.255.255']:
             self.assertEqual(socket.gethostbyname(addr), addr)
--- Lib/test/test_spwd.py
+++ Lib/test/test_spwd.py
@@ -5,8 +5,7 @@
 spwd = support.import_module('spwd')

-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
-                     'root privileges required')
+@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
 class TestSpwdRoot(unittest.TestCase):

     def test_getspall(self):
@@ -56,8 +55,7 @@
             self.assertRaises(TypeError, spwd.getspnam, bytes_name)

-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
-                     'non-root user required')
+@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
 class TestSpwdNonRoot(unittest.TestCase):

     def test_getspnam_exception(self):
--- Lib/test/test_regrtest.py
+++ Lib/test/test_regrtest.py
@@ -700,6 +700,7 @@
         output = self.run_tests('--fromfile', filename)
         self.check_executed_tests(output, tests)

+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
     def test_interrupted(self):
         code = TEST_INTERRUPTED
         test = self.create_test('sigint', code=code)
@@ -717,6 +718,7 @@
                  % (self.TESTNAME_REGEX, len(tests)))
         self.check_line(output, regex)

+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
     def test_slow_interrupted(self):
         # Issue #25373: test --slowest with an interrupted test
         code = TEST_INTERRUPTED
--- Lib/test/test_generators.py
+++ Lib/test/test_generators.py
@@ -29,6 +29,7 @@
         else:
             return "FAILED"

+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment')
     def test_raise_and_yield_from(self):
         gen = self.generator1()
         gen.send(None)
--- Lib/test/test_normalization.py
+++ Lib/test/test_normalization.py
@@ -2,6 +2,7 @@
 import unittest

 from http.client import HTTPException
+from urllib.error import URLError
 import sys
 from unicodedata import normalize, unidata_version

@@ -43,6 +44,8 @@
         except PermissionError:
             self.skipTest(f"Permission error when downloading {TESTDATAURL} "
                           f"into the test data directory")
+        except URLError:
+            self.skipTest("DNS lookups are not enabled.")
         except (OSError, HTTPException):
             self.fail(f"Could not retrieve {TESTDATAURL}")


code:
Make sure the build system honors C_INCLUDE_PATH and LIBRARY_PATH when
looking for headers and libraries.

--- setup.py	2015-10-07 23:32:58.891329173 +0200
+++ setup.py	2015-10-07 23:46:29.653349924 +0200
@@ -575,8 +575,8 @@
         # if a file is found in one of those directories, it can
         # be assumed that no additional -I,-L directives are needed.
         if not cross_compiling:
-            lib_dirs = self.compiler.library_dirs + system_lib_dirs
-            inc_dirs = self.compiler.include_dirs + system_include_dirs
+            lib_dirs = os.getenv('LIBRARY_PATH', '').split(os.pathsep)
+            inc_dirs = os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)
         else:
             # Add the sysroot paths. 'sysroot' is a compiler option used to
             # set the logical path of the standard system headers and


code:
Patch taken from the Debian package for python-axolotl-0.1.39.
See <https://bugs.gnu.org/29415>.

Description: Removes IV paramenter from AES constructor, since it is not necessary for ctr mode.
Author: Josue Ortega <josue@debian.org>
Last-Update: 2017-04-13

--- a/axolotl/sessioncipher.py
+++ b/axolotl/sessioncipher.py
@@ -228,13 +228,7 @@
         # counterint = struct.unpack(">L", counterbytes)[0]
         # counterint = int.from_bytes(counterbytes, byteorder='big')
         ctr = Counter.new(128, initial_value=counter)
-
-        # cipher = AES.new(key, AES.MODE_CTR, counter=ctr)
-        ivBytes = bytearray(16)
-        ByteUtil.intToByteArray(ivBytes, 0, counter)
-
-        cipher = AES.new(key, AES.MODE_CTR, IV=bytes(ivBytes), counter=ctr)
-
+        cipher = AES.new(key, AES.MODE_CTR, counter=ctr)
         return cipher


code:
--- cairocffi-0.8.0/cairocffi/__init__.py.orig	2018-07-16 11:00:59.075664158 +0200
+++ cairocffi-0.8.0/cairocffi/__init__.py	2018-07-16 17:09:42.471958015 +0200
@@ -35,6 +35,7 @@
                         return lib
             except OSError:
                 pass
+        return ffi.dlopen(name)
     raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))


code:
From 16fbc38f13e435b4e3e1a37d706e64e05bad4691 Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Tue, 10 Nov 2015 23:09:24 -0500
Subject: [PATCH] patch build to use setuptools

---
 setup.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index c6d57a6..27bf260 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,12 @@
 # http://opensource.org/licenses/BSD-3-Clause
 import os
 import sys
-from distutils.core import setup
+
+try:
+    from setuptools import setup
+except ImportError:
+    from distutils.core import setup
+
 # a simple import wouldn't work if we moved towards a package with __init__
 from _version import __version__

--
2.6.2


code:
These tests fail on 32-bit due to an overflow.

Upstream bug URL: https://github.com/joke2k/faker/issues/408

diff --git a/tests/__init__.py b/tests/__init__.py
index 6026772..58b6b83 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -384,7 +384,6 @@ class FactoryTestCase(unittest.TestCase):
         provider = Provider
         # test century
         self.assertTrue(self._datetime_to_time(provider.date_time_this_century(after_now=False)) <= self._datetime_to_time(datetime.datetime.now()))
-        self.assertTrue(self._datetime_to_time(provider.date_time_this_century(before_now=False, after_now=True)) >= self._datetime_to_time(datetime.datetime.now()))
         # test decade
         self.assertTrue(self._datetime_to_time(provider.date_time_this_decade(after_now=False)) <= self._datetime_to_time(datetime.datetime.now()))
         self.assertTrue(self._datetime_to_time(provider.date_time_this_decade(before_now=False, after_now=True)) >= self._datetime_to_time(datetime.datetime.now()))
@@ -413,8 +412,6 @@ class FactoryTestCase(unittest.TestCase):

         # ensure all methods provide timezone aware datetimes
         with self.assertRaises(TypeError):
-            provider.date_time_this_century(before_now=False, after_now=True, tzinfo=utc) >= datetime.datetime.now()
-        with self.assertRaises(TypeError):
             provider.date_time_this_decade(after_now=False, tzinfo=utc) <= datetime.datetime.now()
         with self.assertRaises(TypeError):
             provider.date_time_this_year(after_now=False, tzinfo=utc) <= datetime.datetime.now()
@@ -423,7 +420,6 @@ class FactoryTestCase(unittest.TestCase):

         # test century
         self.assertTrue(provider.date_time_this_century(after_now=False, tzinfo=utc) <= datetime.datetime.now(utc))
-        self.assertTrue(provider.date_time_this_century(before_now=False, after_now=True, tzinfo=utc) >= datetime.datetime.now(utc))
         # test decade
         self.assertTrue(provider.date_time_this_decade(after_now=False, tzinfo=utc) <= datetime.datetime.now(utc))
         self.assertTrue(provider.date_time_this_decade(before_now=False, after_now=True, tzinfo=utc) >= datetime.datetime.now(utc))
--
2.11.1


code:
See the discussion about the issues fixed here at:
http://bugs.python.org/issue20868 .

--- Lib/test/test_shutil.py     2014-03-01 03:02:36.088311000 +0100
+++ Lib/test/test_shutil.py     2014-03-01 04:56:37.768311000 +0100
@@ -1127,6 +1127,7 @@
         self.assertRaises(ValueError, make_archive, base_name, 'xxx')

     @support.requires_zlib
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_make_archive_owner_group(self):
         # testing make_archive with owner and group, with various combinations
         # this works even if there's not gid/uid support
@@ -1155,6 +1156,7 @@

     @support.requires_zlib
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
     def test_tarfile_root_owner(self):
         root_dir, base_dir = self._create_files()
--- Lib/test/test_socket.py.orig	2014-03-02 22:14:12.264311000 +0100
+++ Lib/test/test_socket.py	2014-03-21 03:50:45.660311000 +0100
@@ -819,6 +819,8 @@
             self.assertRaises(OverflowError, socket.htonl, k)
             self.assertRaises(OverflowError, socket.htons, k)

+    @unittest.skipUnless(os.path.exists("/etc/services"),
+                         "getservbyname uses /etc/services, which is not in the chroot")
     def testGetServBy(self):
         eq = self.assertEqual
         # Find one service that exists, then check all the related interfaces.
@@ -1104,6 +1106,8 @@
         self.assertRaises(ValueError, s.ioctl, -1, None)
         s.ioctl(socket.SIO_KEEPALIVE_VALS, (1, 100, 100))

+    @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
+                         "getaddrinfo() will fail")
     def testGetaddrinfo(self):
         try:
             socket.getaddrinfo('localhost', 80)
@@ -1174,6 +1178,8 @@
         # only IP addresses are allowed
         self.assertRaises(socket.error, socket.getnameinfo, ('mail.python.org',0), 0)

+    @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
+                         "getaddrinfo() will fail")
     @unittest.skipUnless(support.is_resource_enabled('network'),
                          'network is not enabled')
     def test_idna(self):
--- Lib/test/_test_multiprocessing.py	2014-04-06 23:12:27.575235000 +0200
+++ Lib/test/_test_multiprocessing.py	2014-04-06 23:13:04.827235000 +0200
@@ -1016,6 +1016,7 @@
         if pid is not None:
             os.kill(pid, signal.SIGINT)

+    @unittest.skipIf(True, "This fails for unknown reasons on Guix")
     def test_wait_result(self):
         if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
             pid = os.getpid()
--- Lib/ctypes/test/test_libc.py	2014-04-07 23:17:41.351235000 +0200
+++ Lib/ctypes/test/test_libc.py	2014-04-07 23:32:18.799235000 +0200
@@ -2,6 +2,7 @@

 from ctypes import *
 import _ctypes_test
+import platform

 lib = CDLL(_ctypes_test.__file__)

@@ -17,6 +18,8 @@
         import math
         self.assertEqual(lib.my_sqrt(2.0), math.sqrt(2.0))

+    @unittest.skipIf(platform.machine() in ['mips64'],
+                     "This test fails on this platform")
     def test_qsort(self):
         comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char))
         lib.my_qsort.argtypes = c_void_p, c_size_t, c_size_t, comparefunc
--- Lib/ctypes/test/test_callbacks.py	2014-04-07 23:15:42.835235000 +0200
+++ Lib/ctypes/test/test_callbacks.py	2014-04-07 23:32:42.035235000 +0200
@@ -1,6 +1,7 @@
 import unittest
 from ctypes import *
 import _ctypes_test
+import platform

 class Callbacks(unittest.TestCase):
     functype = CFUNCTYPE
@@ -174,6 +175,8 @@

         self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)

+    @unittest.skipIf(platform.machine() in ['mips64'],
+                     "This test fails on this platform")
     def test_issue_8959_a(self):
         from ctypes.util import find_library
         libc_path = find_library("c")
--- Tools/scripts/run_tests.py.orig	2015-04-06 03:52:17.484000000 +0200
+++ Tools/scripts/run_tests.py	2015-04-06 03:52:25.880000000 +0200
@@ -47,7 +47,7 @@
     if threading and not any(is_multiprocess_flag(arg) for arg in regrtest_args):
         args.extend(['-j', '0'])  # Use all CPU cores
     if not any(is_resource_use_flag(arg) for arg in regrtest_args):
-        args.extend(['-u', 'all,-largefile,-audio,-gui'])
+        args.extend(['-u', 'all,-largefile,-audio,-gui,-network'])
     args.extend(regrtest_args)
     print(' '.join(args))
     os.execv(sys.executable, args)
--- Lib/distutils/tests/test_archive_util.py.orig	2015-04-06 04:08:49.288000000 +0200
+++ Lib/distutils/tests/test_archive_util.py	2015-04-06 04:09:34.396000000 +0200
@@ -282,6 +282,7 @@
         finally:
             del ARCHIVE_FORMATS['xxx']

+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_make_archive_owner_group(self):
         # testing make_archive with owner and group, with various combinations
         # this works even if there's not gid/uid support
@@ -310,6 +311,7 @@

     @unittest.skipUnless(ZLIB_SUPPORT, "Requires zlib")
     @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_tarfile_root_owner(self):
         tmpdir, tmpdir2, base_name =  self._create_files()
         old_dir = os.getcwd()
--- Lib/distutils/tests/test_sdist.py.orig	2015-04-06 04:10:05.264000000 +0200
+++ Lib/distutils/tests/test_sdist.py	2015-04-06 04:10:21.448000000 +0200
@@ -435,6 +435,7 @@
                      "The tar command is not found")
     @unittest.skipIf(find_executable('gzip') is None,
                      "The gzip command is not found")
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_make_distribution_owner_group(self):
         # now building a sdist
         dist, cmd = self.get_cmd()
--- Lib/test/test_resource.py.orig	2015-04-06 21:30:24.708000000 +0200
+++ Lib/test/test_resource.py	2015-04-06 23:07:27.220000000 +0200
@@ -146,6 +146,7 @@

     @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
     @support.requires_linux_version(2, 6, 36)
+    @unittest.skipIf(True, "Bug: the PermissionError is not raised")
     def test_prlimit(self):
         self.assertRaises(TypeError, resource.prlimit)
         if os.geteuid() != 0:


code:
Fix regex so that it works with Python 3.6.

See <https://docs.python.org/3/library/re.html#re.LOCALE>.

Copied from upstream bug report:
https://bugs.launchpad.net/python-mox3/+bug/1665266

From 05064cdb6ea7a16450c6beae2b6f7c6074212a69 Mon Sep 17 00:00:00 2001
From: Zac Medico <zmedico@gentoo.org>
Date: Thu, 16 Feb 2017 00:24:10 -0800
Subject: [PATCH] RegexTest: python3.6 compatibility

These fixes are backward-compatible with older python versions:

* raw strings fix invalid escape sequences
* flags=8 fixes ValueError: cannot use LOCALE flag with a str pattern
---
 mox3/tests/test_mox.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mox3/tests/test_mox.py b/mox3/tests/test_mox.py
index 15ac565..3a1af17 100644
--- a/mox3/tests/test_mox.py
+++ b/mox3/tests/test_mox.py
@@ -312,12 +312,12 @@ class RegexTest(testtools.TestCase):
     def testReprWithoutFlags(self):
         """repr should return the regular expression pattern."""
         self.assertTrue(
-            repr(mox.Regex(r"a\s+b")) == "<regular expression 'a\s+b'>")
+            repr(mox.Regex(r"a\s+b")) == r"<regular expression 'a\s+b'>")

     def testReprWithFlags(self):
         """repr should return the regular expression pattern and flags."""
-        self.assertTrue(repr(mox.Regex(r"a\s+b", flags=4)) ==
-                        "<regular expression 'a\s+b', flags=4>")
+        self.assertTrue(repr(mox.Regex(r"a\s+b", flags=8)) ==
+                        r"<regular expression 'a\s+b', flags=8>")

 class IsTest(testtools.TestCase):
--
2.10.2


code:
From c065b972ed294769a41936d6b9feb336473af5d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Boskovits?= <boskovits@gmail.com>
Date: Sat, 4 Nov 2017 15:28:47 +0100
Subject: Fix SOURCE_DATE_EPOCH ignored bug (#2735)

* Fix SOURCE_DATE_EPOCH ignored bug

Fix a bug in networkx/release.py that makes build
non-reproducible.
---
 networkx/release.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/networkx/release.py b/networkx/release.py
index e81fc0c0..6322cf0d 100644
--- a/networkx/release.py
+++ b/networkx/release.py
@@ -135,7 +135,7 @@ def get_revision():

 def get_info(dynamic=True):
     # Date information
-    date_info = datetime.datetime.now()
+    date_info = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
     date = time.asctime(date_info.timetuple())

     revision, version, version_info, vcs_info = None, None, None, None
--
2.14.2


code:
Remove this test to verify that things were modified since a certain time.

That assumption doesn't hold up when your environment doesn't have access to a
real clock and thinks it's living in 1970 :)

--- a/tests/test_fileapp.py    2015-04-23 13:48:37.000000000 -0700
+++ b/tests/test_fileapp.py	2016-02-22 19:20:08.332802417 -0800
@@ -223,8 +223,6 @@
                   status=304)
     res = app.get('/', headers={'If-None-Match': 'asdf'},
                   status=200)
-    res = app.get('/', headers={'If-Modified-Since': 'Sat, 1 Jan 2005 12:00:00 GMT'},
-                  status=200)
     res = app.get('/', headers={'If-Modified-Since': last_mod + '; length=100'},
                   status=304)
     res = app.get('/', headers={'If-Modified-Since': 'invalid date'},


code:
Remove the test to see if the Python Paste website is up.

Obviously without network access there is no way for us to check this, and
it's pretty strange to test a project's website when you really mean to test
the project anyhow...

--- a/tests/test_proxy.py	2016-02-22 19:13:04.040117767 -0800
+++ b/tests/test_proxy.py	2016-02-22 19:13:04.040117767 -0800
@@ -1,12 +1,3 @@
 from paste import proxy
 from paste.fixture import TestApp

-def test_paste_website():
-    # Not the most robust test...
-    # need to test things like POSTing to pages, and getting from pages
-    # that don't set content-length.
-    app = proxy.Proxy('http://pythonpaste.org')
-    app = TestApp(app)
-    res = app.get('/')
-    assert 'documentation' in res
-


code:
Fix CVE-2013-7459:

https://github.com/dlitz/pycrypto/issues/176
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-7459

Copied from Debian:

https://anonscm.debian.org/cgit/collab-maint/python-crypto.git/commit/?id=0de2243837ed369a086f15c50cca2be85bdfab9d

Debian adapts this upstream commit:

https://github.com/dlitz/pycrypto/commit/8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4

From 8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4 Mon Sep 17 00:00:00 2001
From: Legrandin <helderijs@gmail.com>
Date: Sun, 22 Dec 2013 22:24:46 +0100
Subject: [PATCH] Throw exception when IV is used with ECB or CTR

The IV parameter is currently ignored when initializing
a cipher in ECB or CTR mode.

For CTR mode, it is confusing: it takes some time to see
that a different parameter is needed (the counter).

For ECB mode, it is outright dangerous.

This patch forces an exception to be raised.
---
 lib/Crypto/SelfTest/Cipher/common.py | 31 +++++++++++++++++++++++--------
 src/block_template.c                 | 11 +++++++++++
 2 files changed, 34 insertions(+), 8 deletions(-)

--- a/lib/Crypto/SelfTest/Cipher/common.py
+++ b/lib/Crypto/SelfTest/Cipher/common.py
@@ -239,19 +239,34 @@ class RoundtripTest(unittest.TestCase):
         return """%s .decrypt() output of .encrypt() should not be garbled""" % (self.module_name,)

     def runTest(self):
-        for mode in (self.module.MODE_ECB, self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB, self.module.MODE_OPENPGP):
+
+        ## ECB mode
+        mode = self.module.MODE_ECB
+        encryption_cipher = self.module.new(a2b_hex(self.key), mode)
+        ciphertext = encryption_cipher.encrypt(self.plaintext)
+        decryption_cipher = self.module.new(a2b_hex(self.key), mode)
+        decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
+        self.assertEqual(self.plaintext, decrypted_plaintext)
+
+        ## OPENPGP mode
+        mode = self.module.MODE_OPENPGP
+        encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
+        eiv_ciphertext = encryption_cipher.encrypt(self.plaintext)
+        eiv = eiv_ciphertext[:self.module.block_size+2]
+        ciphertext = eiv_ciphertext[self.module.block_size+2:]
+        decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv)
+        decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
+        self.assertEqual(self.plaintext, decrypted_plaintext)
+
+        ## All other non-AEAD modes (but CTR)
+        for mode in (self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB):
             encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
             ciphertext = encryption_cipher.encrypt(self.plaintext)
-
-            if mode != self.module.MODE_OPENPGP:
-                decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
-            else:
-                eiv = ciphertext[:self.module.block_size+2]
-                ciphertext = ciphertext[self.module.block_size+2:]
-                decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv)
+            decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
             decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
             self.assertEqual(self.plaintext, decrypted_plaintext)

+
 class PGPTest(unittest.TestCase):
     def __init__(self, module, params):
         unittest.TestCase.__init__(self)
--- a/src/block_template.c
+++ b/src/block_template.c
@@ -170,6 +170,17 @@ ALGnew(PyObject *self, PyObject *args, P
 				"Key cannot be the null string");
 		return NULL;
 	}
+	if (IVlen != 0 && mode == MODE_ECB)
+	{
+		PyErr_Format(PyExc_ValueError, "ECB mode does not use IV");
+		return NULL;
+	}
+	if (IVlen != 0 && mode == MODE_CTR)
+	{
+		PyErr_Format(PyExc_ValueError,
+			"CTR mode needs counter parameter, not IV");
+		return NULL;
+	}
 	if (IVlen != BLOCK_SIZE && mode != MODE_ECB && mode != MODE_CTR)
 	{
 		PyErr_Format(PyExc_ValueError,


code:
Fix test failure of test_XXX caused by upgrade of gpgme from 1.6.0 to
1.8.0:

======================================================================
FAIL: test_encrypt_to_signonly (tests.test_encrypt_decrypt.EncryptDecryptTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/guix-build-python2-pygpgme-0.3.drv-0/pygpgme-0.3/tests/test_encrypt_decrypt.py", line 185, in test_encrypt_to_signonly
    self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_UNKNOWN)
AssertionError: 7 != 0

----------------------------------------------------------------------

Patch copied from the Debian package pygpgme-0.3-1.2:

https://sources.debian.net/src/pygpgme/0.3-1.2/debian/patches/0005-Fix-test-failures-with-pinentry.patch/

From: "Dr. Tobias Quathamer" <toddy@debian.org>
Date: Thu, 24 Nov 2016 12:20:54 +0100
Subject: Fix test failures with pinentry

---
 tests/test_encrypt_decrypt.py | 5 +++--
 tests/test_passphrase.py      | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/test_encrypt_decrypt.py b/tests/test_encrypt_decrypt.py
index 21ae83e..05707e1 100644
--- a/tests/test_encrypt_decrypt.py
+++ b/tests/test_encrypt_decrypt.py
@@ -132,6 +132,7 @@ class EncryptDecryptTestCase(GpgHomeTestCase):
             os.write(fd, b'Symmetric passphrase\n')
         ctx = gpgme.Context()
         ctx.armor = True
+        ctx.pinentry_mode = gpgme.PINENTRY_MODE_LOOPBACK
         ctx.passphrase_cb = passphrase
         ctx.encrypt(None, 0, plaintext, ciphertext)
         self.assertTrue(
@@ -182,8 +183,8 @@ class EncryptDecryptTestCase(GpgHomeTestCase):
             ctx.encrypt([recipient], gpgme.ENCRYPT_ALWAYS_TRUST,
                         plaintext, ciphertext)
         except gpgme.GpgmeError as exc:
-            self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_UNKNOWN)
-            self.assertEqual(exc.args[1], gpgme.ERR_GENERAL)
+            self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_GPGME)
+            self.assertEqual(exc.args[1], gpgme.ERR_UNUSABLE_PUBKEY)
         else:
             self.fail('gpgme.GpgmeError not raised')

diff --git a/tests/test_passphrase.py b/tests/test_passphrase.py
index 35b3c59..05e6811 100644
--- a/tests/test_passphrase.py
+++ b/tests/test_passphrase.py
@@ -34,6 +34,7 @@ class PassphraseTestCase(GpgHomeTestCase):
         ctx = gpgme.Context()
         key = ctx.get_key('EFB052B4230BBBC51914BCBB54DCBBC8DBFB9EB3')
         ctx.signers = [key]
+        ctx.pinentry_mode = gpgme.PINENTRY_MODE_LOOPBACK
         plaintext = BytesIO(b'Hello World\n')
         signature = BytesIO()

@@ -55,6 +56,7 @@ class PassphraseTestCase(GpgHomeTestCase):
         ctx = gpgme.Context()
         key = ctx.get_key('EFB052B4230BBBC51914BCBB54DCBBC8DBFB9EB3')
         ctx.signers = [key]
+        ctx.pinentry_mode = gpgme.PINENTRY_MODE_LOOPBACK
         ctx.passphrase_cb = self.passphrase_cb
         plaintext = BytesIO(b'Hello World\n')
         signature = BytesIO()


code:
This patch stops a test sometimes failing because of non-determinism.  See
https://github.com/scikit-learn/scikit-learn/pull/9542

From ff9f6db6e8b59c2b3528c8137ed4054f57c1d7c4 Mon Sep 17 00:00:00 2001
From: Hanmin Qin <qinhanmin2005@sina.com>
Date: Sun, 13 Aug 2017 22:13:49 +0800
Subject: [PATCH] add random_state

---
 sklearn/tests/test_kernel_ridge.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sklearn/tests/test_kernel_ridge.py b/sklearn/tests/test_kernel_ridge.py
index 4750a096ac6..979875870b6 100644
--- a/sklearn/tests/test_kernel_ridge.py
+++ b/sklearn/tests/test_kernel_ridge.py
@@ -10,7 +10,7 @@
 from sklearn.utils.testing import assert_array_almost_equal

-X, y = make_regression(n_features=10)
+X, y = make_regression(n_features=10, random_state=0)
 Xcsr = sp.csr_matrix(X)
 Xcsc = sp.csc_matrix(X)
 Y = np.array([y, y]).T


code:
Skip tests that fail with newer versions of Python.

Patch copied from Gentoo:

https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-python/unittest2/files/unittest2-1.1.0-python3.5-test.patch

diff --git a/unittest2/test/test_loader.py b/unittest2/test/test_loader.py
index 683f662..347eea5 100644
--- a/unittest2/test/test_loader.py
+++ b/unittest2/test/test_loader.py
@@ -509,6 +509,7 @@ class Test_TestLoader(unittest2.TestCase):
     #
     # What happens when an impossible name is given, relative to the provided
     # `module`?
+    @unittest.skipIf(sys.version_info[:2] >= (3, 5), "python 3.5 has problems here")
     def test_loadTestsFromName__relative_malformed_name(self):
         loader = unittest.TestLoader()

@@ -811,6 +812,7 @@ class Test_TestLoader(unittest2.TestCase):
     # TestCase or TestSuite instance."
     #
     # What happens when presented with an impossible module name?
+    @unittest.skipIf(sys.version_info[:2] >= (3, 5), "python 3.5 has problems here")
     def test_loadTestsFromNames__malformed_name(self):
         loader = unittest2.TestLoader()

@@ -918,6 +920,7 @@ class Test_TestLoader(unittest2.TestCase):
     # "The method optionally resolves name relative to the given module"
     #
     # What happens when presented with an impossible attribute name?
+    @unittest.skipIf(sys.version_info[:2] >= (3, 5), "python 3.5 has problems here")
     def test_loadTestsFromNames__relative_malformed_name(self):
         loader = unittest.TestLoader()


code:
--- a/setup.py	2017-09-12 01:22:06.273997788 +0200
+++ b/setup.py	2017-09-12 01:22:14.297918757 +0200
@@ -57,7 +57,7 @@
 # Both install and setup requires - because we read VERSION from within the
 # package, and the package also exports all the APIs.
 # six for compat helpers
-REQUIRES = ['argparse', 'six>=1.4', 'traceback2'],
+REQUIRES = ['six>=1.4', 'traceback2'],

 params = dict(
     name=NAME,


code:
Skip test that requires getaddrinfo(), which is not available in the build
environment.  This package uses a regexp for finding tests (see runner.py),
so using @unittest.skip does not work.

--- a/waitress/tests/test_adjustments.py
+++ b/waitress/tests/test_adjustments.py
@@ -185,22 +185,6 @@
     def test_bad_port(self):
         self.assertRaises(ValueError, self._makeOne, listen='127.0.0.1:test')

-    def test_service_port(self):
-        if WIN and PY2: # pragma: no cover
-            # On Windows and Python 2 this is broken, so we raise a ValueError
-            self.assertRaises(
-                ValueError,
-                self._makeOne,
-                listen='127.0.0.1:http',
-            )
-            return
-
-        inst = self._makeOne(listen='127.0.0.1:http 0.0.0.0:https')
-
-        bind_pairs = [sockaddr[:2] for (_, _, _, sockaddr) in inst.listen]
-
-        self.assertEqual(bind_pairs, [('127.0.0.1', 80), ('0.0.0.0', 443)])
-
     def test_dont_mix_host_port_listen(self):
         self.assertRaises(
             ValueError,


code:
From ca548da9ba78ddee90779051210e3e89185e4f7d Mon Sep 17 00:00:00 2001
From: Michel Alexandre Salim <michel@michel-slm.name>
Date: Mon, 15 Feb 2016 23:03:42 +0700
Subject: coverage-4.0a6 compatibility

coverage 4.0a6 no longer generates .coverage file, so use -f when
deleting .coverage to ensure deletion does not fail.
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Makefile')

diff --git a/Makefile b/Makefile
index 7818f57..362c07f 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ fsck-larch.1: fsck-larch.1.in fsck-larch

 check:
 	python -m CoverageTestRunner --ignore-missing-from=without-tests
-	rm .coverage
+	rm -f .coverage
 	./insert-remove-test tempdir 100
 	rm -r tempdir larch.log
 	cmdtest tests
--
cgit v1.1


code:
From e5df32ffbf37481dbb6a70c4d4e7b7b9778c5549 Mon Sep 17 00:00:00 2001
From: "John (J5) Palmieri" <johnp@redhat.com>
Date: Sat, 13 Aug 2011 04:13:28 -0400
Subject: remove references to deprecated GI_INFO_TYPE_ERROR_DOMAIN

diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 8729e25..007b609 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -165,9 +165,6 @@ _pygi_info_new (GIBaseInfo *info)
         case GI_INFO_TYPE_CONSTANT:
             type = &PyGIConstantInfo_Type;
             break;
-        case GI_INFO_TYPE_ERROR_DOMAIN:
-            type = &PyGIErrorDomainInfo_Type;
-            break;
         case GI_INFO_TYPE_UNION:
             type = &PyGIUnionInfo_Type;
             break;
@@ -484,7 +481,6 @@ _pygi_g_type_info_size (GITypeInfo *type_info)
                 case GI_INFO_TYPE_INVALID:
                 case GI_INFO_TYPE_FUNCTION:
                 case GI_INFO_TYPE_CONSTANT:
-                case GI_INFO_TYPE_ERROR_DOMAIN:
                 case GI_INFO_TYPE_VALUE:
                 case GI_INFO_TYPE_SIGNAL:
                 case GI_INFO_TYPE_PROPERTY:
@@ -863,7 +859,6 @@ pygi_g_struct_info_is_simple (GIStructInfo *struct_info)
                     case GI_INFO_TYPE_INVALID:
                     case GI_INFO_TYPE_FUNCTION:
                     case GI_INFO_TYPE_CONSTANT:
-                    case GI_INFO_TYPE_ERROR_DOMAIN:
                     case GI_INFO_TYPE_VALUE:
                     case GI_INFO_TYPE_SIGNAL:
                     case GI_INFO_TYPE_PROPERTY:
--
cgit v0.10.1


code:
Drop SPARQLWrapper from the required install inputs under Python 2, as it
creates a circular dependency.

diff -u rdflib-4.1.2.alt/setup.py rdflib-4.1.2/setup.py
--- rdflib-4.1.2.alt/setup.py	2014-03-04 12:40:26.000000000 +0100
+++ rdflib-4.1.2/setup.py	2015-01-23 21:52:59.000000000 +0100
@@ -52,7 +52,7 @@
         kwargs['test_suite'] = "nose.collector"
         kwargs['install_requires'] = [
             'isodate',
-            'pyparsing', 'SPARQLWrapper']
+            'pyparsing']

         if sys.version_info[1]<7:  # Python 2.6
             kwargs['install_requires'].append('ordereddict')


code:
This test tries to send a KeyboardInterrupt, which does
not work in the build environment.

--- a/test_subprocess32.py	2017-03-06 22:21:49.334045485 +0100
+++ b/test_subprocess32.py	2017-03-06 22:22:02.490439949 +0100
@@ -1299,12 +1299,6 @@
         getattr(p, method)(*args)
         return p

-    def test_send_signal(self):
-        p = self._kill_process('send_signal', signal.SIGINT)
-        _, stderr = p.communicate()
-        self.assertIn('KeyboardInterrupt', stderr)
-        self.assertNotEqual(p.wait(), 0)
-
     def test_kill(self):
         p = self._kill_process('kill')
         _, stderr = p.communicate()


code:
From 75e5b70e6b5dcc4f2219992d7cffa462aa406af0 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 28 Nov 2017 11:51:27 +0100
Subject: [PATCH] memfd: fix configure test
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Recent glibc added memfd_create in sys/mman.h.  This conflicts with
the definition in util/memfd.c:

    /builddir/build/BUILD/qemu-2.11.0-rc1/util/memfd.c:40:12: error: static declaration of memfd_create follows non-static declaration

Fix the configure test, and remove the sys/memfd.h inclusion since the
file actually does not exist---it is a typo in the memfd_create(2) man
page.

Cc: Marc-AndrÃ© Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure    | 2 +-
 util/memfd.c | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 9c8aa5a..99ccc17 100755
--- a/configure
+++ b/configure
@@ -3923,7 +3923,7 @@ fi
 # check if memfd is supported
 memfd=no
 cat > $TMPC << EOF
-#include <sys/memfd.h>
+#include <sys/mman.h>

 int main(void)
 {
diff --git a/util/memfd.c b/util/memfd.c
index 4571d1a..412e94a 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -31,9 +31,7 @@

 #include "qemu/memfd.h"

-#ifdef CONFIG_MEMFD
-#include <sys/memfd.h>
-#elif defined CONFIG_LINUX
+#if defined CONFIG_LINUX && !defined CONFIG_MEMFD
 #include <sys/syscall.h>
 #include <asm/unistd.h>

--
1.8.3.1


code:
Explicitly link against libicui18n so that libQtCore.so always finds it.

--- qt-everywhere-opensource-src-4.8.6/src/corelib/corelib.pro	2015-04-15 12:01:41.661862663 +0200
+++ qt-everywhere-opensource-src-4.8.6/src/corelib/corelib.pro	2015-04-15 12:03:57.954586336 +0200
@@ -19,6 +19,13 @@ include(codecs/codecs.pri)
 include(statemachine/statemachine.pri)
 include(xml/xml.pri)

+# Explicitly link with icui18n, which is dlopened by libQtCore.so.
+# We cannot do this by setting LDFLAGS because that then overrides
+# other LDFLAGS: <https://bugreports.qt.io/browse/QTBUG-5471>.
+# XXX: According to the Nixpkgs recipe, this may be necessary for
+# further libraries (cups, gtk-x11-2.0, libgdk-x11-2.0).
+LIBS_PRIVATE += -licui18n
+
 !qpa:mac|darwin:LIBS_PRIVATE += -framework ApplicationServices
 qpa:mac {
     !ios {


code:
Use $TZDIR to search for time-zone data. Thus avoid depending on package
"tzdata", which often introduces changes with near-immediate effects, so it's
important to be able to update it fast.

Based on a patch fron NixOS.
===================================================================
--- qtbase-opensource-src-5.9.4.orig/src/corelib/tools/qtimezoneprivate_tz.cpp
+++ qtbase-opensource-src-5.9.4/src/corelib/tools/qtimezoneprivate_tz.cpp
@@ -70,7 +70,11 @@
 // Parse zone.tab table, assume lists all installed zones, if not will need to read directories
 static QTzTimeZoneHash loadTzTimeZones()
 {
-    QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
+    // Try TZDIR first, in case we're running on GuixSD.
+    QString path = QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/zone.tab");
+    // Fallback to traditional paths in case we are not on GuixSD.
+    if (!QFile::exists(path))
+        path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
     if (!QFile::exists(path))
         path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");

@@ -645,6 +649,9 @@
         if (!tzif.open(QIODevice::ReadOnly))
             return;
     } else {
+      // Try TZDIR first, in case we're running on GuixSD.
+      tzif.setFileName(QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/") + QString::fromLocal8Bit(ianaId));
+      if (!tzif.open(QIODevice::ReadOnly)) {
         // Open named tz, try modern path first, if fails try legacy path
         tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
         if (!tzif.open(QIODevice::ReadOnly)) {
@@ -652,6 +659,7 @@
             if (!tzif.open(QIODevice::ReadOnly))
                 return;
         }
+      }
     }

     QDataStream ds(&tzif);