2020-02-28 07:02:15 +03:00
|
|
|
begin
|
2020-12-16 02:00:36 +03:00
|
|
|
STAGE = Configuration["stage"]
|
2020-02-28 07:02:15 +03:00
|
|
|
|
2020-05-29 23:35:59 +03:00
|
|
|
LOADER = "/loader"
|
|
|
|
|
2020-02-28 07:02:15 +03:00
|
|
|
log("************************")
|
|
|
|
log("* Mobile NixOS stage-#{STAGE} *")
|
|
|
|
log("************************")
|
|
|
|
log("")
|
2020-10-22 06:15:42 +03:00
|
|
|
# Since we would like to *somewhat* guesstimate how long it took to get to the
|
|
|
|
# actual init program, we can print the CLOCK_MONOTONIC at startup.
|
|
|
|
# It's not perfect, but that gets us halfway there I guess.
|
|
|
|
log("init started ~#{"%.6f" % (Process.clock_gettime(Process::CLOCK_MONOTONIC))}s after kernel boot time.")
|
2020-02-28 07:02:15 +03:00
|
|
|
log("Built for device #{Configuration["device"]["name"]}")
|
|
|
|
log("")
|
|
|
|
|
|
|
|
# This file is a hard-coded map of non-implicit tasks.
|
|
|
|
# To these tasks, add all Singleton tasks found under tasks/*
|
|
|
|
|
|
|
|
# Without any added dependency, show a first splash ASAP
|
2020-10-27 08:26:09 +03:00
|
|
|
Tasks::Splash.instance()
|
2020-02-28 07:02:15 +03:00
|
|
|
|
|
|
|
# Some software (mainly extfs tools) bark angrily and fail when this is missing.
|
|
|
|
Tasks::Symlink.new("/proc/mounts", "/etc/mtab")
|
|
|
|
|
|
|
|
Mounting.create_special_mount_points()
|
|
|
|
Mounting.create_boot_mount_points()
|
|
|
|
|
|
|
|
[
|
|
|
|
"/etc/udev",
|
|
|
|
"/var/log",
|
|
|
|
].each do |dir|
|
|
|
|
Tasks::Directory.new(dir)
|
|
|
|
end
|
|
|
|
|
|
|
|
Tasks::Modules.new(*Configuration["kernel"]["modules"])
|
|
|
|
|
|
|
|
Tasks::go()
|
|
|
|
|
|
|
|
$logger.fatal("Tasks all ran, but we're still here...")
|
2020-11-09 01:25:24 +03:00
|
|
|
System.failure(
|
2020-11-13 00:55:46 +03:00
|
|
|
"INIT_FAILED_SWITCH",
|
2020-11-09 01:25:24 +03:00
|
|
|
"Boot process failed to switch to stage-2",
|
|
|
|
"The stage-1 init did not detect any failure condition, but failed to switch to stage-2.\n\n" +
|
|
|
|
"It shouldn't happen, yet here we are.",
|
|
|
|
color: "ff0000"
|
|
|
|
)
|
2020-02-28 07:02:15 +03:00
|
|
|
|
|
|
|
rescue => e
|
2020-11-09 01:25:24 +03:00
|
|
|
# Then fail
|
2020-11-13 00:55:46 +03:00
|
|
|
System.failure("INIT_EXCEPTION", "Uncaught Exception", e.inspect, color: "765300", status: 99)
|
2020-02-28 07:02:15 +03:00
|
|
|
end
|