[packages/spice-gtk2] - saving last version of spice-gtk2 library from spice-gtk.spec - added no-tunnel patch (adapt for r

qboosh qboosh at pld-linux.org
Sun May 17 08:19:07 CEST 2020


commit 9657c1790518c787f41430e887680762206f39a7
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sun May 17 08:19:31 2020 +0200

    - saving last version of spice-gtk2 library from spice-gtk.spec
    - added no-tunnel patch (adapt for recent spice-protocol with removed tunnel channel functionality)
    - added openssl patch (openssl 1.1.x fixes)
    - added sysmacros patch (recent glibc fix)

 spice-gtk2-am.patch        |  11 ++
 spice-gtk2-builddir.patch  |  11 ++
 spice-gtk2-no-tunnel.patch | 118 ++++++++++++
 spice-gtk2-openssl.patch   | 472 +++++++++++++++++++++++++++++++++++++++++++++
 spice-gtk2-sysmacros.patch |  15 ++
 spice-gtk2.spec            | 312 ++++++++++++++++++++++++++++++
 6 files changed, 939 insertions(+)
---
diff --git a/spice-gtk2.spec b/spice-gtk2.spec
new file mode 100644
index 0000000..2d8b3a7
--- /dev/null
+++ b/spice-gtk2.spec
@@ -0,0 +1,312 @@
+#
+# Conditional build:
+%bcond_without	smartcard		# Smartcard support
+%bcond_without	usbredir		# USB redirection
+%bcond_without	static_libs		# static libraries
+%bcond_without	system_spiceglib	# disable packaging spice-glib
+
+%if %{without system_spiceglib}
+# usbredir option doesn't affect gtk library (just glib library and spicy program)
+%undefine	with_usbredir
+%endif
+
+Summary:	SPICE Client GTK 2.0 library
+Summary(pl.UTF-8):	Biblioteka kliencka SPICE GTK 2.0
+Name:		spice-gtk2
+Version:	0.31
+Release:	3
+License:	LGPL v2.1+
+Group:		X11/Applications
+Source0:	https://www.spice-space.org/download/gtk/spice-gtk-%{version}.tar.bz2
+# Source0-md5:	1ef438eabc19b0f339d746a93cab4f56
+Patch0:		%{name}-builddir.patch
+Patch1:		%{name}-am.patch
+Patch2:		%{name}-no-tunnel.patch
+Patch3:		%{name}-openssl.patch
+Patch4:		%{name}-sysmacros.patch
+URL:		https://spice-space.org/
+BuildRequires:	autoconf >= 2.63
+BuildRequires:	automake >= 1:1.11
+BuildRequires:	cairo-devel >= 1.2.0
+BuildRequires:	celt051-devel >= 0.5.1.1
+BuildRequires:	cyrus-sasl-devel >= 2.0
+BuildRequires:	gcc >= 5:3.0
+BuildRequires:	gettext-tools >= 0.17
+BuildRequires:	glib2-devel >= 1:2.44
+BuildRequires:	gobject-introspection-devel >= 0.9.4
+BuildRequires:	gstreamer-devel >= 1.0
+BuildRequires:	gstreamer-plugins-base-devel >= 1.0
+BuildRequires:	gtk+2-devel >= 2:2.18.0
+BuildRequires:	gtk-doc >= 1.14
+BuildRequires:	intltool >= 0.40.0
+%{?with_smartcard:BuildRequires:	libcacard-devel >= 0.1.2}
+BuildRequires:	libepoxy-devel
+BuildRequires:	libjpeg-devel
+BuildRequires:	libsoup-devel >= 2.50
+BuildRequires:	libstdc++-devel
+BuildRequires:	libtool >= 2:2.0
+BuildRequires:	lz4-devel
+BuildRequires:	openssl-devel >= 1.0.0
+BuildRequires:	opus-devel >= 0.9.14
+BuildRequires:	perl-Text-CSV
+BuildRequires:	perl-base >= 1:5.8.1
+BuildRequires:	phodav-devel >= 2.0
+BuildRequires:	pixman-devel >= 0.17.7
+BuildRequires:	pkgconfig
+BuildRequires:	pulseaudio-devel
+BuildRequires:	python >= 2
+BuildRequires:	python-devel >= 2.0
+BuildRequires:	python-pygtk-devel >= 2:2.0.0
+BuildRequires:	python-pyparsing
+BuildRequires:	python-six
+BuildRequires:	sed >= 4.0
+BuildRequires:	spice-protocol >= 0.12.11
+BuildRequires:	xorg-lib-libX11-devel
+BuildRequires:	xorg-lib-libXrandr-devel
+BuildRequires:	zlib-devel
+%if %{with usbredir}
+BuildRequires:	acl-devel
+BuildRequires:	libusb-devel >= 1.0.16
+BuildRequires:	polkit-devel >= 0.96
+BuildRequires:	usbredir-devel >= 0.5.2
+%endif
+%{?with_smartcard:Requires:	libcacard >= 0.1.2}
+Requires:	gtk+2 >= 2:2.18.0
+Requires:	spice-glib >= %{version}-%{release}
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+SPICE Client GTK 2.0 library.
+
+%description -l pl.UTF-8
+Biblioteka kliencka SPICE GTK 2.0.
+
+%package devel
+Summary:	Header files for SPICE GTK 2.0 Client library
+Summary(pl.UTF-8):	Pliki nagłówkowe biblioteki klienckiej SPICE GTK 2.0
+Group:		X11/Development/Libraries
+Requires:	%{name} = %{version}-%{release}
+Requires:	gtk+2-devel >= 2:2.18.0
+Requires:	spice-glib-devel >= %{version}-%{release}
+
+%description devel
+Header files for SPICE GTK 2.0 client library.
+
+%description devel -l pl.UTF-8
+Pliki nagłówkowe biblioteki klienckiej SPICE GTK 2.0.
+
+%package static
+Summary:	Static SPICE GTK 2.0 client library
+Summary(pl.UTF-8):	Statyczna biblioteka kliencka SPICE GTK 2.0
+Group:		X11/Development/Libraries
+Requires:	%{name}-devel = %{version}-%{release}
+
+%description static
+Static SPICE GTK 2.0 client library.
+
+%description static -l pl.UTF-8
+Statyczna biblioteka kliencka SPICE GTK 2.0.
+
+%package -n python-spice-gtk
+Summary:	Python interface to SPICE client GTK library
+Summary(pl.UTF-8):	Pythonowy interfejs do biblioteki klienckiej SPICE GTK
+Group:		Libraries/Python
+Requires:	spice-gtk2 = %{version}-%{release}
+
+%description -n python-spice-gtk
+Python interface to SPICE client GTK library.
+
+%description -n python-spice-gtk -l pl.UTF-8
+Pythonowy interfejs do biblioteki klienckiej SPICE GTK.
+
+%package -n spice-glib
+Summary:	SPICE Client GLib library
+Summary(pl.UTF-8):	Biblioteka kliencka SPICE GLib
+Group:		Libraries
+Requires:	celt051 >= 0.5.1.1
+Requires:	glib2 >= 1:2.44
+%{?with_smartcard:Requires:	libcacard >= 0.1.2}
+Requires:	libsoup >= 2.50
+Requires:	opus >= 0.9.14
+Requires:	pixman >= 0.17.7
+%if %{with usbredir}
+Requires:	libusb >= 1.0.16
+Requires:	usbredir >= 0.5.2
+%endif
+
+%description -n spice-glib
+SPICE Client GLib library.
+
+%description -n spice-glib -l pl.UTF-8
+Biblioteka kliencka SPICE GLib.
+
+%package -n spice-glib-devel
+Summary:	Header files for SPICE Client GLib library
+Summary(pl.UTF-8):	Pliki nagłówkowe biblioteki klienckiej SPICE GLib
+Group:		Development/Libraries
+Requires:	celt051-devel >= 0.5.1.1
+Requires:	cyrus-sasl-devel >= 2.0
+Requires:	glib2-devel >= 1:2.44
+%{?with_smartcard:Requires:	libcacard-devel >= 0.1.2}
+Requires:	libjpeg-devel
+Requires:	openssl-devel >= 1.0.0
+Requires:	pixman-devel >= 0.17.7
+Requires:	pulseaudio-devel
+Requires:	spice-glib = %{version}-%{release}
+Requires:	spice-protocol >= 0.12.11
+%if %{with usbredir}
+Requires:	libusb-devel >= 1.0.16
+Requires:	usbredir-devel >= 0.5.2
+%endif
+
+%description -n spice-glib-devel
+Header files for SPICE Client GLib library.
+
+%description -n spice-glib-devel -l pl.UTF-8
+Pliki nagłówkowe biblioteki klienckiej SPICE GLib.
+
+%package -n spice-glib-static
+Summary:	SPICE Client GLib static library
+Summary(pl.UTF-8):	Statyczna biblioteka kliencka SPICE GLib
+Group:		Development/Libraries
+Requires:	spice-glib-devel = %{version}-%{release}
+
+%description -n spice-glib-static
+SPICE Client GLib static library.
+
+%description -n spice-glib-static -l pl.UTF-8
+Statyczna biblioteka kliencka SPICE GLib.
+
+%package -n spice-glib-usb
+Summary:	USB redirection ACL helper for SPICE Client GLib library
+Summary(pl.UTF-8):	Program pomocniczy ACL do przekierowań USB dla biblioteki klienckiej SPICE GLib
+Group:		Applications/System
+Requires:	polkit >= 0.96
+Requires:	spice-glib = %{version}-%{release}
+
+%description -n spice-glib-usb
+USB redirection ACL helper for SPICE Client GLib library.
+
+%description -n spice-glib-usb -l pl.UTF-8
+Program pomocniczy ACL do przekierowań USB dla biblioteki klienckiej
+SPICE GLib.
+
+%prep
+%setup -q -n spice-gtk-%{version}
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+
+# force regeneration
+%{__rm} spice-common/common/generated_*marshallers.[ch]
+
+%build
+%{__intltoolize}
+%{__libtoolize}
+%{__aclocal} -I m4
+%{__autoconf}
+%{__autoheader}
+%{__automake}
+cd spice-common
+%{__aclocal} -I m4
+%{__autoconf}
+%{__autoheader}
+%{__automake}
+cd ..
+
+%configure \
+	--enable-lz4 \
+	--disable-controller \
+	--disable-silent-rules \
+	%{!?with_smartcard:--disable-smartcard} \
+	%{?with_static_libs:--enable-static} \
+	%{!?with_usbredir:--disable-usbredir} \
+	--with-gtk=2.0 \
+	--with-html-dir=%{_gtkdocdir} \
+	--with-pnp-ids-path=/lib/hwdata/pnp.ids \
+	--with-usb-ids-path=/lib/hwdata/usb.ids
+%{__make}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%{__make} install -j1 \
+	DESTDIR=$RPM_BUILD_ROOT
+
+%{__rm} $RPM_BUILD_ROOT%{py_sitedir}/SpiceClientGtk.la
+%if %{with static_libs}
+%{__rm} $RPM_BUILD_ROOT%{py_sitedir}/SpiceClientGtk.a
+%endif
+# obsoleted by pkg-config
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/lib*.la
+
+%{__rm} $RPM_BUILD_ROOT%{_bindir}/* \
+	$RPM_BUILD_ROOT%{_mandir}/man1/* \
+	$RPM_BUILD_ROOT%{_localedir}/*/LC_MESSAGES/spice-gtk.mo \
+	$RPM_BUILD_ROOT%{_datadir}/polkit-1/actions/org.spice-space.lowlevelusbaccess.policy \
+	$RPM_BUILD_ROOT%{_datadir}/vala/vapi/spice-protocol.vapi
+%{__rm} -r $RPM_BUILD_ROOT%{_gtkdocdir}/spice-gtk
+
+%if %{with system_spiceglib}
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/libspice-client-glib-2.0.* \
+	$RPM_BUILD_ROOT%{_libdir}/girepository-1.0/SpiceClientGLib-2.0.typelib \
+	$RPM_BUILD_ROOT%{_datadir}/gir-1.0/SpiceClientGLib-2.0.gir \
+	$RPM_BUILD_ROOT%{_pkgconfigdir}/spice-client-glib-2.0.pc
+%{__rm} -r $RPM_BUILD_ROOT%{_includedir}/spice-client-glib-2.0
+%endif
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post	-p /sbin/ldconfig
+%postun	-p /sbin/ldconfig
+
+%post	-n spice-glib -p /sbin/ldconfig
+%postun	-n spice-glib -p /sbin/ldconfig
+
+%files
+%defattr(644,root,root,755)
+%doc AUTHORS NEWS README THANKS TODO
+%attr(755,root,root) %{_libdir}/libspice-client-gtk-2.0.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libspice-client-gtk-2.0.so.4
+%{_libdir}/girepository-1.0/SpiceClientGtk-2.0.typelib
+
+%files devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libspice-client-gtk-2.0.so
+%{_includedir}/spice-client-gtk-2.0
+%{_pkgconfigdir}/spice-client-gtk-2.0.pc
+%{_datadir}/gir-1.0/SpiceClientGtk-2.0.gir
+
+%if %{with static_libs}
+%files static
+%defattr(644,root,root,755)
+%{_libdir}/libspice-client-gtk-2.0.a
+%endif
+
+%files -n python-spice-gtk
+%defattr(644,root,root,755)
+%attr(755,root,root) %{py_sitedir}/SpiceClientGtk.so
+
+%if %{without system_spiceglib}
+%files -n spice-glib
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libspice-client-glib-2.0.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libspice-client-glib-2.0.so.8
+%{_libdir}/girepository-1.0/SpiceClientGLib-2.0.typelib
+
+%files -n spice-glib-devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libspice-client-glib-2.0.so
+%{_includedir}/spice-client-glib-2.0
+%{_pkgconfigdir}/spice-client-glib-2.0.pc
+%{_datadir}/gir-1.0/SpiceClientGLib-2.0.gir
+
+%if %{with static_libs}
+%files -n spice-glib-static
+%defattr(644,root,root,755)
+%{_libdir}/libspice-client-glib-2.0.a
+%endif
+%endif
diff --git a/spice-gtk2-am.patch b/spice-gtk2-am.patch
new file mode 100644
index 0000000..f5805c8
--- /dev/null
+++ b/spice-gtk2-am.patch
@@ -0,0 +1,11 @@
+--- spice-gtk-0.20/configure.ac.orig	2013-06-26 15:55:08.000000000 +0200
++++ spice-gtk-0.20/configure.ac	2013-07-19 18:01:59.371274971 +0200
+@@ -7,7 +7,7 @@
+ AC_CONFIG_HEADER([config.h])
+ AC_CONFIG_AUX_DIR([build-aux])
+ 
+-AM_INIT_AUTOMAKE([foreign dist-bzip2 -Wall -Werror -Wno-portability])
++AM_INIT_AUTOMAKE([foreign dist-bzip2 -Wall -Wno-portability])
+ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+ LT_INIT
+ AM_MAINTAINER_MODE
diff --git a/spice-gtk2-builddir.patch b/spice-gtk2-builddir.patch
new file mode 100644
index 0000000..8e31e46
--- /dev/null
+++ b/spice-gtk2-builddir.patch
@@ -0,0 +1,11 @@
+--- spice-gtk-0.29/src/Makefile.am.orig	2012-01-31 14:31:38.000000000 +0100
++++ spice-gtk-0.29/src/Makefile.am	2012-02-04 08:30:40.437278387 +0100
+@@ -549,7 +549,7 @@
+ DEFSDIR = `pkg-config --variable=defsdir pygtk-2.0`
+ 
+ spice-client-gtk.defs: $(libspice_client_gtkinclude_HEADERS) $(nodist_libspice_client_gtkinclude_HEADERS) $(libspice_client_glibinclude_HEADERS) $(nodist_libspice_client_glibinclude_HEADERS)
+-	$(AM_V_GEN)$(PYTHON) $(CODEGENDIR)/h2def.py \
++	$(AM_V_GEN)$(PYTHON) $(CODEGENDIR)/h2def.pyc \
+ 		-f $(srcdir)/spice-client-gtk-manual.defs \
+ 		$^ > $@
+ 
diff --git a/spice-gtk2-no-tunnel.patch b/spice-gtk2-no-tunnel.patch
new file mode 100644
index 0000000..93dd158
--- /dev/null
+++ b/spice-gtk2-no-tunnel.patch
@@ -0,0 +1,118 @@
+TunnelChannel support has been removed from spice-protocol 0.14
+--- spice-gtk-0.31/spice-common/spice.proto.orig	2016-03-10 17:05:02.000000000 +0100
++++ spice-gtk-0.31/spice-common/spice.proto	2020-05-16 21:33:40.991128832 +0200
+@@ -1185,113 +1185,7 @@
+     } start_mark;
+ };
+ 
+-enum16 tunnel_service_type {
+-    INVALID,
+-    GENERIC,
+-    IPP,
+-};
+-
+-enum16 tunnel_ip_type {
+-    INVALID,
+-    IPv4,
+-};
+-
+-struct TunnelIpInfo {
+-    tunnel_ip_type type;
+-    switch (type) {
+-    case IPv4:
+-	uint8 ipv4[4];
+-    } u;
+-} @ctype(SpiceMsgTunnelIpInfo);
+-
+-channel TunnelChannel : BaseChannel {
+- server:
+-    message {
+-	uint16 max_num_of_sockets;
+-	uint32 max_socket_data_size;
+-    } init = 101;
+-
+-    message {
+-	uint32 service_id;
+-	TunnelIpInfo virtual_ip;
+-    } service_ip_map;
+-
+-    message {
+-	uint16 connection_id;
+-	uint32 service_id;
+-	uint32 tokens;
+-    } socket_open;
+-
+-    message {
+-	uint16 connection_id;
+-    } socket_fin;
+-
+-    message {
+-	uint16 connection_id;
+-    } socket_close;
+-
+-    message {
+-	uint16 connection_id;
+-	uint8 data[] @end;
+-    } socket_data;
+-
+-    message {
+-	uint16 connection_id;
+-    } socket_closed_ack;
+-
+-    message {
+-	uint16 connection_id;
+-	uint32 num_tokens;
+-    } @ctype(SpiceMsgTunnelSocketTokens) socket_token;
+-
+- client:
+-    message {
+-	tunnel_service_type type;
+-	uint32 id;
+-	uint32 group;
+-	uint32 port;
+-	uint8 *name[cstring()] @nocopy;
+-	uint8 *description[cstring()] @nocopy;
+-	switch (type) {
+-	case IPP:
+-	    TunnelIpInfo ip @ctype(SpiceMsgTunnelIpInfo);
+-	} u;
+-    } @ctype(SpiceMsgcTunnelAddGenericService) service_add = 101;
+-
+-    message {
+-	uint32 id;
+-    } @ctype(SpiceMsgcTunnelRemoveService) service_remove;
+-
+-    message {
+-	uint16 connection_id;
+-	uint32 tokens;
+-    } socket_open_ack;
+-
+-    message {
+-	uint16 connection_id;
+-    } socket_open_nack;
+-
+-    message {
+-	uint16 connection_id;
+-    } socket_fin;
+-
+-    message {
+-	uint16 connection_id;
+-    } socket_closed;
+-
+-    message {
+-	uint16 connection_id;
+-    } socket_closed_ack;
+-
+-    message {
+-	uint16 connection_id;
+-	uint8 data[] @end;
+-    } socket_data;
+-
+-    message {
+-	uint16 connection_id;
+-	uint32 num_tokens;
+-    } @ctype(SpiceMsgcTunnelSocketTokens) socket_token;
++channel TunnelChannel {
+ };
+ 
+ enum32 vsc_message_type {
diff --git a/spice-gtk2-openssl.patch b/spice-gtk2-openssl.patch
new file mode 100644
index 0000000..7f1bb25
--- /dev/null
+++ b/spice-gtk2-openssl.patch
@@ -0,0 +1,472 @@
+Support for OpenSSL 1.1.x frm spice-gtk-0.38
+--- spice-gtk-0.31/src/bio-gio.c.orig	2015-11-11 22:28:40.000000000 +0100
++++ spice-gtk-0.31/src/bio-gio.c	2020-05-16 22:07:27.066819305 +0200
+@@ -23,21 +23,92 @@
+ #include "spice-util.h"
+ #include "bio-gio.h"
+ 
+-typedef struct bio_gsocket_method {
+-    BIO_METHOD method;
+-    GIOStream *stream;
+-} bio_gsocket_method;
+-
+-#define BIO_GET_GSOCKET(bio)  (((bio_gsocket_method*)bio->method)->gsocket)
+-#define BIO_GET_ISTREAM(bio)  (g_io_stream_get_input_stream(((bio_gsocket_method*)bio->method)->stream))
+-#define BIO_GET_OSTREAM(bio)  (g_io_stream_get_output_stream(((bio_gsocket_method*)bio->method)->stream))
++#if OPENSSL_VERSION_NUMBER < 0x10100000 || \
++    (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000)
++static BIO_METHOD one_static_bio;
++
++static int BIO_meth_set_read(BIO_METHOD *biom,
++                             int (*bread) (BIO *, char *, int))
++{
++    biom->bread = bread;
++    return 1;
++}
++
++static int BIO_meth_set_write(BIO_METHOD *biom,
++                              int (*bwrite) (BIO *, const char *, int))
++{
++    biom->bwrite = bwrite;
++    return 1;
++}
++
++static int BIO_meth_set_puts(BIO_METHOD *biom,
++                             int (*bputs) (BIO *, const char *))
++{
++    biom->bputs = bputs;
++    return 1;
++}
++
++static int BIO_meth_set_ctrl(BIO_METHOD *biom,
++                             long (*ctrl) (BIO *, int, long, void *))
++{
++    biom->ctrl = ctrl;
++    return 1;
++}
++
++#define BIO_TYPE_START 128
++
++static int BIO_get_new_index(void)
++{
++    static int bio_index = BIO_TYPE_START;
++    return bio_index++;
++}
++
++static void BIO_set_init(BIO *a, int init)
++{
++	a->init = init;
++}
++
++static void BIO_set_data(BIO *a, void *ptr)
++{
++    a->ptr = ptr;
++}
++
++static void *BIO_get_data(BIO *a)
++{
++    return a->ptr;
++}
++
++static BIO_METHOD *BIO_meth_new(int type, const char *name)
++{
++    BIO_METHOD *biom = &one_static_bio;
++
++    biom->type = type;
++    biom->name = name;
++    return biom;
++}
++
++static void BIO_meth_free(BIO_METHOD *biom)
++{
++}
++
++#endif
++
++static long bio_gio_ctrl(G_GNUC_UNUSED BIO *b,
++                         int cmd,
++                         G_GNUC_UNUSED long num,
++                         G_GNUC_UNUSED void *ptr)
++{
++    return (cmd == BIO_CTRL_FLUSH);
++}
+ 
+ static int bio_gio_write(BIO *bio, const char *in, int inl)
+ {
++    GOutputStream *stream;
+     gssize ret;
+     GError *error = NULL;
+ 
+-    ret = g_pollable_output_stream_write_nonblocking(G_POLLABLE_OUTPUT_STREAM(BIO_GET_OSTREAM(bio)),
++    stream = g_io_stream_get_output_stream(BIO_get_data(bio));
++    ret = g_pollable_output_stream_write_nonblocking(G_POLLABLE_OUTPUT_STREAM(stream),
+                                                      in, inl, NULL, &error);
+     BIO_clear_retry_flags(bio);
+ 
+@@ -53,10 +124,12 @@
+ 
+ static int bio_gio_read(BIO *bio, char *out, int outl)
+ {
++    GInputStream *stream;
+     gssize ret;
+     GError *error = NULL;
+ 
+-    ret = g_pollable_input_stream_read_nonblocking(G_POLLABLE_INPUT_STREAM(BIO_GET_ISTREAM(bio)),
++    stream = g_io_stream_get_input_stream(BIO_get_data(bio));
++    ret = g_pollable_input_stream_read_nonblocking(G_POLLABLE_INPUT_STREAM(stream),
+                                                    out, outl, NULL, &error);
+     BIO_clear_retry_flags(bio);
+ 
+@@ -70,18 +143,6 @@
+     return ret;
+ }
+ 
+-static int bio_gio_destroy(BIO *bio)
+-{
+-    if (bio == NULL || bio->method == NULL)
+-        return 0;
+-
+-    SPICE_DEBUG("bio gsocket destroy");
+-    g_free(bio->method);
+-    bio->method = NULL;;
+-
+-    return 1;
+-}
+-
+ static int bio_gio_puts(BIO *bio, const char *str)
+ {
+     int n, ret;
+@@ -92,23 +153,35 @@
+     return ret;
+ }
+ 
++static BIO_METHOD *bio_gio_method;
++
+ G_GNUC_INTERNAL
+ BIO* bio_new_giostream(GIOStream *stream)
+ {
+-    // TODO: make an actual new BIO type, or just switch to GTls already...
+-    BIO *bio = BIO_new_socket(-1, BIO_NOCLOSE);
++    BIO *bio;
++
++    if (!bio_gio_method) {
++        bio_gio_method = BIO_meth_new(BIO_get_new_index() |
++                                      BIO_TYPE_SOURCE_SINK,
++                                      "gio stream");
++        if (!bio_gio_method)
++            return NULL;
++
++        if (!BIO_meth_set_write(bio_gio_method, bio_gio_write) ||
++            !BIO_meth_set_read(bio_gio_method, bio_gio_read) ||
++            !BIO_meth_set_puts(bio_gio_method, bio_gio_puts) ||
++            !BIO_meth_set_ctrl(bio_gio_method, bio_gio_ctrl)) {
++            BIO_meth_free(bio_gio_method);
++            bio_gio_method = NULL;
++            return NULL;
++        }
++    }
+ 
+-    bio_gsocket_method *bio_method = g_new(bio_gsocket_method, 1);
+-    bio_method->method = *bio->method;
+-    bio_method->stream = stream;
+-
+-    bio->method->destroy(bio);
+-    bio->method = (BIO_METHOD*)bio_method;
+-
+-    bio->method->bwrite = bio_gio_write;
+-    bio->method->bread = bio_gio_read;
+-    bio->method->bputs = bio_gio_puts;
+-    bio->method->destroy = bio_gio_destroy;
++    bio = BIO_new(bio_gio_method);
++    if (!bio)
++        return NULL;
+ 
++    BIO_set_init(bio, 1);
++    BIO_set_data(bio, stream);
+     return bio;
+ }
+--- spice-gtk-0.31/src/spice-channel.c.orig	2016-03-11 19:04:46.000000000 +0100
++++ spice-gtk-0.31/src/spice-channel.c	2020-05-16 22:18:16.793299435 +0200
+@@ -56,6 +56,16 @@
+ static void spice_channel_send_migration_handshake(SpiceChannel *channel);
+ static gboolean channel_connect(SpiceChannel *channel, gboolean tls);
+ 
++#if OPENSSL_VERSION_NUMBER < 0x10100000 || \
++    (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000)
++static RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
++{
++    if (pkey->type != EVP_PKEY_RSA) {
++        return NULL;
++    }
++    return pkey->pkey.rsa;
++}
++#endif
+ /**
+  * SECTION:spice-channel
+  * @short_description: the base channel class
+@@ -739,6 +749,53 @@
+ }
+ 
+ /*
++ * Helper function to deal with the nonblocking part of _flush_wire() function.
++ * It returns the result of the write and will set the proper bits in @cond in
++ * case the write function would block.
++ *
++ * Returns -1 in case of any problems.
++ */
++/* coroutine context */
++static gint spice_channel_flush_wire_nonblocking(SpiceChannel *channel,
++                                                 const gchar *ptr,
++                                                 size_t len,
++                                                 GIOCondition *cond)
++{
++    SpiceChannelPrivate *c = channel->priv;
++    gssize ret;
++
++    g_assert(cond != NULL);
++    *cond = 0;
++
++    if (c->tls) {
++        ret = SSL_write(c->ssl, ptr, len);
++        if (ret < 0) {
++            ret = SSL_get_error(c->ssl, ret);
++            if (ret == SSL_ERROR_WANT_READ)
++                *cond |= G_IO_IN;
++            if (ret == SSL_ERROR_WANT_WRITE)
++                *cond |= G_IO_OUT;
++            ret = -1;
++        }
++    } else {
++        GError *error = NULL;
++        ret = g_pollable_output_stream_write_nonblocking(G_POLLABLE_OUTPUT_STREAM(c->out),
++                                                         ptr, len, NULL, &error);
++        if (ret < 0) {
++            if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
++                *cond = G_IO_OUT;
++            } else {
++                CHANNEL_DEBUG(channel, "Send error %s", error->message);
++            }
++            g_clear_error(&error);
++            ret = -1;
++        }
++    }
++
++    return ret;
++}
++
++/*
+  * Write all 'data' of length 'datalen' bytes out to
+  * the wire
+  */
+@@ -754,34 +811,10 @@
+ 
+     while (offset < datalen) {
+         gssize ret;
+-        GError *error = NULL;
+ 
+         if (c->has_error) return;
+ 
+-        cond = 0;
+-        if (c->tls) {
+-            ret = SSL_write(c->ssl, ptr+offset, datalen-offset);
+-            if (ret < 0) {
+-                ret = SSL_get_error(c->ssl, ret);
+-                if (ret == SSL_ERROR_WANT_READ)
+-                    cond |= G_IO_IN;
+-                if (ret == SSL_ERROR_WANT_WRITE)
+-                    cond |= G_IO_OUT;
+-                ret = -1;
+-            }
+-        } else {
+-            ret = g_pollable_output_stream_write_nonblocking(G_POLLABLE_OUTPUT_STREAM(c->out),
+-                                                             ptr+offset, datalen-offset, NULL, &error);
+-            if (ret < 0) {
+-                if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
+-                    cond = G_IO_OUT;
+-                } else {
+-                    CHANNEL_DEBUG(channel, "Send error %s", error->message);
+-                }
+-                g_clear_error(&error);
+-                ret = -1;
+-            }
+-        }
++        ret = spice_channel_flush_wire_nonblocking(channel, ptr+offset, datalen-offset, &cond);
+         if (ret == -1) {
+             if (cond != 0) {
+                 // TODO: should use g_pollable_input/output_stream_create_source() in 2.28 ?
+@@ -941,29 +974,32 @@
+ #endif
+ 
+ /*
+- * Read at least 1 more byte of data straight off the wire
+- * into the requested buffer.
++ * Helper function to deal with the nonblocking part of _read_wire() function.
++ * It returns the result of the read and will set the proper bits in @cond in
++ * case the read function would block.
++ *
++ * Returns -1 in case of any problems.
+  */
+ /* coroutine context */
+-static int spice_channel_read_wire(SpiceChannel *channel, void *data, size_t len)
++static int spice_channel_read_wire_nonblocking(SpiceChannel *channel,
++                                               void *data,
++                                               size_t len,
++                                               GIOCondition *cond)
+ {
+     SpiceChannelPrivate *c = channel->priv;
+     gssize ret;
+-    GIOCondition cond;
+-
+-reread:
+ 
+-    if (c->has_error) return 0; /* has_error is set by disconnect(), return no error */
++    g_assert(cond != NULL);
++    *cond = 0;
+ 
+-    cond = 0;
+     if (c->tls) {
+         ret = SSL_read(c->ssl, data, len);
+         if (ret < 0) {
+             ret = SSL_get_error(c->ssl, ret);
+             if (ret == SSL_ERROR_WANT_READ)
+-                cond |= G_IO_IN;
++                *cond |= G_IO_IN;
+             if (ret == SSL_ERROR_WANT_WRITE)
+-                cond |= G_IO_OUT;
++                *cond |= G_IO_OUT;
+             ret = -1;
+         }
+     } else {
+@@ -972,7 +1008,7 @@
+                                                        data, len, NULL, &error);
+         if (ret < 0) {
+             if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
+-                cond = G_IO_IN;
++                *cond = G_IO_IN;
+             } else {
+                 CHANNEL_DEBUG(channel, "Read error %s", error->message);
+             }
+@@ -981,23 +1017,47 @@
+         }
+     }
+ 
+-    if (ret == -1) {
+-        if (cond != 0) {
+-            // TODO: should use g_pollable_input/output_stream_create_source() ?
+-            g_coroutine_socket_wait(&c->coroutine, c->sock, cond);
+-            goto reread;
+-        } else {
++    return ret;
++}
++
++/*
++ * Read at least 1 more byte of data straight off the wire
++ * into the requested buffer.
++ */
++/* coroutine context */
++static int spice_channel_read_wire(SpiceChannel *channel, void *data, size_t len)
++{
++    SpiceChannelPrivate *c = channel->priv;
++
++    while (TRUE) {
++        gssize ret;
++        GIOCondition cond;
++
++        if (c->has_error) {
++            /* has_error is set by disconnect(), return no error */
++            return 0;
++        }
++
++        ret = spice_channel_read_wire_nonblocking(channel, data, len, &cond);
++
++        if (ret == -1) {
++            if (cond != 0) {
++                // TODO: should use g_pollable_input/output_stream_create_source() ?
++                g_coroutine_socket_wait(&c->coroutine, c->sock, cond);
++                continue;
++            } else {
++                c->has_error = TRUE;
++                return errno > 0 ? -errno : -EIO;
++            }
++        }
++        if (ret == 0) {
++            CHANNEL_DEBUG(channel, "Closing the connection: spice_channel_read() - ret=0");
+             c->has_error = TRUE;
+-            return -errno;
++            return 0;
+         }
+-    }
+-    if (ret == 0) {
+-        CHANNEL_DEBUG(channel, "Closing the connection: spice_channel_read() - ret=0");
+-        c->has_error = TRUE;
+-        return 0;
+-    }
+ 
+-    return ret;
++        return ret;
++    }
+ }
+ 
+ #ifdef HAVE_SASL
+@@ -1140,7 +1200,7 @@
+     pubkey = d2i_PUBKEY_bio(bioKey, NULL);
+     g_return_val_if_fail(pubkey != NULL, ret);
+ 
+-    rsa = pubkey->pkey.rsa;
++    rsa = EVP_PKEY_get0_RSA(pubkey);
+     nRSASize = RSA_size(rsa);
+ 
+     encrypted = g_alloca(nRSASize);
+@@ -2327,18 +2387,9 @@
+     return FALSE;
+ }
+ 
+-static X509_LOOKUP_METHOD spice_x509_mem_lookup = {
+-    "spice_x509_mem_lookup",
+-    0
+-};
+-
+ static int spice_channel_load_ca(SpiceChannel *channel)
+ {
+     SpiceChannelPrivate *c = channel->priv;
+-    STACK_OF(X509_INFO) *inf;
+-    X509_INFO *itmp;
+-    X509_LOOKUP *lookup;
+-    BIO *in;
+     int i, count = 0;
+     guint8 *ca;
+     guint size;
+@@ -2347,25 +2398,30 @@
+ 
+     g_return_val_if_fail(c->ctx != NULL, 0);
+ 
+-    lookup = X509_STORE_add_lookup(c->ctx->cert_store, &spice_x509_mem_lookup);
+     ca_file = spice_session_get_ca_file(c->session);
+     spice_session_get_ca(c->session, &ca, &size);
+ 
+     CHANNEL_DEBUG(channel, "Load CA, file: %s, data: %p", ca_file, ca);
+ 
+     if (ca != NULL) {
++        STACK_OF(X509_INFO) *inf;
++        X509_STORE *store;
++        BIO *in;
++
++        store = SSL_CTX_get_cert_store(c->ctx);
+         in = BIO_new_mem_buf(ca, size);
+         inf = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL);
+         BIO_free(in);
+ 
+         for (i = 0; i < sk_X509_INFO_num(inf); i++) {
++            X509_INFO *itmp;
+             itmp = sk_X509_INFO_value(inf, i);
+             if (itmp->x509) {
+-                X509_STORE_add_cert(lookup->store_ctx, itmp->x509);
++                X509_STORE_add_cert(store, itmp->x509);
+                 count++;
+             }
+             if (itmp->crl) {
+-                X509_STORE_add_crl(lookup->store_ctx, itmp->crl);
++                X509_STORE_add_crl(store, itmp->crl);
+                 count++;
+             }
+         }
diff --git a/spice-gtk2-sysmacros.patch b/spice-gtk2-sysmacros.patch
new file mode 100644
index 0000000..29444de
--- /dev/null
+++ b/spice-gtk2-sysmacros.patch
@@ -0,0 +1,15 @@
+--- spice-gtk-0.31/src/usbutil.c.orig	2015-11-11 22:28:41.000000000 +0100
++++ spice-gtk-0.31/src/usbutil.c	2020-05-16 22:40:00.116238729 +0200
+@@ -25,6 +25,12 @@
+ #include <glib/gi18n.h>
+ #include <ctype.h>
+ #include <stdlib.h>
++#ifdef __linux__
++#include <sys/sysmacros.h>
++#ifndef major /* major and minor macros were moved to sys/sysmacros.h from sys/types.h */
++#include <sys/types.h>
++#endif
++#endif
+ 
+ #include "glib-compat.h"
+ 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/spice-gtk2.git/commitdiff/9657c1790518c787f41430e887680762206f39a7



More information about the pld-cvs-commit mailing list