ifplugd: upgraded package to upstream

Upgraded sys-apps/ifplugd to version 0.28-r9 on arm

BUG=b:34770285
TEST=builds on board=loonix

Change-Id: I756946a2f044cd045c668f00253f1ae58e8e36c5
Reviewed-on: https://chromium-review.googlesource.com/439782
Commit-Ready: Ian Coolidge <icoolidge@google.com>
Tested-by: Ian Coolidge <icoolidge@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/metadata/md5-cache/sys-apps/ifplugd-0.28-r9 b/metadata/md5-cache/sys-apps/ifplugd-0.28-r9
new file mode 100644
index 0000000..225d0c9
--- /dev/null
+++ b/metadata/md5-cache/sys-apps/ifplugd-0.28-r9
@@ -0,0 +1,13 @@
+DEFINED_PHASES=configure install postinst prepare
+DEPEND=virtual/pkgconfig doc? ( www-client/lynx ) >=dev-libs/libdaemon-0.5
+DESCRIPTION=Brings up/down ethernet ports automatically with cable detection
+EAPI=4
+HOMEPAGE=http://0pointer.de/lennart/projects/ifplugd/
+IUSE=doc selinux
+KEYWORDS=*
+LICENSE=GPL-2
+RDEPEND=>=dev-libs/libdaemon-0.5 >=sys-apps/baselayout-1.12 selinux? ( sec-policy/selinux-ifplugd )
+SLOT=0
+SRC_URI=http://0pointer.de/lennart/projects/ifplugd/ifplugd-0.28.tar.gz
+_eclasses_=eutils	06133990e861be0fe60c2b428fd025d9	multilib	3972ca401cf7dbb430df9995f5d8d580	toolchain-funcs	6198c04daba0e1307bd844df7d37f423
+_md5_=ca0ed2bf4fb210cf77b51468cdb203a9
diff --git a/sys-apps/ifplugd/Manifest b/sys-apps/ifplugd/Manifest
new file mode 100644
index 0000000..bd43f5d
--- /dev/null
+++ b/sys-apps/ifplugd/Manifest
@@ -0,0 +1 @@
+DIST ifplugd-0.28.tar.gz 142677 SHA256 474754ac4ab32d738cbf2a4a3e87ee0a2c71b9048a38bdcd7df1e4f9fd6541f0 SHA512 c606e456f81f224eba9f8912e11fb76b759c160313d1db3c9035775b8c1ca57ca10c88dfb33318ba02f5c025218a377ca78ee160fc3d9a31ac6e95b92f340d4f WHIRLPOOL c8cb4a2518b4a97974da412f7f975a9abe54374967630f38781b00ce1f1f887a4485dd6efd775f1aee259a2b877bf5570bca72b5acf036a93c0de33a123c5c00
diff --git a/sys-apps/ifplugd/files/ifplugd-0.28-interface.patch b/sys-apps/ifplugd/files/ifplugd-0.28-interface.patch
new file mode 100644
index 0000000..f99f3a2
--- /dev/null
+++ b/sys-apps/ifplugd/files/ifplugd-0.28-interface.patch
@@ -0,0 +1,13 @@
+--- a/src/interface.c
++++ b/src/interface.c
+@@ -22,9 +22,9 @@
+ #include <config.h>
+ #endif
+ 
++#include <sys/types.h>
+ #include <linux/sockios.h>
+ #include <linux/if_ether.h>
+-#include <sys/types.h>
+ #include <sys/socket.h>
+ #include <sys/ioctl.h>
+ #include <linux/if.h>
diff --git a/sys-apps/ifplugd/files/ifplugd-0.28-musl.patch b/sys-apps/ifplugd/files/ifplugd-0.28-musl.patch
new file mode 100644
index 0000000..ecaaabf
--- /dev/null
+++ b/sys-apps/ifplugd/files/ifplugd-0.28-musl.patch
@@ -0,0 +1,19 @@
+--- a/src/ethtool-local.h
++++ b/src/ethtool-local.h
+@@ -21,10 +21,12 @@
+  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+  */
+ 
+-typedef unsigned long long u64;
+-typedef __uint32_t u32;        
+-typedef __uint16_t u16;        
+-typedef __uint8_t u8;          
++#include <stdint.h>
++
++typedef uint64_t u64;
++typedef uint32_t u32;
++typedef uint16_t u16;
++typedef uint8_t u8;
+ 
+ #include "ethtool-kernel.h"
+ 
diff --git a/sys-apps/ifplugd/files/ifplugd-0.28-nlapi.diff b/sys-apps/ifplugd/files/ifplugd-0.28-nlapi.diff
new file mode 100644
index 0000000..a3d128f
--- /dev/null
+++ b/sys-apps/ifplugd/files/ifplugd-0.28-nlapi.diff
@@ -0,0 +1,12 @@
+diff -urN src/nlapi.c src/nlapi.c
+--- a/src/nlapi.c
++++ b/src/nlapi.c
+@@ -86,7 +86,7 @@
+         for (; bytes > 0; p = NLMSG_NEXT(p, bytes)) {
+             struct callback_info *c;
+             
+-            if (!NLMSG_OK(p, bytes) || (size_t) bytes < sizeof(struct nlmsghdr) || (size_t) bytes < p->nlmsg_len) {
++            if (!NLMSG_OK(p, (size_t) bytes) || (size_t) bytes < sizeof(struct nlmsghdr) || (size_t) bytes < (size_t) p->nlmsg_len) {
+                 daemon_log(LOG_ERR, "NLAPI: Packet too small or truncated!\n");
+                 return -1;
+             }
diff --git a/sys-apps/ifplugd/files/ifplugd-0.28-noip.patch b/sys-apps/ifplugd/files/ifplugd-0.28-noip.patch
new file mode 100644
index 0000000..5daa453
--- /dev/null
+++ b/sys-apps/ifplugd/files/ifplugd-0.28-noip.patch
@@ -0,0 +1,21 @@
+[PATCH] Allow ifplugd to run when no TCP/IP is available
+
+This simple patch create AF_LOCAL socket instead of AF_INET so if TCP/IP
+is not linked into kernel it still works.
+
+Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
+
+---
+
+diff -urNp ifplugd-0.28.org/src/ifplugd.c ifplugd-0.28/src/ifplugd.c
+--- ifplugd-0.28.org/src/ifplugd.c	2005-06-04 22:21:51.000000000 +0300
++++ ifplugd-0.28/src/ifplugd.c	2007-10-30 05:22:53.000000000 +0200
+@@ -409,7 +409,7 @@ void work(void) {
+             break;
+     }
+ 
+-    if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
++    if ((fd = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) {
+         daemon_log(LOG_ERR, "socket(): %s", strerror(errno));
+         goto finish;
+     }
diff --git a/sys-apps/ifplugd/files/ifplugd-0.28-strictalias.patch b/sys-apps/ifplugd/files/ifplugd-0.28-strictalias.patch
new file mode 100644
index 0000000..ae8292d
--- /dev/null
+++ b/sys-apps/ifplugd/files/ifplugd-0.28-strictalias.patch
@@ -0,0 +1,63 @@
+--- a/src/interface.c
++++ b/src/interface.c
+@@ -89,6 +89,10 @@
+ 
+ interface_status_t interface_detect_beat_mii(int fd, char *iface) {
+     struct ifreq ifr;
++    union {
++      caddr_t *data;
++      unsigned short *usz;
++    } ifd;
+     
+     if (interface_auto_up)
+         interface_up(fd, iface);
+@@ -103,7 +107,8 @@
+         return IFSTATUS_ERR;
+     }
+ 
+-    ((unsigned short*) &ifr.ifr_data)[1] = 1;
++    ifd.data = &ifr.ifr_data;
++    *++ifd.usz = 1;
+ 
+     if (ioctl(fd, SIOCGMIIREG, &ifr) == -1) {
+         if (interface_do_message)
+@@ -112,12 +117,17 @@
+         return IFSTATUS_ERR;
+     }
+ 
+-    return (((unsigned short*) &ifr.ifr_data)[3] & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
++    ifd.usz += 2;
++    return (*ifd.usz & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
+ }
+ 
+ interface_status_t interface_detect_beat_priv(int fd, char *iface) {
+     struct ifreq ifr;
+-    
++    union {
++      caddr_t *data;
++      unsigned short *usz;
++    } ifd;
++   
+     if (interface_auto_up)
+         interface_up(fd, iface);
+     
+@@ -131,7 +141,8 @@
+         return IFSTATUS_ERR;
+     }
+ 
+-    ((unsigned short*) &ifr.ifr_data)[1] = 1;
++    ifd.data = &ifr.ifr_data;
++    *++ifd.usz = 1;
+ 
+     if (ioctl(fd, SIOCDEVPRIVATE+1, &ifr) == -1) {
+         if (interface_do_message)
+@@ -140,7 +151,8 @@
+         return IFSTATUS_ERR;
+     }
+ 
+-    return (((unsigned short*) &ifr.ifr_data)[3] & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
++    ifd.usz += 2;
++    return (*ifd.usz & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
+ }
+ 
+ interface_status_t interface_detect_beat_ethtool(int fd, char *iface) {
diff --git a/sys-apps/ifplugd/files/ifplugd.action b/sys-apps/ifplugd/files/ifplugd.action
new file mode 100644
index 0000000..ba4cfd7
--- /dev/null
+++ b/sys-apps/ifplugd/files/ifplugd.action
@@ -0,0 +1,55 @@
+#!/bin/sh
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+#
+# Gentoo-specific ifplugd.action
+#
+# This file gets called by ifplugd when it wants to bring an interface
+# up or down.
+#
+
+if grep -q initng /proc/1/cmdline 
+then
+    EXEC="/sbin/ngc"
+    INITNG="yes"
+else
+    EXEC="/etc/init.d/net.$1"
+    INITNG="no"
+fi
+
+case "$2" in
+    up)
+	if [ "${INITNG}" = "yes" ]
+	then
+	    ARGS="-u net/$1"
+	else
+	    ARGS="--quiet start"
+	fi
+	;;
+    down)
+	if [ "${INITNG}" = "yes" ]
+	then
+	    ARGS="-d net/$1"
+	else
+	    ARGS="--quiet stop"
+	fi
+	;;
+    *)
+	echo "$0: wrong arguments" >&2
+	echo "Call with <interface> <up|down>" >&2
+	exit 1
+	;;
+esac
+
+export IN_BACKGROUND=true
+
+if [ -x "${EXEC}" ]
+then
+    ${EXEC} ${ARGS}
+    exit 0
+else
+    logger -t ifplugd.action "Error: Couldn't configure $1, no ${EXEC} !"
+    exit 1
+fi
+
+# vim: set ts=4
diff --git a/sys-apps/ifplugd/ifplugd-0.28-r9.ebuild b/sys-apps/ifplugd/ifplugd-0.28-r9.ebuild
new file mode 100644
index 0000000..fac3845
--- /dev/null
+++ b/sys-apps/ifplugd/ifplugd-0.28-r9.ebuild
@@ -0,0 +1,71 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=4
+
+inherit eutils
+
+DESCRIPTION="Brings up/down ethernet ports automatically with cable detection"
+HOMEPAGE="http://0pointer.de/lennart/projects/ifplugd/"
+SRC_URI="http://0pointer.de/lennart/projects/ifplugd/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="*"
+IUSE="doc selinux"
+
+DEPEND="virtual/pkgconfig
+	doc? ( www-client/lynx )
+	>=dev-libs/libdaemon-0.5"
+RDEPEND=">=dev-libs/libdaemon-0.5
+	>=sys-apps/baselayout-1.12
+	selinux? ( sec-policy/selinux-ifplugd )"
+
+src_prepare() {
+	epatch "${FILESDIR}/${P}-nlapi.diff"
+	epatch "${FILESDIR}/${P}-interface.patch"
+	epatch "${FILESDIR}/${P}-strictalias.patch"
+	epatch "${FILESDIR}/${P}-noip.patch"
+}
+
+src_configure() {
+	econf \
+		$(use_enable doc lynx) \
+		--with-initdir=/etc/init.d \
+		--disable-xmltoman \
+		--disable-subversion
+}
+
+src_install() {
+	default
+
+	# Remove init.d configuration as we no longer use it
+	rm -rf "${D}/etc/ifplugd" "${D}/etc/init.d/${PN}"
+
+	exeinto "/etc/${PN}"
+	newexe "${FILESDIR}/${PN}.action" "${PN}.action"
+
+	cd "${S}/doc"
+	dodoc README SUPPORTED_DRIVERS
+	use doc && dohtml *.html *.css
+}
+
+pkg_postinst() {
+	# Warn about old init script
+	einfo "baselayout now starts ifplugd automatically on wired interfaces"
+	einfo "If you do not want this behaviour then add !plug to your modules"
+	einfo "in /etc/conf.d/net like so"
+	einfo "   modules=( \"!plug\" )"
+
+	if [ -e "${ROOT}/etc/init.d/ifplugd" -o -e "${ROOT}/etc/conf.d/ifplugd" ] ; then
+		echo
+		ewarn "You should stop the ifplugd service now and remove its init"
+		ewarn "script and config file"
+		if [ "${ROOT}" = "/" ] ; then
+			ewarn "   /etc/init.d/ifplugd stop"
+			ewarn "   rc-update del ifplugd"
+			ewarn "   rm -f /etc/{conf,init}.d/ifplugd"
+		fi
+	fi
+}
diff --git a/sys-apps/ifplugd/metadata.xml b/sys-apps/ifplugd/metadata.xml
new file mode 100644
index 0000000..bb67101
--- /dev/null
+++ b/sys-apps/ifplugd/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+	<email>base-system@gentoo.org</email>
+	<name>Gentoo Base System</name>
+</maintainer>
+<longdescription lang="en">
+	Brings up/down ethernet ports automatically with cable detection
+</longdescription>
+</pkgmetadata>