main/avahi: add python module, cleanup

this is needed for kodi
This commit is contained in:
psykose 2023-04-08 03:45:38 +00:00
parent 1a9b769553
commit 3c7818a771
3 changed files with 218 additions and 20 deletions

View File

@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=avahi
pkgver=0.8
pkgrel=9
pkgrel=10
pkgdesc="multicast/unicast DNS-SD framework"
url="https://www.avahi.org/"
arch="all"
@ -24,6 +24,10 @@ makedepends="
libdaemon-dev
libevent-dev
libtool
py3-dbus
py3-gobject3-dev
python3-dev
python3-gdbm
"
install="$pkgname.pre-install"
subpackages="
@ -32,6 +36,7 @@ subpackages="
$pkgname-tools
$pkgname-glib
$pkgname-libs
py3-avahi:py3
$pkgname-compat-howl:howl
$pkgname-compat-libdns_sd:lidns_sd
$pkgname-lang
@ -40,6 +45,8 @@ subpackages="
source="https://github.com/lathiat/avahi/releases/download/v$pkgver/avahi-$pkgver.tar.gz
CVE-2021-3468.patch
CVE-2021-3502.patch
Fetch-build-db-from-upstream-git.patch
build-db-Use-the-same-database-format-that-the-C-code-exp.patch
"
# secfixes:
@ -79,7 +86,7 @@ build() {
--disable-xmltoman \
--enable-compat-libdns_sd \
--enable-compat-howl \
--disable-python \
--enable-python \
--with-dbus-sys=/usr/share/dbus-1/system.d \
--with-distro="gentoo"
make
@ -97,53 +104,61 @@ package() {
ln -s avahi-compat-howl.pc "$pkgdir"/usr/lib/pkgconfig/howl.pc
ln -s avahi-compat-libdns_sd.pc "$pkgdir"/usr/lib/pkgconfig/libdns_sd.pc
ln -s avahi-compat-libdns_sd/dns_sd.h "$pkgdir"/usr/include/
# XXX these are added since the python support, but are broken
rm -v "$pkgdir"/usr/bin/avahi-bookmarks
rm -v "$pkgdir"/usr/bin/avahi-discover
rm -v "$pkgdir"/usr/share/applications/avahi-discover.desktop
rmdir -p "$pkgdir"/usr/share/applications/ || true
}
tools() {
pkgdesc="Command line tools for mDNS browsing and publishing"
mkdir -p "$subpkgdir"/usr/bin
cd "$pkgdir"/usr/bin
mv avahi-browse* avahi-publish* avahi-resolve* avahi-set* \
"$subpkgdir"/usr/bin/
amove \
usr/bin/avahi-browse* \
usr/bin/avahi-publish* \
usr/bin/avahi-resolve* \
usr/bin/avahi-set*
}
glib() {
pkgdesc="Glib libraries and GObject wrapper for avahi"
mkdir -p "$subpkgdir"/usr/lib
mv "$pkgdir"/usr/lib/libavahi-glib.so.* \
"$pkgdir"/usr/lib/libavahi-gobject.so.* \
"$subpkgdir"/usr/lib/
amove usr/lib/libavahi-glib.so.* \
usr/lib/libavahi-gobject.so.*
}
libs() {
pkgdesc="Libraries for avahi run-time use"
mkdir -p "$subpkgdir"/usr/lib
mv "$pkgdir"/usr/lib/libavahi-common.so.* \
"$pkgdir"/usr/lib/libavahi-client.so.* \
"$subpkgdir"/usr/lib/
amove usr/lib/libavahi-common.so.* \
usr/lib/libavahi-client.so.*
}
howl() {
pkgdesc="Libraries for howl compatibility"
mkdir -p "$subpkgdir"/usr/lib
mv "$pkgdir"/usr/lib/libhowl.so.* \
"$subpkgdir"/usr/lib/
amove usr/lib/libhowl.so.*
}
lidns_sd() {
pkgdesc="Libraries for Apple Bonjour mDNSResponder compatibility"
mkdir -p "$subpkgdir"/usr/lib
mv "$pkgdir"/usr/lib/libdns_sd.so.* \
"$subpkgdir"/usr/lib/
amove usr/lib/libdns_sd.so.*
}
py3() {
pkgdesc="Python Avahi module"
depends="py3-dbus python3"
amove usr/lib/python*
}
sha512sums="
c6ba76feb6e92f70289f94b3bf12e5f5c66c11628ce0aeb3cadfb72c13a5d1a9bd56d71bdf3072627a76cd103b9b056d9131aa49ffe11fa334c24ab3b596c7de avahi-0.8.tar.gz
743430a532b8ec246672cd0997b7831efc15c461cbfe0461faac5d6525293297efb7c06f759b2bcd71d1842ba165464fd334508534e6c247211d613061c49da5 CVE-2021-3468.patch
9e4688ffd8e512c0f614fd24fff2a2a1c66e009069229a6f81dcd382edfff5a8635e0551533c7f9271973a87e62e199fdb34a5560dab27c0a328f531c94f757d CVE-2021-3502.patch
302db5f4c8339b7f074aa4b2f2e8108e33e128db26f10a201a63bd09f9c2bde600929e586e00d7f7c448019eefbc3e97eb8b419079253f5f4fb60e477a577fa1 Fetch-build-db-from-upstream-git.patch
e4e923dbaa0c729a8685b71f1487f337fd7c68b464b04643127a2f7a3a34b24f87869c9c185632229b25f350425ea979ddb329eda043548d55ae86f5c905dd11 build-db-Use-the-same-database-format-that-the-C-code-exp.patch
"

View File

@ -0,0 +1,74 @@
Patch-Source: https://salsa.debian.org/utopia-team/avahi/-/blob/b1a3a539ac0b6d79a7a0b87dccbb99028e10ec63/debian/patches/Fetch-build-db-from-upstream-git.patch
this is needed when building python
--
From: Andreas Henriksson <andreas@fatal.se>
Date: Sat, 26 Oct 2019 15:49:35 +0200
Subject: Fetch build-db from upstream git
Fetch the build-db file from:
https://raw.githubusercontent.com/lathiat/avahi/master/service-type-database/build-db
This file is missing dist tarball, likely caused by changes in:
https://github.com/lathiat/avahi/pull/134
Carry it as a patch for now.
---
service-type-database/build-db | 49 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100755 service-type-database/build-db
diff --git a/service-type-database/build-db b/service-type-database/build-db
new file mode 100755
index 0000000..78ee892
--- /dev/null
+++ b/service-type-database/build-db
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# -*-python-*-
+# This file is part of avahi.
+#
+# avahi is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# avahi 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 Lesser General Public
+# License along with avahi; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+try:
+ import anydbm as dbm
+except ImportError:
+ import dbm
+
+import sys
+
+if len(sys.argv) > 1:
+ infn = sys.argv[1]
+else:
+ infn = "service-types"
+
+if len(sys.argv) > 2:
+ outfn = sys.argv[2]
+else:
+ outfn = infn + ".db"
+
+db = dbm.open(outfn, "n")
+
+for ln in open(infn, "r"):
+ ln = ln.strip(" \r\n\t")
+
+ if ln == "" or ln.startswith("#"):
+ continue
+
+ t, n = ln.split(":", 1)
+
+ db[t.strip()] = n.strip()
+
+db.close()

View File

@ -0,0 +1,109 @@
Patch-Source: https://salsa.debian.org/utopia-team/avahi/-/blob/b1a3a539ac0b6d79a7a0b87dccbb99028e10ec63/debian/patches/build-db-Use-the-same-database-format-that-the-C-code-exp.patch
this is needed to build the python module
--
From: Simon McVittie <smcv@debian.org>
Date: Thu, 7 May 2020 12:13:56 +0100
Subject: build-db: Use the same database format that the C code expects
Otherwise, Python 2 anydbm will preferentially choose Berkeley DB format
(dbhash/bsddb), which is neither GNU gdbm nor traditional Unix (n)dbm.
Signed-off-by: Simon McVittie <smcv@debian.org>
Fixes: https://github.com/lathiat/avahi/issues/260
---
configure.ac | 11 ++++++++---
service-type-database/Makefile.am | 4 ++--
service-type-database/build-db | 27 +++++++++++++++++++++------
3 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac
index 58db8c7..5aea4e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -871,9 +871,14 @@ 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" || test "x$HAVE_DBM" = "xyes"; then
- AM_CHECK_PYMOD(anydbm,,,[
- AM_CHECK_PYMOD(dbm,,,[AC_MSG_ERROR(Could not find Python module dbm)])
+ if test "x$HAVE_GDBM" = "xyes"; then
+ AM_CHECK_PYMOD([dbm.gnu], [], [], [
+ AM_CHECK_PYMOD([gdbm], [], [], [AC_MSG_ERROR(Could not find Python module dbm.gnu or gdbm)])
+ ])
+ fi
+ if test "x$HAVE_DBM" = "xyes"; then
+ AM_CHECK_PYMOD([dbm.ndbm], [], [], [
+ AM_CHECK_PYMOD([dbm], [], [], [AC_MSG_ERROR(Could not find Python module dbm.ndbm or dbm)])
])
fi
fi
diff --git a/service-type-database/Makefile.am b/service-type-database/Makefile.am
index f9fa082..0ead0f6 100644
--- a/service-type-database/Makefile.am
+++ b/service-type-database/Makefile.am
@@ -28,7 +28,7 @@ noinst_SCRIPTS=build-db
pkglibdata_DATA+=service-types.db
service-types.db: service-types
- $(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \
+ $(AM_V_GEN)$(PYTHON) build-db --gnu $< $@.coming && \
mv $@.coming $@
CLEANFILES = service-types.db
@@ -44,7 +44,7 @@ service-types.db.pag: service-types.db
service-types.db.dir: service-types.db
$(AM_V_GEN)mv service-types.db.coming.dir service-types.db.dir
service-types.db: service-types build-db
- $(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \
+ $(AM_V_GEN)$(PYTHON) build-db --ndbm $< $@.coming && \
if test -f "$@.coming"; then mv $@.coming $@; fi
CLEANFILES = service-types.db*
diff --git a/service-type-database/build-db b/service-type-database/build-db
index 78ee892..6415d27 100755
--- a/service-type-database/build-db
+++ b/service-type-database/build-db
@@ -17,13 +17,28 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-try:
- import anydbm as dbm
-except ImportError:
- import dbm
-
import sys
+if sys.argv[1] == '--gnu':
+ if sys.version_info >= (3,):
+ import dbm.gnu as chosen_dbm
+ else:
+ import gdbm as chosen_dbm
+
+ sys.argv[1:] = sys.argv[2:]
+elif sys.argv[1] == '--ndbm':
+ if sys.version_info >= (3,):
+ import dbm.ndbm as chosen_dbm
+ else:
+ import dbm as chosen_dbm
+
+ sys.argv[1:] = sys.argv[2:]
+else:
+ if sys.version_info >= (3,):
+ import dbm as chosen_dbm
+ else:
+ import anydbm as chosen_dbm
+
if len(sys.argv) > 1:
infn = sys.argv[1]
else:
@@ -34,7 +49,7 @@ if len(sys.argv) > 2:
else:
outfn = infn + ".db"
-db = dbm.open(outfn, "n")
+db = chosen_dbm.open(outfn, "n")
for ln in open(infn, "r"):
ln = ln.strip(" \r\n\t")