dev-vcs/tig: fix segfault with split tinfo lib (bug #614590)
authorTim Harder <radhermit@gentoo.org>
Wed, 12 Apr 2017 07:46:59 +0000 (03:46 -0400)
committerTim Harder <radhermit@gentoo.org>
Wed, 12 Apr 2017 07:50:28 +0000 (03:50 -0400)
dev-vcs/tig/files/tig-2.2.1-termcap-tinfo.patch [new file with mode: 0644]
dev-vcs/tig/tig-2.2.1-r1.ebuild [new file with mode: 0644]

diff --git a/dev-vcs/tig/files/tig-2.2.1-termcap-tinfo.patch b/dev-vcs/tig/files/tig-2.2.1-termcap-tinfo.patch
new file mode 100644 (file)
index 0000000..4b3df2e
--- /dev/null
@@ -0,0 +1,56 @@
+From c4aded6c8f63471b30fe171072e11407929301ac Mon Sep 17 00:00:00 2001
+From: Tim Harder <radhermit@gmail.com>
+Date: Tue, 11 Apr 2017 05:17:52 -0400
+Subject: [PATCH] Check for termcap support in split tinfo libs
+
+Previously only the main ncurses libs were checked leading to users with
+enabled unicode support (ncursesw) and split tinfo libs running into
+segfaults since the checks would fallback to setting TERMCAP_LIB=-lcurses.
+
+Fixes #568.
+---
+ tools/ax_lib_readline.m4 | 16 +++++++++++-----
+ 1 file changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/tools/ax_lib_readline.m4 b/tools/ax_lib_readline.m4
+index 1be9125..24ca194 100644
+--- a/tools/ax_lib_readline.m4
++++ b/tools/ax_lib_readline.m4
+@@ -34,16 +34,19 @@ fi
+ AC_CACHE_VAL(bash_cv_termcap_lib,
+ [AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc,
+ if test "$ax_cv_curses_which" = "ncursesw"; then
+-      [AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw)]
++      [AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw,
++              [AC_CHECK_LIB(tinfow, tgetent, bash_cv_termcap_lib=libtinfow)]
++      )]
+ elif test "$ax_cv_curses_which" = "ncurses"; then
+-      [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses)]
++      [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
++              [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo)]
++      )]
+ elif test "$ax_cv_curses_which" = "plaincurses"; then
+       [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses)]
+ else
+       [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
+-              [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
+-                      bash_cv_termcap_lib=gnutermcap
+-      )])]
++              bash_cv_termcap_lib=gnutermcap
++      )]
+ fi
+ )])
+ if test "X$_bash_needmsg" = "Xyes"; then
+@@ -57,6 +60,9 @@ TERMCAP_DEP="./lib/termcap/libtermcap.a"
+ elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
+ TERMCAP_LIB=-ltermcap
+ TERMCAP_DEP=
++elif test $bash_cv_termcap_lib = libtinfow; then
++TERMCAP_LIB=-ltinfow
++TERMCAP_DEP=
+ elif test $bash_cv_termcap_lib = libtinfo; then
+ TERMCAP_LIB=-ltinfo
+ TERMCAP_DEP=
+-- 
+2.12.0
+
diff --git a/dev-vcs/tig/tig-2.2.1-r1.ebuild b/dev-vcs/tig/tig-2.2.1-r1.ebuild
new file mode 100644 (file)
index 0000000..0947cba
--- /dev/null
@@ -0,0 +1,61 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit autotools bash-completion-r1
+
+if [[ ${PV} == "9999" ]] ; then
+       EGIT_REPO_URI="https://github.com/jonas/tig.git"
+       inherit git-r3 autotools
+else
+       SRC_URI="https://github.com/jonas/tig/releases/download/${P}/${P}.tar.gz"
+       KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos"
+fi
+
+DESCRIPTION="text mode interface for git"
+HOMEPAGE="https://jonas.github.io/tig/"
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="unicode"
+
+DEPEND="
+       sys-libs/ncurses:0=[unicode?]
+       sys-libs/readline:0="
+RDEPEND="${DEPEND}
+       dev-vcs/git"
+[[ ${PV} == "9999" ]] && DEPEND+=" app-text/asciidoc"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-2.2.1-tinfo.patch
+       "${FILESDIR}"/${PN}-2.2.1-termcap-tinfo.patch
+)
+
+src_prepare() {
+       default
+       eautoreconf
+}
+
+src_configure() {
+       econf $(use_with unicode ncursesw)
+}
+
+src_compile() {
+       emake V=1
+       [[ ${PV} == "9999" ]] && emake V=1 doc-man doc-html
+}
+
+src_test() {
+       # workaround parallel test failures
+       emake -j1 test
+}
+
+src_install() {
+       emake DESTDIR="${D}" install install-doc-man
+       dodoc doc/manual.html README.html NEWS.html
+       newbashcomp contrib/tig-completion.bash ${PN}
+
+       docinto examples
+       dodoc contrib/*.tigrc
+}