From: Frank Brehm Date: Tue, 28 Feb 2017 22:57:45 +0000 (+0100) Subject: saving uncommitted changes in /etc prior to emerge run X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=c904b18c5a8457b40c7c9a27293b71d7cde7352f;p=config%2Fbruni%2Fetc.git saving uncommitted changes in /etc prior to emerge run --- diff --git a/conf.d/udev b/conf.d/udev index 41f6b9bc..a714032f 100644 --- a/conf.d/udev +++ b/conf.d/udev @@ -1,31 +1,5 @@ # /etc/conf.d/udev: config file for udev -# udev can trigger coldplug events which cause services to start and -# kernel modules to be loaded. -# Services are deferred to start in the boot runlevel. -# Set rc_coldplug="NO" if you don't want this. -# If you want module coldplugging but not coldplugging of services then you -# can disable service coldplugging in baselayout/openrc config files. -# The setting is named different in different versions. -# in /etc/rc.conf: rc_hotplug="!*" or -# in /etc/conf.d/rc: rc_plug_services="!*" -#rc_coldplug="YES" - -# We can create a /dev/root symbolic link to point to the root device in -# some situations. This is on by default because some software relies on -# it,. However, this software should be fixed to not do this. -# For more information, see -# https://bugs.gentoo.org/show_bug.cgi?id=438380. -# If you are not using any affected software, you do not need this, so -# feel free to turn it off. -#rc_dev_root_symlink="YES" - -# Expert options: - -# Timeout in seconds to wait for processing of uevents at boot. -# There should be no need to change this. -#udev_settle_timeout="60" - # Add extra command line options to udevd, use with care # udevd --help for possible values #udev_opts="" @@ -33,15 +7,3 @@ # Run udevd --debug and write output to /run/udevdebug.log # Should not be kept on as it fills diskspace slowly #udev_debug="YES" - -# Run udevadmin monitor to get a log of all events -# in /run/udevmonitor.log -#udev_monitor="YES" - -# Keep udevmonitor running after populating /dev. -#udev_monitor_keep_running="no" - -# Set cmdline options for udevmonitor. -# could be some of --env --kernel --udev -#udev_monitor_opts="--env" - diff --git a/conf.d/udev-settle b/conf.d/udev-settle new file mode 100644 index 00000000..cb995e41 --- /dev/null +++ b/conf.d/udev-settle @@ -0,0 +1,5 @@ +# /etc/conf.d/udev-settle: config file for udev-settle + +# Timeout in seconds to wait for processing of uevents at boot. +# There should be no need to change this. +#udev_settle_timeout=120 diff --git a/conf.d/udev-trigger b/conf.d/udev-trigger new file mode 100644 index 00000000..5850b8be --- /dev/null +++ b/conf.d/udev-trigger @@ -0,0 +1,32 @@ +# /etc/conf.d/udev-trigger: config file for udev-trigger + +# udev can trigger coldplug events which cause services to start and +# kernel modules to be loaded. +# Services are deferred to start in the boot runlevel. +# Set rc_coldplug="NO" if you don't want this. +# If you want module coldplugging but not coldplugging of services then you +# can disable service coldplugging in baselayout/openrc config files. +# The setting is named different in different versions. +# in /etc/rc.conf: rc_hotplug="!*" or +# in /etc/conf.d/rc: rc_plug_services="!*" +#rc_coldplug="YES" + +# We can create a /dev/root symbolic link to point to the root device in +# some situations. This is on by default because some software relies on +# it,. However, this software should be fixed to not do this. +# For more information, see +# https://bugs.gentoo.org/show_bug.cgi?id=438380. +# If you are not using any affected software, you do not need this, so +# feel free to turn it off. +#rc_dev_root_symlink="YES" + +# Run udevadmin monitor to get a log of all events +# in /run/udevmonitor.log +#udev_monitor="YES" + +# Keep udevmonitor running after populating /dev. +#udev_monitor_keep_running="no" + +# Set cmdline options for udevmonitor. +# could be some of --env --kernel --udev +#udev_monitor_opts="--env" diff --git a/init.d/udev b/init.d/udev index 72b2be22..6ff21b2e 100755 --- a/init.d/udev +++ b/init.d/udev @@ -1,4 +1,4 @@ -#!/sbin/runscript +#!/sbin/openrc-run # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 @@ -7,18 +7,24 @@ description="udev manages device permissions and symbolic links in /dev" extra_started_commands="reload" description_reload="Reload the udev rules and databases" -udev_monitor="${udev_monitor:-no}" -udevmonitor_log=/run/udevmonitor.log -udevmonitor_pid=/run/udevmonitor.pid - depend() { - provide dev need sysfs dev-mount before checkfs fsck + keyword -lxc -systemd-nspawn -vserver +} - # udev does not work inside vservers - keyword -vserver -lxc +get_udevd_binary() { + local bins="/sbin/udevd /lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd" + for f in ${bins}; do + if [ -x "$f" -a ! -L "$f" ]; then + command="$f" + fi + done + if [ -z "$command" ]; then + eerror "Unable to find udev executable." + return 1 + fi } start_pre() @@ -52,16 +58,7 @@ start_pre() fi fi - bins="/sbin/udevd /lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd" - for f in ${bins}; do - if [ -x "$f" -a ! -L "$f" ]; then - command="$f" - fi - done - if [ -z "$command" ]; then - eerror "Unable to find udev executable." - return 1 - fi + get_udevd_binary || return 1 if [ -e /proc/sys/kernel/hotplug ]; then echo "" >/proc/sys/kernel/hotplug @@ -74,94 +71,6 @@ start_pre() return 0 } -start_udevmonitor() -{ - yesno "${udev_monitor}" || return 0 - - einfo "udev: Running udevadm monitor ${udev_monitor_opts} to log all events" - start-stop-daemon --start --stdout "${udevmonitor_log}" \ - --make-pidfile --pidfile "${udevmonitor_pid}" \ - --background --exec /bin/udevadm -- monitor ${udev_monitor_opts} -} - -# This is here because some software expects /dev/root to exist. -# For more information, see this bug: -# https://bugs.gentoo.org/show_bug.cgi?id=438380 -dev_root_link() -{ - local RULESDIR=/run/udev/rules.d - [ -d $RULESDIR ] || mkdir -p $RULESDIR - eval $(udevadm info --export --export-prefix=ROOT_ --device-id-of-file=/ || - true) - [ "$ROOT_MAJOR" -a "$ROOT_MINOR" ] || return 0 - - # btrfs filesystems have bogus major/minor numbers - [ "$ROOT_MAJOR" != 0 ] || return 0 - - echo 'ACTION=="add|change", SUBSYSTEM=="block", ENV{MAJOR}=="'$ROOT_MAJOR'", ENV{MINOR}=="'$ROOT_MINOR'", SYMLINK+="root"' > $RULESDIR/61-dev-root-link.rules -} - -populate_dev() -{ - if yesno ${rc_dev_root_symlink:-yes}; then - ebegin "Generating a rule to create a /dev/root symlink" - dev_root_link - eend $? - fi - - get_bootparam "nocoldplug" && rc_coldplug="no" - if ! yesno ${rc_coldplug:-${RC_COLDPLUG:-yes}}; then - einfo "Setting /dev permissions and symbolic links" - udevadm trigger --attr-match=dev --action=add - udevadm trigger --subsystem-match=net --action=add - ewarn "Skipping udev coldplug sequence" - return 0 - fi - - ebegin "Populating /dev with existing devices through uevents" - udevadm trigger --type=subsystems --action=add - udevadm trigger --type=devices --action=add - eend $? - - ebegin "Waiting for uevents to be processed" - udevadm settle --timeout=${udev_settle_timeout:-60} - eend $? - return 0 -} - -stop_udevmonitor() -{ - yesno "${udev_monitor}" || return 0 - - if yesno "${udev_monitor_keep_running:-no}"; then - ewarn "udev: udevmonitor is still running and writing into ${udevmonitor_log}" - else - einfo "udev: Stopping udevmonitor: Log is in ${udevmonitor_log}" - start-stop-daemon --stop --pidfile "${udevmonitor_pid}" --exec /bin/udevadm - fi -} - -display_hotplugged_services() -{ - local svcfile= svc= services= - for svcfile in "${RC_SVCDIR}"/hotplugged/*; do - svc="${svcfile##*/}" - [ -x "${svcfile}" ] || continue - - services="${services} ${svc}" - done - [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}" -} - -start_post() -{ - start_udevmonitor - populate_dev - stop_udevmonitor - display_hotplugged_services - return 0 -} - stop() { local rc=0 @@ -170,8 +79,9 @@ stop() rc=$? if [ $rc -ne 0 ]; then eend $rc "Failed to stop $RC_SVCNAME using udevadm" + get_udevd_binary || return 1 ebegin "Trying with start-stop-daemon" - start-stop-daemon --stop --exec /sbin/udevd + start-stop-daemon --stop --exec ${command} rc=$? fi eend $rc "Failed to stop $RC_SVCNAME" diff --git a/init.d/udev-settle b/init.d/udev-settle new file mode 100755 index 00000000..c495769e --- /dev/null +++ b/init.d/udev-settle @@ -0,0 +1,19 @@ +#!/sbin/openrc-run +# Copyright 2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() +{ + need udev + after udev-trigger + provide dev-settle + keyword -lxc -systemd-nspawn -vserver +} + +start() +{ + ebegin "Waiting for uevents to be processed" + udevadm settle \ + ${udev_settle_timeout:+--timeout=}$udev_settle_timeout + eend $? +} diff --git a/init.d/udev-trigger b/init.d/udev-trigger new file mode 100755 index 00000000..bdd4884a --- /dev/null +++ b/init.d/udev-trigger @@ -0,0 +1,96 @@ +#!/sbin/openrc-run +# Copyright 2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="udev Coldplug all Devices" + +udevmonitor_log=/run/udevmonitor.log +udevmonitor_pid=/run/udevmonitor.pid + +depend() +{ + need udev + provide dev + keyword -lxc -systemd-nspawn -vserver +} + +start_pre() +{ + if yesno "${udev_monitor:-no}"; then + einfo "Running udevadm monitor ${udev_monitor_opts} to log all events" + start-stop-daemon --start --stdout "${udevmonitor_log}" \ + --make-pidfile --pidfile "${udevmonitor_pid}" \ + --background --exec /bin/udevadm -- monitor ${udev_monitor_opts} + fi + return 0 +} + +display_hotplugged_services() +{ + local svcfile= svc= services= + for svcfile in "${RC_SVCDIR}"/hotplugged/*; do + svc="${svcfile##*/}" + [ -x "${svcfile}" ] || continue + + services="${services} ${svc}" + done + [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}" + return 0 +} + +start_post() +{ + if yesno "${udev_monitor:-no}"; then + if yesno "${udev_monitor_keep_running:-no}"; then + ewarn "udevmonitor is still writing into ${udevmonitor_log}" + else + einfo "Stopping udevmonitor: Log is in ${udevmonitor_log}" + start-stop-daemon --stop --pidfile "${udevmonitor_pid}" \ + --exec /bin/udevadm + fi + fi + display_hotplugged_services + return 0 +} + +# This is here because some software expects /dev/root to exist. +# For more information, see this bug: +# https://bugs.gentoo.org/show_bug.cgi?id=438380 +dev_root_link() +{ + local RULESDIR=/run/udev/rules.d + [ -d $RULESDIR ] || mkdir -p $RULESDIR + eval $(udevadm info --export --export-prefix=ROOT_ --device-id-of-file=/ || + true) + [ "$ROOT_MAJOR" -a "$ROOT_MINOR" ] || return 0 + + # btrfs filesystems have bogus major/minor numbers + [ "$ROOT_MAJOR" != 0 ] || return 0 + + echo 'ACTION=="add|change", SUBSYSTEM=="block", ENV{MAJOR}=="'$ROOT_MAJOR'", ENV{MINOR}=="'$ROOT_MINOR'", SYMLINK+="root"' > $RULESDIR/61-dev-root-link.rules + return 0 +} + +start() +{ + if yesno ${rc_dev_root_symlink:-yes}; then + ebegin "Generating a rule to create a /dev/root symlink" + dev_root_link + eend $? + fi + + get_bootparam "nocoldplug" && rc_coldplug="no" + if ! yesno ${rc_coldplug:-${RC_COLDPLUG:-yes}}; then + einfo "Setting /dev permissions and symbolic links" + udevadm trigger --attr-match=dev --action=add + udevadm trigger --subsystem-match=net --action=add + rc=$? + ewarn "Skipping udev coldplug sequence" + return $rc + fi + + ebegin "Populating /dev with existing devices through uevents" + udevadm trigger --type=subsystems --action=add + udevadm trigger --type=devices --action=add + eend $? +}