diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:35:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:35:19 +0000 |
commit | b7e8d5af06ee840cc48217ca4629cf28aeeb3c50 (patch) | |
tree | 6aa8dc840b085de50db46e2ad0725eae248fef02 /debian/udev.postinst | |
parent | Adding upstream version 252.22. (diff) | |
download | systemd-b7e8d5af06ee840cc48217ca4629cf28aeeb3c50.tar.xz systemd-b7e8d5af06ee840cc48217ca4629cf28aeeb3c50.zip |
Adding debian version 252.22-1~deb12u1.debian/252.22-1_deb12u1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/udev.postinst')
-rw-r--r-- | debian/udev.postinst | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/debian/udev.postinst b/debian/udev.postinst new file mode 100644 index 0000000..828fa63 --- /dev/null +++ b/debian/udev.postinst @@ -0,0 +1,86 @@ +#!/bin/sh + +set -e + +chrooted() { + if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; + then + # the devicenumber/inode pair of / is the same as that of /sbin/init's + # root, so we're *not* in a chroot and hence return false. + return 1 + fi + echo "A chroot environment has been detected, udev not started." + return 0 +} + +in_debootstrap() { + # debootstrap --second-stage may be run in an emulator instead of a chroot, + # we need to check for this special case because start-stop-daemon would + # not be available. (#520742) + if [ -d /debootstrap/ ]; then + echo "Being installed by debootstrap, udev not started." + return 0 + fi + return 1 +} + +can_start_udevd() { + if [ ! -d /sys/class/ ]; then + echo "udev requires a mounted sysfs, not started." + return 1 + fi + return 0 +} + +enable_udev() { + can_start_udevd || return 0 + invoke-rc.d udev start +} + +upgrade_fixes() { + : +} + +update_hwdb() { + systemd-hwdb --usr update || true +} + +case "$1" in + configure) + # update/create hwdb before we (re)start udev + update_hwdb + + # Add new system groups used by udev rules + addgroup --quiet --system input + addgroup --quiet --system sgx + + # Make /dev/kvm accessible to kvm group + addgroup --quiet --system kvm + + # Make /dev/dri/renderD* accessible to render group + addgroup --quiet --system render + + if [ -z "$2" ]; then # first install + if ! chrooted && ! in_debootstrap; then + enable_udev + fi + else # upgrades + upgrade_fixes "$@" + if ! chrooted; then + if can_start_udevd; then + if [ -d /run/systemd/system ] ; then + systemctl daemon-reload || true + fi + invoke-rc.d udev restart + fi + fi + fi + ;; + + triggered) + update_hwdb + exit 0 + ;; +esac + +#DEBHELPER# |