code:
From d1d1368c7909ffd8423730afaa811ce7b6a3a8aa Mon Sep 17 00:00:00 2001
From: Tommy Jerry Mairo <tommy.mairo@gmail.com>
Date: Sun, 4 Feb 2018 12:42:00 -0800
Subject: [PATCH 1/2] Bugfix: API mismatch with crypto++ 6.0.0

---
 src/ClientCreditsList.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ClientCreditsList.cpp b/src/ClientCreditsList.cpp
index 3bea9fe2d..a7ae1e34c 100644
--- a/src/ClientCreditsList.cpp
+++ b/src/ClientCreditsList.cpp
@@ -312,7 +312,7 @@ void CClientCreditsList::InitalizeCrypting()
 		// calculate and store public key
 		CryptoPP::RSASSA_PKCS1v15_SHA_Verifier pubkey(*static_cast<CryptoPP::RSASSA_PKCS1v15_SHA_Signer *>(m_pSignkey));
 		CryptoPP::ArraySink asink(m_abyMyPublicKey, 80);
-		pubkey.DEREncode(asink);
+		pubkey.AccessMaterial().Save(asink);
 		m_nMyPublicKeyLen = asink.TotalPutLength();
 		asink.MessageEnd();
 	} catch (const CryptoPP::Exception& e) {

From 88ba0ac952b78382445f2fff73c6792c0474dc62 Mon Sep 17 00:00:00 2001
From: Tommy Jerry Mairo <tommy.mairo@gmail.com>
Date: Wed, 21 Mar 2018 11:56:28 -0700
Subject: [PATCH 2/2] Update: Change AccessMaterial to GetMaterial

---
 src/ClientCreditsList.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ClientCreditsList.cpp b/src/ClientCreditsList.cpp
index a7ae1e34c..69e881fd8 100644
--- a/src/ClientCreditsList.cpp
+++ b/src/ClientCreditsList.cpp
@@ -312,7 +312,7 @@ void CClientCreditsList::InitalizeCrypting()
 		// calculate and store public key
 		CryptoPP::RSASSA_PKCS1v15_SHA_Verifier pubkey(*static_cast<CryptoPP::RSASSA_PKCS1v15_SHA_Signer *>(m_pSignkey));
 		CryptoPP::ArraySink asink(m_abyMyPublicKey, 80);
-		pubkey.AccessMaterial().Save(asink);
+		pubkey.GetMaterial().Save(asink);
 		m_nMyPublicKeyLen = asink.TotalPutLength();
 		asink.MessageEnd();
 	} catch (const CryptoPP::Exception& e) {


code:
Ansible changes its behaviour depending on the name of the script that it is
called as. Make it deal with guix' .real wrapper scripts.

FIXME: Remove once wrapping ansible works properly.
See http://lists.gnu.org/archive/html/bug-guix/2017-05/msg00015.html.
--- ansible-2.3.0.0/bin/ansible	2017-04-12 16:08:05.000000000 +0200
+++ ansible-2.3.0.0-fixed/bin/ansible	2017-05-21 20:11:18.720872385 +0200
@@ -75,7 +75,13 @@
             # sometimes add that
             target = target[:-1]

-        if len(target) > 1:
+        if target[-1] == "real" and target[0].startswith('.'):
+            target = target[:-1]
+            target[0] = target[0][1:]
+        if len(target) > 1 and target[1] != "real" :
+            sub = target[1]
+            myclass = "%sCLI" % sub.capitalize()
+        elif len(target) > 2 and target[2] == "real" :
             sub = target[1]
             myclass = "%sCLI" % sub.capitalize()
         elif target[0] == 'ansible':

license: mit


code:
Description: Add check for buffer overflow with malformed input files
 This was later re-found and became CVE-2014-8123.
Author: <eriks@debian.org>
Bug-Debian: http://bugs.debian.org/407015
Bug-Debian: https://bugs.debian.org/771768
Forwarded: http://seclists.org/oss-sec/2014/q4/870
Last-Update: 2016-01-11

--- antiword-0.37~/wordole.c	2005-08-26 21:49:57.000000000 +0200
+++ antiword-0.37/wordole.c	2009-06-03 22:31:15.948014682 +0200
@@ -259,6 +259,10 @@
 		}
 		tNameSize = (size_t)usGetWord(0x40, aucBytes);
 		tNameSize = (tNameSize + 1) / 2;
+		if ( tNameSize > sizeof(atPPSlist[iIndex].szName)) {
+			werr(0, "Name Size of PPS %d is too large", iIndex);
+			tNameSize = sizeof(atPPSlist[iIndex].szName);
+		}
 		vName2String(atPPSlist[iIndex].szName, aucBytes, tNameSize);
 		atPPSlist[iIndex].ucType = ucGetByte(0x42, aucBytes);
 		if (atPPSlist[iIndex].ucType == 5) {


code:
Based on the upstream fix for the java8 compilation issue.
Simplified patch.
Upstream version of patch does not work with this source tree.

The issue is that in java8 it is an error to pass null to
removeAll. Results in null pointer exception. java7
behaviour was to return the list unmodified.

From db2a350c6d90efaa8dde949fa76005c2c5af45c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Boskovits?= <boskovits@gmail.com>
Date: Fri, 5 Jan 2018 17:05:31 +0100
Subject: [PATCH] Fix java8 compilation.

---
 src/org/antlr/tool/CompositeGrammar.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/org/antlr/tool/CompositeGrammar.java b/src/org/antlr/tool/CompositeGrammar.java
index f1408e7..7e02431 100644
--- a/src/org/antlr/tool/CompositeGrammar.java
+++ b/src/org/antlr/tool/CompositeGrammar.java
@@ -218,7 +218,9 @@ public class CompositeGrammar {
 	public List<Grammar> getIndirectDelegates(Grammar g) {
 		List<Grammar> direct = getDirectDelegates(g);
 		List<Grammar> delegates = getDelegates(g);
-		delegates.removeAll(direct);
+		if (direct != null) {
+			delegates.removeAll(direct);
+		}
 		return delegates;
 	}

--
2.15.1


code:
Based on the upstream fix for the java8 compilation issue.
Simplified patch.
Upstream version of patch does not work with this source tree.

The issue is that in java8 it is an error to pass null to
removeAll. Results in null pointer exception. java7
behaviour was to return the list unmodified.

From 43867d50c05d1c06ab7220eb974a8874ae10c308 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Boskovits?= <boskovits@gmail.com>
Date: Fri, 5 Jan 2018 19:08:24 +0100
Subject: [PATCH] Fix java8 complilation error.

---
 tool/src/main/java/org/antlr/tool/CompositeGrammar.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tool/src/main/java/org/antlr/tool/CompositeGrammar.java b/tool/src/main/java/org/antlr/tool/CompositeGrammar.java
index f34ea73..63740a6 100644
--- a/tool/src/main/java/org/antlr/tool/CompositeGrammar.java
+++ b/tool/src/main/java/org/antlr/tool/CompositeGrammar.java
@@ -226,7 +226,9 @@ public class CompositeGrammar {
 	public List<Grammar> getIndirectDelegates(Grammar g) {
 		List<Grammar> direct = getDirectDelegates(g);
 		List<Grammar> delegates = getDelegates(g);
-		delegates.removeAll(direct);
+		if(direct != null) {
+		        delegates.removeAll(direct);
+		}
 		return delegates;
 	}

--
2.15.1


code:
Support in ao-cad for aarch64.

Submitted upstream at https://github.com/mkeeter/ao/issues/69

--- ao/ui/vendor/efsw/src/efsw/inotify-nosys.h.orig	2017-12-14 16:27:16.125871099 -0600
+++ ao/ui/vendor/efsw/src/efsw/inotify-nosys.h	2017-12-14 16:26:39.786022981 -0600
@@ -69,6 +69,11 @@
 # define __NR_inotify_add_watch (__NR_SYSCALL_BASE+317)
 # define __NR_inotify_rm_watch (__NR_SYSCALL_BASE+318)

+#elif defined (__aarch64__)
+# define __NR_inotify_init 1043
+# define __NR_inotify_add_watch 27
+# define __NR_inotify_rm_watch 28
+
 #elif defined (__frv__)
 # define __NR_inotify_init 291
 # define __NR_inotify_add_watch 292


code:
--- test/testsock.c	2013-01-24 06:57:21.000000000 +0100
+++ test/testsock.c	2013-01-24 17:24:54.000000000 +0100
@@ -90,16 +90,22 @@
     rv = apr_sockaddr_info_get(&sa, NULL, APR_UNSPEC, 0, 0, p);
     APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);

+    /* /etc/services is not available while compiling, so apr_getservbyname
+     * will always return APR_ENOENT. */
+#if 0
     rv = apr_getservbyname(sa, "ftp");
     APR_ASSERT_SUCCESS(tc, "Problem getting ftp service", rv);
     ABTS_INT_EQUAL(tc, 21, sa->port);
+#endif

     rv = apr_getservbyname(sa, "complete_and_utter_rubbish");
     APR_ASSERT_SUCCESS(tc, "Problem getting non-existent service", !rv);

+#if 0
     rv = apr_getservbyname(sa, "telnet");
     APR_ASSERT_SUCCESS(tc, "Problem getting telnet service", rv);
     ABTS_INT_EQUAL(tc, 23, sa->port);
+#endif
 }

 static apr_socket_t *setup_socket(abts_case *tc)


code:
This patch changes the default value of 'dict-dir' to correspond
to ~/.guix-profile/lib/aspell rather than $prefix/lib/aspell-X.Y.

This is not strictly necessary for the 'aspell' program itself since
one can simply set "ASPELL_CONF=dict-dir $HOME/.guix-profile/lib/aspell".
However it is necessary for applications that use libaspell since
'ASPELL_CONF' is not honored in this case.  See <https://bugs.gnu.org/25836>.

--- a/common/config.cpp
+++ b/common/config.cpp
@@ -1349,6 +1349,9 @@ namespace acommon {
 #  define REPL     ".aspell.<lang>.prepl"
 #endif

+#undef DICT_DIR
+#define DICT_DIR "<$ASPELL_DICT_DIR|home-dir/.guix-profile/lib/aspell>"
+
   static const KeyInfo config_keys[] = {
     // the description should be under 50 chars
     {"actual-dict-dir", KeyInfoString, "<dict-dir^master>", 0}


code:
This GCC patch is from the ath9k-htc-firmware repository (version 1.3.2).
Not applying it (apparently) leads to miscompiled firmware, and loading it
fails with a "Target is unresponsive" message from the 'ath9k_htc' module.

From c7162b8a3db42e7faf47606d3aa3dd61e64aea17 Mon Sep 17 00:00:00 2001
From: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Date: Mon, 7 Jan 2013 16:06:28 +0530
Subject: [PATCH] gcc: AR9271/AR7010 config

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
---
 include/xtensa-config.h | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/include/xtensa-config.h b/include/xtensa-config.h
index 30f4f41..fe9b051 100644
--- a/include/xtensa-config.h
+++ b/include/xtensa-config.h
@@ -1,7 +1,7 @@
 /* Xtensa configuration settings.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
-   Contributed by Bob Wilson (bob.wilson@acm.org) at Tensilica.
+   Contributed by Bob Wilson (bwilson@tensilica.com) at Tensilica.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -44,10 +44,7 @@
 #define XCHAL_HAVE_L32R			1

 #undef XSHAL_USE_ABSOLUTE_LITERALS
-#define XSHAL_USE_ABSOLUTE_LITERALS	0
-
-#undef XSHAL_HAVE_TEXT_SECTION_LITERALS
-#define XSHAL_HAVE_TEXT_SECTION_LITERALS 1 /* Set if there is some memory that allows both code and literals.  */
+#define XSHAL_USE_ABSOLUTE_LITERALS	1

 #undef XCHAL_HAVE_MAC16
 #define XCHAL_HAVE_MAC16		0
@@ -59,10 +56,10 @@
 #define XCHAL_HAVE_MUL32		1

 #undef XCHAL_HAVE_MUL32_HIGH
-#define XCHAL_HAVE_MUL32_HIGH		0
+#define XCHAL_HAVE_MUL32_HIGH		1

 #undef XCHAL_HAVE_DIV32
-#define XCHAL_HAVE_DIV32		1
+#define XCHAL_HAVE_DIV32		0

 #undef XCHAL_HAVE_NSA
 #define XCHAL_HAVE_NSA			1
@@ -103,8 +100,6 @@
 #undef XCHAL_HAVE_FP_RSQRT
 #define XCHAL_HAVE_FP_RSQRT		0

-#undef XCHAL_HAVE_DFP_accel
-#define XCHAL_HAVE_DFP_accel			0
 #undef XCHAL_HAVE_WINDOWED
 #define XCHAL_HAVE_WINDOWED		1

@@ -119,32 +114,32 @@

 #undef XCHAL_ICACHE_SIZE
-#define XCHAL_ICACHE_SIZE		16384
+#define XCHAL_ICACHE_SIZE		0

 #undef XCHAL_DCACHE_SIZE
-#define XCHAL_DCACHE_SIZE		16384
+#define XCHAL_DCACHE_SIZE		0

 #undef XCHAL_ICACHE_LINESIZE
-#define XCHAL_ICACHE_LINESIZE		32
+#define XCHAL_ICACHE_LINESIZE		16

 #undef XCHAL_DCACHE_LINESIZE
-#define XCHAL_DCACHE_LINESIZE		32
+#define XCHAL_DCACHE_LINESIZE		16

 #undef XCHAL_ICACHE_LINEWIDTH
-#define XCHAL_ICACHE_LINEWIDTH		5
+#define XCHAL_ICACHE_LINEWIDTH		4

 #undef XCHAL_DCACHE_LINEWIDTH
-#define XCHAL_DCACHE_LINEWIDTH		5
+#define XCHAL_DCACHE_LINEWIDTH		4

 #undef XCHAL_DCACHE_IS_WRITEBACK
-#define XCHAL_DCACHE_IS_WRITEBACK	1
+#define XCHAL_DCACHE_IS_WRITEBACK	0

 #undef XCHAL_HAVE_MMU
 #define XCHAL_HAVE_MMU			1

 #undef XCHAL_MMU_MIN_PTE_PAGE_SIZE
-#define XCHAL_MMU_MIN_PTE_PAGE_SIZE	12
+#define XCHAL_MMU_MIN_PTE_PAGE_SIZE	29

 #undef XCHAL_HAVE_DEBUG
@@ -157,8 +152,11 @@
 #define XCHAL_NUM_DBREAK		2

 #undef XCHAL_DEBUGLEVEL
-#define XCHAL_DEBUGLEVEL		6
+#define XCHAL_DEBUGLEVEL		4
+

+#undef XCHAL_EXCM_LEVEL
+#define XCHAL_EXCM_LEVEL                3

 #undef XCHAL_MAX_INSTRUCTION_SIZE
 #define XCHAL_MAX_INSTRUCTION_SIZE	3
--
1.8.1


code:
The firmware is cross-compiled, but the build system ends up using
'objcopy' instead of 'xtensa-elf-objcopy' by default.  Force it to
use the right one.

--- source/target_firmware/configure	2014-10-28 20:57:26.834436561 +0100
+++ source/target_firmware/configure	2014-10-28 20:57:29.666436530 +0100
@@ -11,6 +11,7 @@ mkdir -p build
 cat > "$TOOLCHAIN_FILE" <<EOF
 INCLUDE(CMakeForceCompiler)

+SET(CMAKE_OBJCOPY xtensa-elf-objcopy)
 SET(CMAKE_SYSTEM_PROCESSOR xtensa)
 SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/$TARGET)
 SET(CMAKE_STRIP :)


code:
Downloaded from here:
https://sourceforge.net/p/audacity/mailman/message/36106562/

>From 5f9482a191359f2c477763a36d2c865c5f186602 Mon Sep 17 00:00:00 2001
From: Antonio Ospite <ao2@ao2.it>
Date: Tue, 7 Nov 2017 13:06:33 +0100
Subject: [PATCH] Fix building against the system portaudio library

Building against the system portaudio results in this error:

./src/AudioIO.cpp:983: undefined reference to `PaUtil_GetTime'
audacity-AudioIO.o: In function `audacityAudioCallback(void const*, void*,
unsigned long, PaStreamCallbackTimeInfo const*, unsigned long, void*)':
./src/AudioIO.cpp:4630: undefined reference to `PaUtil_GetTime'
collect2: error: ld returned 1 exit status
Makefile:2349: recipe for target 'audacity' failed
make[3]: *** [audacity] Error 1

This is because PaUtil_GetTime is declared as a C symbol in pa_util.h
but is resolved as a C++ symbol at link time.

Audacity fixes this in the local tree with this change:
https://github.com/audacity/audacity/commit/38fd97b8e26060332ab3e9e000a8882326a70ba7

However this is not general enough for the portaudio debian package.

Since PaUtil_GetTime() is the only function causing problems, just copy
over the code where it's used.
---
 src/AudioIO.cpp | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp
index a78bd1cab..d5481838d 100644
--- a/src/AudioIO.cpp
+++ b/src/AudioIO.cpp
@@ -452,8 +452,23 @@ writing audio.
    #define ROUND(x) (int) ((x)+0.5)
    //#include <string.h>
    #include "../lib-src/portmidi/pm_common/portmidi.h"
-   #include "../lib-src/portaudio-v19/src/common/pa_util.h"
    #include "NoteTrack.h"
+
+PaTime PaUtil_GetTime( void )
+{
+#ifdef HAVE_MACH_ABSOLUTE_TIME
+    return mach_absolute_time() * machSecondsConversionScaler_;
+#elif defined(HAVE_CLOCK_GETTIME)
+    struct timespec tp;
+    clock_gettime(CLOCK_REALTIME, &tp);
+    return (PaTime)(tp.tv_sec + tp.tv_nsec * 1e-9);
+#else
+    struct timeval tv;
+    gettimeofday( &tv, NULL );
+    return (PaTime) tv.tv_usec * 1e-6 + tv.tv_sec;
+#endif
+}
+
 #endif

 #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
--
2.15.0


code:
Skip tests that rely on the `amhello' tarball that comes with Automake.
That tarball's `configure' uses #!/bin/sh, but we can't easily patch it.

diff --git a/t/amhello-binpkg.sh b/t/amhello-binpkg.sh
index fa88cc6..d988cee 100755
--- a/t/amhello-binpkg.sh
+++ b/t/amhello-binpkg.sh
@@ -17,6 +17,7 @@
 # Test an example from the manual about the 'amhello' package:
 # using DESTDIR to build simple, no-frills binary packages.

+exit 77
 am_create_testdir=empty
 . ./defs || exit 1

diff --git a/t/amhello-cflags.sh b/t/amhello-cflags.sh
index 666011f..2a95e3c 100755
--- a/t/amhello-cflags.sh
+++ b/t/amhello-cflags.sh
@@ -18,6 +18,7 @@
 # using VPATH builds to configure the same package with different
 # options.

+exit 77
 am_create_testdir=empty
 required=gcc
 . ./defs || exit 1
diff --git a/t/amhello-cross-compile.sh b/t/amhello-cross-compile.sh
index 708abda..2ee4292 100755
--- a/t/amhello-cross-compile.sh
+++ b/t/amhello-cross-compile.sh
@@ -17,6 +17,7 @@
 # Test an example from the manual about the 'amhello' package:
 # cross-compiling a package from Linux/Unix to MinGW.

+exit 77
 am_create_testdir=empty
 required=i586-mingw32msvc-gcc
 . ./defs || exit 1


code:
Don't "mkdir $(localstatedir)" since we can't do it (/var).

--- avahi-0.6.27/avahi-daemon/Makefile.in	2010-07-13 05:06:35.000000000 +0200
+++ avahi-0.6.27/avahi-daemon/Makefile.in	2010-07-13 18:03:45.000000000 +0200
@@ -1625,7 +1625,6 @@
 	done

 install-data-local:
-	test -z "$(avahi_runtime_dir)" || $(MKDIR_P) "$(DESTDIR)$(avahi_runtime_dir)"

 update-systemd:
 	curl http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c > sd-daemon.c


code:
Patch by Andreas Enge to force installation of libraries into lib
independently of the architecture, instead of lib32 or lib64.
On x86_64, the C library path coded in CMAKE_C_IMPLICIT_LINK_DIRECTORIES
contains a library (jack) installed into lib64, which forces lib64
for avidemux with the original code.

diff -u -r avidemux_2.6.8.orig/cmake/admInstallDir.cmake avidemux_2.6.8/cmake/admInstallDir.cmake
--- avidemux_2.6.8.orig/cmake/admInstallDir.cmake	2014-03-12 07:15:23.000000000 +0100
+++ avidemux_2.6.8/cmake/admInstallDir.cmake	2015-07-26 14:31:10.418459984 +0200
@@ -16,13 +16,7 @@
                 MESSAGE(STATUS "No install dir provided, using /usr/local")
         ENDIF(NOT AVIDEMUX_INSTALL_DIR )
         SET(AVIDEMUX_BIN_DIR ${AVIDEMUX_INSTALL_DIR}/bin)
-        IF(CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES "\\/lib64([; ]|$)")
-                SET(AVIDEMUX_RELATIVE_LIB_DIR lib64)
-        ELSEIF(CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES "\\/lib32([; ]|$)")
-                SET(AVIDEMUX_RELATIVE_LIB_DIR lib32)
-        ELSE(CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES "\\/lib64([; ]|$)")
-                SET(AVIDEMUX_RELATIVE_LIB_DIR lib)
-        ENDIF(CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES "\\/lib64([; ]|$)")
+        SET(AVIDEMUX_RELATIVE_LIB_DIR lib)
         SET(AVIDEMUX_LIB_DIR ${AVIDEMUX_INSTALL_DIR}/${AVIDEMUX_RELATIVE_LIB_DIR})
 ENDIF(WIN32)
 SET(AVIDEMUX_INCLUDE_DIR ${AVIDEMUX_INSTALL_DIR}/include)


code:
Index: avogadro-1.2.0/libavogadro/src/pythonengine_p.h
===================================================================
--- avogadro-1.2.0.orig/libavogadro/src/pythonengine_p.h
+++ avogadro-1.2.0/libavogadro/src/pythonengine_p.h
@@ -31,7 +31,9 @@

 #include <avogadro/global.h>
 #include <avogadro/engine.h>
+#ifndef Q_MOC_RUN
 #include <boost/python.hpp>
+#endif

 namespace Avogadro {

Index: avogadro-1.2.0/libavogadro/src/pythonextension_p.h
===================================================================
--- avogadro-1.2.0.orig/libavogadro/src/pythonextension_p.h
+++ avogadro-1.2.0/libavogadro/src/pythonextension_p.h
@@ -33,7 +33,9 @@
 #include <avogadro/extension.h>
 #include <avogadro/primitive.h>
 #include <avogadro/glwidget.h>
+#ifndef Q_MOC_RUN
 #include <boost/python.hpp>
+#endif

 #include <QWidget>
 #include <QList>
Index: avogadro-1.2.0/libavogadro/src/pythontool_p.h
===================================================================
--- avogadro-1.2.0.orig/libavogadro/src/pythontool_p.h
+++ avogadro-1.2.0/libavogadro/src/pythontool_p.h
@@ -31,7 +31,9 @@

 #include <avogadro/global.h>
 #include <avogadro/tool.h>
+#ifndef Q_MOC_RUN
 #include <boost/python.hpp>
+#endif

 #include <QObject>
 #include <QAction>
Index: avogadro-1.2.0/libavogadro/src/pythoninterpreter.h
===================================================================
--- avogadro-1.2.0.orig/libavogadro/src/pythoninterpreter.h
+++ avogadro-1.2.0/libavogadro/src/pythoninterpreter.h
@@ -26,7 +26,9 @@
 #define PYTHONINTERPRETER_H

 #include <avogadro/global.h>
+#ifndef Q_MOC_RUN
 #include <boost/python.hpp>
+#endif
 #include <avogadro/primitive.h>
 #include <QString>

Index: avogadro-1.2.0/libavogadro/src/pythonscript.h
===================================================================
--- avogadro-1.2.0.orig/libavogadro/src/pythonscript.h
+++ avogadro-1.2.0/libavogadro/src/pythonscript.h
@@ -27,6 +27,8 @@
 #define PYTHONSCRIPT_H

 #include <avogadro/global.h>
+#ifndef Q_MOC_RUN
 #include <boost/python.hpp>
+#endif

 #include "pythonerror.h"


code:
From 43af3c117b0b3220b15c2fe2895b94bbd83d3a60 Mon Sep 17 00:00:00 2001
From: Claudio Fernandes <claudiosf.claudio@gmail.com>
Date: Sun, 15 Jan 2017 21:23:39 -0200
Subject: [PATCH] Adapt Avogadro to Eigen 3.3

---
 CMakeLists.txt                                     |  9 +------
 avogadro/src/mainwindow.cpp                        |  5 ++--
 libavogadro/src/camera.cpp                         | 10 ++++----
 libavogadro/src/camera.h                           | 14 +++++------
 libavogadro/src/engines/wireengine.cpp             |  4 ++--
 .../crystallography/crystallographyextension.cpp   |  2 +-
 .../crystallography/ui/ceviewoptionswidget.cpp     |  2 +-
 .../src/extensions/orca/orcaanalysedialog.cpp      |  1 -
 .../src/extensions/orca/orcainputdialog.cpp        |  1 -
 .../src/extensions/qtaim/qtaimmathutilities.cpp    |  1 +
 .../qtaim/qtaimwavefunctionevaluator.cpp           | 28 +++++++++++-----------
 .../extensions/surfaces/openqube/gamessukout.cpp   |  1 +
 .../src/extensions/surfaces/openqube/slaterset.cpp |  6 +++--
 libavogadro/src/glpainter_p.cpp                    | 14 +++++------
 libavogadro/src/glwidget.cpp                       |  4 ++--
 libavogadro/src/molecule.cpp                       | 26 ++++++++++++++++++--
 libavogadro/src/navigate.cpp                       |  2 +-
 libavogadro/src/tools/bondcentrictool.cpp          | 28 +++++++++++-----------
 libavogadro/src/tools/manipulatetool.cpp           | 17 +++++++------
 libavogadro/src/tools/navigatetool.cpp             |  3 ++-
 libavogadro/src/tools/skeletontree.cpp             |  7 +++---
 libavogadro/src/tools/skeletontree.h               |  2 +-
 22 files changed, 102 insertions(+), 85 deletions(-)

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -231,14 +231,7 @@ if(NOT Linguist_FOUND)
   message(WARNING " Qt4 Linguist not found, please install it if you want Avogadro translations")
 endif()

-find_package(Eigen3) # find and setup Eigen3 if available
-if(NOT EIGEN3_FOUND)
-   message(STATUS "Cannot find Eigen3, trying Eigen2")
-   find_package(Eigen2 REQUIRED) # Some version is required
-else()
-# Use Stage10 Eigen3 support
-   set (EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API TRUE)
-endif()
+find_package(Eigen3 REQUIRED) # find and setup Eigen3 if available

 find_package(ZLIB REQUIRED)
 find_package(OpenBabel2 REQUIRED) # find and setup OpenBabel
--- a/avogadro/src/mainwindow.cpp
+++ b/avogadro/src/mainwindow.cpp
@@ -115,7 +115,6 @@
 #include <QDebug>

 #include <Eigen/Geometry>
-#include <Eigen/Array>
 #define USEQUAT
 // This is a "hidden" exported Qt function on the Mac for Qt-4.x.
 #ifdef Q_WS_MAC
@@ -2775,7 +2774,7 @@ protected:
     linearGoal.row(1) = linearGoal.row(2).cross(linearGoal.row(0));

     // calculate the translation matrix
-    Transform3d goal(linearGoal);
+    Projective3d goal(linearGoal);

     goal.pretranslate(- 3.0 * (d->glWidget->radius() + CAMERA_NEAR_DISTANCE) * Vector3d::UnitZ());

@@ -2840,7 +2839,7 @@ protected:
     Matrix3d linearGoal = Matrix3d::Identity();

     // calculate the translation matrix
-    Transform3d goal(linearGoal);
+    Projective3d goal(linearGoal);

     goal.pretranslate(- 3.0 * (d->glWidget->radius() + CAMERA_NEAR_DISTANCE) * Vector3d::UnitZ());

--- a/libavogadro/src/camera.cpp
+++ b/libavogadro/src/camera.cpp
@@ -47,7 +47,7 @@ namespace Avogadro

       CameraPrivate() {};

-      Eigen::Transform3d modelview, projection;
+      Eigen::Projective3d modelview, projection;
       const GLWidget *parent;
       double angleOfViewY;
       double orthoScale;
@@ -169,20 +169,20 @@ namespace Avogadro

   double Camera::distance(const Eigen::Vector3d & point) const
   {
-    return ( d->modelview * point ).norm();
+    return ( d->modelview * point.homogeneous() ).head<3>().norm();
   }

-  void Camera::setModelview(const Eigen::Transform3d &matrix)
+  void Camera::setModelview(const Eigen::Projective3d &matrix)
   {
     d->modelview = matrix;
   }

-  const Eigen::Transform3d & Camera::modelview() const
+  const Eigen::Projective3d & Camera::modelview() const
   {
     return d->modelview;
   }

-  Eigen::Transform3d & Camera::modelview()
+  Eigen::Projective3d & Camera::modelview()
   {
     return d->modelview;
   }
--- a/libavogadro/src/camera.h
+++ b/libavogadro/src/camera.h
@@ -101,16 +101,16 @@ namespace Avogadro {
       double angleOfViewY() const;
       /** Sets 4x4 "modelview" matrix representing the camera orientation and position.
         * @param matrix the matrix to copy from
-        * @sa Eigen::Transform3d & modelview(), applyModelview() */
-      void setModelview(const Eigen::Transform3d &matrix);
+        * @sa Eigen::Projective3d & modelview(), applyModelview() */
+      void setModelview(const Eigen::Projective3d &matrix);
       /** @return a constant reference to the 4x4 "modelview" matrix representing
         *         the camera orientation and position
-        * @sa setModelview(), Eigen::Transform3d & modelview() */
-      const Eigen::Transform3d & modelview() const;
+        * @sa setModelview(), Eigen::Projective3d & modelview() */
+      const Eigen::Projective3d & modelview() const;
       /** @return a non-constant reference to the 4x4 "modelview" matrix representing
         *         the camera orientation and position
-        * @sa setModelview(), const Eigen::Transform3d & modelview() const */
-      Eigen::Transform3d & modelview();
+        * @sa setModelview(), const Eigen::Projective3d & modelview() const */
+      Eigen::Projective3d & modelview();
       /** Calls gluPerspective() or glOrtho() with parameters automatically chosen
         * for rendering the GLWidget's molecule with this camera. Should be called
         * only in GL_PROJECTION matrix mode. Example code is given
@@ -342,7 +342,7 @@ namespace Avogadro {
        * @return {x/w, y/w, z/w} vector
        */
       Eigen::Vector3d V4toV3DivW(const Eigen::Vector4d & v4) {
-        return v4.start<3>()/v4.w();
+        return v4.head<3>()/v4.w();
       }
   };

--- a/libavogadro/src/engines/wireengine.cpp
+++ b/libavogadro/src/engines/wireengine.cpp
@@ -109,7 +109,7 @@ namespace Avogadro {
     const Camera *camera = pd->camera();

     // perform a rough form of frustum culling
-    Eigen::Vector3d transformedPos = pd->camera()->modelview() * v;
+    Eigen::Vector3d transformedPos = (pd->camera()->modelview() * v.homogeneous()).head<3>();
     double dot = transformedPos.z() / transformedPos.norm();
     if(dot > -0.8)
       return true;
@@ -167,7 +167,7 @@ namespace Avogadro {
       map = pd->colorMap(); // fall back to global color map

     // perform a rough form of frustum culling
-    Eigen::Vector3d transformedEnd1 = pd->camera()->modelview() * v1;
+    Eigen::Vector3d transformedEnd1 = (pd->camera()->modelview() * v1.homogeneous()).head<3>();
     double dot = transformedEnd1.z() / transformedEnd1.norm();
     if(dot > -0.8)
       return true; // i.e., don't bother rendering
--- a/libavogadro/src/extensions/crystallography/crystallographyextension.cpp
+++ b/libavogadro/src/extensions/crystallography/crystallographyextension.cpp
@@ -1989,7 +1989,7 @@ namespace Avogadro
     // fix coordinates
     // Apply COB matrix:
     Eigen::Matrix3d invCob;
-    cob.computeInverse(&invCob);
+    invCob = cob.inverse();
     for (QList<Eigen::Vector3d>::iterator
            it = fcoords.begin(),
            it_end = fcoords.end();
--- a/libavogadro/src/extensions/crystallography/ui/ceviewoptionswidget.cpp
+++ b/libavogadro/src/extensions/crystallography/ui/ceviewoptionswidget.cpp
@@ -139,7 +139,7 @@ namespace Avogadro
   {
     // View into a Miller plane
     Camera *camera = m_glWidget->camera();
-    Eigen::Transform3d modelView;
+    Eigen::Projective3d modelView;
     modelView.setIdentity();

     // OK, so we want to rotate to look along the normal at the plane
--- a/libavogadro/src/extensions/orca/orcaanalysedialog.cpp
+++ b/libavogadro/src/extensions/orca/orcaanalysedialog.cpp
@@ -41,7 +41,6 @@
 #include <openbabel/mol.h>

 #include <Eigen/Geometry>
-#include <Eigen/LeastSquares>

 #include <vector>

--- a/libavogadro/src/extensions/orca/orcainputdialog.cpp
+++ b/libavogadro/src/extensions/orca/orcainputdialog.cpp
@@ -33,7 +33,6 @@
 #include <openbabel/mol.h>

 #include <Eigen/Geometry>
-#include <Eigen/LeastSquares>

 #include <vector>

--- a/libavogadro/src/extensions/qtaim/qtaimmathutilities.cpp
+++ b/libavogadro/src/extensions/qtaim/qtaimmathutilities.cpp
@@ -28,6 +28,7 @@

 #include <cmath>
 #include <Eigen/QR>
+#include <Eigen/Eigenvalues>

 namespace Avogadro {
   namespace QTAIMMathUtilities {
--- a/libavogadro/src/extensions/qtaim/qtaimwavefunctionevaluator.cpp
+++ b/libavogadro/src/extensions/qtaim/qtaimwavefunctionevaluator.cpp
@@ -35,21 +35,21 @@ namespace Avogadro
     m_nprim=wfn.numberOfGaussianPrimitives();
     m_nnuc=wfn.numberOfNuclei();

-    m_nucxcoord=Map<Matrix<qreal,Dynamic,1> >(wfn.xNuclearCoordinates(),m_nnuc);
-    m_nucycoord=Map<Matrix<qreal,Dynamic,1> >(wfn.yNuclearCoordinates(),m_nnuc);
-    m_nuczcoord=Map<Matrix<qreal,Dynamic,1> >(wfn.zNuclearCoordinates(),m_nnuc);
-    m_nucz=Map<Matrix<qint64,Dynamic,1> >(wfn.nuclearCharges(),m_nnuc);
-    m_X0=Map<Matrix<qreal,Dynamic,1> >(wfn.xGaussianPrimitiveCenterCoordinates(),m_nprim,1);
-    m_Y0=Map<Matrix<qreal,Dynamic,1> >(wfn.yGaussianPrimitiveCenterCoordinates(),m_nprim,1);
-    m_Z0=Map<Matrix<qreal,Dynamic,1> >(wfn.zGaussianPrimitiveCenterCoordinates(),m_nprim,1);
-    m_xamom=Map<Matrix<qint64,Dynamic,1> >(wfn.xGaussianPrimitiveAngularMomenta(),m_nprim,1);
-    m_yamom=Map<Matrix<qint64,Dynamic,1> >(wfn.yGaussianPrimitiveAngularMomenta(),m_nprim,1);
-    m_zamom=Map<Matrix<qint64,Dynamic,1> >(wfn.zGaussianPrimitiveAngularMomenta(),m_nprim,1);
-    m_alpha=Map<Matrix<qreal,Dynamic,1> >(wfn.gaussianPrimitiveExponentCoefficients(),m_nprim,1);
+    m_nucxcoord=Map<Matrix<qreal,Dynamic,1> >(const_cast<qreal*>(wfn.xNuclearCoordinates()),m_nnuc);
+    m_nucycoord=Map<Matrix<qreal,Dynamic,1> >(const_cast<qreal*>(wfn.yNuclearCoordinates()),m_nnuc);
+    m_nuczcoord=Map<Matrix<qreal,Dynamic,1> >(const_cast<qreal*>(wfn.zNuclearCoordinates()),m_nnuc);
+    m_nucz=Map<Matrix<qint64,Dynamic,1> >(const_cast<qint64*>(wfn.nuclearCharges()),m_nnuc);
+    m_X0=Map<Matrix<qreal,Dynamic,1> >(const_cast<qreal*>(wfn.xGaussianPrimitiveCenterCoordinates()),m_nprim,1);
+    m_Y0=Map<Matrix<qreal,Dynamic,1> >(const_cast<qreal*>(wfn.yGaussianPrimitiveCenterCoordinates()),m_nprim,1);
+    m_Z0=Map<Matrix<qreal,Dynamic,1> >(const_cast<qreal*>(wfn.zGaussianPrimitiveCenterCoordinates()),m_nprim,1);
+    m_xamom=Map<Matrix<qint64,Dynamic,1> >(const_cast<qint64*>(wfn.xGaussianPrimitiveAngularMomenta()),m_nprim,1);
+    m_yamom=Map<Matrix<qint64,Dynamic,1> >(const_cast<qint64*>(wfn.yGaussianPrimitiveAngularMomenta()),m_nprim,1);
+    m_zamom=Map<Matrix<qint64,Dynamic,1> >(const_cast<qint64*>(wfn.zGaussianPrimitiveAngularMomenta()),m_nprim,1);
+    m_alpha=Map<Matrix<qreal,Dynamic,1> >(const_cast<qreal*>(wfn.gaussianPrimitiveExponentCoefficients()),m_nprim,1);
     // TODO Implement screening for unoccupied molecular orbitals.
-    m_occno=Map<Matrix<qreal,Dynamic,1> >(wfn.molecularOrbitalOccupationNumbers(),m_nmo,1);
-    m_orbe=Map<Matrix<qreal,Dynamic,1> >(wfn.molecularOrbitalEigenvalues(),m_nmo,1);
-    m_coef=Map<Matrix<qreal,Dynamic,Dynamic,RowMajor> >(wfn.molecularOrbitalCoefficients(),m_nmo,m_nprim);
+    m_occno=Map<Matrix<qreal,Dynamic,1> >(const_cast<qreal*>(wfn.molecularOrbitalOccupationNumbers()),m_nmo,1);
+    m_orbe=Map<Matrix<qreal,Dynamic,1> >(const_cast<qreal*>(wfn.molecularOrbitalEigenvalues()),m_nmo,1);
+    m_coef=Map<Matrix<qreal,Dynamic,Dynamic,RowMajor> >(const_cast<qreal*>(wfn.molecularOrbitalCoefficients()),m_nmo,m_nprim);
     m_totalEnergy=wfn.totalEnergy();
     m_virialRatio=wfn.virialRatio();

--- a/libavogadro/src/extensions/surfaces/openqube/gamessukout.cpp
+++ b/libavogadro/src/extensions/surfaces/openqube/gamessukout.cpp
@@ -19,6 +19,7 @@
 using Eigen::Vector3d;
 using std::vector;

+#include <iostream>
 #include <fstream>

 namespace OpenQube
--- a/libavogadro/src/extensions/surfaces/openqube/slaterset.cpp
+++ b/libavogadro/src/extensions/surfaces/openqube/slaterset.cpp
@@ -25,9 +25,9 @@

 #include "cube.h"

-#include <Eigen/Array>
 #include <Eigen/LU>
 #include <Eigen/QR>
+#include <Eigen/Eigenvalues>

 #include <cmath>

@@ -250,7 +250,9 @@ bool SlaterSet::initialize()

   SelfAdjointEigenSolver<MatrixXd> s(m_overlap);
   MatrixXd p = s.eigenvectors();
-  MatrixXd m = p * s.eigenvalues().cwise().inverse().cwise().sqrt().asDiagonal() * p.inverse();
+  // TODO check if this is correct
+  MatrixXd m1 = (s.eigenvalues().array().inverse().sqrt());
+  MatrixXd m = p.array()*(m1.diagonal().array())*p.inverse().array();
   m_normalized = m * m_eigenVectors;

   if (!(m_overlap*m*m).isIdentity())
--- a/libavogadro/src/glpainter_p.cpp
+++ b/libavogadro/src/glpainter_p.cpp
@@ -789,13 +789,13 @@ namespace Avogadro
         } else {
           points[theta-1] = Eigen::AngleAxisd(theta * (M_PI / 180.0) / 2, n) * u;
         }
-        points[theta-1] = d->widget->camera()->modelview() * (origin + points[theta-1]);
+        points[theta-1] = (d->widget->camera()->modelview() * (origin + points[theta-1]).homogeneous()).head<3>();
       }

     // Get vectors representing the points' positions in terms of the model view.
-    Eigen::Vector3d _origin = d->widget->camera()->modelview() * origin;
-    Eigen::Vector3d _direction1 = d->widget->camera()->modelview() * (origin+u);
-    Eigen::Vector3d _direction2 = d->widget->camera()->modelview() * (origin+v);
+    Eigen::Vector3d _origin = (d->widget->camera()->modelview() * origin.homogeneous()).head<3>();
+    Eigen::Vector3d _direction1 = (d->widget->camera()->modelview() * (origin+u).homogeneous()).head<3>();
+    Eigen::Vector3d _direction2 = (d->widget->camera()->modelview() * (origin+v).homogeneous()).head<3>();

     glPushAttrib(GL_ALL_ATTRIB_BITS);
     glPushMatrix();
@@ -880,12 +880,12 @@ namespace Avogadro
         } else {
           points[theta-1] = Eigen::AngleAxisd(theta * (M_PI / 180.0) / 2, n) * u;
         }
-        points[theta-1] = d->widget->camera()->modelview() * (origin + points[theta-1]);
+        points[theta-1] = (d->widget->camera()->modelview() * (origin + points[theta-1]).homogeneous()).head<3>();
       }

     // Get vectors representing the points' positions in terms of the model view.
-    Eigen::Vector3d _direction1 = d->widget->camera()->modelview() * (origin + u);
-    Eigen::Vector3d _direction2 = d->widget->camera()->modelview() * (origin + v);
+    Eigen::Vector3d _direction1 = (d->widget->camera()->modelview() * (origin + u).homogeneous()).head<3>();
+    Eigen::Vector3d _direction2 = (d->widget->camera()->modelview() * (origin + v).homogeneous()).head<3>();

     glPushAttrib(GL_ALL_ATTRIB_BITS);
     glPushMatrix();
--- a/libavogadro/src/glwidget.cpp
+++ b/libavogadro/src/glwidget.cpp
@@ -765,7 +765,7 @@ namespace Avogadro {
       GLfloat fogColor[4]= {static_cast<GLfloat>(d->background.redF()), static_cast<GLfloat>(d->background.greenF()),
                             static_cast<GLfloat>(d->background.blueF()), static_cast<GLfloat>(d->background.alphaF())};
       glFogfv(GL_FOG_COLOR, fogColor);
-      Vector3d distance = camera()->modelview() * d->center;
+      Vector3d distance = (camera()->modelview() * d->center.homogeneous()).head<3>();
       double distanceToCenter = distance.norm();
       glFogf(GL_FOG_DENSITY, 1.0);
       glHint(GL_FOG_HINT, GL_NICEST);
@@ -1711,7 +1711,7 @@ namespace Avogadro {

       if (d->renderModelViewDebug) {
         // Model view matrix:
-        const Eigen::Transform3d &modelview = d->camera->modelview();
+        const Eigen::Projective3d &modelview = d->camera->modelview();
         y += d->pd->painter()->drawText
             (x, y, tr("ModelView row 1: %L1 %L2 %L3 %L4")
              .arg(modelview(0, 0), 6, 'f', 2, ' ')
--- a/libavogadro/src/molecule.cpp
+++ b/libavogadro/src/molecule.cpp
@@ -38,7 +38,7 @@
 #include "zmatrix.h"

 #include <Eigen/Geometry>
-#include <Eigen/LeastSquares>
+#include <Eigen/Eigenvalues>

 #include <vector>

@@ -1907,7 +1907,29 @@ namespace Avogadro{
         }
         d->center /= static_cast<double>(nAtoms);
         Eigen::Hyperplane<double, 3> planeCoeffs;
-        Eigen::fitHyperplane(numAtoms(), atomPositions, &planeCoeffs);
+        //Eigen::fitHyperplane(numAtoms(), atomPositions, &planeCoeffs);
+
+        // TODO check if this is OK
+        /************************/
+        typedef Eigen::Matrix<double,3,3> CovMatrixType;
+        typedef Eigen::Vector3d VectorType;
+
+        VectorType mean = d->center;
+        int size=3;
+        int numPoints=numAtoms();
+        VectorType ** points=atomPositions;
+        CovMatrixType covMat = CovMatrixType::Zero(size, size);
+        VectorType remean = VectorType::Zero(size);
+        for(int i = 0; i < numPoints; ++i)
+        {
+          VectorType diff = (*(points[i]) - mean).conjugate();
+          covMat += diff * diff.adjoint();
+        }
+        Eigen::SelfAdjointEigenSolver<CovMatrixType> eig(covMat);
+        planeCoeffs.normal() = eig.eigenvectors().col(0);
+        /************************/
+
+
         delete[] atomPositions;
         d->normalVector = planeCoeffs.normal();
       }
--- a/libavogadro/src/navigate.cpp
+++ b/libavogadro/src/navigate.cpp
@@ -40,7 +40,7 @@ namespace Avogadro {
   void Navigate::zoom(GLWidget *widget, const Eigen::Vector3d &goal,
                       double delta)
   {
-    Vector3d transformedGoal = widget->camera()->modelview() * goal;
+    Vector3d transformedGoal = (widget->camera()->modelview() * goal.homogeneous()).head<3>();
     double distanceToGoal = transformedGoal.norm();

     double t = ZOOM_SPEED * delta;
--- a/libavogadro/src/tools/bondcentrictool.cpp
+++ b/libavogadro/src/tools/bondcentrictool.cpp
@@ -578,8 +578,8 @@ namespace Avogadro {

           Vector3d clicked = *m_clickedAtom->pos();

-          Vector3d axis = Vector3d(0, 0, ((widget->camera()->modelview() * other).z() >=
-                (widget->camera()->modelview() * center).z() ? -1 : 1));
+          Vector3d axis = Vector3d(0, 0, ((widget->camera()->modelview() * other.homogeneous()).z() >=
+                (widget->camera()->modelview() * center.homogeneous()).z() ? -1 : 1));

           Vector3d centerProj = widget->camera()->project(center);
           centerProj -= Vector3d(0,0,centerProj.z());
@@ -673,8 +673,8 @@ namespace Avogadro {

           Vector3d clicked = *m_clickedAtom->pos();

-          Vector3d axis = Vector3d(0, 0, ((widget->camera()->modelview() * other).z() >=
-                (widget->camera()->modelview() * center).z() ? -1 : 1));
+          Vector3d axis = Vector3d(0, 0, ((widget->camera()->modelview() * other.homogeneous()).z() >=
+                (widget->camera()->modelview() * center.homogeneous()).z() ? -1 : 1));

           Vector3d centerProj = widget->camera()->project(center);
           centerProj -= Vector3d(0,0,centerProj.z());
@@ -1362,10 +1362,10 @@ namespace Avogadro {

     planeVec = length * (planeVec / planeVec.norm());

-    Vector3d topLeft = widget->camera()->modelview() * (left + planeVec);
-    Vector3d topRight = widget->camera()->modelview() * (right + planeVec);
-    Vector3d botRight = widget->camera()->modelview() * (right - planeVec);
-    Vector3d botLeft = widget->camera()->modelview() * (left - planeVec);
+    Vector3d topLeft = (widget->camera()->modelview() * (left + planeVec).homogeneous()).head<3>();
+    Vector3d topRight = (widget->camera()->modelview() * (right + planeVec).homogeneous()).head<3>();
+    Vector3d botRight = (widget->camera()->modelview() * (right - planeVec).homogeneous()).head<3>();
+    Vector3d botLeft = (widget->camera()->modelview() * (left - planeVec).homogeneous()).head<3>();

     float alpha = 0.4;
     double lineWidth = 1.5;
@@ -1444,10 +1444,10 @@ namespace Avogadro {
       C = D + ((C-D).normalized() * minWidth);
     }

-    Vector3d topLeft = widget->camera()->modelview() * D;
-    Vector3d topRight = widget->camera()->modelview() * C;
-    Vector3d botRight = widget->camera()->modelview() * B;
-    Vector3d botLeft = widget->camera()->modelview() * A;
+    Vector3d topLeft = (widget->camera()->modelview() * D.homogeneous()).head<3>();
+    Vector3d topRight = (widget->camera()->modelview() * C.homogeneous()).head<3>();
+    Vector3d botRight = (widget->camera()->modelview() * B.homogeneous()).head<3>();
+    Vector3d botLeft = (widget->camera()->modelview() * A.homogeneous()).head<3>();

     float alpha = 0.4;
     double lineWidth = 1.5;
@@ -1506,12 +1506,12 @@ namespace Avogadro {
       Vector3d positionVector)
   {
     //Rotate skeleton around a particular axis and center point
-    Eigen::Transform3d rotation;
+    Eigen::Projective3d rotation;
     rotation = Eigen::AngleAxisd(angle, rotationVector);
     rotation.pretranslate(centerVector);
     rotation.translate(-centerVector);

-    return rotation*positionVector;
+    return (rotation*positionVector.homogeneous()).head<3>();
   }

   // ##########  showAnglesChanged  ##########
--- a/libavogadro/src/tools/manipulatetool.cpp
+++ b/libavogadro/src/tools/manipulatetool.cpp
@@ -40,7 +40,6 @@
 #include <QAbstractButton>

 using Eigen::Vector3d;
-using Eigen::Transform3d;
 using Eigen::AngleAxisd;

 namespace Avogadro {
@@ -138,7 +137,7 @@ namespace Avogadro {
     double yRotate = m_settingsWidget->yRotateSpinBox->value() * DEG_TO_RAD;
     double zRotate = m_settingsWidget->zRotateSpinBox->value() * DEG_TO_RAD;

-    Eigen::Transform3d rotation;
+    Eigen::Projective3d rotation;
     rotation.matrix().setIdentity();
     rotation.translation() = center;
     rotation.rotate(AngleAxisd(xRotate, Vector3d::UnitX())
@@ -152,12 +151,12 @@ namespace Avogadro {
         if (p->type() == Primitive::AtomType) {
           Atom *atom = static_cast<Atom*>(p);
           tempPos = translate + *(atom->pos());
-          atom->setPos(rotation * tempPos);
+          atom->setPos((rotation * tempPos.homogeneous()).head<3>());
         }
     } else {
       foreach(Atom *atom, widget->molecule()->atoms()) {
         tempPos = translate + *(atom->pos());
-        atom->setPos(rotation * tempPos);
+        atom->setPos((rotation * tempPos.homogeneous()).head<3>());
       }
     }

@@ -199,7 +198,7 @@ namespace Avogadro {
     widget->setCursor(Qt::SizeVerCursor);

     // Move the selected atom(s) in to or out of the screen
-    Vector3d transformedGoal = widget->camera()->modelview() * *goal;
+    Vector3d transformedGoal = (widget->camera()->modelview() * goal->homogeneous()).head<3>();
     double distanceToGoal = transformedGoal.norm();

     double t = ZOOM_SPEED * delta;
@@ -255,7 +254,7 @@ namespace Avogadro {

     // Rotate the selected atoms about the center
     // rotate only selected primitives
-    Transform3d fragmentRotation;
+    Eigen::Projective3d fragmentRotation;
     fragmentRotation.matrix().setIdentity();
     fragmentRotation.translation() = *center;
     fragmentRotation.rotate(
@@ -266,7 +265,7 @@ namespace Avogadro {

     foreach(Primitive *p, widget->selectedPrimitives())
       if (p->type() == Primitive::AtomType)
-        static_cast<Atom *>(p)->setPos(fragmentRotation * *static_cast<Atom *>(p)->pos());
+        static_cast<Atom *>(p)->setPos((fragmentRotation * static_cast<Atom *>(p)->pos()->homogeneous()).head<3>());
     widget->molecule()->update();
   }

@@ -274,7 +273,7 @@ namespace Avogadro {
                             double delta) const
   {
     // Tilt the selected atoms about the center
-    Transform3d fragmentRotation;
+    Eigen::Projective3d fragmentRotation;
     fragmentRotation.matrix().setIdentity();
     fragmentRotation.translation() = *center;
     fragmentRotation.rotate(AngleAxisd(delta * ROTATION_SPEED, widget->camera()->backTransformedZAxis()));
@@ -282,7 +281,7 @@ namespace Avogadro {

     foreach(Primitive *p, widget->selectedPrimitives())
       if (p->type() == Primitive::AtomType)
-        static_cast<Atom *>(p)->setPos(fragmentRotation * *static_cast<Atom *>(p)->pos());
+        static_cast<Atom *>(p)->setPos((fragmentRotation * static_cast<Atom *>(p)->pos()->homogeneous()).head<3>());
     widget->molecule()->update();
   }

--- a/libavogadro/src/tools/navigatetool.cpp
+++ b/libavogadro/src/tools/navigatetool.cpp
@@ -92,7 +92,8 @@ namespace Avogadro {
       double sumOfWeights = 0.;
       QList<Atom*> atoms = widget->molecule()->atoms();
       foreach (Atom *atom, atoms) {
-        Vector3d transformedAtomPos = widget->camera()->modelview() * *atom->pos();
+        Vector3d transformedAtomPos = (widget->camera()->modelview() *
+                                       atom->pos()->homogeneous()).head<3>();
         double atomDistance = transformedAtomPos.norm();
         double dot = transformedAtomPos.z() / atomDistance;
         double weight = exp(-30. * (1. + dot));
--- a/libavogadro/src/tools/skeletontree.cpp
+++ b/libavogadro/src/tools/skeletontree.cpp
@@ -29,6 +29,7 @@
 #include <avogadro/atom.h>
 #include <avogadro/bond.h>
 #include <avogadro/molecule.h>
+#include <iostream>

 using namespace Eigen;
 using namespace std;
@@ -221,7 +222,7 @@ namespace Avogadro {
   {
     if (m_rootNode) {
       //Rotate skeleton around a particular axis and center point
-      Eigen::Transform3d rotation;
+      Eigen::Projective3d rotation;
       rotation = Eigen::AngleAxisd(angle, rotationAxis);
       rotation.pretranslate(centerVector);
       rotation.translate(-centerVector);
@@ -248,11 +249,11 @@ namespace Avogadro {
   // ##########  recursiveRotate  ##########

   void SkeletonTree::recursiveRotate(Node* n,
-                                     const Eigen::Transform3d &rotationMatrix)
+                                     const Eigen::Projective3d &rotationMatrix)
   {
     // Update the root node with the new position
     Atom* a = n->atom();
-    a->setPos(rotationMatrix * (*a->pos()));
+    a->setPos((rotationMatrix * (*a->pos()).homogeneous()).head<3>());
     a->update();

     // Now update the children
--- a/libavogadro/src/tools/skeletontree.h
+++ b/libavogadro/src/tools/skeletontree.h
@@ -230,6 +230,6 @@ namespace Avogadro {
        * @param centerVector Center location to rotate around.
        */
       void recursiveRotate(Node* n,
-                           const Eigen::Transform3d &rotationMatrix);
+                           const Eigen::Projective3d &rotationMatrix);

   };
 } // End namespace Avogadro


code:
From 2d4be7ede177a8df7340fe3b209698d591ee8a04 Mon Sep 17 00:00:00 2001
From: Claudio Fernandes <claudiosf.claudio@gmail.com>
Date: Mon, 16 Jan 2017 19:48:23 -0200
Subject: [PATCH] Adapt libavogadro/python to Eigen 3.3

---
 libavogadro/src/python/camera.cpp |  2 +-
 libavogadro/src/python/eigen.cpp  | 60 +++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/libavogadro/src/python/camera.cpp b/libavogadro/src/python/camera.cpp
index 69ca87bf8..30b32af7d 100644
--- a/libavogadro/src/python/camera.cpp
+++ b/libavogadro/src/python/camera.cpp
@@ -10,7 +10,7 @@ using namespace Avogadro;
 void export_Camera()
 {

-  const Eigen::Transform3d& (Camera::*modelview_ptr)() const = &Camera::modelview;
+  const Eigen::Projective3d& (Camera::*modelview_ptr)() const = &Camera::modelview;
   Eigen::Vector3d (Camera::*unProject_ptr1)(const Eigen::Vector3d&) const = &Camera::unProject;
   Eigen::Vector3d (Camera::*unProject_ptr2)(const QPoint&, const Eigen::Vector3d&) const = &Camera::unProject;
   Eigen::Vector3d (Camera::*unProject_ptr3)(const QPoint&) const = &Camera::unProject;
diff --git a/libavogadro/src/python/eigen.cpp b/libavogadro/src/python/eigen.cpp
index c1faedbcc..20b4e719d 100644
--- a/libavogadro/src/python/eigen.cpp
+++ b/libavogadro/src/python/eigen.cpp
@@ -305,9 +305,9 @@ template <> struct ScalarTraits<double>
     struct innerclass
     {
       //
-      //  Eigen::Transform3d --> python array (4x4)
+      //  Eigen::Projective3d --> python array (4x4)
       //
-      static PyObject* convert(Eigen::Transform3d const &trans)
+      static PyObject* convert(Eigen::Projective3d const &trans)
       {
         npy_intp dims[2] = { 4, 4 };
         PyObject *result = PyArray_SimpleNew(2, dims, PyArray_DOUBLE);
@@ -321,9 +321,9 @@ template <> struct ScalarTraits<double>
         return incref(result);
       }
       //
-      //  Eigen::Transform3d* --> python array (4x4)
+      //  Eigen::Projective3d* --> python array (4x4)
       //
-      static PyObject* convert(Eigen::Transform3d *trans)
+      static PyObject* convert(Eigen::Projective3d *trans)
       {
         npy_intp dims[2] = { 4, 4 };
         PyObject *result = PyArray_SimpleNew(2, dims, PyArray_DOUBLE);
@@ -337,9 +337,9 @@ template <> struct ScalarTraits<double>
         return incref(result);
       }
       //
-      //  const Eigen::Transform3d* --> python array (4x4)
+      //  const Eigen::Projective3d* --> python array (4x4)
       //
-      static PyObject* convert(const Eigen::Transform3d *trans)
+      static PyObject* convert(const Eigen::Projective3d *trans)
       {
         npy_intp dims[2] = { 4, 4 };
         PyObject *result = PyArray_SimpleNew(2, dims, PyArray_DOUBLE);
@@ -358,10 +358,10 @@ template <> struct ScalarTraits<double>
     Transform3d_to_python_array()
     {
       #ifndef WIN32
-      to_python_converter<Eigen::Transform3d, innerclass>();
+      to_python_converter<Eigen::Projective3d, innerclass>();
       #endif
-      to_python_converter<Eigen::Transform3d*, innerclass>();
-      to_python_converter<const Eigen::Transform3d*, innerclass>();
+      to_python_converter<Eigen::Projective3d*, innerclass>();
+      to_python_converter<const Eigen::Projective3d*, innerclass>();
     }

   };
@@ -373,17 +373,17 @@ template <> struct ScalarTraits<double>
       // Insert an rvalue from_python converter at the tail of the
       // chain. Used for implicit conversions
       //
-      //  python array --> Eigen::Transform3d
+      //  python array --> Eigen::Projective3d
       //
       // used for:
       //
-      //  void function(Eigen::Transform3d vec)
-      //  void function(Eigen::Transform3d & vec)
-      //  void function(const Eigen::Transform3d & vec)
+      //  void function(Eigen::Projective3d vec)
+      //  void function(Eigen::Projective3d & vec)
+      //  void function(const Eigen::Projective3d & vec)
       //
-      converter::registry::push_back( &convertible, &construct, type_id<Eigen::Transform3d>() );
+      converter::registry::push_back( &convertible, &construct, type_id<Eigen::Projective3d>() );

-      converter::registry::insert( &convert, type_id<Eigen::Transform3d>() );
+      converter::registry::insert( &convert, type_id<Eigen::Projective3d>() );
     }

     static void* convert(PyObject *obj_ptr)
@@ -401,7 +401,7 @@ template <> struct ScalarTraits<double>
         throw_error_already_set(); // the 1D array does not have exactly 3 elements

       double *values = reinterpret_cast<double*>(array->data);
-      Eigen::Transform3d *c_obj = new Eigen::Transform3d();
+      Eigen::Projective3d *c_obj = new Eigen::Projective3d();
       double *dataPtr = c_obj->data();

       for (int i = 0; i < 16; ++i)
@@ -432,7 +432,7 @@ template <> struct ScalarTraits<double>
       // I think this is a better way to get at the double array, where is this
       // deleted though? Does Boost::Python do it?
       double *values = reinterpret_cast<double*>(array->data);
-      Eigen::Transform3d *storage = new Eigen::Transform3d();
+      Eigen::Projective3d *storage = new Eigen::Projective3d();
       double *dataPtr = storage->data();

       for (int i = 0; i < 16; ++i)
@@ -467,21 +467,21 @@ class EigenUnitTestHelper
     void set_vector3d_ptr(Eigen::Vector3d* vec)                 { m_vector3d = *vec; }
     void set_const_vector3d_ptr(const Eigen::Vector3d* const vec) { m_vector3d = *vec; }

-    //Eigen::Transform3d             transform3d()              { return m_transform3d; }
-    //Eigen::Transform3d&            transform3d_ref()          { return m_transform3d; }
-    const Eigen::Transform3d&      const_transform3d_ref()    { return m_transform3d; }
-    Eigen::Transform3d*            transform3d_ptr()          { return &m_transform3d; }
-    const Eigen::Transform3d*      const_transform3d_ptr()    { return &m_transform3d; }
-
-    //void set_transform3d(Eigen::Transform3d vec)                      { m_transform3d = vec; }
-    //void set_transform3d_ref(Eigen::Transform3d& vec)                 { m_transform3d = vec; }
-    void set_const_transform3d_ref(const Eigen::Transform3d& vec)     { m_transform3d = vec; }
-    void set_transform3d_ptr(Eigen::Transform3d* vec)                 { m_transform3d = *vec; }
-    void set_const_transform3d_ptr(const Eigen::Transform3d* const vec) { m_transform3d = *vec; }
+    //Eigen::Projective3d             transform3d()              { return m_transform3d; }
+    //Eigen::Projective3d&            transform3d_ref()          { return m_transform3d; }
+    const Eigen::Projective3d&      const_transform3d_ref()    { return m_transform3d; }
+    Eigen::Projective3d*            transform3d_ptr()          { return &m_transform3d; }
+    const Eigen::Projective3d*      const_transform3d_ptr()    { return &m_transform3d; }
+
+    //void set_transform3d(Eigen::Projective3d vec)                      { m_transform3d = vec; }
+    //void set_transform3d_ref(Eigen::Projective3d& vec)                 { m_transform3d = vec; }
+    void set_const_transform3d_ref(const Eigen::Projective3d& vec)     { m_transform3d = vec; }
+    void set_transform3d_ptr(Eigen::Projective3d* vec)                 { m_transform3d = *vec; }
+    void set_const_transform3d_ptr(const Eigen::Projective3d* const vec) { m_transform3d = *vec; }

   private:
     Eigen::Vector3d m_vector3d;
-    Eigen::Transform3d m_transform3d;
+    Eigen::Projective3d m_transform3d;

 };
 #endif
@@ -529,6 +529,6 @@ void export_Eigen()
   Vector3x_to_python_array<Eigen::Vector3i>();
   Vector3x_from_python_array<Eigen::Vector3i>();

-  // Eigen::Transform3d
+  // Eigen::Projective3d
   Transform3d_to_python_array();
   Transform3d_from_python_array();


code:
Do not introduce timestamps in PNG files (for icons).
See <https://wiki.debian.org/ReproducibleBuilds/TimestampsInPNG>.

--- awesome-3.4.15/CMakeLists.txt	2013-02-11 14:50:21.000000000 +0100
+++ awesome-3.4.15/CMakeLists.txt	2016-06-16 13:59:30.528125439 +0200
@@ -295,7 +295,7 @@ macro(a_icon_convert match replacement i
         set(ALL_ICONS ${ALL_ICONS} ${output})

         add_custom_command(
-            COMMAND ${CONVERT_EXECUTABLE} ${input} -strip ${ARGN} ${output}
+            COMMAND ${CONVERT_EXECUTABLE} +set date:create +set date:modify -define png:exclude-chunk=time ${input} -strip ${ARGN} ${output}
             OUTPUT  ${output}
             DEPENDS ${input}
             VERBATIM)


code:
This patch adds the "sigc" and "std" namespace prefixes where needed.  It also
replaces a double single-argument "bind" with a single two-argument "bind",
because the former would confuse the compiler.

The patch has been sent to the developer on 2016-09-26.

--- azr3-jack-1.2.3/azr3/knob.cpp	2016-09-26 10:29:27.653375902 +0200
+++ azr3-jack-1.2.3/azr3/knob.cpp	2016-09-26 10:29:38.693430647 +0200
@@ -44,7 +44,7 @@
   set_size_request(44, 44);
   add_events(EXPOSURE_MASK | BUTTON1_MOTION_MASK |
              BUTTON_PRESS_MASK | SCROLL_MASK);
-  m_adj.signal_value_changed().connect(mem_fun(*this, &Knob::queue_draw));
+  m_adj.signal_value_changed().connect(sigc::mem_fun(*this, &Knob::queue_draw));
 }

--- azr3-jack-1.2.3/azr3/drawbar.cpp	2016-09-26 10:27:40.632845216 +0200
+++ azr3-jack-1.2.3/azr3/drawbar.cpp	2016-09-26 10:27:48.952886473 +0200
@@ -37,7 +37,7 @@
   set_size_request(22, 150);
   add_events(EXPOSURE_MASK | BUTTON1_MOTION_MASK |
              BUTTON_PRESS_MASK | SCROLL_MASK);
-  m_adj.signal_value_changed().connect(mem_fun(*this, &Drawbar::queue_draw));
+  m_adj.signal_value_changed().connect(sigc::mem_fun(*this, &Drawbar::queue_draw));
 }

--- azr3-jack-1.2.3/azr3/switch.cpp	2016-09-26 10:28:48.169180111 +0200
+++ azr3-jack-1.2.3/azr3/switch.cpp	2016-09-26 10:28:55.713217520 +0200
@@ -49,7 +49,7 @@
   }
   set_size_request(m_width, m_height);
   add_events(EXPOSURE_MASK | BUTTON_PRESS_MASK | SCROLL_MASK);
-  m_adj.signal_value_changed().connect(mem_fun(*this, &Switch::queue_draw));
+  m_adj.signal_value_changed().connect(sigc::mem_fun(*this, &Switch::queue_draw));
 }

--- azr3-jack-1.2.3/azr3/azr3gui.cpp	2016-09-26 09:05:10.106963561 +0200
+++ azr3-jack-1.2.3/azr3/azr3gui.cpp	2016-09-26 10:26:47.480581648 +0200
@@ -73,19 +73,19 @@
   m_tbox = add_textbox(m_fbox, pixmap, 391, 19, 3, 140, 39);
   m_tbox->add_events(SCROLL_MASK);
   m_tbox->signal_scroll_display.
-    connect(mem_fun(*this, &AZR3GUI::display_scroll));
+    connect(sigc::mem_fun(*this, &AZR3GUI::display_scroll));
   m_splitpoint_adj = new Adjustment(0, 0, 1);
   m_adj[n_splitpoint] = m_splitpoint_adj;
   m_splitpoint_adj->signal_value_changed().
-    connect(mem_fun(*this, &AZR3GUI::splitpoint_changed));
+    connect(sigc::mem_fun(*this, &AZR3GUI::splitpoint_changed));
   Menu* menu = create_menu();
   m_tbox->signal_button_press_event().
-    connect(bind(mem_fun(*this, &AZR3GUI::popup_menu), menu));
+    connect(sigc::bind(sigc::mem_fun(*this, &AZR3GUI::popup_menu), menu));

   // keyboard split switch
   m_splitswitch = add_switch(m_fbox, -1, 537, 49, Switch::Mini);
   m_splitswitch->get_adjustment().signal_value_changed().
-    connect(mem_fun(*this, &AZR3GUI::splitbox_clicked));
+    connect(sigc::mem_fun(*this, &AZR3GUI::splitbox_clicked));

   // upper knobs
   add_switch(m_fbox, n_mono, 61, 105, Switch::Mini);
@@ -141,8 +141,8 @@
   // mode switcher
   Widget* eb = add_clickbox(m_fbox, 14, 319, 14, 44);
   eb->signal_button_press_event().
-    connect(sigc::hide(bind(bind(mem_fun(*this, &AZR3GUI::change_mode),
-				 ref(m_fbox)), false)));
+    connect(sigc::hide(sigc::bind(sigc::mem_fun(*this, &AZR3GUI::change_mode),
+                                  false, std::ref(m_fbox))));
   m_fx_widgets.push_back(eb);

   // Mr Valve controls
@@ -182,8 +182,8 @@
   // mode switcher 2
   Widget* eb2 = add_clickbox(m_vbox, 14, 53, 14, 44);
   eb2->signal_button_press_event().
-    connect(sigc::hide(bind(bind(mem_fun(*this, &AZR3GUI::change_mode),
-				 ref(m_fbox)), true)));
+    connect(sigc::hide(sigc::bind(sigc::mem_fun(*this, &AZR3GUI::change_mode),
+                                  true, std::ref(m_fbox))));

   // vibrato controls
   add_switch(m_vbox, n_1_vibrato, 39, 17, Switch::Green);
@@ -352,9 +352,9 @@
   knob->set_style(s);
   if (port >= 0 && port < m_adj.size()) {
     knob->get_adjustment().signal_value_changed().
-      connect(compose(bind<0>(mem_fun(*this, &AZR3GUI::control_changed), port),
-		      mem_fun(knob->get_adjustment(),
-			      &Adjustment::get_value)));
+      connect(compose(sigc::bind<0>(sigc::mem_fun(*this, &AZR3GUI::control_changed), port),
+		      sigc::mem_fun(knob->get_adjustment(),
+                                    &Adjustment::get_value)));
     assert(m_adj[port] == 0);
     m_adj[port] = &knob->get_adjustment();
   }
@@ -382,8 +382,8 @@
   db->set_style(s);
   if (port >= 0 && port < m_adj.size()) {
     db->get_adjustment().signal_value_changed().
-      connect(compose(bind<0>(mem_fun(*this, &AZR3GUI::control_changed), port),
-		      mem_fun(db->get_adjustment(), &Adjustment::get_value)));
+      connect(compose(sigc::bind<0>(sigc::mem_fun(*this, &AZR3GUI::control_changed), port),
+		      sigc::mem_fun(db->get_adjustment(), &Adjustment::get_value)));
     assert(m_adj[port] == 0);
     m_adj[port] = &db->get_adjustment();
   }
@@ -397,8 +397,8 @@
   fbox.put(*sw, xoffset, yoffset);
   if (port >= 0 && port < m_adj.size()) {
     sw->get_adjustment().signal_value_changed().
-      connect(compose(bind<0>(mem_fun(*this, &AZR3GUI::control_changed),port),
-		      mem_fun(sw->get_adjustment(), &Adjustment::get_value)));
+      connect(compose(sigc::bind<0>(sigc::mem_fun(*this, &AZR3GUI::control_changed),port),
+		      sigc::mem_fun(sw->get_adjustment(), &Adjustment::get_value)));
     assert(m_adj[port] == 0);
     m_adj[port] = &sw->get_adjustment();
   }
@@ -489,7 +489,7 @@
     oss<<setw(2)<<setfill('0')<<iter->first<<' '<<iter->second.substr(0, 23);
     MenuItem* item = manage(new MenuItem(oss.str()));
     item->signal_activate().
-      connect(bind(mem_fun(*this, &AZR3GUI::program_changed), iter->first));
+      connect(sigc::bind(sigc::mem_fun(*this, &AZR3GUI::program_changed), iter->first));
     m_program_menu->items().push_back(*item);
     item->show();
     item->get_child()->modify_bg(STATE_NORMAL, m_menu_bg);
@@ -503,8 +503,8 @@
   for (int i = 0; i < 128; ++i) {
     MenuItem* item = manage(new MenuItem(note2str(i)));
     item->signal_activate().
-      connect(bind(mem_fun(*m_splitpoint_adj, &Adjustment::set_value),
-		   i / 128.0));
+      connect(sigc::bind(sigc::mem_fun(*m_splitpoint_adj, &Adjustment::set_value),
+                         i / 128.0));
     m_split_menu->items().push_back(*item);
     item->show();
     item->get_child()->modify_bg(STATE_NORMAL, m_menu_bg);
@@ -533,7 +533,7 @@

   MenuItem* save_item = manage(new MenuItem("Save program"));
   save_item->signal_activate().
-    connect(mem_fun(*this, &AZR3GUI::save_program));
+    connect(sigc::mem_fun(*this, &AZR3GUI::save_program));
   save_item->show();
   save_item->get_child()->modify_fg(STATE_NORMAL, m_menu_bg);
   save_item->get_child()->modify_fg(STATE_NORMAL, m_menu_fg);


code:
Bash-completion is written with FHS in mind where completion scripts
all get added to /usr/share/bash-completion/completions and are picked
up by the dynamic completion loader from there---whether they are
part of bash-completion or installed by another package.

On Guix systems, we want not only to search within bash-completion's own
directory, but also in the user's profile and in the system profile.
This is what this patch does.

--- a/bash_completion
+++ b/bash_completion
@@ -2016,7 +2016,13 @@ complete -F _minimal ''

 __load_completion()
 {
-    local -a dirs=( ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions )
+    local -a dirs=(
+        "$HOME/.guix-profile/share/bash-completion/completions/$base"
+        "$HOME/.guix-profile/etc/bash_completion.d/$base"
+        "/run/current-system/profile/share/bash-completion/completions/$base"
+        "/run/current-system/profile/etc/bash_completion.d/$base"
+        ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions )
+
     local OIFS=$IFS IFS=: dir cmd="${1##*/}" compfile
     for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do
         dirs+=( $dir/bash-completion/completions )


code:
From: Tobias Geerinckx-Rice <me@tobias.gr>
Date: Wed, 3 Oct 2018 23:30:42 +0200
Subject: [PATCH] bastet: Change source of unordered_set.

This allows building bastet 0.43.2 with boost >=1.66.
It was backported verbatim from the upstream master branch.

From 0e03f8d4d6bc6949cf1c447e632ce0d1b98c4be1 Mon Sep 17 00:00:00 2001
From: Federico Poloni <fpoloni@di.unipi.it>
Date: Wed, 4 Oct 2017 19:35:01 +0200
Subject: [PATCH] Changed source of unordered_set (should hopefully fix #6
 without reopening #1)

---
 BastetBlockChooser.hpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/BastetBlockChooser.hpp b/BastetBlockChooser.hpp
index 992e556..7ee3b7c 100644
--- a/BastetBlockChooser.hpp
+++ b/BastetBlockChooser.hpp
@@ -23,8 +23,7 @@

 #include "Well.hpp"

-#include <boost/tr1/tr1/unordered_set>
-#include <set>
+#include <boost/unordered_set.hpp>
 #include <boost/functional/hash.hpp>

 namespace Bastet{
@@ -75,7 +74,7 @@ namespace Bastet{
   public:
     Searcher(BlockType b, const Well *well, Vertex v, WellVisitor *visitor);
   private:
-    std::tr1::unordered_set<Vertex> _visited;
+    boost::unordered_set<Vertex> _visited;
     //std::set<Vertex> _visited; ^^ the above is more efficient, we need to do many inserts
     BlockType _block;
     const Well *_well;


code:
Fix CVE-2017-14176:

https://bugs.launchpad.net/bzr/+bug/1710979
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-14176

Patch copied from Debian's Bazaar package version bzr_2.7.0+bzr6619-7+deb9u1:

https://alioth.debian.org/scm/loggerhead/pkg-bazaar/bzr/2.7/revision/4204

Description: Prevent SSH command line options from being specified in bzr+ssh:// URLs
Bug: https://bugs.launchpad.net/brz/+bug/1710979
Bug-Debian: https://bugs.debian.org/874429
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2017-14176
Forwarded: no
Author: Jelmer Vernooĳ <jelmer@jelmer.uk>
Last-Update: 2017-11-26

=== modified file 'bzrlib/tests/test_ssh_transport.py'
--- old/bzrlib/tests/test_ssh_transport.py	2010-10-07 12:45:51 +0000
+++ new/bzrlib/tests/test_ssh_transport.py	2017-08-20 01:59:20 +0000
@@ -22,6 +22,7 @@
     SSHCorpSubprocessVendor,
     LSHSubprocessVendor,
     SSHVendorManager,
+    StrangeHostname,
     )

@@ -161,6 +162,19 @@

 class SubprocessVendorsTests(TestCase):

+    def test_openssh_command_tricked(self):
+        vendor = OpenSSHSubprocessVendor()
+        self.assertEqual(
+            vendor._get_vendor_specific_argv(
+                "user", "-oProxyCommand=blah", 100, command=["bzr"]),
+            ["ssh", "-oForwardX11=no", "-oForwardAgent=no",
+                "-oClearAllForwardings=yes",
+                "-oNoHostAuthenticationForLocalhost=yes",
+                "-p", "100",
+                "-l", "user",
+                "--",
+                "-oProxyCommand=blah", "bzr"])
+
     def test_openssh_command_arguments(self):
         vendor = OpenSSHSubprocessVendor()
         self.assertEqual(
@@ -171,6 +185,7 @@
                 "-oNoHostAuthenticationForLocalhost=yes",
                 "-p", "100",
                 "-l", "user",
+                "--",
                 "host", "bzr"]
             )

@@ -184,9 +199,16 @@
                 "-oNoHostAuthenticationForLocalhost=yes",
                 "-p", "100",
                 "-l", "user",
-                "-s", "host", "sftp"]
+                "-s", "--", "host", "sftp"]
             )

+    def test_openssh_command_tricked(self):
+        vendor = SSHCorpSubprocessVendor()
+        self.assertRaises(
+            StrangeHostname,
+            vendor._get_vendor_specific_argv,
+                "user", "-oProxyCommand=host", 100, command=["bzr"])
+
     def test_sshcorp_command_arguments(self):
         vendor = SSHCorpSubprocessVendor()
         self.assertEqual(
@@ -209,6 +231,13 @@
                 "-s", "sftp", "host"]
             )

+    def test_lsh_command_tricked(self):
+        vendor = LSHSubprocessVendor()
+        self.assertRaises(
+            StrangeHostname,
+            vendor._get_vendor_specific_argv,
+                "user", "-oProxyCommand=host", 100, command=["bzr"])
+
     def test_lsh_command_arguments(self):
         vendor = LSHSubprocessVendor()
         self.assertEqual(
@@ -231,6 +260,13 @@
                 "--subsystem", "sftp", "host"]
             )

+    def test_plink_command_tricked(self):
+        vendor = PLinkSubprocessVendor()
+        self.assertRaises(
+            StrangeHostname,
+            vendor._get_vendor_specific_argv,
+                "user", "-oProxyCommand=host", 100, command=["bzr"])
+
     def test_plink_command_arguments(self):
         vendor = PLinkSubprocessVendor()
         self.assertEqual(

=== modified file 'bzrlib/transport/ssh.py'
--- old/bzrlib/transport/ssh.py	2015-07-31 01:04:41 +0000
+++ new/bzrlib/transport/ssh.py	2017-08-20 01:59:20 +0000
@@ -46,6 +46,10 @@
     from paramiko.sftp_client import SFTPClient

+class StrangeHostname(errors.BzrError):
+    _fmt = "Refusing to connect to strange SSH hostname %(hostname)s"
+
+
 SYSTEM_HOSTKEYS = {}
 BZR_HOSTKEYS = {}

@@ -360,6 +364,11 @@
     # tests, but beware of using PIPE which may hang due to not being read.
     _stderr_target = None

+    @staticmethod
+    def _check_hostname(arg):
+        if arg.startswith('-'):
+            raise StrangeHostname(hostname=arg)
+
     def _connect(self, argv):
         # Attempt to make a socketpair to use as stdin/stdout for the SSH
         # subprocess.  We prefer sockets to pipes because they support
@@ -424,9 +433,9 @@
         if username is not None:
             args.extend(['-l', username])
         if subsystem is not None:
-            args.extend(['-s', host, subsystem])
+            args.extend(['-s', '--', host, subsystem])
         else:
-            args.extend([host] + command)
+            args.extend(['--', host] + command)
         return args

 register_ssh_vendor('openssh', OpenSSHSubprocessVendor())
@@ -439,6 +448,7 @@

     def _get_vendor_specific_argv(self, username, host, port, subsystem=None,
                                   command=None):
+        self._check_hostname(host)
         args = [self.executable_path, '-x']
         if port is not None:
             args.extend(['-p', str(port)])
@@ -460,6 +470,7 @@

     def _get_vendor_specific_argv(self, username, host, port, subsystem=None,
                                   command=None):
+        self._check_hostname(host)
         args = [self.executable_path]
         if port is not None:
             args.extend(['-p', str(port)])
@@ -481,6 +492,7 @@

     def _get_vendor_specific_argv(self, username, host, port, subsystem=None,
                                   command=None):
+        self._check_hostname(host)
         args = [self.executable_path, '-x', '-a', '-ssh', '-2', '-batch']
         if port is not None:
             args.extend(['-P', str(port)])


code:
Help CMake find Clang's libraries.
Have it install the ICD file in the right place.

diff --git a/CMake/FindLLVM.cmake b/CMake/FindLLVM.cmake
index 5457f248..e8e8f94a 100644
--- a/CMake/FindLLVM.cmake
+++ b/CMake/FindLLVM.cmake
@@ -107,7 +107,7 @@ endif (LLVM_VERSION_NODOT VERSION_GREATER 34)
 macro(add_one_lib name)
   FIND_LIBRARY(CLANG_LIB
     NAMES ${name}
-    PATHS ${LLVM_LIBRARY_DIR} NO_DEFAULT_PATH)
+    PATHS ${CLANG_LIBRARY_DIR} NO_DEFAULT_PATH)
   set(CLANG_LIBRARIES ${CLANG_LIBRARIES} ${CLANG_LIB})
 	unset(CLANG_LIB CACHE)
 endmacro()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c11acbb2..fb99e5c8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -217,7 +217,7 @@ IF(OCLIcd_FOUND)
     "intel-beignet.icd.in"
     "${ICD_FILE_NAME}"
   )
-  install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${ICD_FILE_NAME} DESTINATION /etc/OpenCL/vendors)
+  install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${ICD_FILE_NAME} DESTINATION etc/OpenCL/vendors COMPONENT config)
 ELSE(OCLIcd_FOUND)
   MESSAGE(STATUS "Looking for OCL ICD header file - not found")
   MESSAGE(FATAL_ERROR "OCL ICD loader miss. If you really want to disable OCL ICD support, please run cmake with option -DOCLICD_COMPAT=0.")
--
2.14.3


code:
Fix a regression in Binutils 2.30 where some symbols are incorrectly assumed
to be addresses:

https://sourceware.org/bugzilla/show_bug.cgi?id=22764

Patch taken from upstream (with ChangeLog entries and tests omitted):

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=279b2f94168ee91e02ccd070d27c983fc001fe12

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index af448f9..2737773 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -7189,10 +7189,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 #if ARCH_SIZE == 64
 	case BFD_RELOC_AARCH64_32:
 #endif
-	  if (bfd_link_pic (info)
-	      && (sec->flags & SEC_ALLOC) != 0
-	      && (sec->flags & SEC_READONLY) != 0)
+	  if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0)
 	    {
+	      if (h != NULL
+		  /* This is an absolute symbol.  It represents a value instead
+		     of an address.  */
+		  && ((h->root.type == bfd_link_hash_defined
+		       && bfd_is_abs_section (h->root.u.def.section))
+		      /* This is an undefined symbol.  */
+		      || h->root.type == bfd_link_hash_undefined))
+		break;
+
+	      /* For local symbols, defined global symbols in a non-ABS section,
+		 it is assumed that the value is an address.  */
 	      int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START;
 	      _bfd_error_handler
 		/* xgettext:c-format */


code:
Enable the workaround for the Loongson 2F bug by default.

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

--- binutils/gas/config/tc-mips.c.orig	2012-09-04 10:21:03.000000000 -0400
+++ binutils/gas/config/tc-mips.c	2013-10-06 02:23:21.651983768 -0400
@@ -910,10 +910,10 @@
 };

 /* ...likewise -mfix-loongson2f-jump.  */
-static bfd_boolean mips_fix_loongson2f_jump;
+static bfd_boolean mips_fix_loongson2f_jump = FALSE;

 /* ...likewise -mfix-loongson2f-nop.  */
-static bfd_boolean mips_fix_loongson2f_nop;
+static bfd_boolean mips_fix_loongson2f_nop = TRUE;

 /* True if -mfix-loongson2f-nop or -mfix-loongson2f-jump passed.  */
 static bfd_boolean mips_fix_loongson2f;
--- binutils/gas/testsuite/gas/mips/mips.exp.orig	2012-09-04 10:17:13.000000000 -0400
+++ binutils/gas/testsuite/gas/mips/mips.exp	2013-10-06 02:23:21.663983768 -0400
@@ -91,6 +91,12 @@

     # Catch because the variable won't be set the first time through.
     catch {unset mips_arches}
+
+    # Disable the loongson2f nop fix by default, because most of the
+    # existing test cases for mips will fail otherwise.
+    global ASFLAGS
+    set old_ASFLAGS "$ASFLAGS"
+    set ASFLAGS "$ASFLAGS -mno-fix-loongson2f-nop"
 }

 # mips_arch_create ARCH GPRSIZE EXTENDS PROPS AS_FLAGS OBJDUMP_FLAGS \


code:
Without this patch, the 'make install' attempts to 'install' a directory, which causes an error.

diff --git a/c++/src/build-system/Makefile.in.top b/c++/src/build-system/Makefile.in.top
index 1abe44f..d6000b3 100644
--- a/c++/src/build-system/Makefile.in.top
+++ b/c++/src/build-system/Makefile.in.top
@@ -51,7 +51,7 @@ install-toolkit:
 	    done
 	cd $(includedir0) && find * -name CVS -prune -o -print |\
             cpio -pd $(pincludedir)
-	$(INSTALL) -m 644 $(incdir)/* $(pincludedir)
+	cp -R $(incdir)/* $(pincludedir)
 ## set up appropriate build and status directories somewhere under $(libdir)?

 install-gbench:


code:
Pass -std=c++11 when compiling files that include the ICU headers.  Without
this flag, compilation fails and causes Boost's build system to remove ICU
support.  Note that $(pkg-config --variable=CXXFLAGS icu-uc) includes
"-std=c++11", but Boost's build system does not use 'pkg-config'.

--- boost_1_66_0/libs/locale/build/Jamfile.v2.orig	2017-12-13 18:56:44.000000000 -0500
+++ boost_1_66_0/libs/locale/build/Jamfile.v2	2018-04-08 15:18:58.673025760 -0400
@@ -65,8 +65,8 @@

 if $(ICU_LINK)
 {
-    ICU_OPTS = <include>$(ICU_PATH)/include <linkflags>$(ICU_LINK) <dll-path>$(ICU_PATH)/bin <runtime-link>shared ;
-    ICU64_OPTS = <include>$(ICU_PATH)/include <linkflags>$(ICU_LINK) <dll-path>$(ICU_PATH)/bin64 <runtime-link>shared ;
+    ICU_OPTS = <include>$(ICU_PATH)/include <cxxflags>-std=c++11 <linkflags>$(ICU_LINK) <dll-path>$(ICU_PATH)/bin <runtime-link>shared ;
+    ICU64_OPTS = <include>$(ICU_PATH)/include <cxxflags>-std=c++11 <linkflags>$(ICU_LINK) <dll-path>$(ICU_PATH)/bin64 <runtime-link>shared ;
 }
 else
 {
@@ -121,6 +121,7 @@
     explicit icuuc icudt icuin ;

     ICU_OPTS =   <include>$(ICU_PATH)/include
+      <cxxflags>-std=c++11
       <library>icuuc/<link>shared/<runtime-link>shared
       <library>icudt/<link>shared/<runtime-link>shared
       <library>icuin/<link>shared/<runtime-link>shared
@@ -180,6 +181,7 @@
     explicit icuuc_64 icudt_64 icuin_64 ;

     ICU64_OPTS =   <include>$(ICU_PATH)/include
+      <cxxflags>-std=c++11
       <library>icuuc_64/<link>shared/<runtime-link>shared
       <library>icudt_64/<link>shared/<runtime-link>shared
       <library>icuin_64/<link>shared/<runtime-link>shared
--- boost_1_66_0/libs/regex/build/Jamfile.v2.orig	2017-12-13 18:56:48.000000000 -0500
+++ boost_1_66_0/libs/regex/build/Jamfile.v2	2018-04-08 15:20:40.865532505 -0400
@@ -44,7 +44,7 @@

    if $(ICU_LINK)
    {
-      ICU_OPTS = <include>$(ICU_PATH)/include <linkflags>$(ICU_LINK) <dll-path>$(ICU_PATH)/bin <define>BOOST_HAS_ICU=1 <runtime-link>shared ;
+      ICU_OPTS = <include>$(ICU_PATH)/include <cxxflags>-std=c++11 <linkflags>$(ICU_LINK) <dll-path>$(ICU_PATH)/bin <define>BOOST_HAS_ICU=1 <runtime-link>shared ;
    }
    else
    {
@@ -78,6 +78,7 @@

       ICU_OPTS =
          <include>$(ICU_PATH)/include
+         <cxxflags>-std=c++11
          <runtime-link>shared:<library>icuuc/<link>shared
          <runtime-link>shared:<library>icudt/<link>shared
          <runtime-link>shared:<library>icuin/<link>shared


code:
Make sure the client respects the storage quota set by the server:

https://github.com/borgbackup/borg/issues/4093

Patch copied from upstream source repository:

https://github.com/borgbackup/borg/commit/975cc33206e0e3644626fb7204c34d2157715b61

From 975cc33206e0e3644626fb7204c34d2157715b61 Mon Sep 17 00:00:00 2001
From: Manu <manu@snapdragon.cc>
Date: Wed, 3 Oct 2018 23:47:36 +0800
Subject: [PATCH] Add storage_quota for forced_result if set by serve command.

---
 src/borg/archiver.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/borg/archiver.py b/src/borg/archiver.py
index 916725e7..279194c1 100644
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -4276,6 +4276,7 @@ def get_args(self, argv, cmd):
             result.restrict_to_paths = forced_result.restrict_to_paths
             result.restrict_to_repositories = forced_result.restrict_to_repositories
             result.append_only = forced_result.append_only
+            result.storage_quota = forced_result.storage_quota
         return result

     def parse_args(self, args=None):
--
2.19.1


code:
Skeleton status files are installed read-only.  When copying to the config dir
upon initialization, make sure they end up writable.

--- byobu-5.127/usr/bin/byobu-janitor.in
+++ byobu-5.127/usr/bin/byobu-janitor.in
@@ -82,6 +82,7 @@
 	if [ ! -r "$BYOBU_CONFIG_DIR/$f" ]; then
 		# Copy from skeleton, if possible
 		cp -f "$BYOBU_PREFIX/share/$PKG/status/$f" "$BYOBU_CONFIG_DIR/$f"
+		chmod +w "$BYOBU_CONFIG_DIR/$f"
 	fi
 done


code:
From: Adrian Johnson <ajohnson@redneon.com>
Date: Thu, 20 Oct 2016 21:12:30 +1030
Subject: [PATCH] image: prevent invalid ptr access for > 4GB images

Image data is often accessed using:

  image->data + y * image->stride

On 64-bit achitectures if the image data is > 4GB, this computation
will overflow since both y and stride are 32-bit types.

bug report: https://bugs.freedesktop.org/show_bug.cgi?id=98165
patch: https://bugs.freedesktop.org/attachment.cgi?id=127421
---
 boilerplate/cairo-boilerplate.c     | 4 +++-
 src/cairo-image-compositor.c        | 4 ++--
 src/cairo-image-surface-private.h   | 2 +-
 src/cairo-mesh-pattern-rasterizer.c | 2 +-
 src/cairo-png.c                     | 2 +-
 src/cairo-script-surface.c          | 3 ++-
 6 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 7fdbf79..4804dea 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -42,6 +42,7 @@
 #undef CAIRO_VERSION_H
 #include "../cairo-version.h"

+#include <stddef.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <assert.h>
@@ -976,7 +977,8 @@ cairo_surface_t *
 cairo_boilerplate_image_surface_create_from_ppm_stream (FILE *file)
 {
     char format;
-    int width, height, stride;
+    int width, height;
+    ptrdiff_t stride;
     int x, y;
     unsigned char *data;
     cairo_surface_t *image = NULL;
diff --git a/src/cairo-image-compositor.c b/src/cairo-image-compositor.c
index 48072f8..3ca0006 100644
--- a/src/cairo-image-compositor.c
+++ b/src/cairo-image-compositor.c
@@ -1575,7 +1575,7 @@ typedef struct _cairo_image_span_renderer {
     pixman_image_t *src, *mask;
     union {
 	struct fill {
-	    int stride;
+	    ptrdiff_t stride;
 	    uint8_t *data;
 	    uint32_t pixel;
 	} fill;
@@ -1594,7 +1594,7 @@ typedef struct _cairo_image_span_renderer {
 	struct finish {
 	    cairo_rectangle_int_t extents;
 	    int src_x, src_y;
-	    int stride;
+	    ptrdiff_t stride;
 	    uint8_t *data;
 	} mask;
     } u;
diff --git a/src/cairo-image-surface-private.h b/src/cairo-image-surface-private.h
index 8ca694c..7e78d61 100644
--- a/src/cairo-image-surface-private.h
+++ b/src/cairo-image-surface-private.h
@@ -71,7 +71,7 @@ struct _cairo_image_surface {

     int width;
     int height;
-    int stride;
+    ptrdiff_t stride;
     int depth;

     unsigned owns_data : 1;
diff --git a/src/cairo-mesh-pattern-rasterizer.c b/src/cairo-mesh-pattern-rasterizer.c
index 1b63ca8..e7f0db6 100644
--- a/src/cairo-mesh-pattern-rasterizer.c
+++ b/src/cairo-mesh-pattern-rasterizer.c
@@ -470,7 +470,7 @@ draw_pixel (unsigned char *data, int width, int height, int stride,
 	tg += tg >> 16;
 	tb += tb >> 16;

-	*((uint32_t*) (data + y*stride + 4*x)) = ((ta << 16) & 0xff000000) |
+	*((uint32_t*) (data + y*(ptrdiff_t)stride + 4*x)) = ((ta << 16) & 0xff000000) |
 	    ((tr >> 8) & 0xff0000) | ((tg >> 16) & 0xff00) | (tb >> 24);
     }
 }
diff --git a/src/cairo-png.c b/src/cairo-png.c
index 562b743..aa8c227 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -673,7 +673,7 @@ read_png (struct png_read_closure_t *png_closure)
     }

     for (i = 0; i < png_height; i++)
-        row_pointers[i] = &data[i * stride];
+        row_pointers[i] = &data[i * (ptrdiff_t)stride];

     png_read_image (png, row_pointers);
     png_read_end (png, info);
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index ea0117d..91e4baa 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -1202,7 +1202,8 @@ static cairo_status_t
 _write_image_surface (cairo_output_stream_t *output,
 		      const cairo_image_surface_t *image)
 {
-    int stride, row, width;
+    int row, width;
+    ptrdiff_t stride;
     uint8_t row_stack[CAIRO_STACK_BUFFER_SIZE];
     uint8_t *rowdata;
     uint8_t *data;
--
2.1.4


code:
Taken from debian.

# Description: Disable update check by default.
Index: calibre/src/calibre/gui2/main.py
===================================================================
--- calibre.orig/src/calibre/gui2/main.py	2014-02-02 10:41:28.470954623 +0100
+++ calibre/src/calibre/gui2/main.py	2014-02-02 10:41:56.546954247 +0100
@@ -37,8 +37,8 @@
                       help=_('Start minimized to system tray.'))
     parser.add_option('-v', '--verbose', default=0, action='count',
                       help=_('Ignored, do not use. Present only for legacy reasons'))
-    parser.add_option('--no-update-check', default=False, action='store_true',
-            help=_('Do not check for updates'))
+    parser.add_option('--update-check', dest='no_update_check', default=True, action='store_false',
+            help=_('Check for updates'))
     parser.add_option('--ignore-plugins', default=False, action='store_true',
             help=_('Ignore custom plugins, useful if you installed a plugin'
                 ' that is preventing calibre from starting'))


code:
From: Martin Pitt <mpitt@debian.org>
Date: Mon, 14 Nov 2016 22:41:23 +0100
Subject: Use packaged instead of bundled feedparser Python module

---
 recipes/lenta_ru.recipe           | 4 +++-
 src/calibre/web/feeds/__init__.py | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/recipes/lenta_ru.recipe b/recipes/lenta_ru.recipe
index aa4dac4..4b6710c 100644
--- a/recipes/lenta_ru.recipe
+++ b/recipes/lenta_ru.recipe
@@ -4,11 +4,13 @@
 Lenta.ru
 '''

-from calibre.web.feeds.feedparser import parse
 from calibre.ebooks.BeautifulSoup import Tag
 from calibre.web.feeds.news import BasicNewsRecipe
+from feedparser import parse
+from functools import partial
 import re

+parse = partial(parse, agent='Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11')

 class LentaRURecipe(BasicNewsRecipe):
     title = u'Lenta.ru: \u041d\u043e\u0432\u043e\u0441\u0442\u0438'
diff --git a/src/calibre/web/feeds/__init__.py b/src/calibre/web/feeds/__init__.py
index 8c9d748..f262604 100644
--- a/src/calibre/web/feeds/__init__.py
+++ b/src/calibre/web/feeds/__init__.py
@@ -11,7 +11,10 @@ from calibre.utils.logging import default_log
 from calibre import entity_to_unicode, strftime, force_unicode
 from calibre.utils.date import dt_factory, utcnow, local_tz
 from calibre.utils.cleantext import clean_ascii_chars, clean_xml_chars
+from feedparser import parse
+from functools import partial

+parse = partial(parse, agent='Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11')

 class Article(object):

@@ -334,7 +337,6 @@ def feed_from_xml(raw_xml, title=None, oldest_article=7,
                   max_articles_per_feed=100,
                   get_article_url=lambda item: item.get('link', None),
                   log=default_log):
-    from calibre.web.feeds.feedparser import parse
     # Handle unclosed escaped entities. They trip up feedparser and HBR for one
     # generates them
     raw_xml = re.sub(r'(&#\d+)([^0-9;])', r'\1;\2', raw_xml)


code:
Fix CVE-2017-11110:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-11110
https://bugzilla.redhat.com/show_bug.cgi?id=1468471
https://security-tracker.debian.org/tracker/CVE-2017-11110

Patch copied from openSUSE:

https://build.opensuse.org/package/view_file/openSUSE:Maintenance:6985/catdoc.openSUSE_Leap_42.2_Update/CVE-2017-11110.patch?expand=1

From: Andreas Stieger <astieger@suse.com>
Date: Mon, 10 Jul 2017 15:37:58 +0000
References: CVE-2017-11110 http://bugzilla.suse.com/show_bug.cgi?id=1047877

All .doc I found had sectorSize 0x09 at offset 0x1e. Guarding it against <4.

---
 src/ole.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: catdoc-0.95/src/ole.c
===================================================================
--- catdoc-0.95.orig/src/ole.c	2016-05-25 06:37:12.000000000 +0200
+++ catdoc-0.95/src/ole.c	2017-07-10 17:42:33.578308107 +0200
@@ -106,6 +106,11 @@ FILE* ole_init(FILE *f, void *buffer, si
 		return NULL;
 	}
  	sectorSize = 1<<getshort(oleBuf,0x1e);
+	/* CVE-2017-11110) */
+ 	if (sectorSize < 4) {
+		fprintf(stderr,"sectorSize < 4 not supported\n");
+		return NULL;
+	}
 	shortSectorSize=1<<getshort(oleBuf,0x20);

 /* Read BBD into memory */
@@ -147,7 +152,7 @@ FILE* ole_init(FILE *f, void *buffer, si
 		}

 		fseek(newfile, 512+mblock*sectorSize, SEEK_SET);
-		if(fread(tmpBuf+MSAT_ORIG_SIZE+(sectorSize-4)*i,
+		if(fread(tmpBuf+MSAT_ORIG_SIZE+(sectorSize-4)*i, /* >= 4 for CVE-2017-11110 */
 						 1, sectorSize, newfile) != sectorSize) {
 			fprintf(stderr, "Error read MSAT!\n");
 			ole_finish();


code:
diff -r -u cdparanoia-III-10.2.old/interface/Makefile.in cdparanoia-III-10.2.new/interface/Makefile.in
--- cdparanoia-III-10.2.old/interface/Makefile.in	2008-08-21 18:08:54.000000000 +0200
+++ cdparanoia-III-10.2.new/interface/Makefile.in	2013-08-07 18:48:32.000000000 +0200
@@ -7,7 +7,7 @@
 srcdir=@srcdir@

 @SET_MAKE@
-FLAGS=@SBPCD_H@ @UCDROM_H@ @TYPESIZES@ @CFLAGS@
+FLAGS=@SBPCD_H@ @UCDROM_H@ @TYPESIZES@ @CFLAGS@ -fPIC
 OPT=@OPT@ $(FLAGS)
 DEBUG=@DEBUG@ -DCDDA_TEST
 CC=@CC@
@@ -33,7 +33,7 @@

 slib:
 	$(MAKE) lessmessy
-	$(MAKE) libcdda_interface.so CFLAGS="$(OPT) -fpic"
+	$(MAKE) libcdda_interface.so CFLAGS="$(OPT)"
 	[ -e libcdda_interface.so.0 ] || ln -s libcdda_interface.so libcdda_interface.so.0

 test:
@@ -46,7 +46,7 @@
 	$(RANLIB) libcdda_interface.a

 libcdda_interface.so: 	$(OFILES)
-	$(CC) -fpic -shared -o libcdda_interface.so.0.$(VERSION) -Wl,-soname -Wl,libcdda_interface.so.0 $(OFILES) $(LIBS)
+	$(CC) -fPIC -shared -o libcdda_interface.so.0.$(VERSION) -Wl,-soname -Wl,libcdda_interface.so.0 $(OFILES) $(LIBS)
 	[ -e libcdda_interface.so.0 ] || ln -s libcdda_interface.so.0.$(VERSION) libcdda_interface.so.0
 	[ -e libcdda_interface.so ] || ln -s libcdda_interface.so.0.$(VERSION) libcdda_interface.so

diff -r -u cdparanoia-III-10.2.old/paranoia/Makefile.in cdparanoia-III-10.2.new/paranoia/Makefile.in
--- cdparanoia-III-10.2.old/paranoia/Makefile.in	2008-09-04 21:02:47.000000000 +0200
+++ cdparanoia-III-10.2.new/paranoia/Makefile.in	2013-08-07 18:49:54.000000000 +0200
@@ -9,7 +9,7 @@

 @SET_MAKE@
 FLAGS=@TYPESIZES@ @CFLAGS@
-OPT=@OPT@ $(FLAGS)
+OPT=@OPT@ $(FLAGS) -fPIC
 DEBUG=@DEBUG@
 CC=@CC@
 LD=@CC@
@@ -34,7 +34,7 @@

 slib:
 	$(MAKE) lessmessy
-	$(MAKE) libcdda_paranoia.so CFLAGS="$(OPT) -fpic"
+	$(MAKE) libcdda_paranoia.so CFLAGS="$(OPT)"

 #test:	$(TFILES)
 #
@@ -44,7 +44,7 @@
 	$(RANLIB) libcdda_paranoia.a

 libcdda_paranoia.so: 	$(OFILES)
-	$(CC) -fpic -shared -o libcdda_paranoia.so.0.$(VERSION) -Wl,-soname -Wl,libcdda_paranoia.so.0 $(OFILES) -L ../interface -lcdda_interface
+	$(CC) -fPIC -shared -o libcdda_paranoia.so.0.$(VERSION) -Wl,-soname -Wl,libcdda_paranoia.so.0 $(OFILES) -L ../interface -lcdda_interface
 	[ -e libcdda_paranoia.so.0 ] || ln -s libcdda_paranoia.so.0.$(VERSION) libcdda_paranoia.so.0
 	[ -e libcdda_paranoia.so ] || ln -s libcdda_paranoia.so.0.$(VERSION) libcdda_paranoia.so