x11-misc/barrier: New package
authorJames Le Cuirot <chewi@gentoo.org>
Tue, 10 Mar 2020 23:30:59 +0000 (23:30 +0000)
committerJames Le Cuirot <chewi@gentoo.org>
Tue, 10 Mar 2020 23:30:59 +0000 (23:30 +0000)
Package-Manager: Portage-2.3.93, Repoman-2.3.20
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
x11-misc/barrier/Manifest [new file with mode: 0644]
x11-misc/barrier/barrier-2.3.2.ebuild [new file with mode: 0644]
x11-misc/barrier/files/barrier-2.3.2-pthread.patch [new file with mode: 0644]
x11-misc/barrier/metadata.xml [new file with mode: 0644]

diff --git a/x11-misc/barrier/Manifest b/x11-misc/barrier/Manifest
new file mode 100644 (file)
index 0000000..7630b04
--- /dev/null
@@ -0,0 +1 @@
+DIST barrier-2.3.2.tar.gz 7244128 BLAKE2B 263be99ffb692e5b8e3e3450565fbaf5c5e2f23beca4beaf5d699547933be1bcdcbf1ed6b9ce8bd53f2a5dbb1eba3fc06490620555520fcff0e8d34ff2ad52cb SHA512 0452244afc3294aaafd89f18d2472e24fb2fc62426e7be91ab4ffceca4697c7acb8f4438fc299835f1312f0ada83911679abe6b8e1268631130c5877e193ff83
diff --git a/x11-misc/barrier/barrier-2.3.2.ebuild b/x11-misc/barrier/barrier-2.3.2.ebuild
new file mode 100644 (file)
index 0000000..e559579
--- /dev/null
@@ -0,0 +1,73 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit desktop xdg cmake
+
+DESCRIPTION="Share a mouse and keyboard between computers (fork of Synergy)"
+HOMEPAGE="https://github.com/debauchee/barrier"
+SRC_URI="https://github.com/debauchee/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="gui libressl"
+
+RDEPEND="
+       net-misc/curl
+       x11-libs/libICE
+       x11-libs/libSM
+       x11-libs/libX11
+       x11-libs/libXext
+       x11-libs/libXi
+       x11-libs/libXinerama
+       x11-libs/libXrandr
+       x11-libs/libXtst
+       gui? (
+               dev-qt/qtcore:5
+               dev-qt/qtgui:5
+               dev-qt/qtnetwork:5
+               dev-qt/qtwidgets:5
+               net-dns/avahi[mdnsresponder-compat]
+       )
+       !libressl? ( dev-libs/openssl:0= )
+       libressl? ( dev-libs/libressl:0= )
+"
+DEPEND="
+       ${RDEPEND}
+       x11-base/xorg-proto
+"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-pthread.patch
+)
+
+DOCS=(
+       ChangeLog
+       README.md
+       doc/${PN}.conf.example{,-advanced,-basic}
+)
+
+src_configure() {
+       local mycmakeargs=(
+               -DBARRIER_BUILD_GUI=$(usex gui)
+               -DBARRIER_BUILD_INSTALLER=OFF
+               -DBARRIER_REVISION=00000000
+               -DBARRIER_VERSION_STAGE=gentoo
+       )
+
+       cmake_src_configure
+}
+
+src_install() {
+       cmake_src_install
+       einstalldocs
+       doman doc/${PN}{c,s}.1
+
+       if use gui; then
+               doicon -s scalable res/${PN}.svg
+               doicon -s 256 res/${PN}.png
+               make_desktop_entry ${PN} Barrier ${PN} Utility
+       fi
+}
diff --git a/x11-misc/barrier/files/barrier-2.3.2-pthread.patch b/x11-misc/barrier/files/barrier-2.3.2-pthread.patch
new file mode 100644 (file)
index 0000000..d298448
--- /dev/null
@@ -0,0 +1,115 @@
+From a0b3124f80f5696cbf070b3b714533ab4012398d Mon Sep 17 00:00:00 2001
+From: James Le Cuirot <chewi@gentoo.org>
+Date: Tue, 10 Mar 2020 21:10:48 +0000
+Subject: [PATCH] Use -pthread flag and simplify pthread build logic
+
+Sometimes -lpthread is not enough. This has caused build failures on
+Gentoo Linux in the past.
+
+The logic also seems needlessly complex. We check for HAVE_PTHREAD on
+UNIX platforms even though CMake errors out if pthreads are not
+found. Similarly, we have a fallback for HAVE_PTHREAD_SIGNAL being
+false even though we always set it to true.
+---
+ CMakeLists.txt                             | 11 ++++-------
+ res/config.h.in                            |  6 ------
+ src/lib/arch/Arch.h                        |  4 +---
+ src/lib/arch/unix/ArchMultithreadPosix.cpp | 13 -------------
+ 4 files changed, 5 insertions(+), 29 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 8e10776e..ae7ccb21 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -123,12 +123,10 @@ if (UNIX)
+     check_type_size (short SIZEOF_SHORT)
+     # pthread is used on both Linux and Mac
+-    check_library_exists ("pthread" pthread_create "" HAVE_PTHREAD)
+-    if (HAVE_PTHREAD)
+-        list (APPEND libs pthread)
+-    else()
+-        message (FATAL_ERROR "Missing library: pthread")
+-    endif()
++    set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
++    set (THREADS_PREFER_PTHREAD_FLAG TRUE)
++    find_package (Threads REQUIRED)
++    list (APPEND libs Threads::Threads)
+     # curl is used on both Linux and Mac
+     find_package (CURL)
+@@ -269,7 +267,6 @@ if (UNIX)
+     set (HAVE_CXX_EXCEPTIONS 1)
+     set (HAVE_CXX_MUTABLE 1)
+     set (HAVE_CXX_STDLIB 1)
+-    set (HAVE_PTHREAD_SIGNAL 1)
+     set (SELECT_TYPE_ARG1 int)
+     set (SELECT_TYPE_ARG234 " (fd_set *)")
+     set (SELECT_TYPE_ARG5 " (struct timeval *)")
+diff --git a/res/config.h.in b/res/config.h.in
+index f3a72449..2bd3b3bf 100644
+--- a/res/config.h.in
++++ b/res/config.h.in
+@@ -55,12 +55,6 @@
+ /* Define if you have a POSIX `sigwait` function. */
+ #cmakedefine HAVE_POSIX_SIGWAIT ${HAVE_POSIX_SIGWAIT}
+-/* Define if you have POSIX threads libraries and header files. */
+-#cmakedefine HAVE_PTHREAD ${HAVE_PTHREAD}
+-
+-/* Define if you have `pthread_sigmask` and `pthread_kill` functions. */
+-#cmakedefine HAVE_PTHREAD_SIGNAL ${HAVE_PTHREAD_SIGNAL}
+-
+ /* Define if your compiler defines socklen_t. */
+ #cmakedefine HAVE_SOCKLEN_T ${HAVE_SOCKLEN_T}
+diff --git a/src/lib/arch/Arch.h b/src/lib/arch/Arch.h
+index c062d6f3..940a2e3a 100644
+--- a/src/lib/arch/Arch.h
++++ b/src/lib/arch/Arch.h
+@@ -54,9 +54,7 @@
+ #    include "arch/unix/ArchConsoleUnix.h"
+ #    include "arch/unix/ArchDaemonUnix.h"
+ #    include "arch/unix/ArchLogUnix.h"
+-#    if HAVE_PTHREAD
+-#        include "arch/unix/ArchMultithreadPosix.h"
+-#    endif
++#    include "arch/unix/ArchMultithreadPosix.h"
+ #    include "arch/unix/ArchNetworkBSD.h"
+ #    include "arch/unix/ArchSleepUnix.h"
+ #    include "arch/unix/ArchStringUnix.h"
+diff --git a/src/lib/arch/unix/ArchMultithreadPosix.cpp b/src/lib/arch/unix/ArchMultithreadPosix.cpp
+index c9ddc6ce..4866edce 100644
+--- a/src/lib/arch/unix/ArchMultithreadPosix.cpp
++++ b/src/lib/arch/unix/ArchMultithreadPosix.cpp
+@@ -36,17 +36,6 @@
+ #define SIGWAKEUP SIGUSR1
+-#if !HAVE_PTHREAD_SIGNAL
+-    // boy, is this platform broken.  forget about pthread signal
+-    // handling and let signals through to every process.  barrier
+-    // will not terminate cleanly when it gets SIGTERM or SIGINT.
+-#    define pthread_sigmask sigprocmask
+-#    define pthread_kill(tid_, sig_) kill(0, (sig_))
+-#    define sigwait(set_, sig_)
+-#    undef HAVE_POSIX_SIGWAIT
+-#    define HAVE_POSIX_SIGWAIT 1
+-#endif
+-
+ static
+ void
+ setSignalSet(sigset_t* sigset)
+@@ -344,9 +333,7 @@ ArchMultithreadPosix::newThread(ThreadFunc func, void* data)
+     // can't tell the difference.
+     if (!m_newThreadCalled) {
+         m_newThreadCalled = true;
+-#if HAVE_PTHREAD_SIGNAL
+         startSignalHandler();
+-#endif
+     }
+     // note that the child thread will wait until we release this mutex
+-- 
+2.24.1
+
diff --git a/x11-misc/barrier/metadata.xml b/x11-misc/barrier/metadata.xml
new file mode 100644 (file)
index 0000000..4ec6c62
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+       <maintainer type="person">
+               <email>chewi@gentoo.org</email>
+               <name>James Le Cuirot</name>
+       </maintainer>
+       <upstream>
+               <remote-id type="github">debauchee/barrier</remote-id>
+       </upstream>
+</pkgmetadata>