dtc: upgraded to 1.5.0

Needed for new QEMU.

NB: added tc-export for PKG_CONFIG to account for
https://crrev.com/c/1715466. Sent upstream here:

https://github.com/gentoo/gentoo/pull/16611

BUG=chromium:1099508
TEST=build

Change-Id: Ic6a7664d04ae7d93f316d03e2702811f6016101b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2278488
Tested-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Brian Norris <briannorris@chromium.org>
diff --git a/sys-apps/dtc/Manifest b/sys-apps/dtc/Manifest
index 0803f93..1eaeede 100644
--- a/sys-apps/dtc/Manifest
+++ b/sys-apps/dtc/Manifest
@@ -1 +1 @@
-DIST dtc-1.4.1.tar.xz 107920 SHA256 77992ad8eac7b68f553d0ba58e5b51604ac803d126196c99e3ae38aaae28bb94 SHA512 63df730e65f62b8c9648cfee5461809188f4198cbf98de25fbe5cb7f2f43c405266abb740501740f59847dc6faf0588bcbc734d08ae5430b05c2601e070d6d05 WHIRLPOOL 93e9ed26024e4650bb2de6323ea639a3e52622aa3891a9f9404959b600d2c1cbc633d18e30d3629ac54ae662e8c58a7d0ca7910a9b323cd8dd4ff6e43a3fdf67
+DIST dtc-1.5.0.tar.xz 152936 BLAKE2B 4ad9cf8f8fd0ccde0c7b8b66c0039eb9b012ed26e51387c06c03fa7950ca194878bbb23b50be5b80c4d4e18140d6316092a9f0eea87e5d713856635dcfc1b0ec SHA512 fd1e692a1b7bf7987f921ad17d9be6719f7b3aa7915873b45fa86f4ecb1398a0a62cdf53c1fddf98a0f7fed9bf34a79f684018bd01a2b5e88746b50879bf7102
diff --git a/sys-apps/dtc/dtc-1.4.1-r1.ebuild b/sys-apps/dtc/dtc-1.4.1-r1.ebuild
deleted file mode 100644
index b7529f3..0000000
--- a/sys-apps/dtc/dtc-1.4.1-r1.ebuild
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/dtc/dtc-1.4.1-r1.ebuild,v 1.1 2015/05/06 05:57:23 vapier Exp $
-
-EAPI="4"
-
-inherit multilib toolchain-funcs eutils
-if [[ ${PV} == "9999" ]] ; then
-	EGIT_REPO_URI="git://git.kernel.org/pub/scm/utils/dtc/dtc.git"
-	inherit git-2
-else
-	SRC_URI="mirror://kernel/software/utils/${PN}/${P}.tar.xz"
-	KEYWORDS="*"
-fi
-
-DESCRIPTION="Open Firmware device tree compiler"
-HOMEPAGE="http://devicetree.org/Device_Tree_Compiler"
-
-LICENSE="GPL-2"
-SLOT="0"
-IUSE="static-libs"
-
-RDEPEND=""
-DEPEND="app-arch/xz-utils
-	sys-devel/flex
-	sys-devel/bison"
-
-src_prepare() {
-	epatch "${FILESDIR}"/${P}-missing-syms.patch
-	epatch "${FILESDIR}"/${P}-echo-n.patch
-	sed -i \
-		-e '/^CFLAGS =/s:=:+=:' \
-		-e '/^CPPFLAGS =/s:=:+=:' \
-		-e 's:-Werror::' \
-		-e 's:-g -Os::' \
-		-e "/^PREFIX =/s:=.*:= ${EPREFIX}/usr:" \
-		-e "/^LIBDIR =/s:=.*:= \$(PREFIX)/$(get_libdir):" \
-		Makefile || die
-	tc-export AR CC
-	export V=1
-}
-
-src_test() {
-	# Enable parallel tests.
-	emake check
-}
-
-src_install() {
-	default
-	use static-libs || find "${ED}" -name '*.a' -delete
-	dodoc Documentation/manual.txt
-}
diff --git a/sys-apps/dtc/dtc-1.5.0.ebuild b/sys-apps/dtc/dtc-1.5.0.ebuild
new file mode 100644
index 0000000..e22e84f
--- /dev/null
+++ b/sys-apps/dtc/dtc-1.5.0.ebuild
@@ -0,0 +1,58 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+inherit multilib toolchain-funcs eutils
+
+if [[ ${PV} == "9999" ]] ; then
+	EGIT_REPO_URI="git://git.kernel.org/pub/scm/utils/dtc/dtc.git"
+	inherit git-r3
+else
+	SRC_URI="https://www.kernel.org/pub/software/utils/${PN}/${P}.tar.xz"
+	KEYWORDS="*"
+fi
+
+DESCRIPTION="Open Firmware device tree compiler"
+HOMEPAGE="https://devicetree.org/ https://git.kernel.org/cgit/utils/dtc/dtc.git/"
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="static-libs"
+
+DEPEND="
+	sys-devel/bison
+	sys-devel/flex
+"
+DOCS="
+	Documentation/dt-object-internal.txt
+	Documentation/dts-format.txt
+	Documentation/manual.txt
+"
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-1.4.4-posix-shell.patch
+	"${FILESDIR}"/${PN}-1.5.0-fdt_check_full-visibility.patch
+	"${FILESDIR}"/${PN}-1.5.0-gcc-10.patch
+)
+
+src_prepare() {
+	default
+
+	sed -i \
+		-e '/^CFLAGS =/s:=:+=:' \
+		-e '/^CPPFLAGS =/s:=:+=:' \
+		-e 's:-Werror::' \
+		-e 's:-g -Os::' \
+		-e "/^PREFIX =/s:=.*:= ${EPREFIX}/usr:" \
+		-e "/^LIBDIR =/s:=.*:= \$(PREFIX)/$(get_libdir):" \
+		Makefile || die
+
+	tc-export AR CC PKG_CONFIG
+	export V=1
+}
+
+src_install() {
+	default
+
+	use static-libs || find "${ED}" -name '*.a' -delete
+}
diff --git a/sys-apps/dtc/files/dtc-1.4.1-echo-n.patch b/sys-apps/dtc/files/dtc-1.4.1-echo-n.patch
deleted file mode 100644
index cd45b95..0000000
--- a/sys-apps/dtc/files/dtc-1.4.1-echo-n.patch
+++ /dev/null
@@ -1,95 +0,0 @@
-From ed3d76cd1c8f91f5e86424e899448d6221b0f76c Mon Sep 17 00:00:00 2001
-From: Mike Frysinger <vapier@chromium.org>
-Date: Wed, 6 May 2015 01:53:39 -0400
-Subject: [PATCH] tests: convert `echo -n` to `printf`
-
-The -n option is not standard in POSIX, so convert to printf which should
-work the same in every shell.
-
-Signed-off-by: Mike Frysinger <vapier@chromium.org>
----
- tests/run_tests.sh | 20 ++++++++++----------
- 1 file changed, 10 insertions(+), 10 deletions(-)
-
-diff --git a/tests/run_tests.sh b/tests/run_tests.sh
-index c870432..0dda54a 100755
---- a/tests/run_tests.sh
-+++ b/tests/run_tests.sh
-@@ -42,20 +42,20 @@ base_run_test() {
- 
- shorten_echo () {
-     limit=32
--    echo -n "$1"
-+    printf "$1"
-     shift
-     for x; do
- 	if [ ${#x} -le $limit ]; then
--	    echo -n " $x"
-+	    printf " $x"
- 	else
- 	    short=$(echo "$x" | head -c$limit)
--	    echo -n " \"$short\"...<${#x} bytes>"
-+	    printf " \"$short\"...<${#x} bytes>"
- 	fi
-     done
- }
- 
- run_test () {
--    echo -n "$@:	"
-+    printf "$@:	"
-     if [ -n "$VALGRIND" -a -f $1.supp ]; then
- 	VGSUPP="--suppressions=$1.supp"
-     fi
-@@ -63,7 +63,7 @@ run_test () {
- }
- 
- run_sh_test () {
--    echo -n "$@:	"
-+    printf "$@:	"
-     base_run_test sh "$@"
- }
- 
-@@ -106,12 +106,12 @@ wrap_error () {
- 
- run_wrap_error_test () {
-     shorten_echo "$@"
--    echo -n " {!= 0}:	"
-+    printf " {!= 0}:	"
-     base_run_test wrap_error "$@"
- }
- 
- run_dtc_test () {
--    echo -n "dtc $@:	"
-+    printf "dtc $@:	"
-     base_run_test wrap_test $VALGRIND $DTC "$@"
- }
- 
-@@ -126,7 +126,7 @@ asm_to_so_test () {
- run_fdtget_test () {
-     expect="$1"
-     shift
--    echo -n "fdtget-runtest.sh "$expect" $@:	"
-+    printf "fdtget-runtest.sh "$expect" $@:	"
-     base_run_test sh fdtget-runtest.sh "$expect" "$@"
- }
- 
-@@ -134,14 +134,14 @@ run_fdtput_test () {
-     expect="$1"
-     shift
-     shorten_echo fdtput-runtest.sh "$expect" "$@"
--    echo -n ":	"
-+    printf ":	"
-     base_run_test sh fdtput-runtest.sh "$expect" "$@"
- }
- 
- run_fdtdump_test() {
-     file="$1"
-     shorten_echo fdtdump-runtest.sh "$file"
--    echo -n ":	"
-+    printf ":	"
-     base_run_test sh fdtdump-runtest.sh "$file"
- }
- 
--- 
-2.4.0
-
diff --git a/sys-apps/dtc/files/dtc-1.4.1-missing-syms.patch b/sys-apps/dtc/files/dtc-1.4.1-missing-syms.patch
deleted file mode 100644
index 7057be7..0000000
--- a/sys-apps/dtc/files/dtc-1.4.1-missing-syms.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From a4b093f7366fdb429ca1781144d3985fa50d0fbb Mon Sep 17 00:00:00 2001
-From: Julien Grall <julien.grall@linaro.org>
-Date: Tue, 17 Mar 2015 16:00:34 +0000
-Subject: [PATCH] libfdt: Add missing functions to shared library
-
-The commit 4e76ec7 "libfdt: Add fdt_next_subnode() to permit easy
-subnode iteration" adds new functions (fdt_{first,next}_subnode) but
-forgot to mark them as 'global' in the shared library.
-
-Signed-off-by: Julien Grall <julien.grall@linaro.org>
----
- libfdt/version.lds | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/libfdt/version.lds b/libfdt/version.lds
-index 80b322b..941208e 100644
---- a/libfdt/version.lds
-+++ b/libfdt/version.lds
-@@ -54,6 +54,8 @@ LIBFDT_1.2 {
- 		fdt_get_property_by_offset;
- 		fdt_getprop_by_offset;
- 		fdt_next_property_offset;
-+		fdt_first_subnode;
-+		fdt_next_subnode;
- 
- 	local:
- 		*;
--- 
-2.4.0
-
diff --git a/sys-apps/dtc/files/dtc-1.4.4-posix-shell.patch b/sys-apps/dtc/files/dtc-1.4.4-posix-shell.patch
new file mode 100644
index 0000000..b9b0175
--- /dev/null
+++ b/sys-apps/dtc/files/dtc-1.4.4-posix-shell.patch
@@ -0,0 +1,48 @@
+From 4d9522764985462741c7bb4af1ab231b9251476b Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@chromium.org>
+Date: Wed, 10 Jan 2018 00:41:43 -0500
+Subject: [PATCH] dtdiff: change to POSIX shell
+
+This changes from the bash-specific process substitution feature to
+reading with pipes.  It relies on /dev/fd or /proc/self/fd existing.
+
+URL: https://crbug.com/756559
+Signed-off-by: Mike Frysinger <vapier@chromium.org>
+---
+ dtdiff | 19 +++++++++++++------
+ 1 file changed, 13 insertions(+), 6 deletions(-)
+
+diff --git a/dtdiff b/dtdiff
+index 5fa772b0ab62..4d1b71756c2f 100644
+--- a/dtdiff
++++ b/dtdiff
+@@ -1,8 +1,4 @@
+-#! /bin/bash
+-
+-# This script uses the bash <(...) extension.
+-# If you want to change this to work with a generic /bin/sh, make sure
+-# you fix that.
++#! /bin/sh
+ 
+ 
+ DTC=dtc
+@@ -35,4 +31,15 @@ if [ $# != 2 ]; then
+     exit 1
+ fi
+ 
+-diff -u <(source_and_sort "$1") <(source_and_sort "$2")
++for dir in /dev/fd /proc/self/fd; do
++    if [ -d "${dir}" ]; then
++        break
++    fi
++done
++
++source_and_sort "$1" | (
++    # Duplicate current stdin from the first file to fd 3 so we can change fd 0
++    # to the second file.
++    exec 3<&0
++    source_and_sort "$2" | diff -u "${dir}/3" "${dir}/0"
++)
+-- 
+2.15.1
+
diff --git a/sys-apps/dtc/files/dtc-1.5.0-fdt_check_full-visibility.patch b/sys-apps/dtc/files/dtc-1.5.0-fdt_check_full-visibility.patch
new file mode 100644
index 0000000..a5a3d75
--- /dev/null
+++ b/sys-apps/dtc/files/dtc-1.5.0-fdt_check_full-visibility.patch
@@ -0,0 +1,12 @@
+diff --git a/libfdt/version.lds b/libfdt/version.lds
+index 9f5d708..6b0f6d8 100644
+--- a/libfdt/version.lds
++++ b/libfdt/version.lds
+@@ -1,6 +1,7 @@
+ LIBFDT_1.2 {
+ 	global:
+ 		fdt_next_node;
++		fdt_check_full;
+ 		fdt_check_header;
+ 		fdt_move;
+ 		fdt_string;
diff --git a/sys-apps/dtc/files/dtc-1.5.0-gcc-10.patch b/sys-apps/dtc/files/dtc-1.5.0-gcc-10.patch
new file mode 100644
index 0000000..80773bf
--- /dev/null
+++ b/sys-apps/dtc/files/dtc-1.5.0-gcc-10.patch
@@ -0,0 +1,50 @@
+https://bugs.gentoo.org/706660
+https://git.kernel.org/pub/scm/utils/dtc/dtc.git/patch/?id=0e9225eb0dfec51def612b928d2f1836b092bc7e
+
+From 0e9225eb0dfec51def612b928d2f1836b092bc7e Mon Sep 17 00:00:00 2001
+From: Dirk Mueller <dmueller@suse.com>
+Date: Tue, 14 Jan 2020 18:53:41 +0100
+Subject: Remove redundant YYLOC global declaration
+
+gcc 10 will default to -fno-common, which causes this error at link
+time:
+
+  (.text+0x0): multiple definition of `yylloc'; dtc-lexer.lex.o (symbol from plugin):(.text+0x0): first defined here
+
+This is because both dtc-lexer as well as dtc-parser define the same
+global symbol yyloc. Before with -fcommon those were merged into one
+defintion. The proper solution would be to to mark this as "extern",
+however that leads to:
+
+  dtc-lexer.l:26:16: error: redundant redeclaration of 'yylloc' [-Werror=redundant-decls]
+   26 | extern YYLTYPE yylloc;
+      |                ^~~~~~
+In file included from dtc-lexer.l:24:
+dtc-parser.tab.h:127:16: note: previous declaration of 'yylloc' was here
+  127 | extern YYLTYPE yylloc;
+      |                ^~~~~~
+cc1: all warnings being treated as errors
+
+which means the declaration is completely redundant and can just be
+dropped.
+
+Signed-off-by: Dirk Mueller <dmueller@suse.com>
+Message-Id: <20200114175341.2994-1-dmueller@suse.com>
+Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
+---
+ dtc-lexer.l | 1 -
+ 1 file changed, 1 deletion(-)
+
+--- a/dtc-lexer.l
++++ b/dtc-lexer.l
+@@ -23,7 +23,6 @@ LINECOMMENT	"//".*\n
+ #include "srcpos.h"
+ #include "dtc-parser.tab.h"
+ 
+-YYLTYPE yylloc;
+ extern bool treesource_error;
+ 
+ /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
+-- 
+cgit 1.2-0.3.lf.el7
+
diff --git a/sys-apps/dtc/metadata.xml b/sys-apps/dtc/metadata.xml
index 5e82511..9d02ff2 100644
--- a/sys-apps/dtc/metadata.xml
+++ b/sys-apps/dtc/metadata.xml
@@ -1,10 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
 <pkgmetadata>
-<herd>ppc64</herd>
-<maintainer>
+<maintainer type="person">
 	<email>lu_zero@gentoo.org</email>
 </maintainer>
+<maintainer type="project">
+	<email>ppc@gentoo.org</email>
+	<name>Gentoo Linux PowerPC Development</name>
+</maintainer>
 <upstream>
 	<remote-id type="cpe">cpe:/a:dtc_project:dtc</remote-id>
 </upstream>