#117 installer v0.8b fixed to folder deletion, check command, and preserving comms version in manifest

This commit is contained in:
Mikayla Fischler 2023-02-19 19:56:12 -05:00
parent 950ad2931f
commit e6632c3bd9

View File

@ -22,7 +22,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local function println(message) print(tostring(message)) end local function println(message) print(tostring(message)) end
local function print(message) term.write(tostring(message)) end local function print(message) term.write(tostring(message)) end
local VERSION = "v0.8a" local VERSION = "v0.8b"
local install_dir = "/.install-cache" local install_dir = "/.install-cache"
local repo_path = "http://raw.githubusercontent.com/MikaylaFischler/cc-mek-scada/devel/" local repo_path = "http://raw.githubusercontent.com/MikaylaFischler/cc-mek-scada/devel/"
@ -32,6 +32,9 @@ local opts = { ... }
local mode = nil local mode = nil
local app = nil local app = nil
-- record the local installation manifest
---@param manifest table
---@param dependencies table
local function write_install_manifest(manifest, dependencies) local function write_install_manifest(manifest, dependencies)
local versions = {} local versions = {}
for key, value in pairs(manifest.versions) do for key, value in pairs(manifest.versions) do
@ -43,7 +46,7 @@ local function write_install_manifest(manifest, dependencies)
end end
end end
if key == app or is_dependency then if key == app or key == "comms" or is_dependency then
versions[key] = value versions[key] = value
end end
end end
@ -61,7 +64,7 @@ end
println("-- CC Mekanism SCADA Installer " .. VERSION .. " --") println("-- CC Mekanism SCADA Installer " .. VERSION .. " --")
if #opts == 0 or opts[1] == "help" or #opts ~= 2 then if #opts == 0 or opts[1] == "help" then
println("note: only modifies files that are part of the device application") println("note: only modifies files that are part of the device application")
println("usage: ccmsi <mode> <app>") println("usage: ccmsi <mode> <app>")
println("<mode>") println("<mode>")
@ -151,18 +154,19 @@ if mode == "check" then
end end
for key, value in pairs(manifest.versions) do for key, value in pairs(manifest.versions) do
term.setTextColor(colors.white) term.setTextColor(colors.purple)
print("[" .. key .. "]" ) print(string.format("%-14s", "[" .. key .. "]"))
term.setTextColor(colors.blue) term.setTextColor(colors.blue)
print(value) print(value)
term.setTextColor(colors.lightGray) if local_ok and (local_manifest.versions[key] ~= nil) then
if local_manifest.versions[key] ~= nil then term.setTextColor(colors.white)
print(" (current ") print(" (current ")
term.setTextColor(colors.blue) term.setTextColor(colors.blue)
print(value) print(value)
term.setTextColor(colors.white) term.setTextColor(colors.white)
println(")") println(")")
else else
term.setTextColor(colors.lightGray)
println(" (not installed)") println(" (not installed)")
end end
end end
@ -553,19 +557,20 @@ elseif mode == "remove" or mode == "purge" then
fs.delete(folder) fs.delete(folder)
println("deleted directory " .. folder) println("deleted directory " .. folder)
elseif dependency == app then elseif dependency == app then
local folder = files[1] for _, folder in pairs(files) do
while true do while true do
local dir = fs.getDir(folder) local dir = fs.getDir(folder)
if dir == "" or dir == ".." or dir == app then if dir == "" or dir == ".." or dir == app then
break break
else else
folder = dir folder = dir
end
end end
end
if folder ~= app then if folder ~= app and fs.exists(folder) then
fs.delete(folder) fs.delete(folder)
println("deleted app subdirectory " .. folder) println("deleted app subdirectory " .. folder)
end
end end
end end
end end