2020-01-14 00:29:37 +03:00
|
|
|
begin
|
2019-12-22 07:12:39 +03:00
|
|
|
# TODO: Allow defining depending on stage-0/stage-1.
|
|
|
|
STAGE = 1
|
2019-12-23 06:32:34 +03:00
|
|
|
|
2019-12-22 07:12:39 +03:00
|
|
|
log("************************")
|
|
|
|
log("* Mobile NixOS stage-#{STAGE} *")
|
|
|
|
log("************************")
|
|
|
|
log("")
|
2019-12-23 22:45:04 +03:00
|
|
|
log("Built for device #{Configuration["device"]["name"]}")
|
2019-12-22 07:12:39 +03:00
|
|
|
log("")
|
2019-12-21 08:38:27 +03:00
|
|
|
|
2019-12-24 08:20:30 +03:00
|
|
|
# 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
|
2019-12-23 06:32:34 +03:00
|
|
|
Tasks::Splash.new("stage-0")
|
2019-12-24 08:20:30 +03:00
|
|
|
|
|
|
|
# Some software (mainly extfs tools) bark angrily and fail when this is missing.
|
2019-12-23 06:32:34 +03:00
|
|
|
Tasks::Symlink.new("/proc/mounts", "/etc/mtab")
|
2019-12-24 05:53:00 +03:00
|
|
|
|
2019-12-24 08:20:30 +03:00
|
|
|
Mounting.create_special_mount_points()
|
|
|
|
Mounting.create_boot_mount_points()
|
2019-12-24 05:53:00 +03:00
|
|
|
|
2019-12-23 06:32:34 +03:00
|
|
|
[
|
|
|
|
"/etc/udev",
|
|
|
|
"/var/log",
|
|
|
|
].each do |dir|
|
|
|
|
Tasks::Directory.new(dir)
|
2019-12-21 08:38:27 +03:00
|
|
|
end
|
|
|
|
|
2019-12-23 06:32:34 +03:00
|
|
|
Tasks::Splash.new("stage-1")
|
2019-12-28 04:43:28 +03:00
|
|
|
.add_dependency(:Target, :Devices)
|
2019-12-21 08:38:27 +03:00
|
|
|
|
2019-12-23 22:45:04 +03:00
|
|
|
Tasks::Modules.new(*Configuration["kernel"]["modules"])
|
|
|
|
|
2019-12-23 06:32:34 +03:00
|
|
|
Tasks::go()
|
2019-12-21 08:38:27 +03:00
|
|
|
|
2019-12-23 06:32:34 +03:00
|
|
|
$logger.fatal("Tasks all ran, but we're still here...")
|
2019-12-24 08:21:29 +03:00
|
|
|
System.failure("did_not_switch", color: "ff0000")
|
2020-01-14 00:29:37 +03:00
|
|
|
|
|
|
|
rescue => e
|
2020-01-25 03:50:42 +03:00
|
|
|
System.sad_phone("765300")
|
2020-01-14 00:29:37 +03:00
|
|
|
3.times do
|
|
|
|
$logger.fatal("********************")
|
|
|
|
end
|
|
|
|
$logger.fatal("Handling exception")
|
|
|
|
$logger.fatal(e.inspect)
|
|
|
|
$logger.fatal("`init` will exit and the kernel will crash.")
|
|
|
|
$logger.fatal("********************")
|
|
|
|
# Leave some time for the $logger.fatals to flush before the kernel crashes.
|
|
|
|
sleep(1)
|
2020-01-25 00:02:18 +03:00
|
|
|
System.shell if System.respond_to?(:shell)
|
2020-01-14 00:29:37 +03:00
|
|
|
|
2020-01-14 00:33:40 +03:00
|
|
|
# Users with access to serial debug may prefer crashing to the bootloader.
|
|
|
|
# Though, crashing the kernel is *required* for console ramoops to be present.
|
|
|
|
if Configuration["boot"]["crashToBootloader"] then
|
|
|
|
System.run("reboot bootloader")
|
|
|
|
else
|
|
|
|
exit 99
|
|
|
|
end
|
2020-01-14 00:29:37 +03:00
|
|
|
end
|