Merge pull request #667 from Vexatos/patch-12

Update oppm.lua to make it install itself from loot disk
This commit is contained in:
Florian "Sangar" Nücke 2014-11-13 22:12:55 +01:00
commit 90639ed1c3

View File

@ -480,18 +480,82 @@ local function updatePackage(pack)
end end
end end
if args[1] == "list" then if options.iKnowWhatIAmDoing then
local packs = listPackages(args[2]) if args[1] == "list" then
printPackages(packs) local packs = listPackages(args[2])
elseif args[1] == "info" then printPackages(packs)
provideInfo(args[2]) elseif args[1] == "info" then
elseif args[1] == "install" then provideInfo(args[2])
installPackage(args[2],args[3],false) elseif args[1] == "install" then
elseif args[1] == "update" then installPackage(args[2],args[3],false)
updatePackage(args[2]) elseif args[1] == "update" then
elseif args[1] == "uninstall" then updatePackage(args[2])
uninstallPackage(args[2]) elseif args[1] == "uninstall" then
else uninstallPackage(args[2])
printUsage() else
printUsage()
return
end
return return
end end
--Very much not stolen from Sangar's install.lua
local computer = require("computer")
local unicode = require("unicode")
local candidates = {}
for address in component.list("filesystem") do
local dev = component.proxy(address)
if not dev.isReadOnly() and dev.address ~= computer.tmpAddress() then
table.insert(candidates, dev)
end
end
if #candidates == 0 then
print("No writable disks found, aborting.")
return
end
for i = 1, #candidates do
local label = candidates[i].getLabel()
if label then
label = label .. " (" .. candidates[i].address:sub(1, 8) .. "...)"
else
label = candidates[i].address
end
print(i .. ") " .. label)
end
print("To select the device to install to, please enter a number between 1 and " .. #candidates .. ".")
print("Press 'q' to cancel the installation.")
local choice
while not choice do
result = io.read()
if result:sub(1, 1):lower() == "q" then
return
end
local number = tonumber(result)
if number and number > 0 and number <= #candidates then
choice = candidates[number]
else
print("Invalid input, please try again.")
end
end
candidates = nil
print("Installing OpenOS to device " .. (choice.getLabel() or choice.address))
os.sleep(0.25)
local mnt = choice.address:sub(1, 3)
local result, reason = shell.execute("oppm", nil, "install", "-f", "oppm", "/mnt/" .. mnt .. "/usr/", "--iKnowWhatIAmDoing")
if not result then
error(reason, 0)
end
print("All done! Reboot now? [Y/n]")
local result = io.read()
if not result or result == "" or result:sub(1, 1):lower() == "y" then
print("\nRebooting now!")
computer.shutdown(true)
end
print("Returning to shell.")