aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-06-11 13:36:16 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-06-11 13:36:16 +0000
commit41fe3613bc94b79629f29e12034af2a226ebabca (patch)
tree8433891b1def71486b541c12e245ee9fa7ecfb3d /core
parent3744f0b3b510f2cf038b01d926cee645dabbd285 (diff)
downloadaports-41fe3613bc94b79629f29e12034af2a226ebabca.tar.gz
aports-41fe3613bc94b79629f29e12034af2a226ebabca.tar.bz2
aports-41fe3613bc94b79629f29e12034af2a226ebabca.tar.xz
core/openrc: moved hwdrivers and modloop from alpine-baselayout
Diffstat (limited to 'core')
-rw-r--r--core/openrc/APKBUILD8
-rw-r--r--core/openrc/hwdrivers.initd27
-rw-r--r--core/openrc/modloop.initd87
-rw-r--r--core/openrc/modules.initd2
4 files changed, 121 insertions, 3 deletions
diff --git a/core/openrc/APKBUILD b/core/openrc/APKBUILD
index 089751e761..4496505d3b 100644
--- a/core/openrc/APKBUILD
+++ b/core/openrc/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=openrc
pkgver=0.5.0
-pkgrel=2
+pkgrel=3
pkgdesc="OpenRC manages the services, startup and shutdown of a host"
url="http://roy.marples.name/openrc"
license='BSD-2'
@@ -12,8 +12,10 @@ source="http://roy.marples.name/downloads/$pkgname/$pkgname-$pkgver.tar.bz2
openrc-0.4.3-mkmntdirs.patch
openrc-hwclock.patch
hostname.initd
+ hwdrivers.initd
keymaps.initd
modules.initd
+ modloop.initd
networking.initd
$install
"
@@ -45,8 +47,10 @@ md5sums="9ec7f8425e12abbbd0f7a962aae3fa3c openrc-0.5.0.tar.bz2
8c2c1c2ee0509b63966b7187a2079f4b openrc-0.4.3-mkmntdirs.patch
f462c976b04cfbb35b2335be15eee7f6 openrc-hwclock.patch
c32e15b0858eef708497e7ee6355a055 hostname.initd
+b1e64885f301166df30be3e3cf5338ff hwdrivers.initd
33ca3e558c42cdd17adccbc7807298f7 keymaps.initd
-5608e6e3d836ad01b9714e5b41d223cb modules.initd
+098a1f16812f56fcb56eb6b6f0fa31f6 modules.initd
+2527250f613051be04fd31276661683d modloop.initd
747168eee535e845179eaef5a3fcb334 networking.initd
6e834194b246563fc5acd77e91e038c4 openrc.post-install
393ff61bc0bf2c07f9af81795554c584 openrc.post-upgrade"
diff --git a/core/openrc/hwdrivers.initd b/core/openrc/hwdrivers.initd
new file mode 100644
index 0000000000..3d0ebf12b5
--- /dev/null
+++ b/core/openrc/hwdrivers.initd
@@ -0,0 +1,27 @@
+#!/sbin/runscript
+
+depend() {
+ need sysfs dev
+ before checkfs fsck
+ after modloop
+ keyword novserver
+}
+
+# Load hardware drivers
+start() {
+ # check for boot option "nocoldplug"
+ if get_bootparam noautodetect; then
+ ewarn "Autodetection of hardware disabled from boot cmdline"
+ return 0
+ fi
+
+
+ ebegin "Loading hardware drivers"
+ find /sys -name modalias | xargs sort -u \
+ | xargs modprobe -a 2> /dev/null
+ # we run it twice so we detect all devices
+ find /sys -name modalias | xargs sort -u \
+ | xargs modprobe -a 2> /dev/null
+ eend 0
+}
+
diff --git a/core/openrc/modloop.initd b/core/openrc/modloop.initd
new file mode 100644
index 0000000000..66047da33b
--- /dev/null
+++ b/core/openrc/modloop.initd
@@ -0,0 +1,87 @@
+#!/sbin/runscript
+
+# script that will mount image with modules
+
+depend() {
+ need dev
+ before checkfs fsck hwdrivers modules
+ keyword novserver
+}
+
+# read kernel options
+init_KOPT() {
+ eval set -- $(cat /proc/cmdline 2>/dev/null)
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ *=*) eval "KOPT_${1%%=*}='${1#*=}'" ;;
+ *) eval "KOPT_$(echo $1 | sed 's: :_:g')=yes" ;;
+ esac
+ shift
+ done
+}
+
+find_mnt() {
+ local dev="$1"
+ local fsfile="$2"
+ awk "\$ == \"$dev\" {print \$2}\"" "$fsfile" 2>/dev/null
+}
+
+# initialies: alpine_dev, alpine_mnt, alpine_fs, alpine_mounted
+find_media() {
+ init_KOPT
+ alpine_mounted=
+ alpine_dev=${KOPT_alpine_dev%%:*}
+ alpine_fs=${KOPT_alpine_dev#*:}
+ [ "$alpine_fs" = "$KOPT_alpine_dev" ] && unset alpine_fs
+ # first we check if alpine_dev is mounted and use this
+ alpine_mnt=$(find_mnt /dev/$alpine_dev /proc/mounts)
+ if [ -z "$alpine_mnt" ]; then
+ # then we check fstab
+ alpine_mnt=$(find_mnt /dev/$alpine_dev /etc/fstab)
+ else
+ alpine_mounted=yes
+ fi
+ # finally we fallback to /media/<devicename>
+ [ -z "$alpine_mnt" ] && alpine_mnt=/media/$alpine_dev
+}
+
+start() {
+ local modloop mount_opts
+ find_media
+ if [ -z "$alpine_dev" ] ; then
+ ebegin "Skipping mount module loopback (specify with alpine_dev)"
+ eend 0
+ return 0
+ fi
+
+ modloop=${KOPT_modloop:-$KOPT_BOOT_IMAGE.cmg}
+ [ -n "$alpine_fs" ] && mount_opts="-t $alpine_fs"
+
+ ebegin "Mounting loopback device for kernel modules"
+ if [ -z "$alpine_mounted" ]; then
+ mount $mount_opts $alpine_dev $alpine_mnt 2>/dev/null
+ fi
+ mkdir -p /.modloop /lib
+
+ mount -o loop,ro -t cramfs $alpine_mnt/$modloop /.modloop &&\
+ rm -rf /lib/modules &&\
+ ln -sf /.modloop/modules /lib/
+ eend $?
+
+ # copy firmware if there are any
+ if [ -d $alpine_mnt/firmware ]; then
+ ebegin "Copying firmware from $alpine_mnt/firmware"
+ cp -R -a $alpine_mnt/firmware /lib/
+ eend $?
+ fi
+}
+
+stop() {
+ find_media
+ [ -z "$alpine_dev" ] && return 0
+ ebegin "Unmounting loopback device for kernel modules"
+ umount -d /.modloop &&\
+ umount $alpine_mnt 2>/dev/null
+ eend $?
+}
+
diff --git a/core/openrc/modules.initd b/core/openrc/modules.initd
index 14e28e2e84..ef7d1f15f1 100644
--- a/core/openrc/modules.initd
+++ b/core/openrc/modules.initd
@@ -4,7 +4,7 @@ description="Loads a user defined list of kernel modules."
depend()
{
- before hwclock
+ before hwclock hwdrivers
keyword noopenvz noprefix novserver
}