]> saetta.ns0.it Git - msys2/commitdiff
Aggiunto il pacchetto gcr (WIP).
authorAndrea Zagli <azagli@libero.it>
Sat, 6 Sep 2014 07:49:37 +0000 (09:49 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 6 Sep 2014 07:49:37 +0000 (09:49 +0200)
packages/mingw-w64-gcr/001-3.12.2.patch [new file with mode: 0644]
packages/mingw-w64-gcr/PKGBUILD [new file with mode: 0644]

diff --git a/packages/mingw-w64-gcr/001-3.12.2.patch b/packages/mingw-w64-gcr/001-3.12.2.patch
new file mode 100644 (file)
index 0000000..9bc6c5b
--- /dev/null
@@ -0,0 +1,906 @@
+--- gcr-3.12.2-orig/configure.ac       2014-05-13 21:03:55.000000000 +0200
++++ gcr-3.12.2/configure.ac    2014-08-11 15:41:29.916433400 +0200
+@@ -75,6 +75,16 @@
+ AC_SUBST(GETTEXT_PACKAGE)
+ AM_GLIB_GNU_GETTEXT
++# --------------------------------------------------------------------
++# Check for gio-unix
++#
++
++if test "$os_unix" = "yes"; then
++      GDK_GIO_PACKAGE=gio-2.0 gio-unix-2.0
++else
++      GDK_GIO_PACKAGE=gio-2.0
++fi
++
+ # -----------------------------------------------------------------------------
+ # GLib and GTK+ stuff
+@@ -83,7 +93,7 @@
+       gmodule-no-export-2.0
+       gthread-2.0
+       gobject-2.0
+-      gio-2.0 gio-unix-2.0)
++      $GDK_GIO_PACKAGE)
+ GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=$GLIB_MIN"
+ GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MAX_ALLOWED=$GLIB_MAX"
+ AC_SUBST(GLIB_CFLAGS)
+@@ -140,7 +150,18 @@
+ #
+ AC_CHECK_FUNCS(timegm, AC_DEFINE(HAVE_TIMEGM,1,[Have timegm]))
+-AC_CHECK_FUNCS(mlock)
++AC_CHECK_FUNCS(memrchr, AC_DEFINE(HAVE_MEMRCHR,1,[Have memrchr]))
++AC_CHECK_FUNCS(mlock, AC_DEFINE(HAVE_MLOCK,1,[Have mlock]))
++
++# --------------------------------------------------------------------
++# Checks for headers
++#
++
++AC_CHECK_HEADERS(err.h, AC_DEFINE(HAVE_ERR_H,1,[Have err.h]))
++AC_CHECK_HEADERS(pwd.h, AC_DEFINE(HAVE_PWD_H,1,[Have pwd.h]))
++AC_CHECK_HEADERS(syslog.h, AC_DEFINE(HAVE_SYSLOG_H,1,[Have syslog.h]))
++AC_CHECK_HEADERS(sys/mman.h, AC_DEFINE(HAVE_SYS_MMAN_H,1,[Have mman.h]))
++AC_CHECK_HEADERS(sys/wait.h, AC_DEFINE(HAVE_SYS_WAIT_H,1,[Have wait.h]))
+ # --------------------------------------------------------------------
+ # p11-kit
+--- gcr-3.12.2-orig/egg/egg-armor.c    2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/egg/egg-armor.c 2014-08-11 15:34:41.041658400 +0200
+@@ -59,6 +59,29 @@
+ #define ARMOR_PREF_END      "-----END "
+ #define ARMOR_PREF_END_L    9
++#ifndef HAVE_MEMRCHR
++extern void* memrchr (const void *s, int c, size_t n);
++
++void*
++memrchr (const void *s, int c, size_t n)
++{
++      if (n > 0) {
++              const char*  p = (const char*) s;
++              const char*  q = p + n;
++
++              while (1) {
++                      q--; if (q < p || q[0] == (char) c) break;
++                      q--; if (q < p || q[0] == (char) c) break;
++                      q--; if (q < p || q[0] == (char) c) break;
++                      q--; if (q < p || q[0] == (char) c) break;
++              }
++              if (q >= p)
++                      return (void*)q;
++      }
++      return NULL;
++}
++#endif
++
+ static void
+ parse_header_lines (const gchar *hbeg,
+                     const gchar *hend,
+--- gcr-3.12.2-orig/egg/egg-asn1x.c    2014-05-13 21:01:43.000000000 +0200
++++ gcr-3.12.2/egg/egg-asn1x.c 2014-08-11 15:34:41.034658600 +0200
+@@ -1928,7 +1928,7 @@
+ two_to_four_digit_year (int year)
+ {
+       time_t now;
+-      struct tm tm;
++      GDate *date;
+       int century, current;
+       g_return_val_if_fail (year >= 0 && year <= 99, -1);
+@@ -1936,11 +1936,15 @@
+       /* Get the current year */
+       now = time (NULL);
+       g_return_val_if_fail (now >= 0, -1);
+-      if (!gmtime_r (&now, &tm))
++      date = g_date_new ();
++      g_date_set_time_t (date, now);
++      if (!g_date_valid (date))
+               g_return_val_if_reached (-1);
+-      current = (tm.tm_year % 100);
+-      century = (tm.tm_year + 1900) - current;
++      century = (g_date_get_year (date) / 100) * 100;
++      current = g_date_get_year (date) - century;
++
++      g_date_free (date);
+       /*
+        * Check if it's within 40 years before the
+--- gcr-3.12.2-orig/egg/egg-secure-memory.c    2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/egg/egg-secure-memory.c 2014-08-11 15:36:54.240479000 +0200
+@@ -31,7 +31,9 @@
+ #include "egg-secure-memory.h"
+ #include <sys/types.h>
++#ifdef HAVE_SYS_MMAN_H
+ #include <sys/mman.h>
++#endif
+ #include <stddef.h>
+ #include <string.h>
+ #include <stdio.h>
+@@ -187,9 +189,11 @@
+       /* Create a new pool */
+       if (pool == NULL) {
++#if !defined(_WIN32)
+               len = getpagesize () * 2;
+               pages = mmap (0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+               if (pages == MAP_FAILED)
++#endif
+                       return NULL;
+               /* Fill in the block header, and inlude in block list */
+@@ -253,7 +257,9 @@
+               VALGRIND_DESTROY_MEMPOOL (pool);
+ #endif
++#if !defined(_WIN32)
+               munmap (pool, pool->length);
++#endif
+               return;
+       }
+@@ -859,11 +865,11 @@
+       ASSERT (*sz);
+       ASSERT (during_tag);
++#if defined(HAVE_MLOCK)
+       /* Make sure sz is a multiple of the page size */
+       pgsize = getpagesize ();
+       *sz = (*sz + pgsize -1) & ~(pgsize - 1);
+-#if defined(HAVE_MLOCK)
+       pages = mmap (0, *sz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+       if (pages == MAP_FAILED) {
+               if (show_warning && egg_secure_warnings)
+@@ -901,9 +907,10 @@
+ sec_release_pages (void *pages, size_t sz)
+ {
+       ASSERT (pages);
+-      ASSERT (sz % getpagesize () == 0);
+ #if defined(HAVE_MLOCK)
++      ASSERT (sz % getpagesize () == 0);
++
+       if (munlock (pages, sz) < 0 && egg_secure_warnings)
+               fprintf (stderr, "couldn't unlock private memory: %s\n", strerror (errno));
+@@ -913,7 +920,7 @@
+       DEBUG_ALLOC ("gkr-secure-memory: freed block ", sz);
+ #else
+-      ASSERT (FALSE);
++      ASSERT (0);
+ #endif
+ }
+@@ -936,6 +943,11 @@
+       if (getenv ("SECMEM_FORCE_FALLBACK"))
+               return NULL;
++#ifdef _WIN32
++      /* win32 does not have mlock(), so just fail in that case */
++      return NULL;
++#endif
++
+       block = pool_alloc ();
+       if (!block)
+               return NULL;
+--- gcr-3.12.2-orig/egg/test-asn1x.c   2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/egg/test-asn1x.c        2014-08-11 15:34:41.047660400 +0200
+@@ -26,7 +26,9 @@
+ #include "egg/egg-asn1-defs.h"
+ #include "egg/egg-testing.h"
++#ifdef HAVE_PWD_H
+ #include <pwd.h>
++#endif
+ #include <stdlib.h>
+ #include <unistd.h>
+--- gcr-3.12.2-orig/gck/gck-debug.c    2014-03-02 09:05:22.000000000 +0100
++++ gcr-3.12.2/gck/gck-debug.c 2014-08-11 15:34:41.096675100 +0200
+@@ -33,6 +33,11 @@
+ #include <unistd.h>
++#ifdef G_OS_WIN32
++#define WINVER 0x0501
++#include <windows.h>
++#endif
++
+ #ifdef WITH_DEBUG
+ static gsize initialized_flags = 0;
+--- gcr-3.12.2-orig/gck/gck-slot.c     2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gck/gck-slot.c  2014-08-11 15:34:41.053657400 +0200
+@@ -605,7 +605,7 @@
+ {
+       GckTokenInfo *token_info;
+       gchar *string;
+-      struct tm tm;
++      GTimeVal tv;
+       token_info = g_new0 (GckTokenInfo, 1);
+       token_info->label = gck_string_from_chars (info->label, sizeof (info->label));
+@@ -633,10 +633,12 @@
+       /* Parse the time into seconds since epoch */
+       if (info->flags & CKF_CLOCK_ON_TOKEN) {
+               string = g_strndup ((gchar*)info->utcTime, MIN (14, sizeof (info->utcTime)));
+-              if (!strptime (string, "%Y%m%d%H%M%S", &tm))
++                /* Transform into an ISO-8601 string */
++              string = g_strconcat (g_strndup (string,8), "T", g_strndup (string+8,6), "Z", NULL);
++              if (!g_time_val_from_iso8601 (string, &tv))
+                       token_info->utc_time = -1;
+               else
+-                      token_info->utc_time = timegm (&tm);
++                      token_info->utc_time = tv.tv_sec;
+               g_free (string);
+       } else {
+               token_info->utc_time = -1;
+@@ -648,8 +650,8 @@
+ void
+ _gck_token_info_to_pkcs11 (GckTokenInfo *token_info, CK_TOKEN_INFO_PTR info)
+ {
+-      gchar buffer[64];
+-      struct tm tm;
++      gchar *buffer;
++      GDateTime *datetime = NULL;
+       time_t tim;
+       gsize len;
+@@ -689,9 +691,12 @@
+       /* Parse the time into seconds since epoch */
+       if (token_info->flags & CKF_CLOCK_ON_TOKEN) {
+               tim = token_info->utc_time;
+-              if (!gmtime_r (&tim, &tm))
++              datetime = g_date_time_new_from_unix_utc (tim);
++              if (datetime == NULL)
+                       g_return_if_reached ();
+-              len = strftime (buffer, sizeof (buffer), "%Y%m%d%H%M%S", &tm);
++              buffer = g_date_time_format (datetime, "%Y%m%d%H%M%S");
++              len = strlen (buffer);
++              g_date_time_unref (datetime);
+               g_return_if_fail (len == sizeof (info->utcTime));
+               memcpy (info->utcTime, buffer, sizeof (info->utcTime));
+       } else {
+--- gcr-3.12.2-orig/gck/test-gck-crypto.c      2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gck/test-gck-crypto.c   2014-08-11 15:34:41.105662500 +0200
+@@ -56,7 +56,11 @@
+       GckSlot *slot;
+       /* Successful load */
++#ifdef G_OS_WIN32
++      test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
++#else
+       test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
++#endif
+       g_assert_no_error (err);
+       g_assert (GCK_IS_MODULE (test->module));
+       g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
+--- gcr-3.12.2-orig/gck/test-gck-enumerator.c  2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gck/test-gck-enumerator.c       2014-08-11 15:34:41.110662100 +0200
+@@ -49,7 +49,11 @@
+       GError *err = NULL;
+       /* Successful load */
++#ifdef G_OS_WIN32
++      test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
++#else
+       test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
++#endif
+       g_assert_no_error (err);
+       g_assert (GCK_IS_MODULE (test->module));
+       g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
+--- gcr-3.12.2-orig/gck/test-gck-module.c      2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gck/test-gck-module.c   2014-08-11 15:34:41.117663800 +0200
+@@ -41,7 +41,11 @@
+       GError *err = NULL;
+       /* Successful load */
++#ifdef G_OS_WIN32
++      test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
++#else
+       test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
++#endif
+       g_assert_no_error (err);
+       g_assert (test->module);
+       g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
+@@ -70,7 +74,11 @@
+       GError *error = NULL;
+       /* Shouldn't be able to load modules */
++#ifdef G_OS_WIN32
++      gck_module_initialize_async (BUILDDIR "/.libs/libmock-test-module.dll",
++#else
+       gck_module_initialize_async (BUILDDIR "/.libs/libmock-test-module.so",
++#endif
+                                    NULL, fetch_async_result, &result);
+       egg_test_wait_until (500);
+@@ -100,7 +108,11 @@
+       g_clear_error (&error);
+       /* Shouldn't be able to load any file successfully */
++#ifdef G_OS_WIN32
++      invalid = gck_module_initialize ("c:\\windows\\system32\\shell32.dll", NULL, &error);
++#else
+       invalid = gck_module_initialize ("/usr/lib/libm.so", NULL, &error);
++#endif
+       g_assert_error (error, GCK_ERROR, (int)CKR_GCK_MODULE_PROBLEM);
+       g_assert (invalid == NULL);
+@@ -138,7 +150,11 @@
+       g_object_get (test->module, "path", &path, NULL);
+       g_assert (path != NULL && "no module-path");
++#ifdef G_OS_WIN32
++      g_assert (strcmp (BUILDDIR "/.libs/libmock-test-module.dll", path) == 0 && "module path wrong");
++#else
+       g_assert (strcmp (BUILDDIR "/.libs/libmock-test-module.so", path) == 0 && "module path wrong");
++#endif
+       g_free (path);
+ }
+--- gcr-3.12.2-orig/gck/test-gck-modules.c     2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gck/test-gck-modules.c  2014-08-11 15:34:41.122663400 +0200
+@@ -47,7 +47,11 @@
+       GError *err = NULL;
+       /* Successful load */
++#ifdef G_OS_WIN32
++      module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
++#else
+       module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
++#endif
+       g_assert_no_error (err);
+       g_assert (GCK_IS_MODULE (module));
+--- gcr-3.12.2-orig/gck/test-gck-object.c      2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gck/test-gck-object.c   2014-08-11 15:34:41.129665100 +0200
+@@ -49,7 +49,11 @@
+       GList *slots;
+       /* Successful load */
++#ifdef G_OS_WIN32
++      test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
++#else
+       test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
++#endif
+       g_assert_no_error (err);
+       g_assert (GCK_IS_MODULE (test->module));
+--- gcr-3.12.2-orig/gck/test-gck-session.c     2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gck/test-gck-session.c  2014-08-11 15:34:41.136677400 +0200
+@@ -49,7 +49,11 @@
+       GList *slots;
+       /* Successful load */
++#ifdef G_OS_WIN32
++      test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
++#else
+       test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
++#endif
+       g_assert_no_error (err);
+       g_assert (GCK_IS_MODULE (test->module));
+       g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
+--- gcr-3.12.2-orig/gck/test-gck-slot.c        2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gck/test-gck-slot.c     2014-08-11 15:34:41.141664500 +0200
+@@ -42,7 +42,11 @@
+       GList *slots;
+       /* Successful load */
++#ifdef G_OS_WIN32
++      test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
++#else
+       test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
++#endif
+       g_assert_no_error (err);
+       g_assert (GCK_IS_MODULE (test->module));
+--- gcr-3.12.2-orig/gcr/gcr-enum-types-base.h  2014-05-13 21:05:40.000000000 +0200
++++ gcr-3.12.2/gcr/gcr-enum-types-base.h       2014-08-11 16:55:02.607094500 +0200
+@@ -6,7 +6,7 @@
+ G_BEGIN_DECLS
+-/* enumerations from "../gcr/gcr-certificate-chain.h" */
++/* enumerations from "gcr/gcr-certificate-chain.h" */
+ #ifndef GCR_TYPE_CERTIFICATE_CHAIN_STATUS
+ GType gcr_certificate_chain_status_get_type (void) G_GNUC_CONST;
+ #define GCR_TYPE_CERTIFICATE_CHAIN_STATUS (gcr_certificate_chain_status_get_type ())
+@@ -18,49 +18,49 @@
+ #endif
+-/* enumerations from "../gcr/gcr-certificate-request.h" */
++/* enumerations from "gcr/gcr-certificate-request.h" */
+ #ifndef GCR_TYPE_CERTIFICATE_REQUEST_FORMAT
+ GType gcr_certificate_request_format_get_type (void) G_GNUC_CONST;
+ #define GCR_TYPE_CERTIFICATE_REQUEST_FORMAT (gcr_certificate_request_format_get_type ())
+ #endif
+-/* enumerations from "../gcr/gcr-column.h" */
++/* enumerations from "gcr/gcr-column.h" */
+ #ifndef GCR_TYPE_COLUMN_FLAGS
+ GType gcr_column_flags_get_type (void) G_GNUC_CONST;
+ #define GCR_TYPE_COLUMN_FLAGS (gcr_column_flags_get_type ())
+ #endif
+-/* enumerations from "../gcr/gcr-deprecated-base.h" */
++/* enumerations from "gcr/gcr-deprecated-base.h" */
+ #ifndef GCR_TYPE_IMPORTER_PROMPT_BEHAVIOR
+ GType gcr_importer_prompt_behavior_get_type (void) G_GNUC_CONST;
+ #define GCR_TYPE_IMPORTER_PROMPT_BEHAVIOR (gcr_importer_prompt_behavior_get_type ())
+ #endif
+-/* enumerations from "../gcr/gcr-prompt.h" */
++/* enumerations from "gcr/gcr-prompt.h" */
+ #ifndef GCR_TYPE_PROMPT_REPLY
+ GType gcr_prompt_reply_get_type (void) G_GNUC_CONST;
+ #define GCR_TYPE_PROMPT_REPLY (gcr_prompt_reply_get_type ())
+ #endif
+-/* enumerations from "../gcr/gcr-system-prompt.h" */
++/* enumerations from "gcr/gcr-system-prompt.h" */
+ #ifndef GCR_TYPE_SYSTEM_PROMPT_ERROR
+ GType gcr_system_prompt_error_get_type (void) G_GNUC_CONST;
+ #define GCR_TYPE_SYSTEM_PROMPT_ERROR (gcr_system_prompt_error_get_type ())
+ #endif
+-/* enumerations from "../gcr/gcr-system-prompter.h" */
++/* enumerations from "gcr/gcr-system-prompter.h" */
+ #ifndef GCR_TYPE_SYSTEM_PROMPTER_MODE
+ GType gcr_system_prompter_mode_get_type (void) G_GNUC_CONST;
+ #define GCR_TYPE_SYSTEM_PROMPTER_MODE (gcr_system_prompter_mode_get_type ())
+ #endif
+-/* enumerations from "../gcr/gcr-types.h" */
++/* enumerations from "gcr/gcr-types.h" */
+ #ifndef GCR_TYPE_DATA_ERROR
+ GType gcr_data_error_get_type (void) G_GNUC_CONST;
+ #define GCR_TYPE_DATA_ERROR (gcr_data_error_get_type ())
+--- gcr-3.12.2-orig/gcr/gcr-gnupg-collection.c 2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gcr/gcr-gnupg-collection.c      2014-08-11 15:34:41.058659700 +0200
+@@ -34,7 +34,9 @@
+ #include "gcr-record.h"
+ #include "gcr-util.h"
++#ifdef HAVE_SYS_WAIT_H
+ #include <sys/wait.h>
++#endif
+ #include <string.h>
+ enum {
+--- gcr-3.12.2-orig/gcr/gcr-gnupg-process.c    2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gcr/gcr-gnupg-process.c 2014-08-11 15:39:09.924362200 +0200
+@@ -30,12 +30,25 @@
+ #include <glib/gi18n-lib.h>
++#ifdef HAVE_SYS_WAIT_H
+ #include <sys/wait.h>
++#endif
++#ifdef G_OS_WIN32
++#define WINVER 0x0501
++#include <windows.h>
++#endif
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <string.h>
+ #include <unistd.h>
++#ifndef G_OS_UNIX
++#define WIFEXITED(x) 1
++#define WEXITSTATUS(x) (x)
++#define WIFSIGNALED(x) 0
++#define WTERMSIG(x) (x)
++#endif
++
+ /**
+  * GcrGnupgProcessFlags:
+  * @GCR_GNUPG_PROCESS_NONE: No flags
+@@ -853,7 +866,12 @@
+       gint code;
+       guint i;
++#if defined (G_OS_UNIX)
+       _gcr_debug ("process exited: %d", (int)pid);
++#elif defined (G_OS_WIN32)
++      DWORD real_pid = GetProcessId (pid);
++      _gcr_debug ("process exited: %d", (int)real_pid);
++#endif
+       g_spawn_close_pid (gnupg_source->child_pid);
+       gnupg_source->child_pid = 0;
+@@ -890,11 +908,16 @@
+       }
+       complete_source_is_done (gnupg_source);
++
++#ifdef G_OS_WIN32
++      g_spawn_close_pid (pid);
++#endif
+ }
+ static void
+ on_gnupg_process_child_setup (gpointer user_data)
+ {
++#ifdef G_OS_UNIX 
+       int *child_fds = user_data;
+       long val;
+       guint i;
+@@ -910,6 +933,7 @@
+                       fcntl (child_fds[i], F_SETFD, val & ~FD_CLOEXEC);
+               }
+       }
++#endif
+ }
+ static void
+@@ -928,9 +952,16 @@
+       /* Try and kill the child process */
+       if (gnupg_source->child_pid) {
++#if defined(G_OS_UNIX)
+               _gcr_debug ("sending term signal to process: %d",
+                           (int)gnupg_source->child_pid);
+               kill (gnupg_source->child_pid, SIGTERM);
++#elif defined(G_OS_WIN32)
++              DWORD real_pid = GetProcessId (gnupg_source->child_pid);
++              _gcr_debug ("sending term signal to process: %d",
++                          (int)real_pid);
++              TerminateProcess (gnupg_source->child_pid, 0);
++#endif
+       }
+ }
+@@ -999,14 +1030,22 @@
+       child_fds[FD_ERROR] = 2;
+       if (flags & GCR_GNUPG_PROCESS_WITH_STATUS) {
++#if defined(G_OS_UNIX)
+               if (pipe (status_fds) < 0)
++#elif defined(G_OS_WIN32)
++              if (_pipe (status_fds, 4096, _O_BINARY) < 0)
++#endif
+                       g_return_if_reached ();
+               child_fds[FD_STATUS] = status_fds[1];
+               g_ptr_array_add (args, g_strdup ("--status-fd"));
+               g_ptr_array_add (args, g_strdup_printf ("%d", child_fds[FD_STATUS]));
+       }
+       if (flags & GCR_GNUPG_PROCESS_WITH_ATTRIBUTES) {
++#if defined(G_OS_UNIX)
+               if (pipe (attribute_fds) < 0)
++#elif defined(G_OS_WIN32)
++              if (_pipe (attribute_fds, 4096, _O_BINARY) < 0)
++#endif
+                       g_return_if_reached ();
+               child_fds[FD_ATTRIBUTE] = attribute_fds[1];
+               g_ptr_array_add (args, g_strdup ("--attribute-fd"));
+@@ -1035,11 +1074,11 @@
+       if (_gcr_debugging) {
+               gchar *command = g_strjoinv (" ", (gchar**)args->pdata);
+-              gchar *environ = g_strjoinv (", ", (gchar**)envs->pdata);
++              gchar *environment = g_strjoinv (", ", (gchar**)envs->pdata);
+               _gcr_debug ("running command: %s", command);
+-              _gcr_debug ("process environment: %s", environ);
++              _gcr_debug ("process environment: %s", environment);
+               g_free (command);
+-              g_free (environ);
++              g_free (environment);
+       }
+       g_spawn_async_with_pipes (self->pv->directory, (gchar**)args->pdata,
+@@ -1067,7 +1106,12 @@
+               return;
+       }
++#if defined (G_OS_UNIX)
+       _gcr_debug ("process started: %d", (int)pid);
++#elif defined (G_OS_WIN32)
++      DWORD real_pid = GetProcessId (pid);
++      _gcr_debug ("process started: %d", (int)real_pid);
++#endif
+       source = g_source_new (&gnupg_source_funcs, sizeof (GnupgSource));
+--- gcr-3.12.2-orig/gcr/gcr-record.c   2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/gcr/gcr-record.c        2014-08-11 15:34:41.077660800 +0200
+@@ -595,7 +595,9 @@
+       const gchar *raw;
+       gulong result;
+       gchar *end = NULL;
+-      struct tm tm;
++      gchar **string;
++      int year, month, day;
++      GDateTime *dt = NULL;
+       g_return_val_if_fail (record, NULL);
+@@ -613,14 +615,20 @@
+       }
+       /* Try to parse as a date */
+-      memset (&tm, 0, sizeof (tm));
+-      end = strptime (raw, "%Y-%m-%d", &tm);
+-      if (!end || end[0]) {
++      string = g_strsplit (raw, "-", 3);
++      if ((string[0] != NULL) && (string[1] != NULL) && (string[2] != NULL)) {
++              year = strtol (string[0], NULL, 10);
++              month = strtol (string[1], NULL, 10);
++              day = strtol (string[2], NULL, 10);
++              dt = g_date_time_new_utc (year, month, day, 0, 0, 0);
++      }
++      g_strfreev (string);
++      if (dt == NULL) {
+               _gcr_debug ("invalid date value: %s", raw);
+               return NULL;
+       }
+-      return g_date_time_new_utc (tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 0, 0, 0);
++      return dt;
+ }
+ /**
+@@ -858,4 +866,4 @@
+       g_free (lines);
+       return result;
+-}
++}
+\ Manca newline alla fine del file
+--- gcr-3.12.2-orig/gcr/Makefile.am    2014-04-17 08:51:07.000000000 +0200
++++ gcr-3.12.2/gcr/Makefile.am 2014-08-11 16:46:47.349973900 +0200
+@@ -274,14 +274,10 @@
+       test-secret-exchange \
+       test-simple-certificate \
+       test-certificate \
+-      test-certificate-chain \
+-      test-subject-public-key \
+       test-fingerprint \
+-      test-pkcs11-certificate \
+       test-openpgp \
+       test-openssh \
+       test-secure-memory \
+-      test-trust \
+       test-parser \
+       test-record \
+       test-memory-icon \
+@@ -294,10 +290,6 @@
+ test_certificate_CFLAGS = $(gcr_CFLAGS)
+ test_certificate_LDADD = $(gcr_LIBS)
+-test_certificate_chain_SOURCES = gcr/test-certificate-chain.c
+-test_certificate_chain_CFLAGS = $(gcr_CFLAGS)
+-test_certificate_chain_LDADD = $(gcr_LIBS)
+-
+ test_filter_collection_SOURCES = gcr/test-filter-collection.c
+ test_filter_collection_CFLAGS = $(gcr_CFLAGS)
+ test_filter_collection_LDADD = $(gcr_LIBS)
+@@ -334,10 +326,6 @@
+ test_parser_CFLAGS = $(gcr_CFLAGS)
+ test_parser_LDADD = $(gcr_LIBS)
+-test_pkcs11_certificate_SOURCES = gcr/test-pkcs11-certificate.c
+-test_pkcs11_certificate_CFLAGS = $(gcr_CFLAGS)
+-test_pkcs11_certificate_LDADD = $(gcr_LIBS)
+-
+ test_record_SOURCES = gcr/test-record.c
+ test_record_CFLAGS = $(gcr_CFLAGS)
+ test_record_LDADD = $(gcr_LIBS)
+@@ -354,18 +342,10 @@
+ test_simple_certificate_CFLAGS = $(gcr_CFLAGS)
+ test_simple_certificate_LDADD = $(gcr_LIBS)
+-test_subject_public_key_SOURCES = gcr/test-subject-public-key.c
+-test_subject_public_key_CFLAGS = $(gcr_CFLAGS)
+-test_subject_public_key_LDADD = $(gcr_LIBS)
+-
+ test_system_prompt_SOURCES = gcr/test-system-prompt.c
+ test_system_prompt_CFLAGS = $(gcr_CFLAGS)
+ test_system_prompt_LDADD = $(gcr_LIBS)
+-test_trust_SOURCES = gcr/test-trust.c
+-test_trust_CFLAGS = $(gcr_CFLAGS)
+-test_trust_LDADD = $(gcr_LIBS)
+-
+ test_util_SOURCES = gcr/test-util.c
+ test_util_CFLAGS = $(gcr_CFLAGS)
+ test_util_LDADD = $(gcr_LIBS)
+--- gcr-3.12.2-orig/ui/frob-prompt.c   2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/ui/frob-prompt.c        2014-08-11 16:52:11.692510200 +0200
+@@ -25,15 +25,45 @@
+ #include "gcr/gcr-base.h"
+ #include <gtk/gtk.h>
++#ifdef GDK_WINDOWING_X11
+ #include <gdk/gdkx.h>
+-
++#endif
++#ifdef GDK_WINDOWING_WIN32
++#include <gdk/gdkwin32.h>
++#endif
++ 
++#if defined(HAVE_ERR_H)
+ #include <err.h>
++#else
++#include <errno.h>
++#endif
++#include <stdlib.h>
+ static const gchar *file_name = NULL;
+ static gchar *prompt_type = NULL;
+ static gint prompt_delay = 0;
+ static gboolean prompt_window = FALSE;
++#ifndef HAVE_ERR_H
++extern void errx (int eval, char *format, ...);
++
++void errx (int eval, char *format, ...)
++{
++      gchar *err_s;
++
++      va_list ap;
++      va_start (ap, format);
++      vsprintf (err_s, format, ap);
++      va_end (ap);
++
++      err_s = g_strconcat (g_get_prgname (), ": ", g_strdup (err_s), "\n", NULL);
++      g_printerr (err_s);
++      g_free (err_s);
++
++      exit (eval);
++}
++#endif
++
+ static gboolean
+ on_delay_timeout (gpointer data)
+ {
+@@ -78,7 +108,11 @@
+               errx (1, "couldn't create prompt: %s", error->message);
+       if (parent) {
++#if defined(GDK_WINDOWING_X11)
+               caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_XID (gtk_widget_get_window (parent)));
++#elif defined(GDK_WINDOWING_WIN32)
++              caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_HWND (gtk_widget_get_window (parent)));
++#endif
+               gcr_prompt_set_caller_window (GCR_PROMPT (prompt), caller_id);
+               g_free (caller_id);
+       }
+--- gcr-3.12.2-orig/ui/frob-system-prompt.c    2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/ui/frob-system-prompt.c 2014-08-11 16:52:28.435130400 +0200
+@@ -26,7 +26,12 @@
+ #include "egg/egg-testing.h"
+ #include <gtk/gtk.h>
++#ifdef GDK_WINDOWING_X11
+ #include <gdk/gdkx.h>
++#endif
++#ifdef GDK_WINDOWING_WIN32
++#include <gdk/gdkwin32.h>
++#endif
+ #include <unistd.h>
+ #include <string.h>
+@@ -54,7 +59,11 @@
+       gcr_prompt_set_message (GCR_PROMPT (prompt), "This is the message");
+       gcr_prompt_set_description (GCR_PROMPT (prompt), "This is the description");
++#if defined(GDK_WINDOWING_X11)
+       caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_XID (gtk_widget_get_window (parent)));
++#elif defined(GDK_WINDOWING_WIN32)
++      caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_HWND (gtk_widget_get_window (parent)));
++#endif
+       gcr_prompt_set_caller_window (GCR_PROMPT (prompt), caller_id);
+       g_free (caller_id);
+--- gcr-3.12.2-orig/ui/gcr-prompt-dialog.c     2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/ui/gcr-prompt-dialog.c  2014-08-11 15:52:01.024449200 +0200
+@@ -29,7 +29,12 @@
+ #include "gcr-secure-entry-buffer.h"
+ #include <gtk/gtk.h>
++#ifdef GDK_WINDOWING_X11
+ #include <gdk/gdkx.h>
++#endif
++#ifdef GDK_WINDOWING_WIN32
++#include <gdk/gdkwin32.h>
++#endif
+ #include <glib/gi18n.h>
+ /**
+@@ -150,7 +155,9 @@
+       }
+       display = gtk_widget_get_display (GTK_WIDGET (self));
++#ifndef GDK_WINDOWING_WIN32
+       transient_for = gdk_x11_window_foreign_new_for_display (display, (Window)handle);
++#endif
+       if (transient_for == NULL) {
+               g_warning ("caller-window property doesn't represent a window on current display: %s",
+                          self->pv->caller_window);
+--- gcr-3.12.2-orig/ui/gcr-prompter-tool.c     2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/ui/gcr-prompter-tool.c  2014-08-11 16:07:06.442588100 +0200
+@@ -29,13 +29,20 @@
+ #include <glib/gi18n.h>
+ #include <gtk/gtk.h>
++#ifdef GDK_WINDOWING_X11
+ #include <gdk/gdkx.h>
++#endif
++#ifdef GDK_WINDOWING_WIN32
++#include <gdk/gdkwin32.h>
++#endif
+ #include <pango/pango.h>
+ #include <locale.h>
+ #include <stdlib.h>
+ #include <string.h>
++#ifndef G_OS_WIN32
+ #include <syslog.h>
++#endif
+ #define QUIT_TIMEOUT 10
+@@ -141,6 +148,7 @@
+       /* Note that crit and err are the other way around in syslog */
++#ifndef G_OS_WIN32
+       switch (G_LOG_LEVEL_MASK & log_level) {
+       case G_LOG_LEVEL_ERROR:
+               level = LOG_CRIT;
+@@ -170,6 +178,7 @@
+               syslog (level, "%s: %s", log_domain, message);
+       else
+               syslog (level, "%s", message);
++#endif
+       /* And then to default handler for aborting and stuff like that */
+       g_log_default_handler (log_domain, log_level, message, user_data);
+@@ -179,7 +188,9 @@
+ printerr_handler (const gchar *string)
+ {
+       /* Print to syslog and stderr */
++#ifndef G_OS_WIN32
+       syslog (LOG_WARNING, "%s", string);
++#endif
+       fprintf (stderr, "%s", string);
+ }
+@@ -190,7 +201,9 @@
+                              G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING |
+                              G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO;
++#ifndef G_OS_WIN32
+       openlog ("gcr-prompter", LOG_PID, LOG_AUTH);
++#endif
+       g_log_set_handler (NULL, flags, log_handler, NULL);
+       g_log_set_handler ("Glib", flags, log_handler, NULL);
+--- gcr-3.12.2-orig/ui/Makefile.am     2014-03-03 21:05:24.000000000 +0100
++++ gcr-3.12.2/ui/Makefile.am  2014-08-11 17:11:21.038892800 +0200
+@@ -36,12 +36,6 @@
+       $(GTK_LIBS) \
+       $(NULL)
+-# libgcr-3.so (and  friends) symlink to libgcr-ui-3.so for compatibility raisons
+-install-exec-hook:
+-      $(LN_S) -f `readlink $(DESTDIR)$(libdir)/libgcr-ui-@GCR_MAJOR@.so` $(DESTDIR)$(libdir)/libgcr-@GCR_MAJOR@.so
+-      $(LN_S) -f `readlink $(DESTDIR)$(libdir)/libgcr-ui-@GCR_MAJOR@.so` $(DESTDIR)$(libdir)/libgcr-@GCR_MAJOR@.so.@GCR_CURRENT@
+-      $(LN_S) -f `readlink $(DESTDIR)$(libdir)/libgcr-ui-@GCR_MAJOR@.so` $(DESTDIR)$(libdir)/libgcr-@GCR_MAJOR@.so.@GCR_CURRENT@.0.0
+-
+ uidir = $(datadir)/gcr-@GCR_MAJOR@/ui/
+ ui_DATA = \
diff --git a/packages/mingw-w64-gcr/PKGBUILD b/packages/mingw-w64-gcr/PKGBUILD
new file mode 100644 (file)
index 0000000..236f284
--- /dev/null
@@ -0,0 +1,43 @@
+# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>
+
+_realname=gcr
+pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
+pkgver=3.12.2
+pkgrel=1
+arch=('any')
+pkgdesc="Library for Crypto UI related task (mingw-w64)"
+depends=("${MINGW_PACKAGE_PREFIX}-glib2"
+         "${MINGW_PACKAGE_PREFIX}-mman")
+makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
+options=('strip' 'staticlibs')
+license=("LGPL 2.1")
+url="http://www.gnome.org/"
+source=(http://ftp.gnome.org/pub/gnome/sources/${_realname}/${pkgver:0:4}/${_realname}-$pkgver.tar.xz
+        001-3.12.2.patch)
+sha256sums=('fb70ab60d355edabb05cb82737f322111496b835a0db9e03acee6425891cfd0c'
+            '818ea2e238c3da0ad29f660502433e0c635ea0dfee17fefc980310ee9fed8381')
+
+prepare() {
+  cd ${_realname}-${pkgver}
+  patch -p1 -i ${srcdir}/001-3.12.2.patch
+
+  autoreconf -fi
+}
+
+build() {
+  mkdir -p build-${MINGW_CHOST}
+  cd build-${MINGW_CHOST}
+
+  ../${_realname}-${pkgver}/configure \
+    --host=${MINGW_CHOST} \
+    --target=${MINGW_CHOST} \
+    --build=${MINGW_CHOST} \
+    --prefix=${MINGW_PREFIX} \
+    --libexecdir=${MINGW_PREFIX}/lib
+  make
+}
+
+package() {
+  cd "$srcdir/build-${MINGW_CHOST}"
+  make DESTDIR=$pkgdir install
+}