Move avahi to python3.

req. by feinerer@
This commit is contained in:
ajacoutot 2018-05-16 16:18:52 +00:00
parent d679ec0c08
commit 974c032593
9 changed files with 362 additions and 26 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.129 2018/05/10 15:08:37 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.130 2018/05/16 16:18:52 ajacoutot Exp $
COMMENT-main= framework for Multicast DNS Service Discovery
COMMENT-gtk= gtk+2 avahi-ui libraries
@ -16,15 +16,15 @@ PKGNAME-main= avahi-${V}
PKGNAME-gtk= avahi-gtk-${V}
PKGNAME-gtk3= avahi-gtk3-${V}
PKGNAME-gui= avahi-gui-${V}
PKGNAME-python= py-avahi-${V}
PKGNAME-python= py3-avahi-${V}
PKGNAME-ui= avahi-ui-${V}
REVISION-main= 2
REVISION-gtk= 1
REVISION-gtk3= 1
REVISION-gui= 1
REVISION-python= 0
REVISION-ui= 0
REVISION-main= 3
REVISION-gtk= 2
REVISION-gtk3= 2
REVISION-gui= 2
REVISION-python= 2
REVISION-ui= 1
CATEGORIES= net devel
@ -81,15 +81,16 @@ BUILD_PACKAGES := ${BUILD_PACKAGES:N-gtk:N-gtk3:N-python:N-ui}
.if ${BUILD_PACKAGES:M-gui}
### common
MODULES+= lang/python
BUILD_DEPENDS+= devel/py-gobject3 \
MODPY_VERSION= ${MODPY_DEFAULT_VERSION_3}
BUILD_DEPENDS+= devel/py-gobject3${MODPY_FLAVOR} \
lang/python/${MODPY_VERSION},-gdbm \
x11/dbus-python
x11/dbus-python${MODPY_FLAVOR}
### -gtk
LIB_DEPENDS-gtk= x11/gtk+2 \
${BUILD_PKGPATH}
RUN_DEPENDS-gtk= ${BUILD_PKGPATH},-ui
WANTLIB-gtk += X11 Xcomposite Xcursor Xdamage Xext Xfixes
WANTLIB-gtk += X11 Xcomposite Xcursor Xdamage Xext Xfixes fribidi
WANTLIB-gtk += Xi Xinerama Xrandr Xrender atk-1.0 cairo dbus-1
WANTLIB-gtk += expat fontconfig freetype gdbm gdk-x11-2.0 gthread-2.0
WANTLIB-gtk += gdk_pixbuf-2.0 gio-2.0 glib-2.0 gmodule-2.0
@ -110,15 +111,15 @@ WANTLIB-gtk3 += gio-2.0 glib-2.0 gmodule-2.0 gobject-2.0 gthread-2.0
WANTLIB-gtk3 += gtk-3 m pango-1.0 pangocairo-1.0 pangoft2-1.0
WANTLIB-gtk3 += pcre pixman-1 png pthread xcb xcb-render
WANTLIB-gtk3 += xcb-shm z ffi iconv intl
WANTLIB-gtk3 += ICE SM atk-bridge-2.0 atspi harfbuzz
WANTLIB-gtk3 += fribidi atk-bridge-2.0 atspi harfbuzz
WANTLIB-gtk3 += graphite2 epoxy
### -gui
LIB_DEPENDS-gui= ${BUILD_PKGPATH},-gtk3
RUN_DEPENDS-gui= ${MODPY_RUN_DEPENDS} \
${BUILD_PKGPATH},-python \
x11/dbus-python \
devel/py-twisted \
x11/dbus-python${MODPY_FLAVOR} \
devel/py-twisted${MODPY_FLAVOR} \
devel/desktop-file-utils
# pygobject GTK2 introspection (not provided by indirect dependencies)
@ -132,7 +133,7 @@ WANTLIB-gui += gdbm gdk-3 gdk_pixbuf-2.0 gio-2.0 glib-2.0 gmodule-2.0
WANTLIB-gui += gobject-2.0 gthread-2.0 gtk-3 m pango-1.0
WANTLIB-gui += pangocairo-1.0 pangoft2-1.0 pcre pixman-1 png pthread
WANTLIB-gui += xcb xcb-render xcb-shm z ffi
WANTLIB-gui += ICE SM atk-bridge-2.0 atspi harfbuzz
WANTLIB-gui += fribidi atk-bridge-2.0 atspi harfbuzz
WANTLIB-gui += graphite2 epoxy iconv intl
### -python
@ -164,8 +165,7 @@ CONFIGURE_STYLE= gnu
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include -I${X11BASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib -L${X11BASE}/lib" \
PTHREAD_CFLAGS="-pthread" \
PTHREAD_LIBS="-pthread" \
PYTHON="${MODPY_BIN}"
PTHREAD_LIBS="-pthread"
CONFIGURE_ARGS+= --with-dbus-sys="${SYSCONFDIR}/dbus-1/" \
--with-avahi-user=_avahi \
--with-avahi-group=_avahi \
@ -206,6 +206,8 @@ BUILD_DEPENDS += ${MODGNU_AUTOCONF_DEPENDS} \
devel/libtool
pre-configure:
mv ${WRKSRC}/service-type-database/build-db.in \
${WRKSRC}/service-type-database/build-db
find ${WRKSRC} -name Makefile.in -exec \
sed -i -e 's,LIBINTL,INTLLIBS,g;' \
-e 's,LIBICONV,LTLIBICONV,g' {} \;

View File

@ -0,0 +1,42 @@
$OpenBSD: patch-avahi-python_avahi-discover_Makefile_am,v 1.1 2018/05/16 16:18:52 ajacoutot Exp $
From ffb19d8f3c7f1fe4f31f79f8601dd3079730401b Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@debian.org>
Date: Fri, 27 Apr 2018 09:01:13 +0100
Subject: [PATCH] Remove empty avahi_discover Python module
Index: avahi-python/avahi-discover/Makefile.am
--- avahi-python/avahi-discover/Makefile.am.orig
+++ avahi-python/avahi-discover/Makefile.am
@@ -18,7 +18,6 @@
AM_CFLAGS=-I$(top_srcdir)
EXTRA_DIST = \
- __init__.py \
avahi-discover.py \
avahi-discover.desktop.in.in
@@ -31,15 +30,11 @@ pythonscripts =
desktopdir = $(datadir)/applications
desktop_DATA =
-avahi_discoverdir = $(pythondir)/avahi_discover
-avahi_discover_PYTHON =
-
if HAVE_GDBM
pythonscripts += \
avahi-discover
desktop_DATA += avahi-discover.desktop
@INTLTOOL_DESKTOP_RULE@
-avahi_discover_PYTHON += __init__.py
endif
if HAVE_DBM
@@ -47,7 +42,6 @@ pythonscripts += \
avahi-discover
desktop_DATA += avahi-discover.desktop
@INTLTOOL_DESKTOP_RULE@
-avahi_discover_PYTHON += __init__.py
endif
avahi-discover.desktop.in: avahi-discover.desktop.in.in

View File

@ -0,0 +1,41 @@
$OpenBSD: patch-avahi-python_avahi_Makefile_am,v 1.1 2018/05/16 16:18:52 ajacoutot Exp $
From 63750f1be96ad08c407193b08bf3b9ee74310e2d Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
Date: Tue, 11 Jul 2017 21:52:37 +0200
Subject: [PATCH] avahi-python: Use the agnostic DBM interface
Index: avahi-python/avahi/Makefile.am
--- avahi-python/avahi/Makefile.am.orig
+++ avahi-python/avahi/Makefile.am
@@ -25,29 +25,16 @@ avahidir = $(pythondir)/avahi
if HAVE_GDBM
nodist_avahi_SCRIPTS = ServiceTypeDatabase.py
-
-ServiceTypeDatabase.py: ServiceTypeDatabase.py.in
- $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
- -e 's,@DBM\@,gdbm,g' \
- -e 's,@FIRST_KEY\@,key = self.db.firstkey(),g' \
- -e 's,@CHECK_KEY\@,while key is not None:,g' \
- -e 's,@NEXT_KEY\@,key = self.db.nextkey(key),g' \
- -e 's,@pkglibdatadir\@,$(pkglibdatadir),g' $< > $@ && \
- chmod +x $@
endif
if HAVE_DBM
nodist_avahi_SCRIPTS = ServiceTypeDatabase.py
+endif
ServiceTypeDatabase.py: ServiceTypeDatabase.py.in
$(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
- -e 's,@DBM\@,dbm,g' \
- -e 's,@FIRST_KEY\@,keys = self.db.keys(),g' \
- -e 's,@CHECK_KEY\@,for key in keys:,g' \
- -e 's,@NEXT_KEY\@,,g' \
-e 's,@pkglibdatadir\@,$(pkglibdatadir),g' $< > $@ && \
chmod +x $@
-endif
avahi_PYTHON = $(avahi_SCRIPTS)

View File

@ -0,0 +1,63 @@
$OpenBSD: patch-avahi-python_avahi_ServiceTypeDatabase_py_in,v 1.1 2018/05/16 16:18:52 ajacoutot Exp $
From 63750f1be96ad08c407193b08bf3b9ee74310e2d Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
Date: Tue, 11 Jul 2017 21:52:37 +0200
Subject: [PATCH] avahi-python: Use the agnostic DBM interface
Index: avahi-python/avahi/ServiceTypeDatabase.py.in
--- avahi-python/avahi/ServiceTypeDatabase.py.in.orig
+++ avahi-python/avahi/ServiceTypeDatabase.py.in
@@ -17,7 +17,11 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-import @DBM@
+try:
+ import anydbm as dbm
+except ImportError:
+ import dbm
+
import locale
import re
@@ -28,7 +32,7 @@ class ServiceTypeDatabase:
def __init__(self, filename = "@pkglibdatadir@/service-types.db"):
- self.db = @DBM@.open(filename, "r")
+ self.db = dbm.open(filename, "r")
l = locale.getlocale(locale.LC_MESSAGES)
@@ -90,13 +94,24 @@ class ServiceTypeDatabase:
def __iter__(self):
- @FIRST_KEY@
- @CHECK_KEY@
+ def want_key(key):
+ if not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key):
+ return False
+ if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key):
+ return False
+ return True
- if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key) and not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key):
- yield key
-
- @NEXT_KEY@
+ try:
+ key = self.db.firstkey()
+ except AttributeError:
+ for key in self.db.keys():
+ if want_key(key):
+ yield key
+ else:
+ while key is not None:
+ if want_key(key):
+ yield key
+ key = self.db.nextkey(key)
def __len__(self):

View File

@ -0,0 +1,65 @@
$OpenBSD: patch-avahi-python_avahi___init___py,v 1.1 2018/05/16 16:18:52 ajacoutot Exp $
From ffb19d8f3c7f1fe4f31f79f8601dd3079730401b Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@debian.org>
Date: Fri, 27 Apr 2018 09:01:13 +0100
Subject: [PATCH] Remove empty avahi_discover Python module
Index: avahi-python/avahi/__init__.py
--- avahi-python/avahi/__init__.py.orig
+++ avahi-python/avahi/__init__.py
@@ -17,6 +17,8 @@
# Some definitions matching those in avahi-common/defs.h
+import sys
+
import dbus
SERVER_INVALID, SERVER_REGISTERING, SERVER_RUNNING, SERVER_COLLISION, SERVER_FAILURE = range(0, 5)
@@ -66,6 +68,9 @@ DBUS_INTERFACE_HOST_NAME_RESOLVER = DBUS_NAME + ".Host
DBUS_INTERFACE_SERVICE_RESOLVER = DBUS_NAME + ".ServiceResolver"
DBUS_INTERFACE_RECORD_BROWSER = DBUS_NAME + ".RecordBrowser"
+if sys.version_info[0] >= 3:
+ unicode = str
+
def byte_array_to_string(s):
r = ""
@@ -86,12 +91,19 @@ def txt_array_to_string_array(t):
return l
-
def string_to_byte_array(s):
+ if isinstance(s, unicode):
+ s = s.encode('utf-8')
+
r = []
for c in s:
- r.append(dbus.Byte(ord(c)))
+ if isinstance(c, int):
+ # Python 3: iterating over bytes yields ints
+ r.append(dbus.Byte(c))
+ else:
+ # Python 2: iterating over str yields str
+ r.append(dbus.Byte(ord(c)))
return r
@@ -107,6 +119,12 @@ def dict_to_txt_array(txt_dict):
l = []
for k,v in txt_dict.items():
- l.append(string_to_byte_array("%s=%s" % (k,v)))
+ if isinstance(k, unicode):
+ k = k.encode('utf-8')
+
+ if isinstance(v, unicode):
+ v = v.encode('utf-8')
+
+ l.append(string_to_byte_array(b"%s=%s" % (k,v)))
return l

View File

@ -1,9 +1,32 @@
$OpenBSD: patch-configure_ac,v 1.5 2017/07/13 07:36:39 ajacoutot Exp $
$OpenBSD: patch-configure_ac,v 1.6 2018/05/16 16:18:52 ajacoutot Exp $
1st chunk:
From 63750f1be96ad08c407193b08bf3b9ee74310e2d Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
Date: Tue, 11 Jul 2017 21:52:37 +0200
Subject: [PATCH] avahi-python: Use the agnostic DBM interface
Index: configure.ac
--- configure.ac.orig
+++ configure.ac
@@ -958,7 +958,7 @@ AC_DEFINE_UNQUOTED(AVAHI_AUTOIPD_GROUP,"$AVAHI_AUTOIPD
@@ -824,12 +824,11 @@ if test "x$HAVE_PYTHON" = "xyes" ; then
fi
AM_CHECK_PYMOD(socket,,,[AC_MSG_ERROR(Could not find Python module socket)])
- if test "x$HAVE_GDBM" = "xyes"; then
- AM_CHECK_PYMOD(gdbm,,,[AC_MSG_ERROR(Could not find Python module gdbm)])
+ if test "x$HAVE_GDBM" = "xyes" || test "x$HAVE_DBM" = "xyes"; then
+ AM_CHECK_PYMOD(anydbm,,,[
+ AM_CHECK_PYMOD(dbm,,,[AC_MSG_ERROR(Could not find Python module dbm)])
+ ])
fi
- if test "x$HAVE_DBM" = "xyes"; then
- AM_CHECK_PYMOD(dbm,,,[AC_MSG_ERROR(Could not find Python module dbm)])
- fi
fi
fi
AM_CONDITIONAL(HAVE_PYTHON, [test "x$HAVE_PYTHON" = "xyes" ])
@@ -958,7 +957,7 @@ AC_DEFINE_UNQUOTED(AVAHI_AUTOIPD_GROUP,"$AVAHI_AUTOIPD
#
# Avahi runtime dir
#

View File

@ -0,0 +1,59 @@
$OpenBSD: patch-service-type-database_Makefile_am,v 1.1 2018/05/16 16:18:52 ajacoutot Exp $
From 63750f1be96ad08c407193b08bf3b9ee74310e2d Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
Date: Tue, 11 Jul 2017 21:52:37 +0200
Subject: [PATCH] avahi-python: Use the agnostic DBM interface
Index: service-type-database/Makefile.am
--- service-type-database/Makefile.am.orig
+++ service-type-database/Makefile.am
@@ -15,7 +15,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-EXTRA_DIST=build-db.in service-types
+EXTRA_DIST=service-types
pkglibdatadir=$(libdir)/avahi
@@ -27,16 +27,11 @@ if HAVE_GDBM
noinst_SCRIPTS=build-db
pkglibdata_DATA+=service-types.db
-build-db: build-db.in
- $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
- -e 's,@DBM\@,gdbm,g' $< > $@ && \
- chmod +x $@
-
-service-types.db: service-types build-db
+service-types.db: service-types
$(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \
mv $@.coming $@
-CLEANFILES = service-types.db build-db
+CLEANFILES = service-types.db
endif
if HAVE_DBM
@@ -44,11 +39,6 @@ if HAVE_DBM
noinst_SCRIPTS=build-db
pkglibdata_DATA+=service-types.db.pag service-types.db.dir
-build-db: build-db.in
- $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
- -e 's,@DBM\@,dbm,g' $< > $@ && \
- chmod +x $@
-
service-types.db.pag: service-types.db
$(AM_V_GEN)mv service-types.db.coming.pag service-types.db.pag
service-types.db.dir: service-types.db
@@ -57,7 +47,7 @@ service-types.db: service-types build-db
$(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \
if test -f "$@.coming"; then mv $@.coming $@; fi
-CLEANFILES = service-types.db* build-db
+CLEANFILES = service-types.db*
endif
endif

View File

@ -0,0 +1,43 @@
$OpenBSD: patch-service-type-database_build-db_in,v 1.1 2018/05/16 16:18:52 ajacoutot Exp $
From 63750f1be96ad08c407193b08bf3b9ee74310e2d Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
Date: Tue, 11 Jul 2017 21:52:37 +0200
Subject: [PATCH] avahi-python: Use the agnostic DBM interface
Index: service-type-database/build-db.in
--- service-type-database/build-db.in.orig
+++ service-type-database/build-db.in
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!/usr/bin/env python
# -*-python-*-
# This file is part of avahi.
#
@@ -17,8 +17,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-import @DBM@, sys
+try:
+ import anydbm as dbm
+except ImportError:
+ import dbm
+import sys
+
if len(sys.argv) > 1:
infn = sys.argv[1]
else:
@@ -29,9 +34,9 @@ if len(sys.argv) > 2:
else:
outfn = infn + ".db"
-db = @DBM@.open(outfn, "n")
+db = dbm.open(outfn, "n")
-for ln in file(infn, "r"):
+for ln in open(infn, "r"):
ln = ln.strip(" \r\n\t")
if ln == "" or ln.startswith("#"):

View File

@ -1,14 +1,12 @@
@comment $OpenBSD: PLIST-python,v 1.1 2013/11/02 21:47:56 ajacoutot Exp $
@comment $OpenBSD: PLIST-python,v 1.2 2018/05/16 16:18:52 ajacoutot Exp $
@conflict avahi-gtk-<0.6.30p2
@conflict avahi-gui-<0.6.31p7
@conflict py-avahi-*
lib/avahi/
lib/avahi/service-types.db
lib/python${MODPY_VERSION}/site-packages/avahi/
lib/python${MODPY_VERSION}/site-packages/avahi/ServiceTypeDatabase.py
lib/python${MODPY_VERSION}/site-packages/avahi/__init__.py
lib/python${MODPY_VERSION}/site-packages/avahi/__init__.pyc
lib/python${MODPY_VERSION}/site-packages/avahi/__init__.pyo
lib/python${MODPY_VERSION}/site-packages/avahi_discover/
lib/python${MODPY_VERSION}/site-packages/avahi_discover/__init__.py
lib/python${MODPY_VERSION}/site-packages/avahi_discover/__init__.pyc
lib/python${MODPY_VERSION}/site-packages/avahi_discover/__init__.pyo
lib/python${MODPY_VERSION}/site-packages/avahi/${MODPY_PYCACHE}
lib/python${MODPY_VERSION}/site-packages/avahi/${MODPY_PYCACHE}__init__.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
lib/python${MODPY_VERSION}/site-packages/avahi/${MODPY_PYCACHE}__init__.${MODPY_PYC_MAGIC_TAG}pyc