mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-09 15:25:56 -04:00
fix /bin/install to not suggest source of only rw option
This commit is contained in:
parent
ed05bd11b7
commit
4b286e2479
@ -89,12 +89,10 @@ for dev, path in pairs(devices) do
|
||||
end
|
||||
|
||||
local target = targets[1]
|
||||
if #targets ~= 1 then
|
||||
utils = loadfile(utils_path, "bt", _G)
|
||||
target = utils("select", "targets", options, targets)
|
||||
-- if there is only 1 target, the source selection cannot include it
|
||||
if #targets == 1 then
|
||||
devices[targets[1].dev] = nil
|
||||
end
|
||||
if not target then return end
|
||||
devices[target.dev] = nil
|
||||
|
||||
for dev, path in pairs(devices) do
|
||||
local address = dev.address
|
||||
@ -127,13 +125,29 @@ for dev, path in pairs(devices) do
|
||||
end
|
||||
end
|
||||
|
||||
-- Ask the user to select a source
|
||||
local source = sources[1]
|
||||
if #sources ~= 1 then
|
||||
utils = utils or loadfile(utils_path, "bt", _G)
|
||||
utils = loadfile(utils_path, "bt", _G)
|
||||
source = utils("select", "sources", options, sources)
|
||||
end
|
||||
if not source then return end
|
||||
|
||||
-- Remove the source from the target options
|
||||
for index,entry in ipairs(targets) do
|
||||
if entry.dev == source.dev then
|
||||
table.remove(targets, index)
|
||||
target = targets[1]
|
||||
end
|
||||
end
|
||||
|
||||
-- Ask the user to select a target
|
||||
if #targets ~= 1 then
|
||||
utils = utils or loadfile(utils_path, "bt", _G)
|
||||
target = utils("select", "targets", options, targets)
|
||||
end
|
||||
if not target then return end
|
||||
|
||||
options =
|
||||
{
|
||||
from = source.path .. '/',
|
||||
|
@ -53,6 +53,20 @@ if cmd == "select" then
|
||||
end
|
||||
os.exit(1)
|
||||
end
|
||||
local index_of_rw_source
|
||||
for index,entry in ipairs(devices) do
|
||||
if not entry.dev.isReadOnly() then
|
||||
if index_of_rw_source then
|
||||
-- this means there was another rw source, no special action required
|
||||
index_of_rw_source = nil
|
||||
break
|
||||
end
|
||||
index_of_rw_source = index
|
||||
end
|
||||
end
|
||||
if index_of_rw_source then
|
||||
table.remove(devices, index_of_rw_source)
|
||||
end
|
||||
return select_prompt(devices, "What do you want to install?")
|
||||
elseif arg == "targets" then
|
||||
if #devices == 0 then
|
||||
|
Loading…
x
Reference in New Issue
Block a user