Add KMime
authorAndre Heinecke <aheinecke@intevation.de>
Tue, 26 Jan 2016 09:55:39 +0000 (10:55 +0100)
committerAndre Heinecke <aheinecke@intevation.de>
Tue, 26 Jan 2016 09:55:39 +0000 (10:55 +0100)
* Makefile.am (EXTRA_DIST): Add patches.
* configure.ac: Add KMime.
* packages/packages.current: Add KMime.
* patches/kmime/0001-Check-for-and-replace-strcasestr.patch,
 patches/kmime/0002-Fix-Windows-build.patch: New.
* src/Makefile.am, src/config.nsi.in: Update accordingly.
* src/inst-sections.nsi: Update and fix duplicated kcodecs entry.
* src/inst-kmime.nsi, src/uninst-kmime.nsi: New.

--
Patches were neccessary for Windows build and are already submitted
to upstream for review / inclusion.

Makefile.am
configure.ac
packages/packages.current
patches/kmime/0001-Check-for-and-replace-strcasestr.patch [new file with mode: 0755]
patches/kmime/0002-Fix-Windows-build.patch [new file with mode: 0755]
src/Makefile.am
src/config.nsi.in
src/inst-kmime.nsi [new file with mode: 0644]
src/inst-sections.nsi
src/uninst-kmime.nsi [new file with mode: 0644]

index 5f270fe..9cd7b43 100644 (file)
@@ -35,7 +35,9 @@ EXTRA_DIST = autogen.sh README.GIT ONEWS \
         patches/w32pth-2.0.5/workaround-broken-libtool.patch \
         patches/qttools/disable-most-tools.patch \
         patches/ki18n/no-tests.patch \
         patches/w32pth-2.0.5/workaround-broken-libtool.patch \
         patches/qttools/disable-most-tools.patch \
         patches/ki18n/no-tests.patch \
-        patches/gpgmepp/0002-disable-variants.patch
+        patches/gpgmepp/0002-disable-variants.patch \
+        patches/kmime/0001-Check-for-and-replace-strcasestr.patch \
+        patches/kmime/0002-Fix-Windows-build.patch
 
 copy-news:
        cp NEWS doc/website/NEWS.last
 
 copy-news:
        cp NEWS doc/website/NEWS.last
index 089e501..3f8ec25 100644 (file)
@@ -355,7 +355,8 @@ GPG4WIN_KDEPKG([kcompletion], [kwidgetsaddons])
 GPG4WIN_KDEPKG([kwindowsystem], [qtbase qtwinextras])
 GPG4WIN_KDEPKG([kcoreaddons], [qtbase])
 GPG4WIN_KDEPKG([kcodecs], [qtbase])
 GPG4WIN_KDEPKG([kwindowsystem], [qtbase qtwinextras])
 GPG4WIN_KDEPKG([kcoreaddons], [qtbase])
 GPG4WIN_KDEPKG([kcodecs], [qtbase])
-GPG4WIN_KDEPKG([libkleo], [gpgmepp kcodecs kcoreaddons kwidgetsaddons kwindowsystem kcompletion kconfig gpgme])
+GPG4WIN_KDEPKG([kmime], [kcodecs])
+GPG4WIN_KDEPKG([libkleo], [gpgmepp kcodecs kmime kwidgetsaddons kwindowsystem kcompletion kconfig gpgme])
 
 GPG4WIN_FINALIZE
 
 
 GPG4WIN_FINALIZE
 
index fff39fb..43d56e8 100644 (file)
@@ -420,13 +420,16 @@ file 5.18/kcoreaddons-5.18.0.tar.xz
 chk 7c41dbcc217d0e93cb276c84b23a55ad803e80a3
 
 # KCodecs
 chk 7c41dbcc217d0e93cb276c84b23a55ad803e80a3
 
 # KCodecs
-# last changed: 2016-01-22
+# last changed: 2016-01-25
 # by: ah
 # verified: https://www.kde.org/info/kde-frameworks-5.18.0.php
 file 5.18/kcodecs-5.18.0.tar.xz
 chk 8d5f09a9fa5977658a31a13ae9cef4d81f741da3
 
 # KDE Applications
 # by: ah
 # verified: https://www.kde.org/info/kde-frameworks-5.18.0.php
 file 5.18/kcodecs-5.18.0.tar.xz
 chk 8d5f09a9fa5977658a31a13ae9cef4d81f741da3
 
 # KDE Applications
+#
+# Devel versions are needed until Kleopatra can be based on
+# a stable branch.
 
 # server http://download.kde.org/stable/applications/
 server http://files.intevation.de/projects/gpg4all
 
 # server http://download.kde.org/stable/applications/
 server http://files.intevation.de/projects/gpg4all
@@ -446,6 +449,21 @@ server http://files.intevation.de/projects/gpg4all
 file gpgmepp/gpgmepp-201601221458.tar.xz
 chk 04cfa9a41f06915d95d0d83a199f05bfcc9a527d
 
 file gpgmepp/gpgmepp-201601221458.tar.xz
 chk 04cfa9a41f06915d95d0d83a199f05bfcc9a527d
 
+# kmime
+# last changed: 2016-01-25
+# by: ah
+# verified: https://www.kde.org/info/applications-15.12.1.php
+# file 15.12.1/src/kmime-15.12.1.tar.xz
+# chk 0a9bbe73a2a2f24ee2addfb47f642646d2eae996
+#
+# kmime-devel
+# last changed: 2016-01-25
+# by: ah
+# verified: Tarball created by ah.
+
+file kmime/kmime-201601251644.tar.xz
+chk 0a9bbe73a2a2f24ee2addfb47f642646d2eae996
+
 # Libkleo
 # last changed: 2016-01-22
 # by: ah
 # Libkleo
 # last changed: 2016-01-22
 # by: ah
diff --git a/patches/kmime/0001-Check-for-and-replace-strcasestr.patch b/patches/kmime/0001-Check-for-and-replace-strcasestr.patch
new file mode 100755 (executable)
index 0000000..4695424
--- /dev/null
@@ -0,0 +1,157 @@
+#! /bin/sh
+patch -p1 -f -l $* < $0
+exit $?
+
+From 4e685983ef6f5ba09448378bf115ea581a2d1c58 Mon Sep 17 00:00:00 2001
+From: Andre Heinecke <aheinecke@intevation.de>
+Date: Mon, 25 Jan 2016 17:52:57 +0100
+Subject: [PATCH 1/2] Check for and replace strcasestr
+
+strcasestr is not standard and not available on Windows.
+Check for this and add a simple replacement in case it is
+not found.
+---
+ cmake/CMakeChecks.cmake   | 40 ++++++++++++++++++++++++++++++++++++++++
+ cmake/CheckTimezone.cmake | 34 ----------------------------------
+ src/CMakeLists.txt        |  2 +-
+ src/config-kmime.h.cmake  |  3 +++
+ src/kmime_util.cpp        | 15 +++++++++++++++
+ 5 files changed, 59 insertions(+), 35 deletions(-)
+ create mode 100644 cmake/CMakeChecks.cmake
+ delete mode 100644 cmake/CheckTimezone.cmake
+
+diff --git a/cmake/CMakeChecks.cmake b/cmake/CMakeChecks.cmake
+new file mode 100644
+index 0000000..d4c7375
+--- /dev/null
++++ b/cmake/CMakeChecks.cmake
+@@ -0,0 +1,40 @@
++# Discover the type of the timezone variable,
++# set HAVE_TIMEZONE if found for config.h
++
++include (CheckCXXSourceCompiles)
++
++check_cxx_source_compiles("
++#include <stdlib.h>
++#include <ctype.h>
++#include <time.h>
++#include <unistd.h>
++int main() { timezone = 1; return 0;}
++"
++  HAVE_TIMEZONE)
++
++if (NOT HAVE_TIMEZONE)
++  # Then it's probably this variant, just to be sure
++  check_cxx_source_compiles("
++#include <stdlib.h>
++#include <ctype.h>
++#include <time.h>
++#include <unistd.h>
++int main() { const char *p = timezone(0,0); return 0;}
++"
++    HAVE_BSD_TIMEZONE)
++endif()
++
++check_cxx_source_compiles("
++#include <stdlib.h>
++#include <ctype.h>
++#include <time.h>
++#include <unistd.h>
++int main() { struct tm tm; tm.tm_gmtoff=1; return 0; }
++"
++  HAVE_TM_GMTOFF)
++
++check_cxx_source_compiles("
++#include <string.h>
++int main() { strcasestr(\"\", \"\"); }
++"
++    HAVE_STRCASESTR)
+diff --git a/cmake/CheckTimezone.cmake b/cmake/CheckTimezone.cmake
+deleted file mode 100644
+index adc1937..0000000
+--- a/cmake/CheckTimezone.cmake
++++ /dev/null
+@@ -1,34 +0,0 @@
+-# Discover the type of the timezone variable,
+-# set HAVE_TIMEZONE if found for config.h
+-
+-include (CheckCXXSourceCompiles)
+-
+-check_cxx_source_compiles("
+-#include <stdlib.h>
+-#include <ctype.h>
+-#include <time.h>
+-#include <unistd.h>
+-int main() { timezone = 1; return 0;}
+-"
+-  HAVE_TIMEZONE)
+-
+-if (NOT HAVE_TIMEZONE)
+-  # Then it's probably this variant, just to be sure
+-  check_cxx_source_compiles("
+-#include <stdlib.h>
+-#include <ctype.h>
+-#include <time.h>
+-#include <unistd.h>
+-int main() { const char *p = timezone(0,0); return 0;}
+-"
+-    HAVE_BSD_TIMEZONE)
+-endif()
+-
+-check_cxx_source_compiles("
+-#include <stdlib.h>
+-#include <ctype.h>
+-#include <time.h>
+-#include <unistd.h>
+-int main() { struct tm tm; tm.tm_gmtoff=1; return 0; }
+-"
+-  HAVE_TM_GMTOFF)
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index ef86420..3a4517b 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -1,4 +1,4 @@
+-include(CheckTimezone)
++include(CMakeChecks)
+
+ configure_file(config-kmime.h.cmake ${KMime_BINARY_DIR}/src/config-kmime.h)
+
+diff --git a/src/config-kmime.h.cmake b/src/config-kmime.h.cmake
+index 7b7ef6d..655565c 100644
+--- a/src/config-kmime.h.cmake
++++ b/src/config-kmime.h.cmake
+@@ -3,3 +3,6 @@
+
+ /* Define if you have a tm_gmtoff member in struct tm */
+ #cmakedefine HAVE_TM_GMTOFF 1
++
++/* Define if you have strcasestr in string.h */
++#cmakedefine HAVE_STRCASESTR 1
+diff --git a/src/kmime_util.cpp b/src/kmime_util.cpp
+index ed002b9..c1e5886 100644
+--- a/src/kmime_util.cpp
++++ b/src/kmime_util.cpp
+@@ -285,6 +285,21 @@ int findHeaderLineEnd(const QByteArray &src, int &dataBegin, bool *folded)
+     return end;
+ }
+
++#ifndef HAVE_STRCASESTR
++static const char *strcasestr(const char *haystack, const char *needle)
++{
++    /* Copied from libreplace as part of qtwebengine 5.5.1 */
++    const char *s;
++    size_t nlen = strlen(needle);
++    for (s = haystack; *s; s++) {
++        if (toupper(*needle) == toupper(*s) && strncasecmp(s, needle, nlen) == 0) {
++            return (char *)((uintptr_t)s);
++        }
++    }
++    return NULL;
++}
++#endif
++
+ int indexOfHeader(const QByteArray &src, const QByteArray &name, int &end, int &dataBegin, bool *folded)
+ {
+     QByteArray n = name;
+--
+2.1.4
diff --git a/patches/kmime/0002-Fix-Windows-build.patch b/patches/kmime/0002-Fix-Windows-build.patch
new file mode 100755 (executable)
index 0000000..148a33a
--- /dev/null
@@ -0,0 +1,56 @@
+#! /bin/sh
+patch -p1 -f -l $* < $0
+exit $?
+
+From d977ebb7d83cdbe01875273f133d5696af628c29 Mon Sep 17 00:00:00 2001
+From: Andre Heinecke <aheinecke@intevation.de>
+Date: Mon, 25 Jan 2016 18:05:01 +0100
+Subject: [PATCH 2/2] Fix Windows build
+
+gethostname is part of Winsock2 on Windows.
+---
+ src/CMakeLists.txt | 5 +++++
+ src/kmime_mdn.cpp  | 6 +++++-
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 3a4517b..2b62c6d 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -33,12 +33,17 @@ add_library(KF5::Mime ALIAS KF5Mime)
+ target_include_directories(KF5Mime INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/KMime>")
+ target_include_directories(KF5Mime PUBLIC "$<BUILD_INTERFACE:${KMime_SOURCE_DIR}/src;${KMime_BINARY_DIR}/src;${KMime_BINARY_DIR}>")
+
++if (WIN32)
++    set(_kmime_extra_libs ws2_32)
++endif()
++
+ target_link_libraries(KF5Mime
+ PUBLIC
+     Qt5::Core
+ PRIVATE
+     KF5::I18n
+     KF5::Codecs
++    ${_kmime_extra_libs}
+ )
+
+ set_target_properties(KF5Mime PROPERTIES
+diff --git a/src/kmime_mdn.cpp b/src/kmime_mdn.cpp
+index 3061112..c441291 100644
+--- a/src/kmime_mdn.cpp
++++ b/src/kmime_mdn.cpp
+@@ -41,7 +41,11 @@
+
+ #include <QtCore/QByteArray>
+
+-#include <unistd.h> // gethostname
++#ifdef Q_OS_WIN // gethostname
++# include <winsock2.h>
++#else
++# include <unistd.h>
++#endif
+
+ namespace KMime
+ {
+--
+2.1.4
index e8906ab..039bf4a 100644 (file)
@@ -71,6 +71,7 @@ EXTRA_DIST = pkg-config gpg4win.nsi gpg4win-src.nsi \
         inst-libkleo.nsi uninst-libkleo.nsi \
         inst-kcoreaddons.nsi uninst-kcoreaddons.nsi \
         inst-kcodecs.nsi uninst-kcodecs.nsi \
         inst-libkleo.nsi uninst-libkleo.nsi \
         inst-kcoreaddons.nsi uninst-kcoreaddons.nsi \
         inst-kcodecs.nsi uninst-kcodecs.nsi \
+        inst-kmime.nsi uninst-kmime.nsi \
         inst-qttools.nsi uninst-qttools.nsi \
         inst-boost.nsi uninst-boost.nsi \
         inst-extra-cmake-modules.nsi uninst-extra-cmake-modules.nsi \
         inst-qttools.nsi uninst-qttools.nsi \
         inst-boost.nsi uninst-boost.nsi \
         inst-extra-cmake-modules.nsi uninst-extra-cmake-modules.nsi \
@@ -105,7 +106,8 @@ gpg4win_spkgs = glib libffi gdk-pixbuf gtk+ \
 
 # Source packages following the KDE pattern
 gpg4win_kdepkgs = kconfig kwidgetsaddons gpgmepp ki18n extra-cmake-modules \
 
 # Source packages following the KDE pattern
 gpg4win_kdepkgs = kconfig kwidgetsaddons gpgmepp ki18n extra-cmake-modules \
-                  kcompletion kwindowsystem kcoreaddons libkleo kcodecs
+                  kcompletion kwindowsystem kcoreaddons libkleo kcodecs \
+                  kmime
 
 # Supported source packages to build in an additional architecture
 gpg4win_expkgs = libgpg-error libassuan libiconv gettext w32pth gpgex gpgol \
 
 # Supported source packages to build in an additional architecture
 gpg4win_expkgs = libgpg-error libassuan libiconv gettext w32pth gpgex gpgol \
index 2ac1169..bb35f45 100644 (file)
 !define gpg4win_pkg_kcodecs @gpg4win_pkg_kcodecs@
 !define gpg4win_pkg_kcodecs_version @gpg4win_pkg_kcodecs_version@
 
 !define gpg4win_pkg_kcodecs @gpg4win_pkg_kcodecs@
 !define gpg4win_pkg_kcodecs_version @gpg4win_pkg_kcodecs_version@
 
+@HAVE_PKG_KMIME@
+!define gpg4win_pkg_kmime @gpg4win_pkg_kmime@
+!define gpg4win_pkg_kmime_version @gpg4win_pkg_kmime_version@
+
 # Internal packages.
 @HAVE_PKG_COMPENDIUM@
 
 # Internal packages.
 @HAVE_PKG_COMPENDIUM@
 
diff --git a/src/inst-kmime.nsi b/src/inst-kmime.nsi
new file mode 100644 (file)
index 0000000..10d7238
--- /dev/null
@@ -0,0 +1,35 @@
+# Copyright (C) 2015 Intevation GmbH
+#
+# This file is part of GPG4Win.
+#
+# GPG4Win is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# GPG4Win is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+!ifdef prefix
+!undef prefix
+!endif
+!define prefix ${ipdir}/kmime-${gpg4win_pkg_kmime_version}
+
+!ifdef DEBUG
+Section "kmime" SEC_kmime
+!else
+Section "-kmime" SEC_kmime
+!endif
+  SetOutPath "$INSTDIR"
+!ifdef SOURCES
+  File "${gpg4win_pkg_kmime}"
+!else
+  SetOutPath "$INSTDIR\bin"
+  File ${prefix}/bin/libKF5Mime.dll
+!endif
+SectionEnd
index f923aa8..7081fb4 100644 (file)
 !ifdef HAVE_PKG_KCODECS
 !include "inst-kcodecs.nsi"
 !endif
 !ifdef HAVE_PKG_KCODECS
 !include "inst-kcodecs.nsi"
 !endif
+!ifdef HAVE_PKG_KMIME
+!include "inst-kmime.nsi"
+!endif
 !ifdef HAVE_PKG_LIBKLEO
 !include "inst-libkleo.nsi"
 !endif
 !ifdef HAVE_PKG_LIBKLEO
 !include "inst-libkleo.nsi"
 !endif
 !ifdef HAVE_PKG_KCODECS
 !include "uninst-kcodecs.nsi"
 !endif
 !ifdef HAVE_PKG_KCODECS
 !include "uninst-kcodecs.nsi"
 !endif
+!ifdef HAVE_PKG_KMIME
+!include "uninst-kmime.nsi"
+!endif
 !ifdef HAVE_PKG_LIBKLEO
 !include "uninst-libkleo.nsi"
 !endif
 !ifdef HAVE_PKG_LIBKLEO
 !include "uninst-libkleo.nsi"
 !endif
@@ -604,8 +610,8 @@ Function CalcDepends
 !ifdef HAVE_PKG_LIBKLEO
   !insertmacro UnselectSection ${SEC_libkleo}
 !endif
 !ifdef HAVE_PKG_LIBKLEO
   !insertmacro UnselectSection ${SEC_libkleo}
 !endif
-!ifdef HAVE_PKG_KCODECS
-  !insertmacro UnselectSection ${SEC_kcodecs}
+!ifdef HAVE_PKG_KMIME
+  !insertmacro UnselectSection ${SEC_kmime}
 !endif
 
   # Always install gnupg2.  This is also ensured by putting
 !endif
 
   # Always install gnupg2.  This is also ensured by putting
@@ -705,6 +711,7 @@ Function CalcDepends
   !insertmacro SelectSection ${SEC_kwindowsystem}
   !insertmacro SelectSection ${SEC_kcoreaddons}
   !insertmacro SelectSection ${SEC_kcodecs}
   !insertmacro SelectSection ${SEC_kwindowsystem}
   !insertmacro SelectSection ${SEC_kcoreaddons}
   !insertmacro SelectSection ${SEC_kcodecs}
+  !insertmacro SelectSection ${SEC_kmime}
   !insertmacro SelectSection ${SEC_libkleo}
   !insertmacro SelectSection ${SEC_qttools}
   !insertmacro SelectSection ${SEC_qtwinextras}
   !insertmacro SelectSection ${SEC_libkleo}
   !insertmacro SelectSection ${SEC_qttools}
   !insertmacro SelectSection ${SEC_qtwinextras}
diff --git a/src/uninst-kmime.nsi b/src/uninst-kmime.nsi
new file mode 100644 (file)
index 0000000..504e330
--- /dev/null
@@ -0,0 +1,32 @@
+# Copyright (C) 2015 Intevation GmbH
+#
+# This file is part of GPG4Win.
+#
+# GPG4Win is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# GPG4Win is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+!ifdef prefix
+!undef prefix
+!endif
+!define prefix ${ipdir}/kmime-${gpg4win_pkg_kmime_version}
+
+; Uninstaller section.
+Section "-un.kmime"
+!ifdef SOURCES
+  Push "${gpg4win_pkg_kmime}"
+  Call un.SourceDelete
+!else
+  Delete "$INSTDIR\bin\libKF5Mime.dll"
+  RmDir "$INSTDIR\bin"
+!endif
+SectionEnd