The general consensus amongst distributions is that requiring /var/run to be moved to /run is a good thing(tm) – or, at least, a battle not worth fighting.
I note that the “you have to pre-mount the partition from an initrd” which is now being applied to /usr doesn’t appear to apply to /var (and thank goodness no-one is arguing that /var also has to be conjoined with the root partition)…
One of the greatest strengths of Linux is the ability to do things the way you feel is right – and there’s an awful lot of legacy software with still relies upon the existence of /var/run, and I’m just not keen on having yet another mandatory root-directory entry.
So, here is a patch which will create a custom openrc-0.11.5 ebuild in a (pre-existing) /usr/local/portage repository. As a bonus, it fixes a cosmetic bug when clearing out /var/run on boot.
diff -urx Manifest --unidirectional-new-file /usr/portage/sys-apps/openrc/files/openrc-0.11.5-bootmisc.in.patch /usr/local/portage/sys-apps/openrc/files/openrc-0.11.5-bootmisc.in.patch
--- /usr/portage/sys-apps/openrc/files/openrc-0.11.5-bootmisc.in.patch 1970-01-01 01:00:00.000000000 +0100
+++ /usr/local/portage/sys-apps/openrc/files/openrc-0.11.5-bootmisc.in.patch 2012-11-21 23:14:14.732424125 +0000
@@ -0,0 +1,11 @@
+--- init.d/bootmisc.in.dist 2012-11-21 22:27:04.431229165 +0000
++++ init.d/bootmisc.in 2012-11-21 22:28:29.844249885 +0000
+@@ -145,7 +145,7 @@
+ case "$x" in
+ *.pid)
+ start-stop-daemon --test --quiet \
+- --stop --pidfile "$x" && continue
++ --stop --pidfile "$x" >/dev/null 2>&1 && continue
+ ;;
+ esac
+ rm -f -- "$x"
diff -urx Manifest --unidirectional-new-file /usr/portage/sys-apps/openrc/files/openrc-0.11.5-init.sh.Linux.in.patch /usr/local/portage/sys-apps/openrc/files/openrc-0.11.5-init.sh.Linux.in.patch
--- /usr/portage/sys-apps/openrc/files/openrc-0.11.5-init.sh.Linux.in.patch 1970-01-01 01:00:00.000000000 +0100
+++ /usr/local/portage/sys-apps/openrc/files/openrc-0.11.5-init.sh.Linux.in.patch 2012-11-21 23:14:14.699092258 +0000
@@ -0,0 +1,127 @@
+--- sh/init.sh.Linux.in.dist 2012-11-21 21:59:46.133254024 +0000
++++ sh/init.sh.Linux.in 2012-11-21 22:03:42.763725042 +0000
+@@ -3,6 +3,62 @@
+ # Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
+ # Released under the 2-clause BSD license.
+
++# This basically mounts $RC_SVCDIR as a ramdisk.
++# The tricky part is finding something our kernel supports
++# tmpfs and ramfs are easy, so force one or the other.
++svcdir_restorecon()
++{
++ local rc=0
++ if [ -x /usr/sbin/selinuxenabled -a -c /selinux/null ] &&
++ selinuxenabled; then
++ restorecon $RC_SVCDIR
++ rc=$?
++ fi
++ return $rc
++}
++
++mount_svcdir()
++{
++ # mount from fstab if we can
++ fstabinfo --mount "$RC_SVCDIR" && return 0
++
++ local fs= fsopts="-o rw,noexec,nodev,nosuid"
++ local svcsize=${rc_svcsize:-1024}
++
++ # Some buggy kernels report tmpfs even when not present :(
++ if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then
++ local tmpfsopts="${fsopts},mode=755,size=${svcsize}k"
++ mount -n -t tmpfs $tmpfsopts rc-svcdir "$RC_SVCDIR"
++ if [ $? -eq 0 ]; then
++ svcdir_restorecon
++ [ $? -eq 0 ] && return 0
++ fi
++ fi
++
++ if grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then
++ fs="ramfs"
++ # ramfs has no special options
++ elif [ -e /dev/ram0 ] \
++ && grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then
++ devdir="/dev/ram0"
++ fs="ext2"
++ dd if=/dev/zero of="$devdir" bs=1k count="$svcsize"
++ mkfs -t "$fs" -i 1024 -vm0 "$devdir" "$svcsize"
++ else
++ echo
++ eerror "OpenRC requires tmpfs, ramfs or a ramdisk + ext2"
++ eerror "compiled into the kernel"
++ echo
++ return 1
++ fi
++
++ mount -n -t "$fs" $fsopts rc-svcdir "$RC_SVCDIR"
++ if [ $? -eq 0 ]; then
++ svcdir_restorecon
++ [ $? -eq 0 ] && return 0
++ fi
++}
++
+ . "$RC_LIBEXECDIR"/sh/functions.sh
+ [ -r /etc/rc.conf ] && . /etc/rc.conf
+
+@@ -46,29 +102,34 @@
+ fi
+ mkdir /run
+ else
+- eerror "The /run directory does not exist. Unable to continue."
+- return 1
++ #eerror "The /run directory does not exist. Unable to continue."
++ #return 1
++ :
+ fi
+ fi
+
+-if [ "$sys" = VSERVER ]; then
+- rm -rf /run/*
+-elif ! mountinfo -q /run; then
+- ebegin "Mounting /run"
+- rc=0
+- if ! fstabinfo --mount /run; then
+- mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run
+- rc=$?
+- fi
+- if [ $rc != 0 ]; then
+- eerror "Unable to mount tmpfs on /run."
+- eerror "Can't continue."
+- exit 1
++if [ -d /run ]; then
++ if [ "$sys" = VSERVER ]; then
++ rm -rf /run/*
++ elif ! mountinfo -q /run; then
++ ebegin "Mounting /run"
++ rc=0
++ if ! fstabinfo --mount /run; then
++ mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run
++ rc=$?
++ fi
++ if [ $rc != 0 ]; then
++ eerror "Unable to mount tmpfs on /run."
++ eerror "Can't continue."
++ exit 1
++ fi
+ fi
++ checkpath -d -m 0775 -o root:uucp /run/lock
++else
++ checkpath -d -m 0775 -o root:uucp /var/lock
+ fi
+
+ checkpath -d $RC_SVCDIR
+-checkpath -d -m 0775 -o root:uucp /run/lock
+
+ # Try to mount xenfs as early as possible, otherwise rc_sys() will always
+ # return RC_SYS_XENU and will think that we are in a domU while it's not.
+@@ -80,9 +141,4 @@
+ eend $?
+ fi
+
+-if [ -e "$RC_LIBEXECDIR"/cache/deptree ]; then
+- cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null
+-fi
+-
+-echo sysinit >"$RC_SVCDIR"/softlevel
+-exit 0
++. "$RC_LIBEXECDIR"/sh/init-common-post.sh
diff -urx Manifest --unidirectional-new-file /usr/portage/sys-apps/openrc/files/openrc-0.11.5-rc.h.in.patch /usr/local/portage/sys-apps/openrc/files/openrc-0.11.5-rc.h.in.patch
--- /usr/portage/sys-apps/openrc/files/openrc-0.11.5-rc.h.in.patch 1970-01-01 01:00:00.000000000 +0100
+++ /usr/local/portage/sys-apps/openrc/files/openrc-0.11.5-rc.h.in.patch 2012-11-21 23:14:14.772422358 +0000
@@ -0,0 +1,13 @@
+--- src/librc/rc.h.in.dist 2012-11-20 20:21:51.043277551 +0000
++++ src/librc/rc.h.in 2012-11-20 20:22:12.610081532 +0000
+@@ -39,8 +39,10 @@
+ #define RC_LIBEXECDIR "@LIBEXECDIR@"
+ #if defined(PREFIX)
+ #define RC_SVCDIR RC_LIBEXECDIR "/init.d"
++/*
+ #elif defined(__linux__)
+ #define RC_SVCDIR "@PREFIX@/run/openrc"
++ */
+ #else
+ #define RC_SVCDIR RC_LIBEXECDIR "/init.d"
+ #endif
diff -urx Manifest --unidirectional-new-file /usr/portage/sys-apps/openrc/openrc-0.11.5.ebuild /usr/local/portage/sys-apps/openrc/openrc-0.11.5.ebuild
--- /usr/portage/sys-apps/openrc/openrc-0.11.5.ebuild 2012-11-19 23:31:30.000000000 +0000
+++ /usr/local/portage/sys-apps/openrc/openrc-0.11.5.ebuild 2012-11-22 00:10:20.809626760 +0000
@@ -20,7 +20,7 @@
LICENSE="BSD-2"
SLOT="0"
IUSE="debug elibc_glibc ncurses pam newnet prefix selinux static-libs unicode
- kernel_linux kernel_FreeBSD"
+ +varrun kernel_linux kernel_FreeBSD"
RDEPEND="virtual/init
kernel_FreeBSD? ( || ( >=sys-freebsd/freebsd-ubin-9.0_rc sys-process/fuser-bsd ) )
@@ -44,6 +44,11 @@
sed -i "/^GITVER[[:space:]]*=/s:=.*:=${ver}:" mk/git.mk || die
fi
+ if use varrun ; then
+ epatch "${FILESDIR}/openrc-0.11.5-rc.h.in.patch" || die "rc.h.in epatch failed"
+ epatch "${FILESDIR}/openrc-0.11.5-init.sh.Linux.in.patch" || die "init.sh.Linux.in epatch failed"
+ fi
+ epatch "${FILESDIR}/openrc-0.11.5-bootmisc.in.patch" || die "bootmisc.in epatch failed"
# Allow user patches to be applied without modifying the ebuild
epatch_user
}
Like this:
Like Loading...
Related
Nov 22 2012
Gentoo openrc-0.11.5.ebuild which doesn’t mandate migrating to /run
The general consensus amongst distributions is that requiring /var/run to be moved to /run is a good thing(tm) – or, at least, a battle not worth fighting.
I note that the “you have to pre-mount the partition from an initrd” which is now being applied to /usr doesn’t appear to apply to /var (and thank goodness no-one is arguing that /var also has to be conjoined with the root partition)…
One of the greatest strengths of Linux is the ability to do things the way you feel is right – and there’s an awful lot of legacy software with still relies upon the existence of /var/run, and I’m just not keen on having yet another mandatory root-directory entry.
So, here is a patch which will create a custom openrc-0.11.5 ebuild in a (pre-existing) /usr/local/portage repository. As a bonus, it fixes a cosmetic bug when clearing out /var/run on boot.
Share this:
Like this:
Related
By Stuart • UNIX 0