ebtables: upgraded package to upstream

Upgraded net-firewall/ebtables to version 2.0.11-r2 on amd64.

Upgrading ebtables to resolve package conflict with iptables.

BUG=b/173158844
TEST=presubmit
RELEASE_NOTE=none

Change-Id: I9de82db7d063995a03fdeefb0fbc5d0cc3755dc6
Reviewed-on: https://cos-review.googlesource.com/c/third_party/overlays/portage-stable/+/9081
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
Reviewed-by: Robert Kolchmeyer <rkolchmeyer@google.com>
diff --git a/metadata/md5-cache/net-firewall/ebtables-2.0.10.4-r1 b/metadata/md5-cache/net-firewall/ebtables-2.0.10.4-r1
deleted file mode 100644
index 266dfd0..0000000
--- a/metadata/md5-cache/net-firewall/ebtables-2.0.10.4-r1
+++ /dev/null
@@ -1,12 +0,0 @@
-DEFINED_PHASES=compile install prepare setup
-DESCRIPTION=Utility that enables basic Ethernet frame filtering on a Linux bridge, MAC NAT and brouting
-EAPI=4
-HOMEPAGE=http://ebtables.sourceforge.net/
-IUSE=perl static
-KEYWORDS=*
-LICENSE=GPL-2
-RDEPEND=perl? ( dev-lang/perl )
-SLOT=0
-SRC_URI=mirror://sourceforge/ebtables/ebtables-v2.0.10-4.tar.gz
-_eclasses_=estack	43ddf5aaffa7a8d0482df54d25a66a1f	eutils	06133990e861be0fe60c2b428fd025d9	flag-o-matic	5d5921a298e95441da2f85be419894c0	multilib	2477ebe553d3e4d2c606191fe6c33602	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb	versionator	26ca8a8bd95d6a74122c08ba98a4ee72
-_md5_=5a71d8138c56b5f4980495742dee13ea
diff --git a/metadata/md5-cache/net-firewall/ebtables-2.0.11-r2 b/metadata/md5-cache/net-firewall/ebtables-2.0.11-r2
new file mode 100644
index 0000000..fbda2f3
--- /dev/null
+++ b/metadata/md5-cache/net-firewall/ebtables-2.0.11-r2
@@ -0,0 +1,14 @@
+BDEPEND=>=app-eselect/eselect-iptables-20200508 >=app-portage/elt-patches-20170815
+DEFINED_PHASES=compile configure install postinst prepare prerm setup
+DEPEND=!<sys-devel/gettext-0.18.1.1-r3 || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 ) >=sys-devel/autoconf-2.69 >=sys-devel/libtool-2.4
+DESCRIPTION=Controls Ethernet frame filtering on a Linux bridge, MAC NAT and brouting
+EAPI=7
+HOMEPAGE=http://ebtables.sourceforge.net/
+IUSE=+perl static
+KEYWORDS=*
+LICENSE=GPL-2
+RDEPEND=>=app-eselect/eselect-iptables-20200508 perl? ( dev-lang/perl ) net-misc/ethertypes
+SLOT=0
+SRC_URI=ftp://ftp.netfilter.org/pub/ebtables/ebtables-2.0.11.tar.gz
+_eclasses_=autotools	d0e5375d47f4c809f406eb892e531513	libtool	f143db5a74ccd9ca28c1234deffede96	multilib	2477ebe553d3e4d2c606191fe6c33602	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
+_md5_=da0a0e77269e7420e7ccd340a5c5ba83
diff --git a/net-firewall/ebtables/Manifest b/net-firewall/ebtables/Manifest
index 68edfb1..61a62a5 100644
--- a/net-firewall/ebtables/Manifest
+++ b/net-firewall/ebtables/Manifest
@@ -1 +1 @@
-DIST ebtables-v2.0.10-4.tar.gz 103764 SHA256 dc6f7b484f207dc712bfca81645f45120cb6aee3380e77a1771e9c34a9a4455d SHA512 a6832453812eaede3fcbb5b4cab5902ea1ea752a80a259eed276a01b61e2afaa6cf07d3d023d86a883f9a02505aecc44a1c6e0d27b3a61f341002e4c051cd60a WHIRLPOOL 5a1e0703e3fd5c79e149824e789646d042660081fb8a9f301fa4cc2716e84fbf842216d5b6b4c8c33de3b6949bfbfcaa2eb7293fe7afa71a2305de8f70abd57d
+DIST ebtables-2.0.11.tar.gz 428411 BLAKE2B 62af4c38ad21498e43f41ef96c8abb5704e8d8a48f1327c587b664f36fdfa9849a9a37e59958db56d38019465d8bf1775914f7387fde99a441615913702cf504 SHA512 43a04c6174c8028c501591ef260526297e0f018016f226e2a3bcf80766fddf53d4605c347554d6da7c4ab5e2131584a18da20916ffddcbf2d26ac93b00c5777f
diff --git a/net-firewall/ebtables/ebtables-2.0.10.4-r1.ebuild b/net-firewall/ebtables/ebtables-2.0.10.4-r1.ebuild
deleted file mode 100644
index afebddd..0000000
--- a/net-firewall/ebtables/ebtables-2.0.10.4-r1.ebuild
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI="4"
-
-inherit versionator eutils toolchain-funcs multilib flag-o-matic
-
-MY_PV=$(replace_version_separator 3 '-' )
-MY_P=${PN}-v${MY_PV}
-
-DESCRIPTION="Utility that enables basic Ethernet frame filtering on a Linux bridge, MAC NAT and brouting"
-HOMEPAGE="http://ebtables.sourceforge.net/"
-SRC_URI="mirror://sourceforge/${PN}/${MY_P}.tar.gz"
-
-KEYWORDS="*"
-IUSE="perl static"
-LICENSE="GPL-2"
-SLOT="0"
-
-# The ebtables-save script is written in perl.
-RDEPEND="perl? ( dev-lang/perl )"
-
-S=${WORKDIR}/${MY_P}
-
-pkg_setup() {
-	if use static; then
-		ewarn "You've chosen static build which is useful for embedded devices."
-		ewarn "It has no init script. Make sure that's really what you want."
-	fi
-}
-
-src_prepare() {
-	# Enhance ebtables-save to take table names as parameters bug #189315
-	epatch "${FILESDIR}/${PN}-2.0.8.1-ebt-save.diff"
-
-	sed -i -e "s,^MANDIR:=.*,MANDIR:=/usr/share/man," \
-		-e "s,^BINDIR:=.*,BINDIR:=/sbin," \
-		-e "s,^INITDIR:=.*,INITDIR:=/usr/share/doc/${PF}," \
-		-e "s,^SYSCONFIGDIR:=.*,SYSCONFIGDIR:=/usr/share/doc/${PF}," \
-		-e "s,^LIBDIR:=.*,LIBDIR:=/$(get_libdir)/\$(PROGNAME)," Makefile
-}
-
-src_compile() {
-	# This package uses _init functions to initialise extensions. With
-	# --as-needed this will not work.
-	append-ldflags $(no-as-needed)
-	# This package correctly aliases pointers, but gcc is unable to know that:
-	# unsigned char ip[4];
-	# if (*((uint32_t*)ip) == 0) {
-	#append-cflags -Wno-strict-aliasing
-	emake \
-		CC="$(tc-getCC)" \
-		CFLAGS="${CFLAGS}" \
-		$(use static && echo static)
-}
-
-src_install() {
-	if ! use static; then
-		make DESTDIR="${D}" install
-		keepdir /var/lib/ebtables/
-		newinitd "${FILESDIR}"/ebtables.initd-r1 ebtables
-		newconfd "${FILESDIR}"/ebtables.confd-r1 ebtables
-		if ! use perl; then
-			rm ${D}/sbin/ebtables-save || die
-		fi
-	else
-		into /
-		newsbin static ebtables
-		insinto /etc
-		doins ethertypes
-	fi
-	dodoc ChangeLog THANKS || die
-}
diff --git a/net-firewall/ebtables/ebtables-2.0.11-r2.ebuild b/net-firewall/ebtables/ebtables-2.0.11-r2.ebuild
new file mode 100644
index 0000000..97a7ab8
--- /dev/null
+++ b/net-firewall/ebtables/ebtables-2.0.11-r2.ebuild
@@ -0,0 +1,107 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit toolchain-funcs autotools
+
+MY_PV="$(ver_rs 3 '-' )"
+MY_P="${PN}-${MY_PV}"
+
+DESCRIPTION="Controls Ethernet frame filtering on a Linux bridge, MAC NAT and brouting"
+HOMEPAGE="http://ebtables.sourceforge.net/"
+SRC_URI="ftp://ftp.netfilter.org/pub/${PN}/${MY_P}.tar.gz"
+S="${WORKDIR}/${MY_P}"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="*"
+IUSE="+perl static"
+
+BDEPEND=">=app-eselect/eselect-iptables-20200508"
+# The ebtables-save script is written in perl.
+RDEPEND="${BDEPEND}
+	perl? ( dev-lang/perl )
+	net-misc/ethertypes"
+
+PATCHES=(
+	"${FILESDIR}/${PN}-2.0.11-makefile.patch"
+
+	# Enhance ebtables-save to take table names as parameters bug #189315
+	"${FILESDIR}/${PN}-2.0.11-ebt-save.patch"
+
+	# from upstream git
+	"${FILESDIR}/ebtables-2.0.11-remove-stray-atsign.patch"
+)
+
+pkg_setup() {
+	if use static; then
+		ewarn "You've chosen static build which is useful for embedded devices."
+		ewarn "It has no init script. Make sure that's really what you want."
+	fi
+}
+
+src_prepare() {
+	default
+
+	# don't install perl scripts if USE=perl is disabled
+	if ! use perl; then
+		sed -e '/sbin_SCRIPTS/ d' -i Makefile.am || die
+	fi
+
+	eautoreconf
+}
+
+src_configure() {
+	econf \
+		--bindir="/bin" \
+		--sbindir="/sbin" \
+		--libdir=/$(get_libdir)/${PN} \
+		--sysconfdir="/usr/share/doc/${PF}" \
+		$(use_enable static)
+}
+
+src_compile() {
+	emake $(usex static 'static ebtables-legacy.8' '')
+}
+
+src_install() {
+	local -a DOCS=( ChangeLog THANKS )
+
+	if ! use static; then
+		emake DESTDIR="${D}" install
+		keepdir /var/lib/ebtables/
+		newinitd "${FILESDIR}"/ebtables.initd-r1 ebtables
+		newconfd "${FILESDIR}"/ebtables.confd-r1 ebtables
+
+		find "${D}" -name '*.la' -type f -delete || die
+	else
+		into /
+		newsbin static ebtables
+		insinto /etc
+		doins ethertypes
+	fi
+
+	newman ebtables-legacy.8 ebtables.8
+	einstalldocs
+	docompress -x /usr/share/doc/${PF}/ethertypes #724138
+}
+
+pkg_postinst() {
+	if ! eselect ebtables show &>/dev/null; then
+		elog "Current ebtables implementation is unset, setting to ebtables-legacy"
+		eselect ebtables set ebtables-legacy
+	fi
+
+	eselect ebtables show
+}
+
+pkg_prerm() {
+	if [[ -z ${REPLACED_BY_VERSION} ]] && has_version 'net-firewall/iptables[nftables]'; then
+		elog "Resetting ebtables symlinks to xtables-nft-multi before removal"
+		eselect ebtables set xtables-nft-multi
+	else
+		elog "Unsetting ebtables symlinks before removal"
+		eselect ebtables unset
+	fi
+}
diff --git a/net-firewall/ebtables/files/ebtables-2.0.11-ebt-save.patch b/net-firewall/ebtables/files/ebtables-2.0.11-ebt-save.patch
new file mode 100644
index 0000000..7cfe128
--- /dev/null
+++ b/net-firewall/ebtables/files/ebtables-2.0.11-ebt-save.patch
@@ -0,0 +1,26 @@
+diff --git a/ebtables-save.in b/ebtables-save.in
+index 17924a2..c7a64c3 100644
+--- a/ebtables-save.in
++++ b/ebtables-save.in
+@@ -12,6 +12,7 @@ my $ebtables = "@sbindir@/ebtables";
+ my $cnt = "";
+ my $version = "1.0";
+ my $table_name;
++my @table_names;
+ 
+ # ========================================================
+ # Process filter table
+@@ -49,6 +50,13 @@ sub process_table {
+ }
+ # ========================================================
+ 
++if ($#ARGV + 1 == 0) {
++   @table_names =split("\n", `grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//`);
++}
++else {
++   @table_names = @ARGV;
++}
++# ========================================================
+ unless (-x $ebtables) { exit -1 };
+ print "# Generated by ebtables-save v$version (legacy) on " . `date`;
+ if (defined($ENV{'EBTABLES_SAVE_COUNTER'}) && $ENV{'EBTABLES_SAVE_COUNTER'} eq "yes") {
diff --git a/net-firewall/ebtables/files/ebtables-2.0.11-makefile.patch b/net-firewall/ebtables/files/ebtables-2.0.11-makefile.patch
new file mode 100644
index 0000000..dc9be9e
--- /dev/null
+++ b/net-firewall/ebtables/files/ebtables-2.0.11-makefile.patch
@@ -0,0 +1,13 @@
+diff --git a/Makefile.am b/Makefile.am
+index 6181003..de01139 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -50,7 +50,7 @@ ebtables_legacy_LDADD = libebtc.la
+ ebtablesd_LDADD = libebtc.la
+ ebtables_legacy_restore_SOURCES = ebtables-restore.c
+ ebtables_legacy_restore_LDADD = libebtc.la
+-static_SOURCES = ebtables.c
++static_SOURCES = ebtables.c ebtables-standalone.c
+ static_LDFLAGS = -static
+ static_LDADD = libebtc.la
+ examples_ulog_test_ulog_SOURCES = examples/ulog/test_ulog.c getethertype.c
diff --git a/net-firewall/ebtables/files/ebtables-2.0.11-remove-stray-atsign.patch b/net-firewall/ebtables/files/ebtables-2.0.11-remove-stray-atsign.patch
new file mode 100644
index 0000000..88f1d72
--- /dev/null
+++ b/net-firewall/ebtables/files/ebtables-2.0.11-remove-stray-atsign.patch
@@ -0,0 +1,32 @@
+From 7d00e58157bc61168a057cde91a6e5b54dca573b Mon Sep 17 00:00:00 2001
+From: Jan Engelhardt <jengelh@inai.de>
+Date: Mon, 2 Dec 2019 20:52:04 +0100
+Subject: build: remove stray @ sign in manpage
+
+Because the sed command was not matching the trailing @, it
+was left in the manpage, leading to
+
+NAME
+       ebtables-legacy (2.0.11@) - Ethernet bridge frame table administration (legacy)
+
+Signed-off-by: Jan Engelhardt <jengelh@inai.de>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+---
+ Makefile.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index b879941..6181003 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -64,6 +64,6 @@ ebtables-legacy-save: ebtables-save.in ${top_builddir}/config.status
+ 	${AM_V_GEN}sed -e 's![@]sbindir@!${sbindir}!g' <$< >$@
+ 
+ ebtables-legacy.8: ebtables-legacy.8.in ${top_builddir}/config.status
+-	${AM_V_GEN}sed -e 's![@]PACKAGE_VERSION!${PACKAGE_VERSION}!g' \
++	${AM_V_GEN}sed -e 's![@]PACKAGE_VERSION@!${PACKAGE_VERSION}!g' \
+ 		-e 's![@]PACKAGE_DATE@!${PROGDATE}!g' \
+ 		-e 's![@]LOCKFILE@!${LOCKFILE}!g' <$< >$@
+-- 
+cgit v1.2.1
+
diff --git a/net-firewall/ebtables/files/ebtables-2.0.8.1-ebt-save.diff b/net-firewall/ebtables/files/ebtables-2.0.8.1-ebt-save.diff
deleted file mode 100644
index cdfd823..0000000
--- a/net-firewall/ebtables/files/ebtables-2.0.8.1-ebt-save.diff
+++ /dev/null
@@ -1,31 +0,0 @@
---- ./ebtables-save.orig	2007-09-28 22:50:35.000000000 +0400
-+++ ./ebtables-save	2007-09-28 22:51:22.000000000 +0400
-@@ -12,6 +12,7 @@
- my $cnt = "";
- my $version = "1.0";
- my $table_name;
-+my @table_names;
- 
- # ========================================================
- # Process filter table
-@@ -49,12 +50,19 @@
- }
- # ========================================================
- 
-+if ($#ARGV + 1 == 0) {
-+   @table_names =split("\n", `grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//`);
-+}
-+else {
-+   @table_names = @ARGV;
-+}
-+# ========================================================
- unless (-x $ebtables) { exit -1 };
- print "# Generated by ebtables-save v$version on " . `date`;
- if (defined($ENV{'EBTABLES_SAVE_COUNTER'}) && $ENV{'EBTABLES_SAVE_COUNTER'} eq "yes") {
-     $cnt = "--Lc";
- }
--foreach $table_name (split("\n", `grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//`)) {
-+foreach $table_name (@table_names) {
-     $table =`$ebtables -t $table_name -L $cnt`;
-     unless ($? == 0) { print $table; exit -1 };
-     &process_table($table);
diff --git a/net-firewall/ebtables/files/ebtables.initd-r1 b/net-firewall/ebtables/files/ebtables.initd-r1
index 770dd43..6608760 100644
--- a/net-firewall/ebtables/files/ebtables.initd-r1
+++ b/net-firewall/ebtables/files/ebtables.initd-r1
@@ -1,7 +1,6 @@
-#!/sbin/runscript
-# Copyright 1999-2012 Gentoo Foundation
+#!/sbin/openrc-run
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
-# $Id$
 
 extra_commands="save panic"
 extra_started_commands="reload"
@@ -17,7 +16,7 @@
 ebtables_tables() {
 	for table in filter nat broute; do
 		if ${ebtables_bin} -t ${table} -L > /dev/null 2>&1; then
-			echo -n "${table} "
+			printf '%s' "${table} "
 		fi
 	done
 }
diff --git a/net-firewall/ebtables/metadata.xml b/net-firewall/ebtables/metadata.xml
index cc14422..3386c21 100644
--- a/net-firewall/ebtables/metadata.xml
+++ b/net-firewall/ebtables/metadata.xml
@@ -1,9 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
 <pkgmetadata>
-	<herd>base-system</herd>
+	<maintainer type="project">
+		<email>base-system@gentoo.org</email>
+		<name>Gentoo Base System</name>
+	</maintainer>
 	<use>
-		<flag name='perl'>Install the ebtables-save script which uses perl</flag>
+		<flag name="perl">Install the ebtables-save script which uses perl</flag>
 	</use>
 	<upstream>
 		<remote-id type="sourceforge">ebtables</remote-id>