summaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/openrc/0001-call-sbin-mkmntdirs-in-localmount-OpenRC-service.patch25
-rw-r--r--system/openrc/0002-force-root-be-rw-before-localmount.patch30
-rw-r--r--system/openrc/0003-sysctl-add-compatibility-for-busybox-sysctl.patch46
-rw-r--r--system/openrc/0004-hide-error-when-migrating-var-run-to-run.patch28
-rw-r--r--system/openrc/0005-rc-pull-in-sysinit-and-boot-as-stacked-levels-when-n.patch71
-rw-r--r--system/openrc/0006-mount-efivars-read-only.patch27
-rw-r--r--system/openrc/0007-make-consolefont-service-compatible-with-busyboxs-se.patch70
-rw-r--r--system/openrc/APKBUILD93
-rw-r--r--system/openrc/hostname.initd18
-rw-r--r--system/openrc/hwdrivers.initd32
-rw-r--r--system/openrc/keymaps.initd20
-rw-r--r--system/openrc/modloop.confd3
-rw-r--r--system/openrc/modloop.initd124
-rw-r--r--system/openrc/modules.initd29
-rw-r--r--system/openrc/openrc-configuration.patch20
-rw-r--r--system/openrc/openrc.logrotate4
-rw-r--r--system/openrc/openrc.post-install36
-rw-r--r--system/openrc/openrc.post-upgrade35
-rw-r--r--system/openrc/sysfsconf.initd66
19 files changed, 777 insertions, 0 deletions
diff --git a/system/openrc/0001-call-sbin-mkmntdirs-in-localmount-OpenRC-service.patch b/system/openrc/0001-call-sbin-mkmntdirs-in-localmount-OpenRC-service.patch
new file mode 100644
index 000000000..f6996b3fc
--- /dev/null
+++ b/system/openrc/0001-call-sbin-mkmntdirs-in-localmount-OpenRC-service.patch
@@ -0,0 +1,25 @@
+From 94742e085ac96d366401df883df96d35d0eafd5a Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 1 Feb 2017 04:04:52 +0000
+Subject: [PATCH 1/7] call /sbin/mkmntdirs in localmount OpenRC service
+
+---
+ init.d/localmount.in | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/init.d/localmount.in b/init.d/localmount.in
+index cae80c34..3dbb375b 100644
+--- a/init.d/localmount.in
++++ b/init.d/localmount.in
+@@ -21,6 +21,8 @@ depend()
+
+ start()
+ {
++ [ -x /sbin/mkmntdirs ] && mkmntdirs
++
+ # Mount local filesystems in /etc/fstab.
+ # The types variable must start with no, and must be a type
+ local critical= types="noproc" x= no_netdev= rc=
+--
+2.11.0
+
diff --git a/system/openrc/0002-force-root-be-rw-before-localmount.patch b/system/openrc/0002-force-root-be-rw-before-localmount.patch
new file mode 100644
index 000000000..1c9f12c1a
--- /dev/null
+++ b/system/openrc/0002-force-root-be-rw-before-localmount.patch
@@ -0,0 +1,30 @@
+From 228df9f1f21e08ec659d5fcf1f716393e563a3a5 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 1 Feb 2017 04:05:44 +0000
+Subject: [PATCH 2/7] force root be rw before localmount
+
+The service that pulls in root remount is mtab which we dont need/use.
+---
+ init.d/localmount.in | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/init.d/localmount.in b/init.d/localmount.in
+index 9c8da2d0..c349c951 100644
+--- a/init.d/localmount.in
++++ b/init.d/localmount.in
+@@ -13,9 +13,9 @@ description="Mounts disks and swap according to /etc/fstab."
+
+ depend()
+ {
+- need fsck
+- use lvm modules mtab root
+- after lvm modules root
++ need fsck root
++ use lvm modules mtab
++ after lvm modules
+ keyword -docker -jail -lxc -prefix -systemd-nspawn -vserver
+ }
+
+--
+2.11.1
+
diff --git a/system/openrc/0003-sysctl-add-compatibility-for-busybox-sysctl.patch b/system/openrc/0003-sysctl-add-compatibility-for-busybox-sysctl.patch
new file mode 100644
index 000000000..3803bcca8
--- /dev/null
+++ b/system/openrc/0003-sysctl-add-compatibility-for-busybox-sysctl.patch
@@ -0,0 +1,46 @@
+From ed120780512b6dd0bfabba0ea59d06d1099924b0 Mon Sep 17 00:00:00 2001
+From: William Pitcock <nenolod@dereferenced.org>
+Date: Wed, 1 Feb 2017 04:08:33 +0000
+Subject: [PATCH 3/7] sysctl: add compatibility for busybox sysctl
+
+---
+ init.d/sysctl.in | 21 +++++++++++++++++++--
+ 1 file changed, 19 insertions(+), 2 deletions(-)
+
+diff --git a/init.d/sysctl.in b/init.d/sysctl.in
+index cb756f3a..fc22364b 100644
+--- a/init.d/sysctl.in
++++ b/init.d/sysctl.in
+@@ -38,10 +38,27 @@ BSD_sysctl()
+
+ Linux_sysctl()
+ {
+- local quiet
++ local quiet retval=0
+ yesno $rc_verbose || quiet=-q
+
+- sysctl ${quiet} --system
++ set --
++ eindent
++ for i in /run/sysctl.d/*.conf \
++ /etc/sysctl.d/*.conf \
++ /usr/local/lib/sysctl.d/*.conf \
++ /usr/lib/sysctl.d/*.conf \
++ /lib/sysctl.d/*.conf \
++ /etc/sysctl.conf; do
++ if [ -e "$i" ]; then
++ vebegin "applying $conf"
++ sysctl ${quiet} -p "$i"
++ retval=$(( $retval + $? ))
++ veend $retval
++ fi
++ done
++ eoutdent
++
++ return $retval
+ }
+
+ start()
+--
+2.11.0
+
diff --git a/system/openrc/0004-hide-error-when-migrating-var-run-to-run.patch b/system/openrc/0004-hide-error-when-migrating-var-run-to-run.patch
new file mode 100644
index 000000000..801d3b236
--- /dev/null
+++ b/system/openrc/0004-hide-error-when-migrating-var-run-to-run.patch
@@ -0,0 +1,28 @@
+From 496b984f889531bf629d77a5fa2211f8cb0a1183 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 17 Aug 2016 17:18:21 +0200
+Subject: [PATCH 4/7] hide error when migrating /var/run to /run
+
+The script tries to copy non-existing files. We simply hide the error
+
+http://bugs.alpinelinux.org/issues/3160
+---
+ init.d/bootmisc.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in
+index efc1c572..6e473ade 100644
+--- a/init.d/bootmisc.in
++++ b/init.d/bootmisc.in
+@@ -112,7 +112,7 @@ migrate_to_run()
+ rm $src
+ elif [ ! -L $src -a -d $src ]; then
+ ebegin "Migrating $src to $dst"
+- cp -a $src/* $dst/
++ cp -a $src/* $dst/ 2>/dev/null
+ rm -rf $src
+ eend $?
+ fi
+--
+2.11.0
+
diff --git a/system/openrc/0005-rc-pull-in-sysinit-and-boot-as-stacked-levels-when-n.patch b/system/openrc/0005-rc-pull-in-sysinit-and-boot-as-stacked-levels-when-n.patch
new file mode 100644
index 000000000..eb1ad1408
--- /dev/null
+++ b/system/openrc/0005-rc-pull-in-sysinit-and-boot-as-stacked-levels-when-n.patch
@@ -0,0 +1,71 @@
+From b62d7b9438af6dac50d52708777070f312e6650c Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 1 Feb 2017 04:17:14 +0000
+Subject: [PATCH 5/7] rc: pull in sysinit and boot as stacked levels when
+ needed
+
+We need start services from sysinit and boot runlevel, even if the new
+runlevel is empty.
+
+This fixes problem introduced with commit 7716bf31 (Fix stacked runlevel
+support), at which the start_services list are no longer used to start
+the services.
+
+This also make sure that all services in sysinit and boot runlevels are
+started before switching to next. This was not guaranteed when switching
+to a non-empty runlevel.
+
+Fixes issue #54.
+---
+ src/rc/rc.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/src/rc/rc.c b/src/rc/rc.c
+index 110591e4..13a7e0d4 100644
+--- a/src/rc/rc.c
++++ b/src/rc/rc.c
+@@ -738,6 +738,7 @@ int main(int argc, char **argv)
+ const char *bootlevel = NULL;
+ char *newlevel = NULL;
+ const char *systype = NULL;
++ RC_STRINGLIST *runlevel_chain;
+ RC_STRINGLIST *deporder = NULL;
+ RC_STRINGLIST *tmplist;
+ RC_STRING *service;
+@@ -993,6 +994,7 @@ int main(int argc, char **argv)
+ main_hotplugged_services = rc_services_in_state(RC_SERVICE_HOTPLUGGED);
+ main_start_services = rc_services_in_runlevel_stacked(newlevel ?
+ newlevel : runlevel);
++ runlevel_chain = rc_runlevel_stacks(newlevel ? newlevel : runlevel);
+ if (strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 &&
+ strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_SYSINIT) != 0)
+ {
+@@ -1010,6 +1012,7 @@ int main(int argc, char **argv)
+ tmplist = rc_services_in_runlevel(bootlevel);
+ TAILQ_CONCAT(main_start_services, tmplist, entries);
+ free(tmplist);
++ rc_stringlist_add(runlevel_chain, bootlevel);
+ }
+ if (main_hotplugged_services) {
+ TAILQ_FOREACH(service, main_hotplugged_services,
+@@ -1018,6 +1021,7 @@ int main(int argc, char **argv)
+ service->value);
+ }
+ }
++ rc_stringlist_add(runlevel_chain, RC_LEVEL_SYSINIT);
+ }
+
+ parallel = rc_conf_yesno("rc_parallel");
+@@ -1074,9 +1078,6 @@ int main(int argc, char **argv)
+
+ /* If we have a list of services to start then... */
+ if (main_start_services) {
+- /* Get a list of the chained runlevels which compose the target runlevel */
+- RC_STRINGLIST *runlevel_chain = rc_runlevel_stacks(runlevel);
+-
+ /* Loop through them in reverse order. */
+ RC_STRING *rlevel;
+ TAILQ_FOREACH_REVERSE(rlevel, runlevel_chain, rc_stringlist, entries)
+--
+2.11.0
+
diff --git a/system/openrc/0006-mount-efivars-read-only.patch b/system/openrc/0006-mount-efivars-read-only.patch
new file mode 100644
index 000000000..ec2321dd2
--- /dev/null
+++ b/system/openrc/0006-mount-efivars-read-only.patch
@@ -0,0 +1,27 @@
+From 37feb4b716525f0c5c5469f21686ab4efcf06fab Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 1 Feb 2017 04:18:53 +0000
+Subject: [PATCH 6/7] mount efivars read-only
+
+unintentional writes to efivars may result in bricked hardware. mount it
+read-only to play safe.
+---
+ init.d/sysfs.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/init.d/sysfs.in b/init.d/sysfs.in
+index e493f584..bfd0d438 100644
+--- a/init.d/sysfs.in
++++ b/init.d/sysfs.in
+@@ -101,7 +101,7 @@ mount_misc()
+ if [ -d /sys/firmware/efi/efivars ] &&
+ ! mountinfo -q /sys/firmware/efi/efivars; then
+ ebegin "Mounting efivarfs filesystem"
+- mount -n -t efivarfs -o ${sysfs_opts} \
++ mount -n -t efivarfs -o ro,${sysfs_opts} \
+ efivarfs /sys/firmware/efi/efivars 2> /dev/null
+ eend 0
+ fi
+--
+2.11.1
+
diff --git a/system/openrc/0007-make-consolefont-service-compatible-with-busyboxs-se.patch b/system/openrc/0007-make-consolefont-service-compatible-with-busyboxs-se.patch
new file mode 100644
index 000000000..6c23e2ab0
--- /dev/null
+++ b/system/openrc/0007-make-consolefont-service-compatible-with-busyboxs-se.patch
@@ -0,0 +1,70 @@
+From 3d0d2b89745597ea973129eafa3f999cf19d761f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
+Date: Wed, 17 Aug 2016 17:52:58 +0200
+Subject: [PATCH 7/7] make consolefont service compatible with busyboxs setfont
+ applet
+
+Compared to kdbs setfont program it doesn't support -O and -m.
+---
+ conf.d/consolefont | 11 ++---------
+ init.d/consolefont.in | 7 ++-----
+ 2 files changed, 4 insertions(+), 14 deletions(-)
+
+diff --git a/conf.d/consolefont b/conf.d/consolefont
+index e01ae842..75544b2f 100644
+--- a/conf.d/consolefont
++++ b/conf.d/consolefont
+@@ -3,16 +3,9 @@
+ #
+ # consolefont specifies the default font that you'd like Linux to use on the
+ # console. You can find a good selection of fonts in /usr/share/consolefonts;
+-# you shouldn't specify the trailing ".psf.gz", just the font name below.
+-# To use the default console font, comment out the CONSOLEFONT setting below.
+-consolefont="default8x16"
++consolefont="default8x16.psf.gz"
+
+ # consoletranslation is the charset map file to use. Leave commented to use
+ # the default one. Have a look in /usr/share/consoletrans for a selection of
+ # map files you can use.
+-#consoletranslation="8859-1_to_uni"
+-
+-# unicodemap is the unicode map file to use. Leave commented to use the
+-# default one. Have a look in /usr/share/unimaps for a selection of map files
+-# you can use.
+-#unicodemap="iso01"
++#consoletranslation="8859-1_to_uni.trans"
+diff --git a/init.d/consolefont.in b/init.d/consolefont.in
+index 9fe95afa..173ed426 100644
+--- a/init.d/consolefont.in
++++ b/init.d/consolefont.in
+@@ -22,7 +22,6 @@ start()
+ {
+ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
+ consolefont=${consolefont:-${CONSOLEFONT}}
+- unicodemap=${unicodemap:-${UNICODEMAP}}
+ consoletranslation=${consoletranslation:-${CONSOLETRANSLATION}}
+
+ if [ -z "$consolefont" ]; then
+@@ -43,9 +42,6 @@ start()
+ if [ -n "$consoletranslation" ]; then
+ param="$param -m $consoletranslation"
+ fi
+- if [ -n "${unicodemap}" ]; then
+- param="$param -u $unicodemap"
+- fi
+
+ # Set the console font
+ ebegin "Setting console font [$consolefont]"
+@@ -63,7 +59,8 @@ start()
+ # Store the font so we can use it ASAP on boot
+ if [ $retval -eq 0 ] && checkpath -W "$RC_LIBEXECDIR"; then
+ mkdir -p "$RC_LIBEXECDIR"/console
+- setfont -O "$RC_LIBEXECDIR"/console/font
++ zcat "/usr/share/consolefonts/$consolefont" \
++ > "$RC_LIBEXECDIR"/console/font
+ fi
+
+ return $retval
+--
+2.11.0
+
diff --git a/system/openrc/APKBUILD b/system/openrc/APKBUILD
new file mode 100644
index 000000000..31e6adee6
--- /dev/null
+++ b/system/openrc/APKBUILD
@@ -0,0 +1,93 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=openrc
+pkgver=0.24.1
+_ver=${pkgver/_git*/}
+pkgrel=6
+pkgdesc="OpenRC manages the services, startup and shutdown of a host"
+url="http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git"
+arch="all"
+license='BSD-2'
+depends="psmisc /sbin/init"
+makedepends="bsd-compat-headers"
+subpackages="$pkgname-doc $pkgname-dev"
+install="$pkgname.post-install $pkgname.post-upgrade"
+source="$pkgname-$pkgver.tar.gz::https://github.com/OpenRC/openrc/archive/$pkgver.tar.gz
+
+ 0001-call-sbin-mkmntdirs-in-localmount-OpenRC-service.patch
+ 0002-force-root-be-rw-before-localmount.patch
+ 0003-sysctl-add-compatibility-for-busybox-sysctl.patch
+ 0004-hide-error-when-migrating-var-run-to-run.patch
+ 0005-rc-pull-in-sysinit-and-boot-as-stacked-levels-when-n.patch
+ 0006-mount-efivars-read-only.patch
+ 0007-make-consolefont-service-compatible-with-busyboxs-se.patch
+
+ openrc-configuration.patch
+
+ openrc.logrotate
+ hostname.initd
+ hwdrivers.initd
+ keymaps.initd
+ modules.initd
+ modloop.initd
+ modloop.confd
+ sysfsconf.initd
+ "
+
+builddir="$srcdir/$pkgname-$_ver"
+prepare() {
+ default_prepare
+ sed -i -e '/^sed/d' "$builddir"/pkgconfig/Makefile
+}
+
+build() {
+ cd "$builddir"
+ export BRANDING="Adélie Linux"
+ make LIBEXECDIR=/lib/rc MKNET=no
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make LIBEXECDIR=/lib/rc DESTDIR="$pkgdir/" install
+
+ # we cannot have anything turned on by default
+ mkdir -p "$pkgdir"/usr/share/openrc || true
+ mv "$pkgdir"/etc/runlevels "$pkgdir"/usr/share/openrc/runlevels
+
+ # we override some of the scripts
+ for i in "$srcdir"/*.initd; do
+ j=${i##*/}
+ install -Dm755 $i "$pkgdir"/etc/init.d/${j%.initd}
+ done
+
+ # we override some of the conf.d files
+ for i in "$srcdir"/*.confd; do
+ j=${i##*/}
+ install -Dm644 $i "$pkgdir"/etc/conf.d/${j%.confd}
+ done
+
+ install -Dm644 "$srcdir/$pkgname.logrotate" "$pkgdir/etc/logrotate.d/$pkgname"
+ install -d "$pkgdir"/etc/local.d "$pkgdir"/run
+}
+
+sha512sums="8d2aec029cb675ae5d446fe4a2f9613fac2fc5ea74b091d93e62b1f7bd4f8e3a96893bafa39a301129dad4623cc30acdcfd9e383a74f98c69f29820adb6d9aa0 openrc-0.24.1.tar.gz
+71fce711adbcb411189a089f1d49567c50348e12c42b7a9c9b582dae5d18051f88ccf81c768337e87d6792d953e84d1e8b93d7978a1947d7d20ef3b1cd330875 0001-call-sbin-mkmntdirs-in-localmount-OpenRC-service.patch
+aedf77f9159fefb4bd5f30a29a33b6aedbc986c9a0f993aa928cc79fbe24aac76bd9e5974dcce52ee8736c22d7e90375930d4bb5c66af3519d8e46590df00fe1 0002-force-root-be-rw-before-localmount.patch
+9dea3fcdb90e3e8078a771beefeba3ca91b9966a1b8ee9ff96cf460e7dd21abbc4a46a501a960c3edf5a76c083c2cf60ccb06d9da7a4c6df2a50660745beb278 0003-sysctl-add-compatibility-for-busybox-sysctl.patch
+d54630d40a2d6b10a325cb012d4efcda997a60c008ca953ce5d60059d3f267308a59dabddf93a5fc0d301aa91967137d144effbe5f574394af768ce4ebc48738 0004-hide-error-when-migrating-var-run-to-run.patch
+39a35c54ec9112fe84c901ed155a711cec8e194af02d5483ee60b80743dab12391e6fdc7b3da2f86844dd4edcf53e681ff95bd4d6fa1101a89ce54dce2ddbb7c 0005-rc-pull-in-sysinit-and-boot-as-stacked-levels-when-n.patch
+7221dd2daccd8844f6f9481b7b5921abc2711c8abd1a4bb72f04db8fd8e734b817f5d0d571daea0e2e05d3bc687f75ee1d8025249996bdee0b3328e18d9da7d3 0006-mount-efivars-read-only.patch
+234c4f3cf39df3350dbea25c00b8d584794b28194f44c726767a6a16d91a26fee1b5d2dd16635f19803fc015b4e9d99c52b23128e6b815938b88365feba8cf59 0007-make-consolefont-service-compatible-with-busyboxs-se.patch
+2dde266f3176456724e4b0c40476e7061e31986b67744b4a53c71ba0d3896860b4569e3af2ea4777a9d8fe3b6282ff869666570f1daa86cdc410c0e09805c990 openrc-configuration.patch
+12bb6354e808fbf47bbab963de55ee7901738b4a912659982c57ef2777fff9a670e867fcb8ec316a76b151032c92dc89a950d7d1d835ef53f753a8f3b41d2cec openrc.logrotate
+99b542c0903ad6874b8c308b2e0660a4fe2ff9db962dfec65325cd12c368873a2ae800d5e6d42dc4deff775e1d5c0068869eb72581f7ab16e88d5738afe1d3dd hostname.initd
+c06eac7264f6cc6888563feeae5ca745aae538323077903de1b19102e4f16baa34c18b8c27af5dd5423e7670834e2261e9aa55f2b1ec8d8fdc2be105fe894d55 hwdrivers.initd
+584ecbbcecb284527d7616790b6e337ace610e4b3cedf2993eca294bfbef54674aeaee3078b6c17d746a0c48b5a64a813c3534136915947e6f62a6fa206cd3ca keymaps.initd
+b04058ec630e19de0bafefe06198dc1bff8c8d5d2c89e4660dd83dda8bb82a76cdb1d8661cce88e4a406aa6b4152e17efff52d3eb18ffaec0751d0b6cdbcc48a modules.initd
+92c0245ba4d7cc6828a9b68510fb541cf3b21b9b844a858336af60e84d1db62ddb4471aad0d82ef05d639335a81014f8350a71a746c2bcd90697daa6a8c03408 modloop.initd
+aa702a7da8e6c0e5d8738febaf6b4e4cb021b30ce5c1809b530abf2b36739079446b16fc054740da8d86ed099942cf5deed6597cedb64c058f3def587a8b4689 modloop.confd
+d76c75c58e6f4b0801edac4e081b725ef3d50a9a8c9bbb5692bf4d0f804af7d383bf71a73d5d03ed348a89741ef0b2427eb6a7cbf5a9b9ff60a240639fa6ec88 sysfsconf.initd"
diff --git a/system/openrc/hostname.initd b/system/openrc/hostname.initd
new file mode 100644
index 000000000..c1580db08
--- /dev/null
+++ b/system/openrc/hostname.initd
@@ -0,0 +1,18 @@
+#!/sbin/openrc-run
+
+description="Sets the hostname of the machine."
+
+depend() {
+ keyword -prefix -lxc
+}
+
+start() {
+ if [ -s /etc/hostname ] ; then
+ opts="-F /etc/hostname"
+ else
+ opts="localhost"
+ fi
+ ebegin "Setting hostname"
+ hostname $opts
+ eend $?
+}
diff --git a/system/openrc/hwdrivers.initd b/system/openrc/hwdrivers.initd
new file mode 100644
index 000000000..80184c971
--- /dev/null
+++ b/system/openrc/hwdrivers.initd
@@ -0,0 +1,32 @@
+#!/sbin/openrc-run
+
+depend() {
+ need sysfs dev
+ before checkfs fsck
+ after modloop
+ keyword -vserver -lxc
+}
+
+# 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 -type f -print0 | xargs -0 sort -u \
+ | xargs modprobe -b -a 2> /dev/null
+ # we run it twice so we detect all devices
+ find /sys -name modalias -type f -print0 | xargs -0 sort -u \
+ | xargs modprobe -b -a 2> /dev/null
+
+ # check if framebuffer drivers got pulled in
+ if [ -e /dev/fb0 ] && ! [ -e /sys/module/fbcon ]; then
+ modprobe -b -q fbcon
+ fi
+
+ eend 0
+}
+
diff --git a/system/openrc/keymaps.initd b/system/openrc/keymaps.initd
new file mode 100644
index 000000000..24d1e8777
--- /dev/null
+++ b/system/openrc/keymaps.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+
+description="Applies a keymap for the consoles."
+
+depend()
+{
+ need localmount
+ keyword -openvz -prefix -uml -vserver -xenu -lxc
+}
+
+start() {
+ [ -z "$KEYMAP" ] && return
+ ebegin "Setting keymap"
+ zcat "$KEYMAP" | loadkmap
+ eend $?
+}
+
+stop() {
+ return
+}
diff --git a/system/openrc/modloop.confd b/system/openrc/modloop.confd
new file mode 100644
index 000000000..de4cbb62b
--- /dev/null
+++ b/system/openrc/modloop.confd
@@ -0,0 +1,3 @@
+# enable loadable module support when running from RAM
+# when unionfs support is available in the kernel
+unionfs_size="32M"
diff --git a/system/openrc/modloop.initd b/system/openrc/modloop.initd
new file mode 100644
index 000000000..9d664dd40
--- /dev/null
+++ b/system/openrc/modloop.initd
@@ -0,0 +1,124 @@
+#!/sbin/openrc-run
+
+# script that will mount image with modules
+
+depend() {
+ after dev-mount
+ before checkfs fsck hwdrivers modules hwclock dev sysfs
+ keyword -vserver -lxc
+}
+
+# read kernel options
+init_KOPT() {
+ for opt in $(cat /proc/cmdline 2>/dev/null); do
+ case "$opt" in
+ modloop=*)
+ eval "KOPT_${opt%%=*}='${opt#*=}'" ;;
+ esac
+ done
+}
+
+mountdirs() {
+ awk '$2 !~ /^\/(sys|proc|dev|run)/ && $2 != "/" {print $2}' /proc/mounts
+}
+
+find_modloop() {
+ local dir="$1"
+ local kver=$(uname -r)
+ local oifs="$IFS"
+ IFS=$'\n'
+ set -- $(blkid "$dir"/boot/* "$dir"/*)
+ IFS="$oifs"
+ for line; do
+ img=${line%%:*}
+ mount "$img" -o loop,ro /.modloop || continue
+ if [ -d /.modloop/modules/$kver ]; then
+ return 0
+ fi
+ umount /.modloop
+ done
+ return 1
+}
+
+find_backing_file() {
+ local dir="$1"
+ local dev=$(df -P "$dir" | tail -1 | awk '{print $1}')
+ cat /sys/block/${dev#/dev/}/loop/backing_file 2>/dev/null
+}
+
+start() {
+ local modloop= mount_opts= modloop_dldir="/lib"
+ init_KOPT
+
+ mkdir -p /.modloop /lib
+ case "$KOPT_modloop" in
+ http://*|https://*|ftp://*)
+ wget -P "$modloop_dldir" "$KOPT_modloop" \
+ && modloop=$modloop_dldir/$(basename $KOPT_modloop)
+ ;;
+ *)
+ for dir in $(mountdirs); do
+ if [ -f "$dir"/$KOPT_modloop ]; then
+ modloop="$dir/${KOPT_modloop##/}"
+ alpine_mnt="$dir"
+ break
+ fi
+ done
+ ;;
+ esac
+
+ ebegin "Mounting modloop $modloop"
+ if [ -n "$modloop" ]; then
+ mount -o loop,ro $modloop /.modloop
+ eend $? || return 1
+ else
+ for dir in $(mountdirs); do
+ if find_modloop "$dir"; then
+ alpine_mnt="$dir"
+ break
+ fi
+ done
+ if [ -d /.modloop/modules/$(uname -r) ]; then
+ eend 0
+ else
+ eend 1 || return 1
+ fi
+ fi
+
+ #use overlayfs if available and configured
+ if grep -q -w "overlay$" /proc/filesystems && [ -n "$unionfs_size" ]; then
+ ebegin "OverlayFS detected, mounting modloop rw"
+ mkdir -p /.modunisonfs /lib/modules
+ mount -t tmpfs -o size="$unionfs_size" tmpfs /.modunisonfs
+ mkdir -p /.modunisonfs/modules /.modunisonfs/work
+ mount -t overlay -o upperdir=/.modunisonfs/modules,lowerdir=/.modloop/modules,workdir=/.modunisonfs/work overlay /lib/modules
+ eend $? || return 1
+ else
+ rm -rf /lib/modules && ln -sf /.modloop/modules /lib/
+ fi
+
+ # 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 $?
+ elif [ -d /lib/modules/firmware ]; then
+ rmdir /lib/firmware 2>/dev/null \
+ && ln -s /lib/modules/firmware /lib/
+ fi
+ return 0
+}
+
+stop() {
+ local rc=0
+ if mountinfo --quiet /.modunisonfs/modules && mountinfo --quiet /lib/modules; then
+ umount /lib/modules
+ umount /.modunisonfs/modules
+ fi
+ if mountinfo --quiet /.modloop; then
+ ebegin "Unmounting /.modloop"
+ umount -d /.modloop
+ eend $? || return 1
+ fi
+}
+
diff --git a/system/openrc/modules.initd b/system/openrc/modules.initd
new file mode 100644
index 000000000..d90a3e687
--- /dev/null
+++ b/system/openrc/modules.initd
@@ -0,0 +1,29 @@
+#!/sbin/openrc-run
+
+description="Loads a user defined list of kernel modules."
+
+depend()
+{
+ before hwclock hwdrivers
+ keyword -openvz -prefix -vserver -lxc
+}
+
+start() {
+ ebegin "Loading modules"
+ for f in /etc/modules \
+ /etc/modules-load.d/*.conf \
+ /run/modules-load.d/*.conf \
+ /usr/lib/modules-load.d/*.conf \
+ /lib/modules-load.d/*.conf; do
+ if ! [ -f "$f" ]; then
+ continue
+ fi
+
+ sed -e 's/\#.*//g' -e '/^[[:space:]]*$/d' < "$f" \
+ | while read module args; do
+ modprobe -q $module $args
+ done
+ done
+ eend $?
+}
+
diff --git a/system/openrc/openrc-configuration.patch b/system/openrc/openrc-configuration.patch
new file mode 100644
index 000000000..ff2ce5f34
--- /dev/null
+++ b/system/openrc/openrc-configuration.patch
@@ -0,0 +1,20 @@
+--- openrc-0.24.1/etc/rc.conf.original 2017-03-14 19:58:26.000000000 -0500
++++ openrc-0.24.1/etc/rc.conf 2017-08-22 23:48:32.903169635 -0500
+@@ -48,7 +48,7 @@
+ # /var/log/rc.log
+ # NOTE: Linux systems require the devfs service to be started before
+ # logging can take place and as such cannot log the sysinit runlevel.
+-#rc_logger="NO"
++rc_logger="YES"
+
+ # Through rc_log_path you can specify a custom log file.
+ # The default value is: /var/log/rc.log
+@@ -89,7 +89,7 @@
+ # There variables are shared between many init scripts
+
+ # Set unicode to YES to turn on unicode support for keyboards and screens.
+-#unicode="NO"
++unicode="YES"
+
+ # This is how long fuser should wait for a remote server to respond. The
+ # default is 60 seconds, but it can be adjusted here.
diff --git a/system/openrc/openrc.logrotate b/system/openrc/openrc.logrotate
new file mode 100644
index 000000000..5e5e64b9b
--- /dev/null
+++ b/system/openrc/openrc.logrotate
@@ -0,0 +1,4 @@
+/var/log/rc.log {
+ missingok
+ notifempty
+}
diff --git a/system/openrc/openrc.post-install b/system/openrc/openrc.post-install
new file mode 100644
index 000000000..1057eed41
--- /dev/null
+++ b/system/openrc/openrc.post-install
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+rc_update() {
+ local svc="$1"
+ local level="$2"
+ mkdir -p /etc/runlevels/$level
+ ln -sf /etc/init.d/$svc /etc/runlevels/$level
+}
+
+if [ ! -d etc/rcS.d ] && [ ! -d etc/rcL.d ]; then
+ exit 0
+fi
+
+for i in etc/rc[SL].d/*; do
+ [ -L "$i" ] || continue
+ oldsvc=${i##*/S[0-9][0-9]}
+ # some services are renamed
+ case "$oldsvc" in
+ modutils) svc=modules;;
+ procps) svc=sysctl;;
+ bootmisc.sh) svc=bootmisc;;
+ keymap) svc=keymaps;;
+ rc.local) svc=local;;
+ *) svc=$oldsvc;;
+ esac
+
+ # add the service to correct "runlevel"
+ case "$svc" in
+ hwclock|modules|sysctl|hostname|keymaps|syslog|bootmisc)
+ rc_update $svc boot;;
+ *) rc_update $svc default;;
+ esac
+
+ rm $i
+done
+
diff --git a/system/openrc/openrc.post-upgrade b/system/openrc/openrc.post-upgrade
new file mode 100644
index 000000000..8884202be
--- /dev/null
+++ b/system/openrc/openrc.post-upgrade
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# in 0.8.0-r1 the state dir moved from /libexec/rc/init.d to /lib/rc/init.d
+# and with 0.10 it moved to /run/openrc
+
+mkdir -p /run/openrc
+for dir in /libexec /lib; do
+ [ -d $dir/rc/init.d ] || continue
+
+ for i in $dir/rc/init.d/* ; do
+ [ -e "$i" ] || continue
+ if [ -e /run/openrc/${i##*/} ]; then
+ rm -r $i
+ else
+ mv $i /run/openrc/
+ fi
+ done
+
+ rmdir $dir/rc/init.d $dir/rc /libexec 2>/dev/null
+done
+
+# create rc.local compat
+if [ -f /etc/rc.local ]; then
+ cat >/etc/local.d/rc.local-compat.start<<__EOF__
+#!/bin/sh
+
+# this is only here for compatibility reasons
+if [ -f /etc/rc.local ]; then
+ . /etc/rc.local
+fi
+__EOF__
+ chmod +x /etc/local.d/rc.local-compat.start
+fi
+
+exit 0
diff --git a/system/openrc/sysfsconf.initd b/system/openrc/sysfsconf.initd
new file mode 100644
index 000000000..433e51d63
--- /dev/null
+++ b/system/openrc/sysfsconf.initd
@@ -0,0 +1,66 @@
+#!/sbin/openrc-run
+
+description="Set sysfs variables from /etc/sysfs.conf and /etc/sysfs.d/*.conf"
+conffile=/etc/sysfs.conf
+confdir=/etc/sysfs.d
+
+depend() {
+ need sysfs
+}
+
+setval() {
+ local value="$1" attrib="$2"
+ # Some fields need a terminating newline, others
+ # need the terminating newline to be absent :-(
+ echo -n "$value" > "$attrib" 2>/dev/null \
+ || echo "$value" > "$attrib"
+}
+
+load_conffile() {
+ local file="$1"
+ while read line; do
+ local line=${line%%#*}
+ local cmd= attrib= value=
+ set -- $line
+ if [ $# -eq 0 ]; then
+ continue
+ fi
+ case "$1$3" in
+ mode=) cmd=chmod
+ attrib="$2"
+ value="$4"
+ ;;
+ owner=) cmd=chown
+ attrib="$2"
+ value="$4"
+ ;;
+ *) if [ "$2" = "=" ]; then
+ cmd=setval
+ attrib="$1"
+ value="$3"
+ fi
+ ;;
+ esac
+ if ! [ -e "/sys/$attrib" ]; then
+ eerror "$attrib: unknown attribute"
+ continue
+ fi
+ if [ -z "$attrib" ] || [ -z "$value" ]; then
+ eerror "syntax error in $file: '$line'"
+ continue
+ fi
+ $cmd "$value" "/sys/$attrib"
+ done < "$file"
+}
+
+start() {
+ [ -r "$conffile" -o -d "$confdir" ] || return 0
+ ebegin "Setting sysfs variables"
+ for file in $confdir/*.conf $conffile; do
+ [ -r "$file" ] || continue
+ load_conffile "$file" || return 1
+ done
+ eend 0
+
+}
+