From 4c0d17d6fb1054c08743365191f32d7545d69fef Mon Sep 17 00:00:00 2001 From: payonel Date: Sun, 7 Jan 2018 03:21:09 -0800 Subject: [PATCH] install cleaning reverting a change from july 2017, that had the installer ignore a source if it came from the only rw candidate, when running the multi-selection util. I can see the irritation or confusion of the user when running the installer and it considers a secondary drive as a viable source candidate. Typically, a system would have additional hdds merely to store data. Typically the ro loot floppies are the desired source candidates. I believe the intention here was: "We have multiple source candidates, but only one is rw, thus it is probable that the rw candidate isn't actually intended for install" But I disagree, when testing custom floppies there will easily be one additional rw source. Also, this change includes some additional command line clarification. If the system selects a source automatically, the first prompt the user sees is where to install. This can be jarring or confusing -- as the user doesn't know yet WHAT is being installed. In that case, we now display what is up for installation before asking where to install it. --- .../loot/openos/lib/core/install_basics.lua | 33 +++++++++++-------- .../loot/openos/lib/core/install_utils.lua | 15 --------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/core/install_basics.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/core/install_basics.lua index ef6f57346..f139eeb3b 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/core/install_basics.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/core/install_basics.lua @@ -139,6 +139,19 @@ if #sources ~= 1 then end if not source then return end +options = +{ + from = source.path .. '/', + fromDir = fs.canonical(options.fromDir or source.prop.fromDir or ""), + root = fs.canonical(options.root or options.toDir or source.prop.root or ""), + update = options.update or options.u, + label = source.prop.label or label, + setlabel = not (options.nosetlabel or options.nolabelset) and source.prop.setlabel, + setboot = not (options.nosetboot or options.noboot) and source.prop.setboot, + reboot = not options.noreboot and source.prop.reboot, +} +local source_display = options.label or source.dev.getLabel() or source.path + -- Remove the source from the target options for index,entry in ipairs(targets) do if entry.dev == source.dev then @@ -149,23 +162,16 @@ end -- Ask the user to select a target if #targets ~= 1 then - utils = utils or loadfile(utils_path, "bt", _G) + if #sources == 1 then + io.write(source_display, " selected for install\n") + end + + 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 .. '/', - to = target.path .. '/', - fromDir = fs.canonical(options.fromDir or source.prop.fromDir or ""), - root = fs.canonical(options.root or options.toDir or source.prop.root or ""), - update = options.update or options.u, - label = source.prop.label or label, - setlabel = not (options.nosetlabel or options.nolabelset) and source.prop.setlabel, - setboot = not (options.nosetboot or options.noboot) and source.prop.setboot, - reboot = not options.noreboot and source.prop.reboot, -} +options.to = target.path .. '/' local cp_args = { @@ -175,7 +181,6 @@ local cp_args = fs.concat(options.to , options.root) } -local source_display = options.label or source.dev.getLabel() or source.path local special_target = "" if #targets > 1 or target_filter or source_filter then special_target = " to " .. cp_args[4] diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/core/install_utils.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/core/install_utils.lua index a5704a684..35e5eae42 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/core/install_utils.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/core/install_utils.lua @@ -53,20 +53,6 @@ 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 @@ -77,7 +63,6 @@ if cmd == "select" then end os.exit(1) end - return select_prompt(devices, "Where do you want to install to?") end end \ No newline at end of file