mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 02:12:42 -04:00
Update oppm.lua to make it install itself from loot disk
Too many reports of OPPM not working due to the floppy being read-only.
This commit is contained in:
parent
7c5aa37693
commit
e76970fe64
@ -480,18 +480,82 @@ local function updatePackage(pack)
|
||||
end
|
||||
end
|
||||
|
||||
if args[1] == "list" then
|
||||
local packs = listPackages(args[2])
|
||||
printPackages(packs)
|
||||
elseif args[1] == "info" then
|
||||
provideInfo(args[2])
|
||||
elseif args[1] == "install" then
|
||||
installPackage(args[2],args[3],false)
|
||||
elseif args[1] == "update" then
|
||||
updatePackage(args[2])
|
||||
elseif args[1] == "uninstall" then
|
||||
uninstallPackage(args[2])
|
||||
else
|
||||
printUsage()
|
||||
if options.iKnowWhatIAmDoing then
|
||||
if args[1] == "list" then
|
||||
local packs = listPackages(args[2])
|
||||
printPackages(packs)
|
||||
elseif args[1] == "info" then
|
||||
provideInfo(args[2])
|
||||
elseif args[1] == "install" then
|
||||
installPackage(args[2],args[3],false)
|
||||
elseif args[1] == "update" then
|
||||
updatePackage(args[2])
|
||||
elseif args[1] == "uninstall" then
|
||||
uninstallPackage(args[2])
|
||||
else
|
||||
printUsage()
|
||||
return
|
||||
end
|
||||
return
|
||||
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.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user