summaryrefslogtreecommitdiff
path: root/system/mdevd
diff options
context:
space:
mode:
authorLaurent Bercot <ska-adelie@skarnet.org>2019-10-03 10:27:04 -0500
committerLaurent Bercot <ska-adelie@skarnet.org>2019-10-03 10:27:04 -0500
commit5303f83e37818283991fc5e3966076e14f246077 (patch)
tree1e39931e880ba5bfa11445c4cb4e8a6d047bfcbc /system/mdevd
parent651e22f2032fd7949e52102aa000c5943e654e42 (diff)
downloadpackages-5303f83e37818283991fc5e3966076e14f246077.tar.gz
packages-5303f83e37818283991fc5e3966076e14f246077.tar.bz2
packages-5303f83e37818283991fc5e3966076e14f246077.tar.xz
packages-5303f83e37818283991fc5e3966076e14f246077.zip
system/mdevd: new package. PLEASE REVIEW.
Diffstat (limited to 'system/mdevd')
-rw-r--r--system/mdevd/APKBUILD58
-rw-r--r--system/mdevd/mdev.conf77
-rw-r--r--system/mdevd/mdevd.initd41
-rw-r--r--system/mdevd/mdevd.run3
4 files changed, 179 insertions, 0 deletions
diff --git a/system/mdevd/APKBUILD b/system/mdevd/APKBUILD
new file mode 100644
index 000000000..c902bb6a8
--- /dev/null
+++ b/system/mdevd/APKBUILD
@@ -0,0 +1,58 @@
+# Contributor: Laurent Bercot <ska-adelie@skarnet.org>
+# Maintainer: Laurent Bercot <ska-adelie@skarnet.org>
+pkgname=mdevd
+pkgver=0.1.1.0
+pkgrel=1
+pkgdesc="A small uevent manager daemon"
+url="https://skarnet.org/software/$pkgname/"
+arch="all"
+options="!check" # No test suite.
+license="ISC"
+_skalibs_version=2.9.0.0
+makedepends="skalibs-dev>=$_skalibs_version"
+subpackages="$pkgname-doc $pkgname-openrc"
+provides="udev=176"
+replaces="eudev"
+source="https://skarnet.org/software/$pkgname/$pkgname-$pkgver.tar.gz mdev.conf mdevd.run mdevd.initd"
+
+build() {
+ cd "$builddir"
+ ./configure --enable-allstatic --enable-static-libc
+ make
+}
+
+package() {
+ svcdir="$pkgdir/etc/s6-linux-init/current/run-image/service/mdevd"
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+ mkdir -p -m 0755 "$svcdir"
+ cp -f "$srcdir/mdev.conf" "$pkgdir/etc/"
+ chmod 0644 "$pkgdir/etc/mdev.conf"
+ cp -f "$srcdir/mdevd.run" "$svcdir/run"
+ echo 3 > "$svcdir/notification-fd"
+ touch "$svcdir/down"
+}
+
+
+doc() {
+ pkgdesc="$pkgdesc (documentation)"
+ depends=
+ install_if="docs $pkgname=$pkgver-r$pkgrel"
+ mkdir -p "$subpkgdir/usr/share/doc"
+ cp -a "$builddir/doc" "$subpkgdir/usr/share/doc/$pkgname"
+}
+
+
+openrc() {
+ replaces="eudev-openrc"
+ rldir="$subpkgdir"/etc/runlevels/sysinit
+ default_openrc
+ mkdir -p "$rldir"
+ ln -s ../../init.d/mdevd "$rldir/mdevd"
+ ln -s ../../init.d/mdevd-coldplug "$rldir/mdevd-coldplug"
+}
+
+sha512sums="94bbcaf0c39511da392c932c5d38ced7029727a46997877d03bba41fc7302df3d4400d3957be9361055e954f3a22b785db40d56bb2f031bc49bb2f398179efe0 mdevd-0.1.1.0.tar.gz
+0533b15f0e6349fda3e2da7cfa8e83600e4dd75f5701204b971d97b614d9de499e48bc84f2a2fadcb9682e6a987c72f514c1665545e03b163b91c8915f5ad5d0 mdev.conf
+31231b28d0b980dda634e8b043a2ee31960493d60c2c9aac8a4f3f68ca1d130342569af2acd0bc04d9d8008b8e234ba949b64d9ec3ff1bded64b4e4f0ce3786b mdevd.run
+f6f9eebf49c2de6abde9cfb7a9d7b3a6b3afdd3e01ba4155f1b95dfa27e522363059b69cec19305881773d776ffeccf6c1106d537d01780468bd3b9846edb2cc mdevd.initd"
diff --git a/system/mdevd/mdev.conf b/system/mdevd/mdev.conf
new file mode 100644
index 000000000..1ad0091ad
--- /dev/null
+++ b/system/mdevd/mdev.conf
@@ -0,0 +1,77 @@
+# Thanks to Piotr Karbowski for mdev-like-a-boss.
+# TODO: audit the helpers and adapt them to Adélie
+
+$MODALIAS=.* 0:0 0600 @modprobe -b "$MODALIAS"
+
+console 0:0 0600
+null 0:0 0666
+urandom 0:0 0666
+random 0:0 0444
+kmem 0:0 0000
+zero 0:0 0444
+full 0:0 0222
+ptmx 0:0 0666
+pty.* 0:0 0600
+fuse 0:0 0666
+
+mem root:kmem 0640
+ptmx root:tty 0666
+
+# Typical devices
+tty root:tty 0666
+tty[0-9]* root:tty 0660
+vcs* root:tty 0660
+ttyS[0-9]* root:dialout 0660
+
+# block devices
+ram([0-9]*) root:disk 0660
+loop([0-9]+) root:disk 0660
+fd[0-9]* root:floppy 0660
+sd[a-z].* root:disk 0660 # */opt/mdev/helpers/storage-device
+vd[a-z].* root:disk 0660 # */opt/mdev/helpers/storage-device
+hd[a-z].* root:disk 0660 # */opt/mdev/helpers/storage-device
+md[0-9]* root:disk 0660 # */opt/mdev/helpers/storage-device
+dm-[0-9]* root:disk 0660 # */opt/mdev/helpers/storage-device
+bcache[0-9]* root:disk 0660 # */opt/mdev/helpers/storage-device
+mmcblk[0-9].* root:disk 0660 # */opt/mdev/helpers/storage-device
+sr[0-9]* root:cdrom 0660 @ln -sf $MDEV cdrom
+
+# Run settle-nics every time new NIC appear.
+# If you don't want to auto-populate /etc/mactab with NICs, run 'settle-nis' without '--write-mactab' param.
+# -SUBSYSTEM=net;DEVPATH=.*/net/.*;.* root:root 600 @/opt/mdev/helpers/settle-nics --write-mactab
+
+net/tun[0-9]* root:kvm 0660
+net/tap[0-9]* root:root 0600
+
+# alsa sound devices and audio stuff
+SUBSYSTEM=sound;.* root:audio 0660 # @/opt/mdev/helpers/sound-control
+
+adsp root:audio 0660 # >sound/
+audio root:audio 0660 # >sound/
+dsp root:audio 0660 # >sound/
+mixer root:audio 0660 # >sound/
+sequencer.* root:audio 0660 # >sound/
+
+
+# raid controllers
+cciss!(.*) root:disk 0660 =cciss/%1
+ida!(.*) root:disk 0660 =ida/%1
+rd!(.*) root:disk 0660 =rd/%1
+
+agpgart root:root 0660 # >misc/
+psaux root:root 0660 # >misc/
+rtc[0-9]* root:root 0600 @ln -sf $MDEV rtc
+
+# input stuff
+SUBSYSTEM=input;.* root:input 0660
+
+# v4l stuff
+vbi[0-9] root:video 660 >v4l/
+video[0-9] root:video 660 >v4l/
+
+# dvb stuff
+dvb.* root:video 660
+
+# drm etc
+card[0-9] root:video 0660 =dri/
+dri/.* root:video 0660
diff --git a/system/mdevd/mdevd.initd b/system/mdevd/mdevd.initd
new file mode 100644
index 000000000..3f6bccf86
--- /dev/null
+++ b/system/mdevd/mdevd.initd
@@ -0,0 +1,41 @@
+#!/sbin/openrc-run
+# Copyright 2019 Adélie Linux
+
+description="mdevd manages device permissions and symbolic links in /dev"
+extra_started_commands="reload"
+description_reload="Reload the mdevd configuration file"
+
+depend()
+{
+ use modloop
+ need sysfs dev-mount
+ before checkfs fsck
+ keyword -lxc -systemd-nspawn -vserver
+ provide dev
+}
+
+stop()
+{
+ ebegin "Stopping mdevd"
+ touch /run/service/mdevd/down
+ s6-svc -d /run/service/mdevd
+ eend $?
+}
+
+start()
+{
+ ebegin "Starting mdevd"
+ rm -f /run/service/mdevd/down
+ s6-svc -uwU /run/service/mdevd
+ eend $?
+ ebegin "Coldplugging devices"
+ mdevd-coldplug
+ eend $?
+}
+
+reload()
+{
+ ebegin "Reloading mdevd config file"
+ s6-svc -h /run/service/mdevd
+ eend $?
+}
diff --git a/system/mdevd/mdevd.run b/system/mdevd/mdevd.run
new file mode 100644
index 000000000..d4b5b8320
--- /dev/null
+++ b/system/mdevd/mdevd.run
@@ -0,0 +1,3 @@
+#!/bin/execlineb -P
+
+mdevd -D 3