From 69c37865464916e6a0aa54c88766581375f38dc0 Mon Sep 17 00:00:00 2001 From: BtbN Date: Mon, 23 Aug 2021 02:27:46 +0200 Subject: [PATCH] Add libzvbi Patches and build-mess based on VLC contrib: https://github.com/videolan/vlc/tree/master/contrib/src/zvbi --- patches/zvbi/0000-ssize_max.patch | 28 ++++ patches/zvbi/0001-ioctl.patch | 19 +++ patches/zvbi/0002-fix-static-linking.patch | 11 ++ patches/zvbi/0003-win32.patch | 167 +++++++++++++++++++++ patches/zvbi/0004-fix-clang-support.patch | 30 ++++ scripts.d/50-zvbi.sh | 61 ++++++++ 6 files changed, 316 insertions(+) create mode 100644 patches/zvbi/0000-ssize_max.patch create mode 100644 patches/zvbi/0001-ioctl.patch create mode 100644 patches/zvbi/0002-fix-static-linking.patch create mode 100644 patches/zvbi/0003-win32.patch create mode 100644 patches/zvbi/0004-fix-clang-support.patch create mode 100755 scripts.d/50-zvbi.sh diff --git a/patches/zvbi/0000-ssize_max.patch b/patches/zvbi/0000-ssize_max.patch new file mode 100644 index 0000000..eb980a6 --- /dev/null +++ b/patches/zvbi/0000-ssize_max.patch @@ -0,0 +1,28 @@ +Linear memory extents over SSIZE_MAX are undefined, so there is no +point in protecting against them. +diff -ru zvbi.orig/src/export.c zvbi/src/export.c +--- zvbi.orig/src/export.c 2011-11-06 11:22:47.000000000 +0200 ++++ zvbi/src/export.c 2011-11-06 11:27:39.000000000 +0200 +@@ -1076,8 +1076,6 @@ + size_t count; + + count = src_size; +- if (unlikely (src_size > SSIZE_MAX)) +- count = SSIZE_MAX & -4096; + + for (retry = 10;; --retry) { + actual = write (e->_handle.fd, src, count); +@@ -1632,12 +1630,7 @@ + free (e->buffer.data); + } + +- if (unlikely (e->buffer.offset > (size_t) SSIZE_MAX)) { +- errno = EOVERFLOW; +- actual = -1; /* failed */ +- } else { +- actual = e->buffer.offset; +- } ++ actual = e->buffer.offset; + } else { + if (VBI_EXPORT_TARGET_ALLOC == e->target) + free (e->buffer.data); diff --git a/patches/zvbi/0001-ioctl.patch b/patches/zvbi/0001-ioctl.patch new file mode 100644 index 0000000..2b0e42d --- /dev/null +++ b/patches/zvbi/0001-ioctl.patch @@ -0,0 +1,19 @@ +diff -ru zvbi.orig/contrib/ntsc-cc.c zvbi/contrib/ntsc-cc.c +--- zvbi.orig/contrib/ntsc-cc.c 2011-11-06 11:22:47.000000000 +0200 ++++ zvbi/contrib/ntsc-cc.c 2011-11-06 11:29:04.000000000 +0200 +@@ -32,7 +32,6 @@ + #include + #include + #include +-#include + #include + #include + #ifdef HAVE_GETOPT_LONG +@@ -44,6 +43,7 @@ + #include "src/libzvbi.h" + + #ifdef ENABLE_V4L2 ++# include + # include + # include "src/videodev2k.h" + #endif diff --git a/patches/zvbi/0002-fix-static-linking.patch b/patches/zvbi/0002-fix-static-linking.patch new file mode 100644 index 0000000..03ff7c5 --- /dev/null +++ b/patches/zvbi/0002-fix-static-linking.patch @@ -0,0 +1,11 @@ +--- zvbi/configure.in 2013-08-28 13:52:48.000000000 +0000 ++++ zvbi.patched/configure.in 2016-11-02 21:25:34.292580446 +0000 +@@ -244,7 +244,7 @@ + dnl + HAVE_PNG="yes" + AC_CHECK_LIB(png, png_destroy_write_struct, +- LIBS="$LIBS -lpng -lz", HAVE_PNG="no", -lz -lm) ++ LIBS="-lpng -lz $LIBS", HAVE_PNG="no", -lz -lm) + if test "x$HAVE_PNG" = xyes; then + AC_DEFINE(HAVE_LIBPNG, 1, [Define if you have libpng]) + fi diff --git a/patches/zvbi/0003-win32.patch b/patches/zvbi/0003-win32.patch new file mode 100644 index 0000000..76e3ef6 --- /dev/null +++ b/patches/zvbi/0003-win32.patch @@ -0,0 +1,167 @@ +diff -ruN zvbi/src/conv.c zvbi.new/src/conv.c +--- zvbi/src/conv.c 2008-02-26 15:39:23.000000000 +0100 ++++ zvbi.new/src/conv.c 2008-09-11 21:05:18.000000000 +0200 +@@ -26,7 +26,9 @@ + #endif + + #include ++#ifndef _WIN32 + #include ++#endif + + #include "misc.h" + #include "conv.h" +@@ -1234,9 +1236,12 @@ + const char *dst_format; + + dst_format = bind_textdomain_codeset (vbi_intl_domainname, NULL); +- ++#ifdef _WIN32 ++#warning this is wrong ++#else + if (NULL == dst_format) + dst_format = nl_langinfo (CODESET); ++#endif + + return dst_format; /* may be NULL */ + } +diff -ruN zvbi/src/export.c zvbi.new/src/export.c +--- zvbi/src/export.c 2008-02-19 01:35:15.000000000 +0100 ++++ zvbi.new/src/export.c 2008-09-11 20:38:55.000000000 +0200 +@@ -40,6 +40,26 @@ + #include "conv.h" + #include "vbi.h" /* asprintf */ + ++#ifndef EOVERFLOW ++ #define EOVERFLOW 75 ++#endif ++ ++#ifndef S_IRGRP ++#define S_IRGRP 0 ++#endif ++ ++#ifndef S_IWGRP ++#define S_IWGRP 0 ++#endif ++ ++#ifndef S_IROTH ++#define S_IROTH 0 ++#endif ++ ++#ifndef S_IWOTH ++#define S_IWOTH 0 ++#endif ++ + extern const char _zvbi_intl_domainname[]; + + /** +diff -ruN zvbi/src/packet.c zvbi.new/src/packet.c +--- zvbi/src/packet.c 2008-02-20 18:04:33.000000000 +0100 ++++ zvbi.new/src/packet.c 2008-09-11 21:00:35.000000000 +0200 +@@ -32,7 +32,9 @@ + #include + #include + #include ++#ifndef _WIN32 + #include ++#endif + + #include "misc.h" + #include "hamm.h" +diff -ruN zvbi/src/proxy-msg.c zvbi.new/src/proxy-msg.c +--- zvbi/src/proxy-msg.c 2008-02-19 01:35:21.000000000 +0100 ++++ zvbi.new/src/proxy-msg.c 2008-09-11 21:00:07.000000000 +0200 +@@ -129,7 +129,9 @@ + #include + #include + #include ++#ifndef _WIN32 + #include ++#endif + #include + #include + #include +diff -ruN zvbi/src/proxy-msg.h zvbi.new/src/proxy-msg.h +--- zvbi/src/proxy-msg.h 2008-02-19 01:35:21.000000000 +0100 ++++ zvbi.new/src/proxy-msg.h 2008-09-11 20:59:40.000000000 +0200 +@@ -68,7 +68,9 @@ + #ifndef PROXY_MSG_H + #define PROXY_MSG_H + ++#ifndef _WIN32 + #include ++#endif + + /* Public */ + +diff -ruN zvbi/src/vbi.c zvbi.new/src/vbi.c +--- zvbi/src/vbi.c 2008-03-05 14:33:04.000000000 +0100 ++++ zvbi.new/src/vbi.c 2008-09-11 20:57:55.000000000 +0200 +@@ -39,7 +39,9 @@ + #include + #include + #include ++#ifndef _WIN32 + #include ++#endif + #include + #include + +--- zvbi/src/io.c 2008-02-19 01:35:20.000000000 +0100 ++++ zvbi2/src/io.c 2008-09-11 21:18:59.000000000 +0200 +@@ -28,8 +28,10 @@ + + #include /* open() */ + #include /* close(), mmap(), munmap(), gettimeofday() */ ++#ifndef _WIN32 + #include /* ioctl() */ + #include /* mmap(), munmap() */ ++#endif + #include /* struct timeval */ + #include + #include +@@ -514,7 +516,7 @@ + } + } + +- ++#ifndef _WIN32 + /** + * @internal + * +@@ -554,7 +556,7 @@ + return ret; + } + } +- ++#endif + /* Helper functions to log the communication between the library and drivers. + FIXME remove fp arg, call user log function instead (0.3). */ + +@@ -668,7 +670,9 @@ + "EXCL", O_EXCL, + "TRUNC", O_TRUNC, + "APPEND", O_APPEND, ++#ifndef _WIN32 + "NONBLOCK", O_NONBLOCK, ++#endif + 0); + fprintf (fp, ", 0%o)", mode); + +@@ -773,6 +777,7 @@ + return err; + } + ++#ifndef _WIN32 + /** + * @internal + * Drop-in for mmap(). Logs the request on fp if not NULL. +@@ -822,7 +827,7 @@ + + return r; + } +- ++#endif + /** + * @internal + * Drop-in for munmap(). Logs the request on fp if not NULL. diff --git a/patches/zvbi/0004-fix-clang-support.patch b/patches/zvbi/0004-fix-clang-support.patch new file mode 100644 index 0000000..ca83c55 --- /dev/null +++ b/patches/zvbi/0004-fix-clang-support.patch @@ -0,0 +1,30 @@ +diff -ru zvbi/src/misc.h zvbi-fixed/src/misc.h +--- zvbi/src/misc.h 2013-07-02 04:32:31.000000000 +0200 ++++ zvbi-fixed/src/misc.h 2013-08-08 21:37:22.000000000 +0200 +@@ -52,17 +52,6 @@ + # define unlikely(expr) __builtin_expect(expr, 0) + #endif + +-#undef __i386__ +-#undef __i686__ +-/* FIXME #cpu is deprecated +-#if #cpu (i386) +-# define __i386__ 1 +-#endif +-#if #cpu (i686) +-# define __i686__ 1 +-#endif +-*/ +- + /* &x == PARENT (&x.tm_min, struct tm, tm_min), + safer than &x == (struct tm *) &x.tm_min. A NULL _ptr is safe and + will return NULL, not -offsetof(_member). */ +@@ -156,8 +145,6 @@ + + #define likely(expr) (expr) + #define unlikely(expr) (expr) +-#undef __i386__ +-#undef __i686__ + + static char * + PARENT_HELPER (char *p, unsigned int offset) diff --git a/scripts.d/50-zvbi.sh b/scripts.d/50-zvbi.sh new file mode 100755 index 0000000..f3670ce --- /dev/null +++ b/scripts.d/50-zvbi.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +ZVBI_REPO="https://svn.code.sf.net/p/zapping/svn/trunk/vbi" +ZVBI_REV="4270" + +ffbuild_enabled() { + return 0 +} + +ffbuild_dockerstage() { + to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=patches/zvbi,dst=/patches run_stage /stage.sh" +} + +ffbuild_dockerbuild() { + svn checkout "${ZVBI_REPO}@${ZVBI_REV}" zvbi + cd zvbi + + for patch in /patches/*.patch; do + echo "Applying $patch" + patch -p1 < "$patch" + done + + autoreconf -i + + local myconf=( + --prefix="$FFBUILD_PREFIX" + --disable-shared + --enable-static + --with-pic + --without-doxygen + --without-x + --disable-dvb + --disable-bktr + --disable-nls + --disable-proxy + ) + + if [[ $TARGET == win* || $TARGET == linux* ]]; then + myconf+=( + --host="$FFBUILD_TOOLCHAIN" + ) + else + echo "Unknown target" + return -1 + fi + + ./configure "${myconf[@]}" + make -C src -j$(nproc) + make -C src install + make SUBDIRS=. install + + sed -i "s/\/[^ ]*libiconv.a/-liconv/" "$FFBUILD_PREFIX"/lib/pkgconfig/zvbi-0.2.pc +} + +ffbuild_configure() { + echo --enable-libzvbi +} + +ffbuild_unconfigure() { + echo --disable-libzvbi +}