2019-12-23 07:26:46 +03:00
|
|
|
# Runs udev daemon
|
|
|
|
class Tasks::UDev < SingletonTask
|
|
|
|
def initialize()
|
2019-12-28 04:43:28 +03:00
|
|
|
add_dependency(:Target, :Environment)
|
2019-12-23 22:48:22 +03:00
|
|
|
add_dependency(:Mount, "/dev")
|
|
|
|
add_dependency(:Mount, "/proc")
|
2019-12-24 01:43:22 +03:00
|
|
|
add_dependency(:Mount, "/run")
|
|
|
|
add_dependency(:Mount, "/sys")
|
2019-12-28 04:43:28 +03:00
|
|
|
|
|
|
|
# Make the Devices target depend on this task.
|
|
|
|
# It is preferred to depend on the specific device rather than this target.
|
|
|
|
Targets[:Devices].add_dependency(:Task, self)
|
2019-12-23 07:26:46 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def udevadm(*args)
|
|
|
|
System.run("udevadm", *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run()
|
2019-12-23 22:00:39 +03:00
|
|
|
udevd
|
2019-12-23 07:26:46 +03:00
|
|
|
udevadm("trigger", "--action=add")
|
|
|
|
udevadm("settle")
|
|
|
|
end
|
|
|
|
|
2019-12-23 22:00:39 +03:00
|
|
|
def udevd()
|
|
|
|
*args = []
|
|
|
|
args << "--debug" if debug?
|
|
|
|
System.run("systemd-udevd", "--daemon", *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
# TODO: Allow configuring its debug state
|
|
|
|
def debug?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2019-12-23 07:26:46 +03:00
|
|
|
# TODO: teardown
|
|
|
|
# udevadm control --exit
|
|
|
|
end
|