From 56bd759df1d0c750a065b8c845e93d5dfa6b549d Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sat, 8 Aug 2015 13:49:04 -0700 Subject: proj/gentoo: Initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson X-Thanks: Alec Warner - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring - wrote much python to improve cvs2svn X-Thanks: Rich Freeman - validation scripts X-Thanks: Patrick Lauer - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed --- sys-apps/netplug/Manifest | 1 + .../files/netplug-1.2.9-ignore-wireless.patch | 37 ++++ .../netplug/files/netplug-1.2.9-remove-nest.patch | 187 +++++++++++++++++++++ sys-apps/netplug/files/netplug-2 | 43 +++++ sys-apps/netplug/metadata.xml | 11 ++ sys-apps/netplug/netplug-1.2.9.2-r1.ebuild | 64 +++++++ 6 files changed, 343 insertions(+) create mode 100644 sys-apps/netplug/Manifest create mode 100644 sys-apps/netplug/files/netplug-1.2.9-ignore-wireless.patch create mode 100644 sys-apps/netplug/files/netplug-1.2.9-remove-nest.patch create mode 100755 sys-apps/netplug/files/netplug-2 create mode 100644 sys-apps/netplug/metadata.xml create mode 100644 sys-apps/netplug/netplug-1.2.9.2-r1.ebuild (limited to 'sys-apps/netplug') diff --git a/sys-apps/netplug/Manifest b/sys-apps/netplug/Manifest new file mode 100644 index 000000000000..ebf69a0f3b6f --- /dev/null +++ b/sys-apps/netplug/Manifest @@ -0,0 +1 @@ +DIST netplug-1.2.9.2.tar.bz2 22332 SHA256 5180dfd9a7d3d0633a027b0a04f01b45a6a64623813cd48bd54423b90814864e SHA512 b68a00eb8874ec7dd6aa9f7b7f529a6e1d9ecece4b798c8cee996b7f3534c556656f642de0ac4b2a6d06fbaf18e3bfaab00934a9292b95939a4935e673e9ca8c WHIRLPOOL 51d54d4c7784b82b71b3a8964c9df3f17e8df1b21b11a95250f911c6f0917aabab1bf0fe5117884623b3222b1df0c443ce4416ad74f63c0d761f762e5f39216f diff --git a/sys-apps/netplug/files/netplug-1.2.9-ignore-wireless.patch b/sys-apps/netplug/files/netplug-1.2.9-ignore-wireless.patch new file mode 100644 index 000000000000..de5cba2cb08d --- /dev/null +++ b/sys-apps/netplug/files/netplug-1.2.9-ignore-wireless.patch @@ -0,0 +1,37 @@ +--- netplug-1.2.9/main.c ++++ netplug-1.2.9/main.c +@@ -36,6 +36,10 @@ + + #include "netplug.h" + ++/* Support old kernels without wireless */ ++#ifndef IFLA_WIRELESS ++#define IFLA_WIRELESS (IFLA_MASTER + 1) ++#endif /* IFLA_WIRELESS */ + + int use_syslog; + static char *pid_file; +@@ -63,6 +67,14 @@ + + parse_rtattrs(attrs, IFLA_MAX, IFLA_RTA(info), len); + ++ /* Ignore wireless messages */ ++ if (attrs[IFLA_WIRELESS] != NULL ++ && hdr->nlmsg_type == RTM_NEWLINK ++ && info->ifi_change == 0) { ++ do_log(LOG_DEBUG, "Ignoring wireless netlink message"); ++ return 0; ++ } ++ + if (attrs[IFLA_IFNAME] == NULL) { + do_log(LOG_ERR, "No interface name"); + return -1; +@@ -71,7 +83,7 @@ + char *name = RTA_DATA(attrs[IFLA_IFNAME]); + + if (!if_match(name)) { +- do_log(LOG_INFO, "%s: ignoring event", name); ++ do_log(LOG_DEBUG, "%s: ignoring event", name); + return 0; + } + diff --git a/sys-apps/netplug/files/netplug-1.2.9-remove-nest.patch b/sys-apps/netplug/files/netplug-1.2.9-remove-nest.patch new file mode 100644 index 000000000000..0a3b991a82bf --- /dev/null +++ b/sys-apps/netplug/files/netplug-1.2.9-remove-nest.patch @@ -0,0 +1,187 @@ +This patch replaces the for_each_iface nested funtion with a macro so that we +don't have an executable stack and work correctly on NX capable hardware. +See http://www.gentoo.org/proj/en/hardened/gnu-stack.xml for more information. + +Patch by Diego Pettenò (flameeyes@gentoo.org) + +Index: netplug-1.2.9/if_info.c +=================================================================== +--- netplug-1.2.9.orig/if_info.c ++++ netplug-1.2.9/if_info.c +@@ -29,8 +29,7 @@ + + #include "netplug.h" + +-#define INFOHASHSZ 16 /* must be a power of 2 */ +-static struct if_info *if_info[INFOHASHSZ]; ++struct if_info *if_info[INFOHASHSZ]; + + static const char * + statename(enum ifstate s) +@@ -95,17 +94,6 @@ flags_str(char *buf, unsigned int fl) + return buf; + } + +-void +-for_each_iface(int (*func)(struct if_info *)) +-{ +- for(int i = 0; i < INFOHASHSZ; i++) { +- for(struct if_info *info = if_info[i]; info != NULL; info = info->next) { +- if ((*func)(info)) +- return; +- } +- } +-} +- + /* Reevaluate the state machine based on the current state and flag settings */ + void + ifsm_flagpoll(struct if_info *info) +@@ -284,6 +272,14 @@ ifsm_flagchange(struct if_info *info, un + info->lastchange = time(0); + } + ++int find_pid(struct if_info *i, pid_t pid, struct if_info **info) { ++ if (i->worker == pid) { ++ *info = i; ++ return 1; ++ } ++ return 0; ++} ++ + /* handle a script termination and update the state accordingly */ + void ifsm_scriptdone(pid_t pid, int exitstatus) + { +@@ -291,16 +287,8 @@ void ifsm_scriptdone(pid_t pid, int exit + struct if_info *info; + assert(WIFEXITED(exitstatus) || WIFSIGNALED(exitstatus)); + +- int find_pid(struct if_info *i) { +- if (i->worker == pid) { +- info = i; +- return 1; +- } +- return 0; +- } +- + info = NULL; +- for_each_iface(find_pid); ++ for_each_iface(find_pid, pid, &info); + + if (info == NULL) { + do_log(LOG_INFO, "Unexpected child %d exited with status %d", +Index: netplug-1.2.9/main.c +=================================================================== +--- netplug-1.2.9.orig/main.c ++++ netplug-1.2.9/main.c +@@ -164,6 +164,23 @@ child_handler(int sig, siginfo_t *info, + write(child_handler_pipe[1], &ce, sizeof(ce)); + } + ++int pollflags_state(struct if_info *info, int sockfd) { ++ struct ifreq ifr; ++ ++ if (!if_match(info->name)) ++ return 0; ++ ++ memcpy(ifr.ifr_name, info->name, sizeof(ifr.ifr_name)); ++ if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) ++ do_log(LOG_ERR, "%s: can't get flags: %m", info->name); ++ else { ++ ifsm_flagchange(info, ifr.ifr_flags); ++ ifsm_flagpoll(info); ++ } ++ ++ return 0; ++} ++ + /* Poll the existing interface state, so we can catch any state + changes for which we may not have neen a netlink message. */ + static void +@@ -180,28 +197,20 @@ poll_interfaces(void) + close_on_exec(sockfd); + } + +- int pollflags(struct if_info *info) { +- struct ifreq ifr; +- +- if (!if_match(info->name)) +- return 0; +- +- memcpy(ifr.ifr_name, info->name, sizeof(ifr.ifr_name)); +- if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) +- do_log(LOG_ERR, "%s: can't get flags: %m", info->name); +- else { +- ifsm_flagchange(info, ifr.ifr_flags); +- ifsm_flagpoll(info); +- } +- +- return 0; +- } +- +- for_each_iface(pollflags); ++ for_each_iface(pollflags_state, sockfd); + } + + int debug = 0; + ++/* Run over each of the interfaces we know and care about, and ++ make sure the state machine has done the appropriate thing ++ for their current state. */ ++int poll_flags_check(struct if_info *i) { ++ if (if_match(i->name)) ++ ifsm_flagpoll(i); ++ return 0; ++} ++ + int + main(int argc, char *argv[]) + { +@@ -331,17 +340,7 @@ main(int argc, char *argv[]) + { child_handler_pipe[0], POLLIN, 0 }, + }; + +- { +- /* Run over each of the interfaces we know and care about, and +- make sure the state machine has done the appropriate thing +- for their current state. */ +- int poll_flags(struct if_info *i) { +- if (if_match(i->name)) +- ifsm_flagpoll(i); +- return 0; +- } +- for_each_iface(poll_flags); +- } ++ for_each_iface(poll_flags_check); + + for(;;) { + int ret; +Index: netplug-1.2.9/netplug.h +=================================================================== +--- netplug-1.2.9.orig/netplug.h ++++ netplug-1.2.9/netplug.h +@@ -28,6 +28,9 @@ + + #define NP_SCRIPT NP_SCRIPT_DIR "/netplug" + ++#define INFOHASHSZ 16 /* must be a power of 2 */ ++extern struct if_info *if_info[INFOHASHSZ]; ++ + /* configuration */ + + void read_config(char *filename); +@@ -83,7 +86,14 @@ struct if_info *if_info_update_interface + struct rtattr *attrs[]); + int if_info_save_interface(struct nlmsghdr *hdr, void *arg); + void parse_rtattrs(struct rtattr *tb[], int max, struct rtattr *rta, int len); +-void for_each_iface(int (*func)(struct if_info *)); ++ ++#define for_each_iface(func, ...) \ ++ for(int i = 0; i < INFOHASHSZ; i++) { \ ++ for(struct if_info *each_iface = if_info[i]; each_iface != NULL; each_iface = each_iface->next) { \ ++ if (func (each_iface, ##__VA_ARGS__)) \ ++ break; \ ++ } \ ++ } + + void ifsm_flagpoll(struct if_info *info); + void ifsm_flagchange(struct if_info *info, unsigned int newflags); diff --git a/sys-apps/netplug/files/netplug-2 b/sys-apps/netplug/files/netplug-2 new file mode 100755 index 000000000000..539f1465516a --- /dev/null +++ b/sys-apps/netplug/files/netplug-2 @@ -0,0 +1,43 @@ +#!/bin/sh +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# +# Gentoo-specific netplug script +# +# This file gets called by netplug when it wants to bring an interface +# up or down. +# + +IFACE="$1" +ACTION="$2" + +EXEC="/etc/init.d/net.${IFACE}" + +case "${ACTION}" in + in) + ARGS="--quiet start" + ;; + out) + ARGS="--quiet stop" + ;; + probe) + # Do nothing as we should already be up + exit 0 + ;; + *) + echo "$0: wrong arguments" >&2 + echo "Call with " >&2 + exit 1 + ;; +esac + +export IN_BACKGROUND=true + +if [ -x "${EXEC}" ] +then + ${EXEC} ${ARGS} + exit 0 +else + logger -t netplug "Error: Couldn't configure ${IFACE}, no ${EXEC} !" + exit 1 +fi diff --git a/sys-apps/netplug/metadata.xml b/sys-apps/netplug/metadata.xml new file mode 100644 index 000000000000..786355e6ed0d --- /dev/null +++ b/sys-apps/netplug/metadata.xml @@ -0,0 +1,11 @@ + + + + + polynomial-c@gentoo.org + Lars Wendler + + + Brings up/down ethernet ports automatically with cable detection + + diff --git a/sys-apps/netplug/netplug-1.2.9.2-r1.ebuild b/sys-apps/netplug/netplug-1.2.9.2-r1.ebuild new file mode 100644 index 000000000000..03d4dada07aa --- /dev/null +++ b/sys-apps/netplug/netplug-1.2.9.2-r1.ebuild @@ -0,0 +1,64 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 + +inherit eutils toolchain-funcs + +DESCRIPTION="Brings up/down ethernet ports automatically with cable detection" +HOMEPAGE="http://www.red-bean.com/~bos/" +SRC_URI="http://www.red-bean.com/~bos/netplug/${P}.tar.bz2" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="amd64 arm ~mips ppc sparc x86" +IUSE="debug doc" + +DEPEND="doc? ( app-text/ghostscript-gpl + media-gfx/graphviz )" +RDEPEND="" + +src_prepare() { + # Remove debug flags from CFLAGS + if ! use debug; then + sed -i -e "s/ -ggdb3//" Makefile || die + fi + + # Remove -O3 and -Werror from CFLAGS + sed -i -e "s/ -O3//" -e "s/ -Werror//" Makefile || die + + # Remove nested functions, #116140 + epatch "${FILESDIR}/${PN}-1.2.9-remove-nest.patch" + + # Ignore wireless events + epatch "${FILESDIR}/${PN}-1.2.9-ignore-wireless.patch" +} + +src_compile() { + tc-export CC + emake CC="${CC}" + + if use doc; then + emake -C docs/ + fi +} + +src_install() { + into / + dosbin netplugd + doman man/man8/netplugd.8 + + dodir /etc/netplug.d + exeinto /etc/netplug.d + newexe "${FILESDIR}/netplug-2" netplug + + dodir /etc/netplug + echo "eth*" > "${D}"/etc/netplug/netplugd.conf || die + + dodoc ChangeLog NEWS README TODO + + if use doc; then + dodoc docs/state-machine.ps + fi +} -- cgit v1.2.3-65-gdbad