Subject: [alpine-aports] [PATCH 1/2] testing/nldev: new aport

From: Sören Tempel <[email-masked]>
Date: Mon, 29 Feb 2016 03:26:59 +0100

---
 testing/nldev/APKBUILD              | 94 +++++++++++++++++++++++++++++++++++++
 testing/nldev/increase-buffer.patch | 26 ++++++++++
 testing/nldev/mdev-path.patch       | 41 ++++++++++++++++
 testing/nldev/nldev-trigger.initd   | 13 +++++
 testing/nldev/nldev.initd           | 21 +++++++++
 testing/nldev/preserve-path.patch   | 46 ++++++++++++++++++
 6 files changed, 241 insertions(+)
 create mode 100644 testing/nldev/APKBUILD
 create mode 100644 testing/nldev/increase-buffer.patch
 create mode 100644 testing/nldev/mdev-path.patch
 create mode 100644 testing/nldev/nldev-trigger.initd
 create mode 100644 testing/nldev/nldev.initd
 create mode 100644 testing/nldev/preserve-path.patch

diff --git a/testing/nldev/APKBUILD b/testing/nldev/APKBUILD
new file mode 100644
index 0000000..5b0c78a
--- /dev/null
+++ b/testing/nldev/APKBUILD
@@ -0,0 +1,94 @@
+# Contributor: Sören Tempel <[email-masked]>
+# Maintainer: Sören Tempel <[email-masked]>
+pkgname=nldev
+pkgver=0.3_git20160208
+pkgrel=0
+verbase=0.3
+pkgdesc="A simple netlink device manager"
+url="http://git.r-36.net/nldev/"
+arch="all"
+license="MIT"
+depends=""
+depends_dev=""
+makedepends="linux-headers"
+install=""
+subpackages="$pkgname-doc"
+source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.gz
+	${pkgname}.initd
+	${pkgname}-trigger.initd
+
+	increase-buffer.patch
+	preserve-path.patch
+	mdev-path.patch"
+
+disturl="dev.alpinelinux.org:/archive/rtmpdump"
+reporev="e8a7f8c4131d39eaff0ebb186f6ee01a08db3e59"
+giturl="git://git.r-36.net/$pkgname"
+
+_builddir="$srcdir"/$pkgname-$pkgver
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+}
+
+build() {
+	make CFLAGS="$CFLAGS \${INCS} \${CPPFLAGS}" \
+		LDFLAGS="$LDFLAGS \${LIBS}" CC="${CC:-gcc}" \
+		-C "$_builddir" || return 1
+}
+
+package() {
+	cd "$_builddir"
+	make DESTDIR="$pkgdir" PREFIX=/ \
+		MANPREFIX=/usr/share/man install || return 1
+
+	# Move nldev to /sbin
+	mkdir -p "$pkgdir"/sbin/
+	mv "$pkgdir"/bin/$pkgname "$pkgdir"/sbin/ || return 1
+
+	# We don't need run_nldev, use the init script instead
+	rm -f "$pkgdir"/bin/run_$pkgname
+
+	# Install OpenRC service files
+	for service in ${pkgname} ${pkgname}-trigger; do
+		install -Dm755 "$srcdir"/$service.initd \
+			"$pkgdir"/etc/init.d/$service || return 1
+	done
+	
+	# Install utility scripts
+	mkdir -p "$pkgdir"/lib/$pkgname || return 1
+	install -m755 mdev/lib/* "$pkgdir"/lib/$pkgname/ || return 1
+
+	# Install additional documentation
+	mkdir -p "$pkgdir"/usr/share/doc/$pkgname/examples/
+	install -m644 FIXES.md README.md \
+		"$pkgdir"/usr/share/doc/$pkgname/ || return 1
+	install -m644 mdev/etc/* \
+		"$pkgdir"/usr/share/doc/$pkgname/examples || return 1
+	install -m755 mdev/lib/* \
+		"$pkgdir"/usr/share/doc/$pkgname/examples || return 1
+}
+
+md5sums="180f83ca7127c933df6b23470f4f00f4  nldev-0.3_git20160208.tar.gz
+cfd5fdea112868ef460cd34a60c8bb6a  nldev.initd
+f57e754d52f06529e82979db8bd3106e  nldev-trigger.initd
+05697c7f5073f2fb979499dd03cf5215  increase-buffer.patch
+9368bb6eff39d8cfd4f4d1d8b646e91c  preserve-path.patch
+d0ec31ac3d291d7407a93eb9937d4723  mdev-path.patch"
+sha256sums="5e361bf923b617dd68cc646acdebb83cc730027ac7f8b0dc40cc3a70c4f6915e  nldev-0.3_git20160208.tar.gz
+5bf4054e53415221929973f8e2b96944a138a30091f20a24de94cd062a5fef3a  nldev.initd
+1ab6163a350a7c7e377f0e6ea9070c736c434c9a55c3ef28438af552effa1714  nldev-trigger.initd
+5510964a91ce55e47ee9fc6054682bf000d06c4fffbb40ce92530c59fcc1a211  increase-buffer.patch
+089717cece9b04149cf3c5e096fd98474a1599c97ebf2daa19eceb64cf8b785f  preserve-path.patch
+cc77fa2599b0b4e18e6307a21081bf4ffe2f0320c114cd2e44a0d2787e780701  mdev-path.patch"
+sha512sums="70d9243593030e40735b5d089654f80dce8f8f33f0eea677b30a165be2a78c029688cc05922347ee37538178e5f6302fc8787114d5f0e790ec3018b1d79a56fa  nldev-0.3_git20160208.tar.gz
+022d596e2c598a0904721d042d6b33151c2df5ea5643ba6f8acec4993ce5ce47e68cd7ecfec1236dd68daa306ea6bcc386b4c28ab610ddac8acf7dc79606d17b  nldev.initd
+0e34e2db640bcfe7ba8b8e2a07a681906e7e6a2fe267f255a216c36e93db5096b7ed4865935ef448aabc8c4c130a786e555113d8ba90bed58f4ae3450890a1ea  nldev-trigger.initd
+155eaaab6fa263280d91f1d8480eff605b2bde4873552f5b6de56d9dc1a9f06fdf452171f38349b80fb53a3817d51440b3f5e3b63e94ee847358d6698cba9aaf  increase-buffer.patch
+141fc3e09d15174dc4c83c07f93549061a1a62d4b1d45d671d81097688d239b18fb0f6f51c0bf456dc7830381e884721d393124692126196a35dbbfa80f01538  preserve-path.patch
+f779f844fd4753f2dbb2474c5a2b2d90cc6288f9101f2e38b97add521bef8f0bb0abfa55fc75fa9004c7232fdef6a02ce9e19477d91ec7141bd51f59d2221489  mdev-path.patch"
diff --git a/testing/nldev/increase-buffer.patch b/testing/nldev/increase-buffer.patch
new file mode 100644
index 0000000..d93bff4
--- /dev/null
+++ b/testing/nldev/increase-buffer.patch
@@ -0,0 +1,26 @@
+From 04cef5812c3eb0b757876739dba1f91e1900d5bd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <[email-masked]>
+Date: Wed, 10 Feb 2016 22:57:13 +0100
+Subject: [PATCH] Revert "nldev: set kernel buffer to 16kb"
+
+This reverts commit 025a4aef1a05cf523fbdf98ed71fd2e7b902d7fd.
+---
+ nldev.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/nldev.c b/nldev.c
+index 018ed86..9153fd2 100644
+--- a/nldev.c
++++ b/nldev.c
+@@ -161,7 +161,7 @@ init_netlink_socket(void)
+ 	if (fd < 0)
+ 		edie("socket");
+ 
+-	slen = 16*1024;
++	slen = 128*1024*1024;
+ 	if (setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, &slen,
+ 				sizeof(slen)) < 0) {
+ 		edie("setsockopt");
+-- 
+2.7.1
+
diff --git a/testing/nldev/mdev-path.patch b/testing/nldev/mdev-path.patch
new file mode 100644
index 0000000..f24c7e7
--- /dev/null
+++ b/testing/nldev/mdev-path.patch
@@ -0,0 +1,41 @@
+From 9521d52c1bc2dccebfcae4041e49783961d583c3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <[email-masked]>
+Date: Wed, 10 Feb 2016 23:29:04 +0100
+Subject: [PATCH] Change the default mdev path to /sbin/mdev
+
+You can set it using the -r command line flag but I prefer it when
+things work out of the box (the flag is nice to have non the less).
+---
+ nldev.8 | 2 +-
+ nldev.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/nldev.8 b/nldev.8
+index b1c18db..45c307b 100644
+--- a/nldev.8
++++ b/nldev.8
+@@ -56,7 +56,7 @@ Only show netlink messages from libudev.
+ .
+ .It Fl r Ar runpath
+ This option specifies the runpath for the helper that is launched
+-on every received netlink event (default: /bin/mdev).
++on every received netlink event (default: /sbin/mdev).
+ .El
+ .
+ .Sh AUTHORS
+diff --git a/nldev.c b/nldev.c
+index deabf10..a1d529a 100644
+--- a/nldev.c
++++ b/nldev.c
+@@ -201,7 +201,7 @@ main(int argc, char *argv[])
+ 	showkernel = 1;
+ 	showudev = 1;
+ 	subsystem = NULL;
+-	runpath = "/bin/mdev";
++	runpath = "/sbin/mdev";
+ 
+ 	origpath = getenv("PATH");
+ 	if (!origpath || strlen(origpath) <= 0)
+-- 
+2.7.1
+
diff --git a/testing/nldev/nldev-trigger.initd b/testing/nldev/nldev-trigger.initd
new file mode 100644
index 0000000..65482d8
--- /dev/null
+++ b/testing/nldev/nldev-trigger.initd
@@ -0,0 +1,13 @@
+#!/sbin/openrc-run
+
+depend() {
+	need nldev
+	provide dev
+	keyword -lxc -vserver
+}
+
+start() {
+	ebegin "Populating /dev with existing devices through uevents"
+	/bin/nltrigger add all
+	eend $?
+}
diff --git a/testing/nldev/nldev.initd b/testing/nldev/nldev.initd
new file mode 100644
index 0000000..ea53273
--- /dev/null
+++ b/testing/nldev/nldev.initd
@@ -0,0 +1,21 @@
+#!/sbin/openrc-run
+
+name="$SVCNAME"
+command="/sbin/$SVCNAME"
+command_args="${NLDEV_OPTS:--k}"
+pidfile="/var/run/$SVCNAME.pid"
+command_background="yes"
+
+depend() {
+	provide dev
+	need sysfs dev-mount
+	before checkfs fsck
+	keyword -lxc -vserver
+}
+
+start_pre() {
+	if [ -e /proc/self/fd ]; then
+		rm -f /dev/fd 2>/dev/null
+		ln -sf /proc/self/fd /dev/fd
+	fi
+}
diff --git a/testing/nldev/preserve-path.patch b/testing/nldev/preserve-path.patch
new file mode 100644
index 0000000..b7ba6b5
--- /dev/null
+++ b/testing/nldev/preserve-path.patch
@@ -0,0 +1,46 @@
+From bbb4cfb740e978baed409ea714f32c30c02e6c72 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <[email-masked]>
+Date: Wed, 10 Feb 2016 23:26:23 +0100
+Subject: [PATCH] Preserve the PATH environment variable
+
+No idea why this wasn't done before...
+---
+ nldev.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/nldev.c b/nldev.c
+index 9153fd2..deabf10 100644
+--- a/nldev.c
++++ b/nldev.c
+@@ -193,7 +193,7 @@ main(int argc, char *argv[])
+ 	struct msghdr hdr;
+ 	struct iovec iov;
+ 	char buf[4097], *subsystem, *runpath, *key, *value,
+-	     cbuf[CMSG_SPACE(sizeof(struct ucred))];
++	     *origpath, cbuf[CMSG_SPACE(sizeof(struct ucred))];
+ 	struct cmsghdr *chdr;
+ 	struct ucred *cred;
+ 	int i, len, slen, showudev, showkernel;
+@@ -203,6 +203,10 @@ main(int argc, char *argv[])
+ 	subsystem = NULL;
+ 	runpath = "/bin/mdev";
+ 
++	origpath = getenv("PATH");
++	if (!origpath || strlen(origpath) <= 0)
++		origpath = "/sbin:/bin";
++
+ 	ARGBEGIN {
+ 	case 'b':
+ 		dofork = 1;
+@@ -242,7 +246,7 @@ main(int argc, char *argv[])
+ 	buf[sizeof(buf)-1] = '\0';
+ 	while (poll(&fds, 1, -1) > -1) {
+ 		clearenv();
+-		setenv("PATH", "/sbin:/bin", 1);
++		setenv("PATH", origpath, 1);
+ 
+ 		iov.iov_base = &buf;
+ 		iov.iov_len = sizeof(buf);
+-- 
+2.7.1
+
-- 
2.7.2

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Sören Tempel <[email-masked]>
Date: Mon, 29 Feb 2016 03:27:00 +0100

---
 testing/nlmon/APKBUILD | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 testing/nlmon/APKBUILD

diff --git a/testing/nlmon/APKBUILD b/testing/nlmon/APKBUILD
new file mode 100644
index 0000000..f3aa7c5
--- /dev/null
+++ b/testing/nlmon/APKBUILD
@@ -0,0 +1,46 @@
+# Contributor: Sören Tempel <[email-masked]>
+# Maintainer: Sören Tempel <[email-masked]>
+pkgname=nlmon
+pkgver=0.3_git20160208
+pkgrel=0
+verbase=0.3
+pkgdesc="A lightweight udevadm monitor replacement"
+url="http://git.r-36.net/nlmon/"
+arch="all"
+license="MIT"
+depends=""
+depends_dev=""
+makedepends="linux-headers"
+install=""
+subpackages="$pkgname-doc"
+source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.gz"
+
+disturl="dev.alpinelinux.org:/archive/rtmpdump"
+reporev="5881cff90359800b1d01ebc0bf35f53f4a67815d"
+giturl="git://git.r-36.net/$pkgname"
+
+_builddir="$srcdir"/$pkgname-$pkgver
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+}
+
+build() {
+	make CFLAGS="$CFLAGS \${INCS} \${CPPFLAGS}" \
+		LDFLAGS="$LDFLAGS \${LIBS}" CC="${CC:-gcc}" \
+		-C "$_builddir" || return 1
+}
+
+package() {
+	make DESTDIR="$pkgdir" PREFIX=/usr \
+		-C "$_builddir" install || return 1
+}
+
+md5sums="79cc3840879d6370aa5adccc97c7acf2  nlmon-0.3_git20160208.tar.gz"
+sha256sums="e9e113d344372c7b9d8321f6fa19a35b190e2989bbda9a005a049b499faef11a  nlmon-0.3_git20160208.tar.gz"
+sha512sums="581cb69224552fe293f3ed2da783223570e19d84cbab5c12479cf48088522b9a1d565626d1c24690cb2464858f34cfa9595830395e70f36056ab71631afad3a0  nlmon-0.3_git20160208.tar.gz"
-- 
2.7.2

---