function Bootstrap { parameter bootfile, init, compiled, copied, debug. compileInit(init, debug). compileLibs(compiled, debug). copyLibs(copied). if debug { // Open a terminal and run init. CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal"). if init <> "" { run "/init". } } else { DeletePath("1:" + bootfile). // Set OS to boot and restart. if init = "" { set CORE:BOOTFILENAME to init. } else { set CORE:BOOTFILENAME to "/init". } reboot. } } function compileLibs { parameter libs, debug. if debug { CopyLibs(libs). return. } for lib in libs { local tgt is lib. if lib:StartsWith("/prog") { set tgt to lib:Remove(0, 5). } local res is true. compile "0:" + lib. set res to copypath("0:" + lib + ".ksm", "1:" + tgt). deletepath("0:" + lib + ".ksm"). if not res { print "Can't copy compiled file '" + lib + "', aborting.". print ERR. // intentional error to trap execution } } } function copyLibs { parameter libs. for lib in libs { local tgt is lib. if lib:StartsWith("/prog") { set tgt to lib:Remove(0, 5). } if not copypath("0:" + lib, "1:" + tgt) { print "Can't copy file '" + lib + "', aborting.". print ERR. // intentional error to trap execution } } } function compileInit { parameter init, debug is false. if init = "" { return. } if debug { copypath("0:" + init, "1:/init"). return. } compile "0:" + init to "1:/init". }