seabios: upgraded packages to upstream

Upgraded sys-firmware/seabios to version 1.8.2 for all

BUG=b/27084589
TEST=precq passes
CQ-DEPEND=CL:334371

Change-Id: Id03044f02de8659de0c22d13dd6ffe99e8d31264
Reviewed-on: https://chromium-review.googlesource.com/333951
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/sys-firmware/seabios/Manifest b/sys-firmware/seabios/Manifest
index 3ed8afb..acae8c4 100644
--- a/sys-firmware/seabios/Manifest
+++ b/sys-firmware/seabios/Manifest
@@ -1,2 +1,3 @@
-DIST bios.bin-1.7.5.gz 78943 SHA256 2e83e68e6cff73ede1c2490dabad74c177d7b67f9d93a5ed5f2ef39e76dea0ea SHA512 153a4cf190843540a9a72fcb0cf34f1f9f6ff2efb4b4f700c515dea467b101a8999421b53c2f21599864e2e803ae455a4ae39c7e8be9491c4383b4bfbe734014 WHIRLPOOL 2383f5f3a91581b0ee0ff19fd429a67b7fe09db05c456b98aee01ab9008a12d265e56f81b4d60224c7be15a86da9d2288f83a1d83f621b2ff00ab3aaccb277a4
-DIST seabios-1.7.5.tar.gz 537566 SHA256 858d9eda4ad91efa1c45a5a401d560ef9ca8dd172f03b0a106f06661c252dc51 SHA512 ecf5fb9ac44dde6e4ac00baa6c920dde51b923f23dd74e62c5a02eceaf235e57b885975c5a8bd0927e268115c72bd1143a080fdfd4eff4e168ebeaa30436280e WHIRLPOOL 5e1e99b3bd82a8607c5986fde4592c7437bec4bd78abd5873710f6c431d075436725e8d0d32e9f0dd2921c9d84b8613108b21d31c5309a73e337ead7adf35e90
+DIST bios.bin-1.8.2.xz 67428 SHA256 b4628fdbfc39fd73e7ab0c54dfc26128b6011d34778e381c1b2d2340209be838 SHA512 2b2339c02134bcbd6e71e8d31f9907a160534a047bc91502c215d3d4c79431b962177ac43d826cc5689d71dfc0995bc8a9a5caf1a35929f308b3c2bdad720c15 WHIRLPOOL 050a7880d0da8bb8be1ce3e1262f7e5107a5a426eb31ce9629ef497305e390d348de7ed3c7595248010eb02481a2b4a9e4dca94b3a9c954c18b8a9624f46bbc6
+DIST seabios-1.8.2.tar.gz 538497 SHA256 f59479307fdae840de398b75aacb2333c8eba24a5964d68c77e32ca6c987ee61 SHA512 798d222d5f5725a805cde9e6000b5ce714d0551fd4a3c2642cc6e77b2bdab1a9e239939a358a23bbe0e00112f5ad70696c87d20b90655463c835541fc04e1a00 WHIRLPOOL 9cda0ad502a59dd718c543b759ac3fcf5acb4adee70c3da9bfea95ab188415acf6425827de77f45421ec3be8fd9e0c37fb486e62828217ba3e83f88d942a3f4a
+DIST seavgabios-1.8.2.tar.xz 20284 SHA256 d28ff071ee56f7bd88cec2482908f469d553cd8b61485a8e89989c26cb5c0e4a SHA512 16d2b54cd98aa22f7af21d8c51a4cf87d9462ec0c99bf703bf7f6c3c4e0be4cbd313b8cf0fb79cdb7b6a7f94441493a4f9669b6d44297e12f03a749befa2d845 WHIRLPOOL 9d61957ec4e3a0c5e4b999495119c6cfb4f2165d98b652b530dbee3ceb19b18a75d07902a5ee15b41b877154bb9ac19163d75c6024a40c4e94e6cf5cdf561e9d
diff --git a/sys-firmware/seabios/files/seabios-1.8.2-fstack-check.patch b/sys-firmware/seabios/files/seabios-1.8.2-fstack-check.patch
new file mode 100644
index 0000000..d9431f9
--- /dev/null
+++ b/sys-firmware/seabios/files/seabios-1.8.2-fstack-check.patch
@@ -0,0 +1,37 @@
+https://bugs.gentoo.org/559980
+
+From e4d2b8ce5db86bd56efdaf64b974925bd7a7b249 Mon Sep 17 00:00:00 2001
+From: Magnus Granberg <zorry@gentoo.org>
+Date: Fri, 11 Sep 2015 17:38:40 -0400
+Subject: [PATCH] build: use -fstack-check=no when available
+
+Some compilers (such as the one in hardened/Gentoo) default this
+option to on which leads to build failures:
+src/stacks.c: In function 'call16_back':
+src/stacks.c:139:5: error: 'asm' operand has impossible constraints
+     asm volatile(
+     ^
+
+URL: https://bugs.gentoo.org/559980
+Reported-by: Alon Bar-Lev <alonbl@gentoo.org>
+Signed-off-by: Magnus Granberg <zorry@gentoo.org>
+Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+---
+ Makefile | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/Makefile b/Makefile
+index e287530..3a0d2e8 100644
+--- a/Makefile
++++ b/Makefile
+@@ -63,6 +63,7 @@ COMMONCFLAGS := -I$(OUT) -Isrc -Os -MD -g \
+ COMMONCFLAGS += $(call cc-option,$(CC),-nopie,)
+ COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
+ COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
++COMMONCFLAGS += $(call cc-option,$(CC),-fstack-check=no,)
+ COMMA := ,
+ 
+ CFLAGS32FLAT := $(COMMONCFLAGS) -DMODE16=0 -DMODESEGMENT=0
+-- 
+2.5.1
+
diff --git a/sys-firmware/seabios/files/seavgabios/README b/sys-firmware/seabios/files/seavgabios/README
new file mode 100644
index 0000000..7030949
--- /dev/null
+++ b/sys-firmware/seabios/files/seavgabios/README
@@ -0,0 +1 @@
+The config.vga-xxx files come from the qemu/roms/ tree.
diff --git a/sys-firmware/seabios/files/seavgabios/config.vga-cirrus b/sys-firmware/seabios/files/seavgabios/config.vga-cirrus
new file mode 100644
index 0000000..c8fe582
--- /dev/null
+++ b/sys-firmware/seabios/files/seavgabios/config.vga-cirrus
@@ -0,0 +1,3 @@
+CONFIG_BUILD_VGABIOS=y
+CONFIG_VGA_CIRRUS=y
+CONFIG_VGA_PCI=y
diff --git a/sys-firmware/seabios/files/seavgabios/config.vga-isavga b/sys-firmware/seabios/files/seavgabios/config.vga-isavga
new file mode 100644
index 0000000..e55e294
--- /dev/null
+++ b/sys-firmware/seabios/files/seavgabios/config.vga-isavga
@@ -0,0 +1,3 @@
+CONFIG_BUILD_VGABIOS=y
+CONFIG_VGA_BOCHS=y
+CONFIG_VGA_PCI=n
diff --git a/sys-firmware/seabios/files/seavgabios/config.vga-qxl b/sys-firmware/seabios/files/seavgabios/config.vga-qxl
new file mode 100644
index 0000000..d393f0c
--- /dev/null
+++ b/sys-firmware/seabios/files/seavgabios/config.vga-qxl
@@ -0,0 +1,6 @@
+CONFIG_BUILD_VGABIOS=y
+CONFIG_VGA_BOCHS=y
+CONFIG_VGA_PCI=y
+CONFIG_OVERRIDE_PCI_ID=y
+CONFIG_VGA_VID=0x1b36
+CONFIG_VGA_DID=0x0100
diff --git a/sys-firmware/seabios/files/seavgabios/config.vga-stdvga b/sys-firmware/seabios/files/seavgabios/config.vga-stdvga
new file mode 100644
index 0000000..7d063b7
--- /dev/null
+++ b/sys-firmware/seabios/files/seavgabios/config.vga-stdvga
@@ -0,0 +1,3 @@
+CONFIG_BUILD_VGABIOS=y
+CONFIG_VGA_BOCHS=y
+CONFIG_VGA_PCI=y
diff --git a/sys-firmware/seabios/files/seavgabios/config.vga-virtio b/sys-firmware/seabios/files/seavgabios/config.vga-virtio
new file mode 100644
index 0000000..aa7a15b
--- /dev/null
+++ b/sys-firmware/seabios/files/seavgabios/config.vga-virtio
@@ -0,0 +1,6 @@
+CONFIG_BUILD_VGABIOS=y
+CONFIG_VGA_BOCHS=y
+CONFIG_VGA_PCI=y
+CONFIG_OVERRIDE_PCI_ID=y
+CONFIG_VGA_VID=0x1af4
+CONFIG_VGA_DID=0x1050
diff --git a/sys-firmware/seabios/files/seavgabios/config.vga-vmware b/sys-firmware/seabios/files/seavgabios/config.vga-vmware
new file mode 100644
index 0000000..eb10427
--- /dev/null
+++ b/sys-firmware/seabios/files/seavgabios/config.vga-vmware
@@ -0,0 +1,6 @@
+CONFIG_BUILD_VGABIOS=y
+CONFIG_VGA_BOCHS=y
+CONFIG_VGA_PCI=y
+CONFIG_OVERRIDE_PCI_ID=y
+CONFIG_VGA_VID=0x15ad
+CONFIG_VGA_DID=0x0405
diff --git a/sys-firmware/seabios/metadata.xml b/sys-firmware/seabios/metadata.xml
index d7ef91f..584d4b5 100644
--- a/sys-firmware/seabios/metadata.xml
+++ b/sys-firmware/seabios/metadata.xml
@@ -1,13 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
 <pkgmetadata>
-	<herd>virtualization</herd>
-	<maintainer>
+	<maintainer type="person">
 		<email>cardoe@gentoo.org</email>
 		<name>Doug Goldstein</name>
 	</maintainer>
+	<maintainer type="project">
+		<email>qemu@gentoo.org</email>
+		<name>Gentoo QEMU Project</name>
+	</maintainer>
+	<maintainer type="project">
+		<email>virtualization@gentoo.org</email>
+		<name>Gentoo Virtualization Project</name>
+	</maintainer>
 	<use>
-		<flag name='binary'>Use official upstream pre-built binaries</flag>
+		<flag name="binary">Use official upstream pre-built binaries</flag>
+		<flag name="seavgabios">Include SeaVGABIOS binaries (replacement for vgabios)</flag>
 	</use>
 </pkgmetadata>
-
diff --git a/sys-firmware/seabios/seabios-1.7.5.ebuild b/sys-firmware/seabios/seabios-1.7.5.ebuild
deleted file mode 100644
index a4c4aaf..0000000
--- a/sys-firmware/seabios/seabios-1.7.5.ebuild
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-firmware/seabios/seabios-1.7.5.ebuild,v 1.1 2014/06/09 06:48:16 patrick Exp $
-
-EAPI=5
-
-PYTHON_COMPAT=( python{2_6,2_7} )
-
-inherit eutils toolchain-funcs python-any-r1
-
-#BACKPORTS=1
-
-# SeaBIOS maintainers sometimes don't release stable tarballs or stable
-# binaries to generate the stable tarball the following is necessary:
-# git clone git://git.seabios.org/seabios.git && cd seabios
-# git archive --output seabios-${PV}.tar.gz --prefix seabios-${PV}/ rel-${PV}
-
-if [[ ${PV} = *9999* || ! -z "${EGIT_COMMIT}" ]]; then
-	EGIT_REPO_URI="git://git.seabios.org/seabios.git"
-	inherit git-2
-else
-	KEYWORDS="*"
-	SRC_URI="http://code.coreboot.org/p/seabios/downloads/get/${P}.tar.gz
-	http://code.coreboot.org/p/seabios/downloads/get/bios.bin-${PV}.gz
-	http://dev.gentoo.org/~cardoe/distfiles/${P}.tar.gz
-	http://dev.gentoo.org/~cardoe/distfiles/bios.bin-${PV}.gz
-	${BACKPORTS:+http://dev.gentoo.org/~cardoe/distfiles/${P}-${BACKPORTS}.tar.xz}"
-fi
-
-DESCRIPTION="Open Source implementation of a 16-bit x86 BIOS"
-HOMEPAGE="http://www.seabios.org"
-
-LICENSE="LGPL-3 GPL-3"
-SLOT="0"
-IUSE="+binary"
-
-REQUIRED_USE="ppc? ( binary )
-	ppc64? ( binary )"
-
-DEPEND="
-	!binary? (
-		>=sys-power/iasl-20060912
-		${PYTHON_DEPS}
-	)"
-RDEPEND=""
-
-pkg_pretend() {
-	if ! use binary; then
-		ewarn "You have decided to compile your own SeaBIOS. This is not"
-		ewarn "supported by upstream unless you use their recommended"
-		ewarn "toolchain (which you are not)."
-		elog
-		ewarn "If you are intending to use this build with QEMU, realize"
-		ewarn "you will not receive any support if you have compiled your"
-		ewarn "own SeaBIOS. Virtual machines subtly fail based on changes"
-		ewarn "in SeaBIOS."
-	fi
-
-	local myld=$(tc-getLD)
-
-	${myld} -v | grep -q "GNU gold" && \
-	ewarn "gold linker unable to handle 16-bit code using ld.bfd.  bug #438058"
-}
-
-pkg_setup() {
-	use binary || python-any-r1_pkg_setup
-}
-
-src_prepare() {
-	if [[ -z "${EGIT_COMMIT}" ]]; then
-		sed -e "s/VERSION=.*/VERSION=${PV}/" \
-			-i "${S}/Makefile"
-	else
-		sed -e "s/VERSION=.*/VERSION=${PV}_pre${EGIT_COMMIT}/" \
-			-i "${S}/Makefile"
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	:
-}
-
-src_compile() {
-	if ! use binary ; then
-		LANG=C emake \
-			CC=$(tc-getCC) \
-			LD="$(tc-getLD).bfd" \
-			AR=$(tc-getAR) \
-			OBJCOPY=$(tc-getOBJCOPY) \
-			RANLIB=$(tc-getRANLIB) \
-			OBJDUMP=$(tc-getPROG OBJDUMP objdump) \
-			HOST_CC=$(tc-getBUILD_CC) \
-			out/bios.bin
-	fi
-}
-
-src_install() {
-	insinto /usr/share/seabios
-	if ! use binary ; then
-		doins out/bios.bin
-	else
-		newins ../bios.bin-${PV} bios.bin
-	fi
-}
diff --git a/sys-firmware/seabios/seabios-1.8.2.ebuild b/sys-firmware/seabios/seabios-1.8.2.ebuild
new file mode 100644
index 0000000..3a14e8d
--- /dev/null
+++ b/sys-firmware/seabios/seabios-1.8.2.ebuild
@@ -0,0 +1,140 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="5"
+
+PYTHON_COMPAT=( python{2_7,3_{3,4,5}} )
+
+inherit eutils toolchain-funcs python-any-r1
+
+# SeaBIOS maintainers sometimes don't release stable tarballs or stable
+# binaries to generate the stable tarball the following is necessary:
+# git clone git://git.seabios.org/seabios.git && cd seabios
+# git archive --output seabios-${PV}.tar.gz --prefix seabios-${PV}/ rel-${PV}
+
+if [[ ${PV} = *9999* || ! -z "${EGIT_COMMIT}" ]]; then
+	EGIT_REPO_URI="git://git.seabios.org/seabios.git"
+	inherit git-2
+else
+	KEYWORDS="*"
+	# Upstream hasn't released a new binary.  We snipe ours from Fedora for now.
+	# http://code.coreboot.org/p/seabios/downloads/get/bios.bin-${PV}.gz
+	SRC_URI="!binary? ( http://code.coreboot.org/p/seabios/downloads/get/${P}.tar.gz )
+		binary? (
+			mirror://gentoo/bios.bin-${PV}.xz
+			seavgabios? ( mirror://gentoo/seavgabios-${PV}.tar.xz )
+		)"
+fi
+
+DESCRIPTION="Open Source implementation of a 16-bit x86 BIOS"
+HOMEPAGE="http://www.seabios.org"
+
+LICENSE="LGPL-3 GPL-3"
+SLOT="0"
+IUSE="+binary debug +seavgabios"
+
+REQUIRED_USE="debug? ( !binary )
+	!amd64? ( !x86? ( binary ) )"
+
+# The amd64/x86 check is needed to workaround #570892.
+SOURCE_DEPEND="
+	>=sys-power/iasl-20060912
+	${PYTHON_DEPS}"
+DEPEND="
+	!binary? (
+		amd64? ( ${SOURCE_DEPEND} )
+		x86? ( ${SOURCE_DEPEND} )
+	)"
+RDEPEND=""
+
+pkg_pretend() {
+	if ! use binary; then
+		ewarn "You have decided to compile your own SeaBIOS. This is not"
+		ewarn "supported by upstream unless you use their recommended"
+		ewarn "toolchain (which you are not)."
+		elog
+		ewarn "If you are intending to use this build with QEMU, realize"
+		ewarn "you will not receive any support if you have compiled your"
+		ewarn "own SeaBIOS. Virtual machines subtly fail based on changes"
+		ewarn "in SeaBIOS."
+	fi
+}
+
+pkg_setup() {
+	use binary || python-any-r1_pkg_setup
+}
+
+src_unpack() {
+	default
+
+	# This simplifies the logic between binary & source builds.
+	mkdir -p "${S}"
+}
+
+src_prepare() {
+	use binary && return
+
+	epatch "${FILESDIR}"/${P}-fstack-check.patch #559980
+	epatch_user
+}
+
+src_configure() {
+	use binary && return
+
+	tc-ld-disable-gold #438058
+
+	if use debug ; then
+		echo "CONFIG_DEBUG_LEVEL=8" >.config
+	fi
+	_emake config
+}
+
+_emake() {
+	LANG=C \
+	emake V=1 \
+		CC="$(tc-getCC)" \
+		LD="$(tc-getLD)" \
+		AR="$(tc-getAR)" \
+		OBJCOPY="$(tc-getOBJCOPY)" \
+		RANLIB="$(tc-getRANLIB)" \
+		OBJDUMP="$(tc-getOBJDUMP)" \
+		HOST_CC="$(tc-getBUILD_CC)" \
+		VERSION="Gentoo/${EGIT_COMMIT:-${PVR}}" \
+		"$@"
+}
+
+src_compile() {
+	use binary && return
+
+	_emake out/bios.bin
+	mv out/bios.bin ../bios.bin
+
+	if use seavgabios ; then
+		local config t targets=(
+			cirrus
+			isavga
+			qxl
+			stdvga
+			virtio
+			vmware
+		)
+		for t in "${targets[@]}" ; do
+			emake clean distclean
+			cp "${FILESDIR}/seavgabios/config.vga-${t}" .config || die
+			_emake oldnoconfig
+			_emake out/vgabios.bin
+			cp out/vgabios.bin ../vgabios-${t}.bin || die
+		done
+	fi
+}
+
+src_install() {
+	insinto /usr/share/seabios
+	newins ../bios.bin* bios.bin
+
+	if use seavgabios ; then
+		insinto /usr/share/seavgabios
+		doins ../vgabios*.bin
+	fi
+}