aboutsummaryrefslogtreecommitdiffstats
path: root/main/openrc
diff options
context:
space:
mode:
Diffstat (limited to 'main/openrc')
-rw-r--r--main/openrc/0001-Force-root-be-rw-before-localmount.patch26
-rw-r--r--main/openrc/0001-fsck-add-C0-and-T-options-unless-fsck-is-busybox.patch38
-rw-r--r--main/openrc/APKBUILD78
-rw-r--r--main/openrc/command-line-size-fix.patch100
-rw-r--r--main/openrc/dont-provide-ourself.patch14
-rw-r--r--main/openrc/hostname.initd18
-rw-r--r--main/openrc/hwclock-hctosys.patch15
-rw-r--r--main/openrc/hwdrivers.initd27
-rw-r--r--main/openrc/keymaps.initd20
-rw-r--r--main/openrc/modloop.confd3
-rw-r--r--main/openrc/modloop.initd100
-rw-r--r--main/openrc/modules.initd23
-rw-r--r--main/openrc/networking.initd69
-rw-r--r--main/openrc/openrc-0.4.3-command-line-size-fix.patch94
-rw-r--r--main/openrc/openrc-0.4.3-mkmntdirs.patch11
-rw-r--r--main/openrc/openrc-hwclock.patch13
-rw-r--r--main/openrc/openrc.post-install36
-rw-r--r--main/openrc/openrc.post-upgrade28
-rw-r--r--main/openrc/remove-rc_sys-warning.patch10
19 files changed, 723 insertions, 0 deletions
diff --git a/main/openrc/0001-Force-root-be-rw-before-localmount.patch b/main/openrc/0001-Force-root-be-rw-before-localmount.patch
new file mode 100644
index 0000000000..3381d9f0dd
--- /dev/null
+++ b/main/openrc/0001-Force-root-be-rw-before-localmount.patch
@@ -0,0 +1,26 @@
+From c92e702f6dddab58a749f5fea5479ff2affeb498 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Tue, 21 Dec 2010 10:29:37 +0000
+Subject: [PATCH] Force root be rw before localmount
+
+The service that pulls in root remount is mtab which we dont need/use.
+---
+ init.d/localmount.in | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/init.d/localmount.in b/init.d/localmount.in
+index a4d1116..2895894 100644
+--- a/init.d/localmount.in
++++ b/init.d/localmount.in
+@@ -6,7 +6,7 @@ description="Mounts disks and swap according to /etc/fstab."
+
+ depend()
+ {
+- need fsck
++ need fsck root
+ use lvm modules mtab
+ keyword -jail -openvz -prefix -vserver -lxc
+ }
+--
+1.7.3.4
+
diff --git a/main/openrc/0001-fsck-add-C0-and-T-options-unless-fsck-is-busybox.patch b/main/openrc/0001-fsck-add-C0-and-T-options-unless-fsck-is-busybox.patch
new file mode 100644
index 0000000000..86676e5ad7
--- /dev/null
+++ b/main/openrc/0001-fsck-add-C0-and-T-options-unless-fsck-is-busybox.patch
@@ -0,0 +1,38 @@
+From d1cb63729cb64cd3aebb14f00eaa8f03b90a57fe Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 9 Mar 2011 18:07:39 +0000
+Subject: [PATCH] fsck: add -C0 and -T options unless fsck is busybox
+
+---
+ init.d/fsck.in | 8 +++++++-
+ 1 files changed, 7 insertions(+), 1 deletions(-)
+
+diff --git a/init.d/fsck.in b/init.d/fsck.in
+index de44ea8..3b55fbd 100644
+--- a/init.d/fsck.in
++++ b/init.d/fsck.in
+@@ -30,6 +30,10 @@ _forcefsck()
+ [ -e /forcefsck ] || get_bootparam forcefsck
+ }
+
++_fsck_is_busybox() {
++ [ -L /sbin/fsck ] && [ "$(readlink -f /sbin/fsck)" = "/bin/busybox" ]
++}
++
+ start()
+ {
+ local fsck_opts= p= check_extra=
+@@ -60,7 +64,9 @@ start()
+ done
+
+ if [ "$RC_UNAME" = Linux ]; then
+- fsck_opts="$fsck_opts -C0 -T"
++ if ! _fsck_is_busybox; then
++ fsck_opts="$fsck_opts -C0 -T"
++ fi
+ if [ -z "$fsck_passno" ]; then
+ fsck_args=${fsck_args--A -p}
+ if echo 2>/dev/null >/.test.$$; then
+--
+1.7.4.1
+
diff --git a/main/openrc/APKBUILD b/main/openrc/APKBUILD
new file mode 100644
index 0000000000..812542cd1e
--- /dev/null
+++ b/main/openrc/APKBUILD
@@ -0,0 +1,78 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=openrc
+pkgver=0.8.2
+_ver=${pkgver/_git*/}
+pkgrel=2
+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=""
+subpackages="$pkgname-doc $pkgname-dev"
+install="$pkgname.post-install $pkgname.post-upgrade"
+source="http://distfiles.gentoo.org/distfiles/$pkgname-$_ver.tar.bz2
+ openrc-0.4.3-mkmntdirs.patch
+
+ 0001-Force-root-be-rw-before-localmount.patch
+ 0001-fsck-add-C0-and-T-options-unless-fsck-is-busybox.patch
+ remove-rc_sys-warning.patch
+ hwclock-hctosys.patch
+
+ hostname.initd
+ hwdrivers.initd
+ keymaps.initd
+ modules.initd
+ modloop.initd
+ networking.initd
+ modloop.confd
+ "
+
+_builddir="$srcdir/$pkgname-$_ver"
+prepare() {
+ cd "$_builddir"
+ for i in $source; do
+ case $i in
+ *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1
+ esac
+ done
+ sed -i -e '/^sed/d' pkgconfig/Makefile
+}
+
+build() {
+ cd "$_builddir"
+ make LIBEXECDIR=/lib/rc || return 1
+}
+
+package() {
+ cd "$_builddir"
+ make LIBEXECDIR=/lib/rc DESTDIR="$pkgdir/" install
+
+ # we cannot have anything turned on by default
+ rm -f "$pkgdir"/etc/runlevels/*/*
+
+ # we still use our ifup/ifdown based net config
+ rm -f "$pkgdir"/etc/conf.d/network "$pkgdir"/etc/init.d/network
+
+ # we override some of the scripts
+ for i in "$srcdir"/*.initd; do
+ j=${i##*/}
+ install -Dm755 $i "$pkgdir"/etc/init.d/${j%.initd}
+ done
+
+ install -D -m644 "$srcdir"/modloop.confd "$pkgdir"/etc/conf.d/modloop
+ install -d "$pkgdir"/etc/local.d
+}
+
+md5sums="a30f2e54f025b92fb40a0be5d464877d openrc-0.8.2.tar.bz2
+8c2c1c2ee0509b63966b7187a2079f4b openrc-0.4.3-mkmntdirs.patch
+4fd036ff07ed9ad7fb76af6a3ffc0695 0001-Force-root-be-rw-before-localmount.patch
+fb8baeaf32f4d53491312675f28a9939 0001-fsck-add-C0-and-T-options-unless-fsck-is-busybox.patch
+2a1749ee829877d80c3696eade59be8a remove-rc_sys-warning.patch
+95927c85beb1476bda46ab8933c5e780 hwclock-hctosys.patch
+c32e15b0858eef708497e7ee6355a055 hostname.initd
+b1e64885f301166df30be3e3cf5338ff hwdrivers.initd
+33ca3e558c42cdd17adccbc7807298f7 keymaps.initd
+098a1f16812f56fcb56eb6b6f0fa31f6 modules.initd
+408e28f247c7cc71fa104c07869417f4 modloop.initd
+af16db0d798392c7c0ed3434e4bad241 networking.initd
+c1ec888202d868710b5749f7b217d1e3 modloop.confd"
diff --git a/main/openrc/command-line-size-fix.patch b/main/openrc/command-line-size-fix.patch
new file mode 100644
index 0000000000..77fa2bd810
--- /dev/null
+++ b/main/openrc/command-line-size-fix.patch
@@ -0,0 +1,100 @@
+diff -ru a/src/librc/librc.h b/src/librc/librc.h
+--- a/src/librc/librc.h 2009-09-01 11:42:31.000000000 +0000
++++ b/src/librc/librc.h 2009-09-01 11:42:47.000000000 +0000
+@@ -72,8 +72,6 @@
+ #define librc_hidden_proto(x) hidden_proto(x)
+ #define librc_hidden_def(x) hidden_def(x)
+
+-ssize_t rc_getline(char **, size_t *, FILE *);
+-
+ librc_hidden_proto(rc_config_list)
+ librc_hidden_proto(rc_config_load)
+ librc_hidden_proto(rc_config_value)
+diff -ru a/src/librc/rc.h.in b/src/librc/rc.h.in
+--- a/src/librc/rc.h.in 2009-09-01 11:42:31.000000000 +0000
++++ b/src/librc/rc.h.in 2009-09-01 11:42:47.000000000 +0000
+@@ -517,5 +517,9 @@
+ * @return NULL terminated list of pids */
+ RC_PIDLIST *rc_find_pids(const char *, const char *const *, uid_t, pid_t);
+
++/* getline is a handy glibc function that not all libcs have, so
++ * we have our own */
++ssize_t rc_getline(char **, size_t *, FILE *);
++
+ __END_DECLS
+ #endif
+diff -ru a/src/librc/rc.map b/src/librc/rc.map
+--- a/src/librc/rc.map 2009-09-01 11:42:31.000000000 +0000
++++ b/src/librc/rc.map 2009-09-01 11:42:47.000000000 +0000
+@@ -12,6 +12,7 @@
+ rc_deptree_update_needed;
+ rc_environ_fd;
+ rc_find_pids;
++ rc_getline;
+ rc_newer_than;
+ rc_older_than;
+ rc_runlevel_exists;
+diff -ru a/src/rc/rc.c b/src/rc/rc.c
+--- a/src/rc/rc.c 2009-09-01 11:42:31.000000000 +0000
++++ b/src/rc/rc.c 2009-09-01 11:47:00.000000000 +0000
+@@ -43,10 +43,6 @@
+ #include <sys/utsname.h>
+ #include <sys/wait.h>
+
+-#ifdef __linux__
+-# include <asm/setup.h> /* for COMMAND_LINE_SIZE */
+-#endif
+-
+ #include <errno.h>
+ #include <dirent.h>
+ #include <ctype.h>
+@@ -177,10 +173,8 @@
+ proc_getent(const char *ent)
+ {
+ FILE *fp;
+- char proc[COMMAND_LINE_SIZE];
+- char *p;
+- char *value = NULL;
+- int i;
++ char *proc, *p, *value = NULL;
++ size_t i;
+
+ if (!exists("/proc/cmdline"))
+ return NULL;
+@@ -190,11 +184,11 @@
+ return NULL;
+ }
+
+- memset(proc, 0, sizeof(proc));
+- p = fgets(proc, sizeof(proc), fp);
+- if (p == NULL)
+- eerror("fgets: %s", strerror(errno));
+- else if (*proc && (p = strstr(proc, ent))) {
++ proc = NULL;
++ i = 0;
++ if (rc_getline(&proc, &i, fp) == -1 || proc == NULL)
++ eerror("rc_getline: %s", strerror(errno));
++ if (*proc && (p = strstr(proc, ent))) {
+ i = p - proc;
+ if (i == '\0' || proc[i - 1] == ' ') {
+ p += strlen(ent);
+@@ -205,6 +199,7 @@
+ } else
+ errno = ENOENT;
+ fclose(fp);
++ free(proc);
+
+ return value;
+ }
+diff -ru a/src/test/rc.funcs.list b/src/test/rc.funcs.list
+--- a/src/test/rc.funcs.list 2009-09-01 11:42:31.000000000 +0000
++++ b/src/test/rc.funcs.list 2009-09-01 11:42:57.000000000 +0000
+@@ -20,6 +20,8 @@
+ rc_deptree_update_needed@@RC_1.0
+ rc_find_pids
+ rc_find_pids@@RC_1.0
++rc_getline
++rc_getline@@RC_1.0
+ rc_newer_than
+ rc_newer_than@@RC_1.0
+ rc_older_than
diff --git a/main/openrc/dont-provide-ourself.patch b/main/openrc/dont-provide-ourself.patch
new file mode 100644
index 0000000000..2ff988f7f6
--- /dev/null
+++ b/main/openrc/dont-provide-ourself.patch
@@ -0,0 +1,14 @@
+Index: src/librc/librc-depend.c
+===================================================================
+--- a/src/librc/librc-depend.c (revision b4104957b198b38aba609ed3889e7fa605012d19)
++++ b/src/librc/librc-depend.c (revision 7fbb6ad42742ebc5e6ec244eedc85e9ac0a6236d)
+@@ -802,4 +802,9 @@
+ continue;
+ }
++
++ /* Don't provide ourself */
++ if (strcmp(type, "iprovide") == 0 &&
++ strcmp(depend, service) == 0)
++ continue;
+
+ /* .sh files are not init scripts */
diff --git a/main/openrc/hostname.initd b/main/openrc/hostname.initd
new file mode 100644
index 0000000000..995e4b95d8
--- /dev/null
+++ b/main/openrc/hostname.initd
@@ -0,0 +1,18 @@
+#!/sbin/runscript
+
+description="Sets the hostname of the machine."
+
+depend() {
+ keyword noprefix
+}
+
+start() {
+ if [ -f /etc/hostname ] ; then
+ opts="-F /etc/hostname"
+ else
+ opts="localhost"
+ fi
+ ebegin "Setting hostname"
+ hostname $opts
+ eend $?
+}
diff --git a/main/openrc/hwclock-hctosys.patch b/main/openrc/hwclock-hctosys.patch
new file mode 100644
index 0000000000..6616a9990f
--- /dev/null
+++ b/main/openrc/hwclock-hctosys.patch
@@ -0,0 +1,15 @@
+--- openrc-0.8.2.orig/init.d/hwclock.in
++++ openrc-0.8.2/init.d/hwclock.in
+@@ -94,11 +94,7 @@
+ "$utc_cmd" != --utc -o \
+ -n "$clock_args" ];
+ then
+- if yesno $clock_hctosys; then
+- _hwclock --hctosys $utc_cmd $clock_args
+- else
+- _hwclock --systz $utc_cmd $clock_args
+- fi
++ _hwclock --hctosys $utc_cmd $clock_args
+ retval=$(($retval + $?))
+ fi
+
diff --git a/main/openrc/hwdrivers.initd b/main/openrc/hwdrivers.initd
new file mode 100644
index 0000000000..3d0ebf12b5
--- /dev/null
+++ b/main/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/main/openrc/keymaps.initd b/main/openrc/keymaps.initd
new file mode 100644
index 0000000000..8ee019c69d
--- /dev/null
+++ b/main/openrc/keymaps.initd
@@ -0,0 +1,20 @@
+#!/sbin/runscript
+
+description="Applies a keymap for the consoles."
+
+depend()
+{
+ need localmount
+ keyword noopenvz noprefix nouml novserver noxenu
+}
+
+start() {
+ [ -z "$KEYMAP" ] && return
+ ebegin "Setting keymap"
+ zcat "$KEYMAP" | loadkmap
+ eend $?
+}
+
+stop() {
+ return
+}
diff --git a/main/openrc/modloop.confd b/main/openrc/modloop.confd
new file mode 100644
index 0000000000..de4cbb62b8
--- /dev/null
+++ b/main/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/main/openrc/modloop.initd b/main/openrc/modloop.initd
new file mode 100644
index 0000000000..714b6057a3
--- /dev/null
+++ b/main/openrc/modloop.initd
@@ -0,0 +1,100 @@
+#!/sbin/runscript
+
+# script that will mount image with modules
+
+depend() {
+ need dev
+ before checkfs fsck hwdrivers modules hwclock
+ 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
+ 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 /dev/$alpine_dev $alpine_mnt 2>/dev/null
+ fi
+ mkdir -p /.modloop /lib
+
+ mount -o loop,ro -t cramfs $alpine_mnt/$modloop /.modloop
+
+ eend $? || return 1
+
+ #use unionfs is available and configured
+ if grep -q -w "unionfs$" /proc/filesystems && [ -n "$unionfs_size" ]; then
+ ebegin "UnionFS detected. Mounting modloop rw"
+ mkdir -p /.modunisonfs/modules /lib/modules
+ mount -t tmpfs -o size="$unionfs_size" tmpfs /.modunisonfs/modules
+ mount -t unionfs -o dirs=/.modunisonfs/modules=rw:/.modloop/modules=ro unionfs /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 $?
+ fi
+}
+
+stop() {
+ local rc=0
+ find_media
+ [ -z "$alpine_dev" ] && return 0
+ ebegin "Unmounting loopback device for kernel modules"
+ if mountinfo --quiet /.modloop; then
+ umount -d /.modloop || rc=1
+ fi
+ if mountinfo --quiet $alpine_mnt; then
+ umount $alpine_mnt || rc=1
+ fi
+ eend $rc
+}
+
diff --git a/main/openrc/modules.initd b/main/openrc/modules.initd
new file mode 100644
index 0000000000..ef7d1f15f1
--- /dev/null
+++ b/main/openrc/modules.initd
@@ -0,0 +1,23 @@
+#!/sbin/runscript
+
+description="Loads a user defined list of kernel modules."
+
+depend()
+{
+ before hwclock hwdrivers
+ keyword noopenvz noprefix novserver
+}
+
+
+start() {
+ if [ -f /etc/modules ] ; then
+ ebegin "Loading modules"
+ sed 's/\#.*//g' < /etc/modules |
+ while read module args
+ do
+ modprobe -q $module $args
+ done
+ eend $?
+ fi
+}
+
diff --git a/main/openrc/networking.initd b/main/openrc/networking.initd
new file mode 100644
index 0000000000..895db59eed
--- /dev/null
+++ b/main/openrc/networking.initd
@@ -0,0 +1,69 @@
+#!/sbin/runscript
+
+# note that the spoofprotect, syncoockies and ip_forward options are set in
+# /etc/sysctl.conf
+
+ifconf=/etc/network/interfaces
+ifstate=/var/run/ifstate
+
+single_iface="${SVCNAME#*.}"
+if [ "$single_iface" = "$SVCNAME" ]; then
+ single_iface=
+fi
+
+depend() {
+ after bootmisc hwdrivers modules
+ provide net
+ keyword nojail noprefix novserver
+}
+
+# find interfaces we want to start
+find_ifaces() {
+ if [ -n "$single_iface" ]; then
+ echo $single_iface
+ else
+ awk '$1 == "auto" {for (i = 2; i <= NF; i = i + 1) printf("%s ", $i)}' $ifconf
+ fi
+}
+
+# return the list of interfaces we should try stop
+find_running_ifaces() {
+ if [ -n "$single_iface" ]; then
+ echo $single_iface
+ else
+ awk -F= '{print $2}' $ifstate
+ fi
+}
+
+start() {
+ local iface= ret=1
+ ebegin "Starting networking"
+ eindent
+ for iface in $(find_ifaces); do
+ local r=0
+ ebegin "$iface"
+ if ! ifup $iface >/dev/null; then
+ ifdown $iface >/dev/null 2>&1
+ r=1
+ fi
+ # atleast one interface needs to be started for action
+ # to be success
+ eend $r && ret=0
+ done
+ eoutdent
+ return $ret
+}
+
+stop() {
+ local iface=
+ ebegin "Stopping networking"
+ eindent
+ for iface in $(find_running_ifaces); do
+ ebegin "$iface"
+ ifdown -f $iface >/dev/null
+ eend $?
+ done
+ eoutdent
+ return 0
+}
+
diff --git a/main/openrc/openrc-0.4.3-command-line-size-fix.patch b/main/openrc/openrc-0.4.3-command-line-size-fix.patch
new file mode 100644
index 0000000000..0ca4c8b1de
--- /dev/null
+++ b/main/openrc/openrc-0.4.3-command-line-size-fix.patch
@@ -0,0 +1,94 @@
+Index: src/librc/librc.h
+===================================================================
+--- a/src/librc/librc.h (revision 7c81f74b60b9d15ed472f1ca63cab0a105a84c08)
++++ b/src/librc/librc.h (revision 6abeec74301d8406ebbbd653b9fe9a0e234c09bf)
+@@ -73,6 +73,4 @@
+ #define librc_hidden_def(x) hidden_def(x)
+
+-ssize_t rc_getline(char **, size_t *, FILE *);
+-
+ librc_hidden_proto(rc_config_list)
+ librc_hidden_proto(rc_config_load)
+Index: src/librc/rc.h.in
+===================================================================
+--- a/src/librc/rc.h.in (revision c0fd1b49e49cec28c1f5a3a76f9db11c62e550dc)
++++ b/src/librc/rc.h.in (revision 6abeec74301d8406ebbbd653b9fe9a0e234c09bf)
+@@ -518,4 +518,8 @@
+ RC_PIDLIST *rc_find_pids(const char *, const char *const *, uid_t, pid_t);
+
++/* getline is a handy glibc function that not all libcs have, so
++ * we have our own */
++ssize_t rc_getline(char **, size_t *, FILE *);
++
+ __END_DECLS
+ #endif
+Index: src/librc/rc.map
+===================================================================
+--- a/src/librc/rc.map (revision 6615eb4b689d7aa1d047bd9ed75eca80beac9767)
++++ b/src/librc/rc.map (revision 6abeec74301d8406ebbbd653b9fe9a0e234c09bf)
+@@ -13,4 +13,5 @@
+ rc_environ_fd;
+ rc_find_pids;
++ rc_getline;
+ rc_newer_than;
+ rc_older_than;
+Index: src/rc/rc.c
+===================================================================
+--- a/src/rc/rc.c
++++ b/src/rc/rc.c
+@@ -43,10 +43,6 @@
+ #include <sys/utsname.h>
+ #include <sys/wait.h>
+
+-#ifdef __linux__
+-# include <asm/setup.h> /* for COMMAND_LINE_SIZE */
+-#endif
+-
+ #include <errno.h>
+ #include <dirent.h>
+ #include <ctype.h>
+@@ -176,10 +172,8 @@
+ proc_getent(const char *ent)
+ {
+ FILE *fp;
+- char proc[COMMAND_LINE_SIZE];
+- char *p;
+- char *value = NULL;
+- int i;
++ char *proc, *p, *value = NULL;
++ size_t i;
+
+ if (!exists("/proc/cmdline"))
+ return NULL;
+@@ -189,8 +183,10 @@
+ return NULL;
+ }
+
+- memset(proc, 0, sizeof(proc));
+- fgets(proc, sizeof(proc), fp);
++ proc = NULL;
++ i = 0;
++ if (rc_getline(&proc, &i, fp) == -1 || proc == NULL)
++ eerror("rc_getline: %s", strerror(errno));
+ if (*proc && (p = strstr(proc, ent))) {
+ i = p - proc;
+ if (i == '\0' || proc[i - 1] == ' ') {
+@@ -202,6 +198,7 @@
+ } else
+ errno = ENOENT;
+ fclose(fp);
++ free(proc);
+
+ return value;
+ }
+Index: src/test/rc.funcs.list
+===================================================================
+--- a/src/test/rc.funcs.list (revision 6615eb4b689d7aa1d047bd9ed75eca80beac9767)
++++ b/src/test/rc.funcs.list (revision 6abeec74301d8406ebbbd653b9fe9a0e234c09bf)
+@@ -21,4 +21,6 @@
+ rc_find_pids
+ rc_find_pids@@RC_1.0
++rc_getline
++rc_getline@@RC_1.0
+ rc_newer_than
+ rc_newer_than@@RC_1.0
diff --git a/main/openrc/openrc-0.4.3-mkmntdirs.patch b/main/openrc/openrc-0.4.3-mkmntdirs.patch
new file mode 100644
index 0000000000..01512ad7c0
--- /dev/null
+++ b/main/openrc/openrc-0.4.3-mkmntdirs.patch
@@ -0,0 +1,11 @@
+diff -ru openrc-0.4.3.orig/init.d/localmount.in openrc-0.4.3/init.d/localmount.in
+--- openrc-0.4.3.orig/init.d/localmount.in 2009-04-19 14:24:11.000000000 +0000
++++ openrc-0.4.3/init.d/localmount.in 2009-04-19 14:25:06.000000000 +0000
+@@ -13,6 +13,7 @@
+
+ start()
+ {
++ [ -x /sbin/mkmntdirs ] && mkmntdirs
+ # Mount local filesystems in /etc/fstab.
+ local types="noproc" x=
+ for x in ${net_fs_list}; do
diff --git a/main/openrc/openrc-hwclock.patch b/main/openrc/openrc-hwclock.patch
new file mode 100644
index 0000000000..593e9ba82f
--- /dev/null
+++ b/main/openrc/openrc-hwclock.patch
@@ -0,0 +1,13 @@
+Index: hwclock.in
+===================================================================
+--- a/init.d/hwclock.in (revision 1571)
++++ b/niit.d/hwclock.in (working copy)
+@@ -118,7 +118,7 @@
+
+ if ! yesno $clock_adjfile; then
+ # Some implementations don't handle adjustments
+- if LC_ALL=C hwclock --help | grep -q "\-\-noadjfile"; then
++ if LC_ALL=C hwclock --help 2>&1 | grep -q "\-\-noadjfile"; then
+ utc_cmd="$utc_cmd --noadjfile"
+ fi
+ fi
diff --git a/main/openrc/openrc.post-install b/main/openrc/openrc.post-install
new file mode 100644
index 0000000000..1057eed416
--- /dev/null
+++ b/main/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/main/openrc/openrc.post-upgrade b/main/openrc/openrc.post-upgrade
new file mode 100644
index 0000000000..76c2da75eb
--- /dev/null
+++ b/main/openrc/openrc.post-upgrade
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# in 0.8.0-r1 the state dir moved from /libexec/rc/init.d to /lib/rc/init.d
+
+[ -d /libexec/rc/init.d ] || exit 0
+
+for i in /libexec/rc/init.d/* ; do
+ [ -e "$i" ] || continue
+ mv $i /lib/rc/init.d/
+done
+
+rmdir /libexec/rc/init.d /libexec/rc /libexec 2>/dev/null
+
+
+# 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/main/openrc/remove-rc_sys-warning.patch b/main/openrc/remove-rc_sys-warning.patch
new file mode 100644
index 0000000000..4f11674888
--- /dev/null
+++ b/main/openrc/remove-rc_sys-warning.patch
@@ -0,0 +1,10 @@
+--- ./src/rc/rc.c.orig
++++ ./src/rc/rc.c
+@@ -878,7 +878,6 @@
+ if (bootlevel)
+ printf("%s\n", bootlevel);
+ } else {
+- ewarn("WARNING: rc_sys not defined in rc.conf. Falling back to automatic detection");
+ bootlevel = rc_sys_v1();
+ if (bootlevel)
+ printf("%s\n", bootlevel);