added ifplugd-0.28-r9 ebuild
authorPatrik Gornicz <Gornicz.P@gmail.com>
Wed, 23 May 2012 01:44:29 +0000 (21:44 -0400)
committerPatrik Gornicz <Gornicz.P@gmail.com>
Wed, 23 May 2012 02:08:15 +0000 (22:08 -0400)
sys-apps/ifplugd/files/ifplugd-0.28-interface.patch [new file with mode: 0644]
sys-apps/ifplugd/files/ifplugd-0.28-nlapi.diff [new file with mode: 0644]
sys-apps/ifplugd/files/ifplugd-0.28-noip.patch [new file with mode: 0644]
sys-apps/ifplugd/files/ifplugd-0.28-strictalias.patch [new file with mode: 0644]
sys-apps/ifplugd/files/ifplugd.action [new file with mode: 0644]
sys-apps/ifplugd/ifplugd-0.28-r9.ebuild [new file with mode: 0644]
sys-apps/ifplugd/metadata.xml [new file with mode: 0644]

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 (file)
index 0000000..9c2de46
--- /dev/null
@@ -0,0 +1,13 @@
+--- src/interface.c    2004/12/19 00:08:01     114
++++ src/interface.c    2006/03/07 13:15:11     133
+@@ -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-nlapi.diff b/sys-apps/ifplugd/files/ifplugd-0.28-nlapi.diff
new file mode 100644 (file)
index 0000000..b640543
--- /dev/null
@@ -0,0 +1,12 @@
+diff -urN src/nlapi.c src/nlapi.c
+--- src/nlapi.c        2004-12-20 08:39:14.682706517 -0500
++++ src/nlapi.c        2004-12-20 08:39:50.185734092 -0500
+@@ -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 (file)
index 0000000..5daa453
--- /dev/null
@@ -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 (file)
index 0000000..3c5de8a
--- /dev/null
@@ -0,0 +1,63 @@
+--- src/interface.c.orig       2007-03-23 13:29:40.000000000 +0000
++++ src/interface.c    2007-03-23 13:30:05.000000000 +0000
+@@ -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 (file)
index 0000000..ba4cfd7
--- /dev/null
@@ -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 (file)
index 0000000..6880f5e
--- /dev/null
@@ -0,0 +1,70 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/ifplugd/ifplugd-0.28-r9.ebuild,v 1.8 2012/05/04 09:17:30 jdhore Exp $
+
+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="~arm amd64 hppa ppc x86"
+IUSE="doc"
+
+DEPEND="virtual/pkgconfig
+       doc? ( www-client/lynx )
+       >=dev-libs/libdaemon-0.5"
+RDEPEND=">=dev-libs/libdaemon-0.5
+       >=sys-apps/baselayout-1.12"
+
+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 (file)
index 0000000..26ed76b
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+       <herd>base-system</herd>
+       <longdescription lang="en">
+               Brings up/down ethernet ports automatically with cable detection
+       </longdescription>
+</pkgmetadata>