Merge pull request #2118 from payonel/openloader-installer

make openloader installer compatable with openos install tool
This commit is contained in:
payonel 2016-11-02 21:42:45 -07:00 committed by GitHub
commit 1d5c69924f
2 changed files with 16 additions and 15 deletions

View File

@ -0,0 +1 @@
os.execute(install.from .. "/bin/opl-flash.lua")

View File

@ -142,25 +142,25 @@ local term = require "term"
local args, options = shell.parse(...) local args, options = shell.parse(...)
if options.h or options.help then if options.h or options.help then
print("opl-flash [-hqr] [--label=EEPROMLabel]") print("opl-flash [-hqr] [--label=EEPROMLabel]")
print(" --label= Set specified label for the EEPROM") print(" --label= Set specified label for the EEPROM")
print(" -q --quiet Do not output anything, and don't ask if sure") print(" -q --quiet Do not output anything, and don't ask if sure")
print(" -r --reboot Reboot after installing") print(" -r --reboot Reboot after installing")
print(" -h --help Display this help") print(" -h --help Display this help")
return return
end end
local say = not (options.q or options.quiet) and print or function()end local say = not (options.q or options.quiet) and print or function()end
say ("Do you really want to flash openloader to EEPROM("..tostring(#eeprom).." bytes)[Y/n]") say ("Do you really want to flash openloader to EEPROM("..tostring(#eeprom).." bytes)[Y/n]")
if options.q or options.quiet or io.read():lower() == "y" then if options.q or options.quiet or ((io.read() or "n").."y"):match("^%s*[Yy]") then
say("Flashing... Do not reboot now!") say("Flashing... Do not reboot now!")
component.eeprom.set(eeprom) component.eeprom.set(eeprom)
component.eeprom.setLabel((type(options.label) == "string" and options.label) or version) component.eeprom.setLabel((type(options.label) == "string" and options.label) or version)
if options.r or options.reboot then if options.r or options.reboot then
computer.shutdown(true) computer.shutdown(true)
else else
say("Done. you can reboot now") say("Done. you can reboot now")
end end
end end