sys-apps/lshw: add upstream fix for crashes w/Intel SGX
authorWenkai Du <wenkai.du@intel.com>
Thu, 4 Jan 2018 07:13:02 +0000 (02:13 -0500)
committerMike Frysinger <vapier@gentoo.org>
Thu, 4 Jan 2018 07:13:27 +0000 (02:13 -0500)
sys-apps/lshw/files/lshw-02.18b-sgx.patch [new file with mode: 0644]
sys-apps/lshw/lshw-02.18b-r1.ebuild [new file with mode: 0644]

diff --git a/sys-apps/lshw/files/lshw-02.18b-sgx.patch b/sys-apps/lshw/files/lshw-02.18b-sgx.patch
new file mode 100644 (file)
index 0000000..92bd6c2
--- /dev/null
@@ -0,0 +1,32 @@
+patch from upstream:
+https://ezix.org/src/pkg/lshw/commit/5e5744732b2dcdf83845919256388b3842033183
+
+From 5e5744732b2dcdf83845919256388b3842033183 Mon Sep 17 00:00:00 2001
+From: Wenkai Du <wenkai.du@intel.com>
+Date: Fri, 22 Dec 2017 09:57:57 -0800
+Subject: [PATCH] lshw: fix segmentation fault when /dev/sgx is present
+
+When Intel SGX is enabled in kernel, /dev/sgx is created and is
+picked up by "/dev/sg*" glob matching.
+
+Signed-off-by: Wenkai Du <wenkai.du@intel.com>
+---
+ src/core/scsi.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/core/scsi.cc b/src/core/scsi.cc
+index b38dda2cd8a8..75061c0fb195 100644
+--- a/src/core/scsi.cc
++++ b/src/core/scsi.cc
+@@ -30,7 +30,7 @@
+ 
+ __ID("@(#) $Id$");
+ 
+-#define SG_X "/dev/sg*"
++#define SG_X "/dev/sg[0-9]*"
+ #define SG_MAJOR 21
+ 
+ #ifndef SCSI_IOCTL_GET_PCI
+-- 
+2.15.1
+
diff --git a/sys-apps/lshw/lshw-02.18b-r1.ebuild b/sys-apps/lshw/lshw-02.18b-r1.ebuild
new file mode 100644 (file)
index 0000000..c22eab4
--- /dev/null
@@ -0,0 +1,73 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+PLOCALES='fr'
+
+inherit flag-o-matic eutils toolchain-funcs l10n
+
+MAJ_PV=${PV:0:${#PV}-1}
+MIN_PVE=${PV:0-1}
+MIN_PV=${MIN_PVE/b/B}
+
+MY_P="$PN-$MIN_PV.$MAJ_PV"
+DESCRIPTION="Hardware Lister"
+HOMEPAGE="https://www.ezix.org/project/wiki/HardwareLiSter"
+SRC_URI="https://www.ezix.org/software/files/${MY_P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~arm-linux ~x86-linux"
+IUSE="gtk sqlite static"
+
+REQUIRED_USE="static? ( !gtk )"
+
+RDEPEND="gtk? ( x11-libs/gtk+:2 )
+       sqlite? ( dev-db/sqlite:3 )"
+DEPEND="${RDEPEND}
+       gtk? ( virtual/pkgconfig )
+       sqlite? ( virtual/pkgconfig )"
+RDEPEND="${RDEPEND}
+       sys-apps/hwids"
+
+S=${WORKDIR}/${MY_P}
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-02.18b-gentoo.patch
+       "${FILESDIR}"/${PN}-02.18b-gettext-array.patch
+       "${FILESDIR}"/${PN}-02.18b-sgx.patch
+)
+
+src_prepare() {
+       epatch "${PATCHES[@]}"
+
+       l10n_find_plocales_changes "src/po" "" ".po" || die
+       sed -i \
+               -e "/^LANGUAGES =/ s/=.*/= $(l10n_get_locales)/" \
+               src/po/Makefile || die
+       sed -i \
+               -e 's:\<pkg-config\>:${PKG_CONFIG}:' \
+               src/Makefile src/gui/Makefile || die
+}
+
+src_compile() {
+       tc-export CC CXX AR PKG_CONFIG
+       use static && append-ldflags -static
+
+       # Need two sep make statements to avoid parallel build issues. #588174
+       local sqlite=$(usex sqlite 1 0)
+       emake SQLITE=${sqlite} all
+       use gtk && emake SQLITE=${sqlite} gui
+}
+
+src_install() {
+       emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" install $(usex gtk 'install-gui' '')
+       dodoc README.md docs/*
+       if use gtk ; then
+               newicon -s scalable src/gui/artwork/logo.svg gtk-lshw.svg
+               make_desktop_entry \
+                       "${EPREFIX}"/usr/sbin/gtk-lshw \
+                       "${DESCRIPTION}"
+       fi
+}