#51 include versioned lockbox in installer, reduced installer file size

This commit is contained in:
Mikayla Fischler 2023-06-25 17:53:02 -04:00
parent 57763702ff
commit bfbbfb164b
4 changed files with 156 additions and 298 deletions

441
ccmsi.lua
View File

@ -20,7 +20,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 CCMSI_VERSION = "v1.4f" local CCMSI_VERSION = "v1.5"
local install_dir = "/.install-cache" local install_dir = "/.install-cache"
local manifest_path = "https://mikaylafischler.github.io/cc-mek-scada/manifests/" local manifest_path = "https://mikaylafischler.github.io/cc-mek-scada/manifests/"
@ -29,22 +29,88 @@ local repo_path = "http://raw.githubusercontent.com/MikaylaFischler/cc-mek-scada
local opts = { ... } local opts = { ... }
local mode = nil local mode = nil
local app = nil local app = nil
local target local target = nil
local install_manifest = manifest_path .. "main/install_manifest.json"
local function red() term.setTextColor(colors.red) end
local function orange() term.setTextColor(colors.orange) end
local function yellow() term.setTextColor(colors.yellow) end
local function green() term.setTextColor(colors.green) end
local function blue() term.setTextColor(colors.blue) end
local function white() term.setTextColor(colors.white) end
local function lgray() term.setTextColor(colors.lightGray) end
-- get command line option in list
local function get_opt(opt, options)
for _, v in pairs(options) do if opt == v then return v end end
return nil
end
-- ask the user yes or no
local function ask_y_n(question, default)
print(question)
if default == true then print(" (Y/n)? ") else print(" (y/N)? ") end
local response = read()
if response == "" then return default
elseif response == "Y" or response == "y" then return true
elseif response == "N" or response == "n" then return false
else return nil end
end
-- print out a white + blue text message
local function pkg_message(message, package) white(); print(message .. " "); blue(); println(package); white() end
-- indicate actions to be taken based on package differences for installs/updates
local function show_pkg_change(name, v_local, v_remote)
if v_local ~= nil then
if v_local ~= v_remote then
print("[" .. name .. "] updating "); blue(); print(v_local); white(); print(" \xbb "); blue(); println(v_local); white()
elseif mode == "install" then
pkg_message("[" .. name .. "] reinstalling", v_local)
end
else
pkg_message("[" .. name .. "] new install of", v_remote)
end
end
-- read the local manifest file
local function read_local_manifest()
local local_ok = false
local local_manifest = {}
local imfile = fs.open("install_manifest.json", "r")
if imfile ~= nil then
local_ok, local_manifest = pcall(function () return textutils.unserializeJSON(imfile.readAll()) end)
imfile.close()
end
return local_ok, local_manifest
end
local function get_remote_manifest()
local response, error = http.get(install_manifest)
if response == nil then
orange(); println("failed to get installation manifest from GitHub, cannot update or install")
red(); println("HTTP error: " .. error); white()
return false, {}
end
local ok, manifest = pcall(function () return textutils.unserializeJSON(response.readAll()) end)
if not ok then
red(); println("error parsing remote installation manifest"); white()
end
return ok, manifest
end
-- record the local installation manifest -- 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
local is_dependency = false local is_dependency = false
for _, dependency in pairs(dependencies) do for _, dependency in pairs(dependencies) do
if (key == "bootloader" and dependency == "system") or key == dependency then if (key == "bootloader" and dependency == "system") or key == dependency then
is_dependency = true is_dependency = true; break
break
end end
end end
if key == app or key == "comms" or is_dependency then versions[key] = value end if key == app or key == "comms" or is_dependency then versions[key] = value end
end end
@ -55,184 +121,66 @@ local function write_install_manifest(manifest, dependencies)
imfile.close() imfile.close()
end end
-- ask the user yes or no
---@nodiscard
---@param question string
---@param default boolean
---@return boolean|nil
local function ask_y_n(question, default)
print(question)
if default == true then
print(" (Y/n)? ")
else
print(" (y/N)? ")
end
local response = read(nil, nil)
if response == "" then
return default
elseif response == "Y" or response == "y" then
return true
elseif response == "N" or response == "n" then
return false
else
return nil
end
end
-- print out a white + blue text message<br>
-- automatically adds a space
---@param message string message
---@param package string dependency/package/version
local function pkg_message(message, package)
term.setTextColor(colors.white)
print(message .. " ")
term.setTextColor(colors.blue)
println(package)
term.setTextColor(colors.white)
end
-- indicate actions to be taken based on package differences for installs/updates
---@param name string package name
---@param v_local string|nil local version
---@param v_remote string remote version
local function show_pkg_change(name, v_local, v_remote)
if v_local ~= nil then
if v_local ~= v_remote then
print("[" .. name .. "] updating ")
term.setTextColor(colors.blue)
print(v_local)
term.setTextColor(colors.white)
print(" \xbb ")
term.setTextColor(colors.blue)
println(v_local)
term.setTextColor(colors.white)
elseif mode == "install" then
pkg_message("[" .. name .. "] reinstalling", v_local)
end
else
pkg_message("[" .. name .. "] new install of", v_remote)
end
end
--
-- get and validate command line options -- get and validate command line options
--
println("-- CC Mekanism SCADA Installer " .. CCMSI_VERSION .. " --") println("-- CC Mekanism SCADA Installer " .. CCMSI_VERSION .. " --")
if #opts == 0 or opts[1] == "help" then if #opts == 0 or opts[1] == "help" then
println("usage: ccmsi <mode> <app> <branch>") println("usage: ccmsi <mode> <app> <branch>")
println("<mode>") println("<mode>")
term.setTextColor(colors.lightGray) lgray()
println(" check - check latest versions avilable") println(" check - check latest versions avilable")
term.setTextColor(colors.yellow) yellow()
println(" ccmsi check <branch> for target") println(" ccmsi check <branch> for target")
term.setTextColor(colors.lightGray) lgray()
println(" install - fresh install, overwrites config") println(" install - fresh install, overwrites config")
println(" update - update files EXCEPT for config/logs") println(" update - update files EXCEPT for config/logs")
println(" remove - delete files EXCEPT for config/logs") println(" remove - delete files EXCEPT for config/logs")
println(" purge - delete files INCLUDING config/logs") println(" purge - delete files INCLUDING config/logs")
term.setTextColor(colors.white) white(); println("<app>"); lgray()
println("<app>")
term.setTextColor(colors.lightGray)
println(" reactor-plc - reactor PLC firmware") println(" reactor-plc - reactor PLC firmware")
println(" rtu - RTU firmware") println(" rtu - RTU firmware")
println(" supervisor - supervisor server application") println(" supervisor - supervisor server application")
println(" coordinator - coordinator application") println(" coordinator - coordinator application")
println(" pocket - pocket application") println(" pocket - pocket application")
term.setTextColor(colors.white) white(); println("<branch>"); yellow()
println("<branch>")
term.setTextColor(colors.yellow)
println(" second parameter when used with check") println(" second parameter when used with check")
term.setTextColor(colors.lightGray) lgray(); println(" main (default) | latest | devel"); white()
println(" main (default) | latest | devel")
return return
else else
for _, v in pairs({ "check", "install", "update", "remove", "purge" }) do mode = get_opt(opts[1], { "check", "install", "update", "remove", "purge" })
if opts[1] == v then
mode = v
break
end
end
if mode == nil then if mode == nil then
println("unrecognized mode") red(); println("Unrecognized mode."); white()
return return
end end
for _, v in pairs({ "reactor-plc", "rtu", "supervisor", "coordinator", "pocket" }) do app = get_opt(opts[2], { "reactor-plc", "rtu", "supervisor", "coordinator", "pocket" })
if opts[2] == v then
app = v
break
end
end
if app == nil and mode ~= "check" then if app == nil and mode ~= "check" then
println("unrecognized application") red(); println("Unrecognized application."); white()
return return
end end
-- determine target -- determine target
if mode == "check" then target = opts[2] else target = opts[3] end if mode == "check" then target = opts[2] else target = opts[3] end
if (target ~= "main") and (target ~= "latest") and (target ~= "devel") then if (target ~= "main") and (target ~= "latest") and (target ~= "devel") then
if target ~= "" then yellow(); println("Unknown target, defaulting to 'main'"); white() end
target = "main" target = "main"
println("unknown target, defaulting to 'main'")
end
end end
-- -- set paths
install_manifest = manifest_path .. target .. "/install_manifest.json"
repo_path = repo_path .. target .. "/"
end
-- run selected mode -- run selected mode
--
if mode == "check" then if mode == "check" then
------------------------- local ok, manifest = get_remote_manifest()
-- GET REMOTE MANIFEST -- if not ok then return end
-------------------------
manifest_path = manifest_path .. target .. "/"
local install_manifest = manifest_path .. "install_manifest.json"
local response, error = http.get(install_manifest)
if response == nil then
term.setTextColor(colors.orange)
println("failed to get installation manifest from GitHub, cannot update or install")
term.setTextColor(colors.red)
println("HTTP error: " .. error)
term.setTextColor(colors.white)
return
end
local ok, manifest = pcall(function () return textutils.unserializeJSON(response.readAll()) end)
if not ok then
term.setTextColor(colors.red)
println("error parsing remote installation manifest")
term.setTextColor(colors.white)
return
end
------------------------
-- GET LOCAL MANIFEST --
------------------------
local imfile = fs.open("install_manifest.json", "r")
local local_ok = false
local local_manifest = {}
if imfile ~= nil then
local_ok, local_manifest = pcall(function () return textutils.unserializeJSON(imfile.readAll()) end)
imfile.close()
end
local local_ok, local_manifest = read_local_manifest()
if not local_ok then if not local_ok then
term.setTextColor(colors.yellow) yellow(); println("failed to load local installation information"); white()
println("failed to load local installation information")
term.setTextColor(colors.white)
local_manifest = { versions = { installer = CCMSI_VERSION } } local_manifest = { versions = { installer = CCMSI_VERSION } }
else else
local_manifest.versions.installer = CCMSI_VERSION local_manifest.versions.installer = CCMSI_VERSION
@ -243,84 +191,35 @@ if mode == "check" then
term.setTextColor(colors.purple) term.setTextColor(colors.purple)
print(string.format("%-14s", "[" .. key .. "]")) print(string.format("%-14s", "[" .. key .. "]"))
if key == "installer" or (local_ok and (local_manifest.versions[key] ~= nil)) then if key == "installer" or (local_ok and (local_manifest.versions[key] ~= nil)) then
term.setTextColor(colors.blue) blue(); print(local_manifest.versions[key])
print(local_manifest.versions[key])
if value ~= local_manifest.versions[key] then if value ~= local_manifest.versions[key] then
term.setTextColor(colors.white) white(); print(" (")
print(" (")
term.setTextColor(colors.cyan) term.setTextColor(colors.cyan)
print(value) print(value); white(); println(" available)")
term.setTextColor(colors.white) else green(); println(" (up to date)") end
println(" available)")
else else
term.setTextColor(colors.green) lgray(); print("not installed"); white(); print(" (latest ")
println(" (up to date)")
end
else
term.setTextColor(colors.lightGray)
print("not installed")
term.setTextColor(colors.white)
print(" (latest ")
term.setTextColor(colors.cyan) term.setTextColor(colors.cyan)
print(value) print(value); white(); println(")")
term.setTextColor(colors.white)
println(")")
end end
end end
elseif mode == "install" or mode == "update" then elseif mode == "install" or mode == "update" then
------------------------- local ok, manifest = get_remote_manifest()
-- GET REMOTE MANIFEST -- if not ok then return end
-------------------------
repo_path = repo_path .. target .. "/"
manifest_path = manifest_path .. target .. "/"
local install_manifest = manifest_path .. "install_manifest.json"
local response, error = http.get(install_manifest)
if response == nil then
term.setTextColor(colors.orange)
println("failed to get installation manifest from GitHub, cannot update or install")
term.setTextColor(colors.red)
println("HTTP error: " .. error)
term.setTextColor(colors.white)
return
end
local ok, manifest = pcall(function () return textutils.unserializeJSON(response.readAll()) end)
if not ok then
term.setTextColor(colors.red)
println("error parsing remote installation manifest")
term.setTextColor(colors.white)
end
------------------------
-- GET LOCAL MANIFEST --
------------------------
local ver = { local ver = {
app = { v_local = nil, v_remote = nil, changed = false }, app = { v_local = nil, v_remote = nil, changed = false },
boot = { v_local = nil, v_remote = nil, changed = false }, boot = { v_local = nil, v_remote = nil, changed = false },
comms = { v_local = nil, v_remote = nil, changed = false }, comms = { v_local = nil, v_remote = nil, changed = false },
graphics = { v_local = nil, v_remote = nil, changed = false } graphics = { v_local = nil, v_remote = nil, changed = false },
lockbox = { v_local = nil, v_remote = nil, changed = false }
} }
local imfile = fs.open("install_manifest.json", "r")
local local_ok = false
local local_manifest = {}
if imfile ~= nil then
local_ok, local_manifest = pcall(function () return textutils.unserializeJSON(imfile.readAll()) end)
imfile.close()
end
-- try to find local versions -- try to find local versions
local local_ok, local_manifest = read_local_manifest()
if not local_ok then if not local_ok then
if mode == "update" then if mode == "update" then
term.setTextColor(colors.red) red(); println("failed to load local installation information, cannot update"); white()
println("failed to load local installation information, cannot update")
term.setTextColor(colors.white)
return return
end end
else else
@ -328,19 +227,16 @@ elseif mode == "install" or mode == "update" then
ver.app.v_local = local_manifest.versions[app] ver.app.v_local = local_manifest.versions[app]
ver.comms.v_local = local_manifest.versions.comms ver.comms.v_local = local_manifest.versions.comms
ver.graphics.v_local = local_manifest.versions.graphics ver.graphics.v_local = local_manifest.versions.graphics
ver.lockbox.v_local = local_manifest.versions.lockbox
if local_manifest.versions[app] == nil then if local_manifest.versions[app] == nil then
term.setTextColor(colors.red) red(); println("another application is already installed, please purge it before installing a new application"); white()
println("another application is already installed, please purge it before installing a new application")
term.setTextColor(colors.white)
return return
end end
local_manifest.versions.installer = CCMSI_VERSION local_manifest.versions.installer = CCMSI_VERSION
if manifest.versions.installer ~= CCMSI_VERSION then if manifest.versions.installer ~= CCMSI_VERSION then
term.setTextColor(colors.yellow) yellow(); println("a newer version of the installer is available, it is recommended to download it"); white()
println("a newer version of the installer is available, consider downloading it")
term.setTextColor(colors.white)
end end
end end
@ -348,14 +244,15 @@ elseif mode == "install" or mode == "update" then
ver.app.v_remote = manifest.versions[app] ver.app.v_remote = manifest.versions[app]
ver.comms.v_remote = manifest.versions.comms ver.comms.v_remote = manifest.versions.comms
ver.graphics.v_remote = manifest.versions.graphics ver.graphics.v_remote = manifest.versions.graphics
ver.lockbox.v_remote = manifest.versions.lockbox
term.setTextColor(colors.green) green()
if mode == "install" then if mode == "install" then
println("Installing " .. app .. " files...") println("Installing " .. app .. " files...")
elseif mode == "update" then elseif mode == "update" then
println("Updating " .. app .. " files... (keeping old config.lua)") println("Updating " .. app .. " files... (keeping old config.lua)")
end end
term.setTextColor(colors.white) white()
-- display bootloader version change information -- display bootloader version change information
show_pkg_change("bootldr", ver.boot.v_local, ver.boot.v_remote) show_pkg_change("bootldr", ver.boot.v_local, ver.boot.v_remote)
@ -369,16 +266,17 @@ elseif mode == "install" or mode == "update" then
show_pkg_change("comms", ver.comms.v_local, ver.comms.v_remote) show_pkg_change("comms", ver.comms.v_local, ver.comms.v_remote)
ver.comms.changed = ver.comms.v_local ~= ver.comms.v_remote ver.comms.changed = ver.comms.v_local ~= ver.comms.v_remote
if ver.comms.changed and ver.comms.v_local ~= nil then if ver.comms.changed and ver.comms.v_local ~= nil then
print("[comms] ") print("[comms] "); yellow(); println("other devices on the network will require an update"); white()
term.setTextColor(colors.yellow)
println("other devices on the network will require an update")
term.setTextColor(colors.white)
end end
-- display graphics version change information -- display graphics version change information
show_pkg_change("graphics", ver.graphics.v_local, ver.graphics.v_remote) show_pkg_change("graphics", ver.graphics.v_local, ver.graphics.v_remote)
ver.graphics.changed = ver.graphics.v_local ~= ver.graphics.v_remote ver.graphics.changed = ver.graphics.v_local ~= ver.graphics.v_remote
-- display lockbox version change information
show_pkg_change("lockbox", ver.lockbox.v_local, ver.lockbox.v_remote)
ver.lockbox.changed = ver.lockbox.v_local ~= ver.lockbox.v_remote
-- ask for confirmation -- ask for confirmation
if not ask_y_n("Continue?", false) then return end if not ask_y_n("Continue?", false) then return end
@ -405,11 +303,9 @@ elseif mode == "install" or mode == "update" then
-- check space constraints -- check space constraints
if space_available < space_required then if space_available < space_required then
single_file_mode = true single_file_mode = true
term.setTextColor(colors.yellow) yellow(); println("WARNING: Insufficient space available for a full download!"); white()
println("WARNING: Insufficient space available for a full download!")
term.setTextColor(colors.white)
println("Files can be downloaded one by one, so if you are replacing a current install this will not be a problem unless installation fails.") println("Files can be downloaded one by one, so if you are replacing a current install this will not be a problem unless installation fails.")
if mode == "update" then println("If installation still fails, delete this device's log file and try again.") end if mode == "update" then println("If installation still fails, delete this device's log file or uninstall the app (not purge) and try again.") end
if not ask_y_n("Do you wish to continue?", false) then if not ask_y_n("Do you wish to continue?", false) then
println("Operation cancelled.") println("Operation cancelled.")
return return
@ -419,12 +315,11 @@ elseif mode == "install" or mode == "update" then
local success = true local success = true
-- helper function to check if a dependency is unchanged -- helper function to check if a dependency is unchanged
---@nodiscard
---@param dependency string
---@return boolean
local function unchanged(dependency) local function unchanged(dependency)
if dependency == "system" then return not ver.boot.changed if dependency == "system" then return not ver.boot.changed
elseif dependency == "graphics" then return not ver.graphics.changed elseif dependency == "graphics" then return not ver.graphics.changed
elseif dependency == "lockbox" then return not ver.lockbox.changed
elseif dependency == "common" then return not (ver.app.changed or ver.comms.changed)
elseif dependency == app then return not ver.app.changed elseif dependency == app then return not ver.app.changed
else return true end else return true end
end end
@ -441,7 +336,7 @@ elseif mode == "install" or mode == "update" then
pkg_message("skipping download of unchanged package", dependency) pkg_message("skipping download of unchanged package", dependency)
else else
pkg_message("downloading package", dependency) pkg_message("downloading package", dependency)
term.setTextColor(colors.lightGray) lgray()
local files = file_list[dependency] local files = file_list[dependency]
for _, file in pairs(files) do for _, file in pairs(files) do
@ -449,8 +344,7 @@ elseif mode == "install" or mode == "update" then
local dl, err = http.get(repo_path .. file) local dl, err = http.get(repo_path .. file)
if dl == nil then if dl == nil then
term.setTextColor(colors.red) red(); println("GET HTTP Error " .. err)
println("GET HTTP Error " .. err)
success = false success = false
break break
else else
@ -469,7 +363,7 @@ elseif mode == "install" or mode == "update" then
pkg_message("skipping install of unchanged package", dependency) pkg_message("skipping install of unchanged package", dependency)
else else
pkg_message("installing package", dependency) pkg_message("installing package", dependency)
term.setTextColor(colors.lightGray) lgray()
local files = file_list[dependency] local files = file_list[dependency]
for _, file in pairs(files) do for _, file in pairs(files) do
@ -486,23 +380,15 @@ elseif mode == "install" or mode == "update" then
fs.delete(install_dir) fs.delete(install_dir)
if success then if success then
-- if we made it here, then none of the file system functions threw exceptions
-- that means everything is OK
write_install_manifest(manifest, dependencies) write_install_manifest(manifest, dependencies)
term.setTextColor(colors.green) green()
if mode == "install" then if mode == "install" then
println("Installation completed successfully.") println("Installation completed successfully.")
else else println("Update completed successfully.") end
println("Update completed successfully.")
end
else else
if mode == "install" then if mode == "install" then
term.setTextColor(colors.red) red(); println("Installation failed.")
println("Installation failed.") else orange(); println("Update failed, existing files unmodified.") end
else
term.setTextColor(colors.orange)
println("Update failed, existing files unmodified.")
end
end end
else else
-- go through all files and replace one by one -- go through all files and replace one by one
@ -511,7 +397,7 @@ elseif mode == "install" or mode == "update" then
pkg_message("skipping install of unchanged package", dependency) pkg_message("skipping install of unchanged package", dependency)
else else
pkg_message("installing package", dependency) pkg_message("installing package", dependency)
term.setTextColor(colors.lightGray) lgray()
local files = file_list[dependency] local files = file_list[dependency]
for _, file in pairs(files) do for _, file in pairs(files) do
@ -520,7 +406,7 @@ elseif mode == "install" or mode == "update" then
local dl, err = http.get(repo_path .. file) local dl, err = http.get(repo_path .. file)
if dl == nil then if dl == nil then
println("GET HTTP Error " .. err) red(); println("GET HTTP Error " .. err)
success = false success = false
break break
else else
@ -534,51 +420,33 @@ elseif mode == "install" or mode == "update" then
end end
if success then if success then
-- if we made it here, then none of the file system functions threw exceptions
-- that means everything is OK
write_install_manifest(manifest, dependencies) write_install_manifest(manifest, dependencies)
term.setTextColor(colors.green) green()
if mode == "install" then if mode == "install" then
println("Installation completed successfully.") println("Installation completed successfully.")
else println("Update completed successfully.") end
else else
println("Update completed successfully.") red()
end
else
term.setTextColor(colors.red)
if mode == "install" then if mode == "install" then
println("Installation failed, files may have been skipped.") println("Installation failed, files may have been skipped.")
else else println("Update failed, files may have been skipped.") end
println("Update failed, files may have been skipped.")
end
end end
end end
elseif mode == "remove" or mode == "purge" then elseif mode == "remove" or mode == "purge" then
local imfile = fs.open("install_manifest.json", "r") local ok, manifest = read_local_manifest()
local ok = false
local manifest = {}
if imfile ~= nil then
ok, manifest = pcall(function () return textutils.unserializeJSON(imfile.readAll()) end)
imfile.close()
end
if not ok then if not ok then
term.setTextColor(colors.red) red(); println("Error parsing local installation manifest."); white()
println("error parsing local installation manifest")
term.setTextColor(colors.white)
return return
elseif mode == "remove" and manifest.versions[app] == nil then elseif mode == "remove" and manifest.versions[app] == nil then
term.setTextColor(colors.red) red(); println(app .. " is not installed, cannot remove."); white()
println(app .. " is not installed")
term.setTextColor(colors.white)
return return
end end
term.setTextColor(colors.orange) orange()
if mode == "remove" then if mode == "remove" then
println("removing all " .. app .. " files except for config.lua and log.txt...") println("Removing all " .. app .. " files except for config and log...")
elseif mode == "purge" then elseif mode == "purge" then
println("purging all " .. app .. " files...") println("Purging all " .. app .. " files including config and log...")
end end
-- ask for confirmation -- ask for confirmation
@ -590,9 +458,8 @@ elseif mode == "remove" or mode == "purge" then
table.insert(dependencies, app) table.insert(dependencies, app)
term.setTextColor(colors.lightGray)
-- delete log file if purging -- delete log file if purging
lgray()
if mode == "purge" and fs.exists(config_file) then if mode == "purge" and fs.exists(config_file) then
local log_deleted = pcall(function () local log_deleted = pcall(function ()
local config = require(app .. ".config") local config = require(app .. ".config")
@ -603,11 +470,9 @@ elseif mode == "remove" or mode == "purge" then
end) end)
if not log_deleted then if not log_deleted then
term.setTextColor(colors.red) red(); println("failed to delete log file")
println("failed to delete log file") white(); println("press enter to continue...")
term.setTextColor(colors.lightGray) read(); lgray()
---@diagnostic disable-next-line: undefined-field
os.sleep(1)
end end
end end
@ -628,11 +493,7 @@ elseif mode == "remove" or mode == "purge" then
local folder = files[1] local folder = files[1]
while true do while true do
local dir = fs.getDir(folder) local dir = fs.getDir(folder)
if dir == "" or dir == ".." then if dir == "" or dir == ".." then break else folder = dir end
break
else
folder = dir
end
end end
if fs.isDir(folder) then if fs.isDir(folder) then
@ -640,14 +501,11 @@ elseif mode == "remove" or mode == "purge" then
println("deleted directory " .. folder) println("deleted directory " .. folder)
end end
elseif dependency == app then elseif dependency == app then
-- delete individual subdirectories so we can leave the config
for _, folder in pairs(files) do 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 else folder = dir end
break
else
folder = dir
end
end end
if folder ~= app and fs.isDir(folder) then if folder ~= app and fs.isDir(folder) then
@ -665,13 +523,12 @@ elseif mode == "remove" or mode == "purge" then
else else
-- remove all data from versions list to show nothing is installed -- remove all data from versions list to show nothing is installed
manifest.versions = {} manifest.versions = {}
imfile = fs.open("install_manifest.json", "w") local imfile = fs.open("install_manifest.json", "w")
imfile.write(textutils.serializeJSON(manifest)) imfile.write(textutils.serializeJSON(manifest))
imfile.close() imfile.close()
end end
term.setTextColor(colors.green) green(); println("Done!")
println("Done!")
end end
term.setTextColor(colors.white) white()

View File

@ -50,6 +50,7 @@ def make_manifest(size):
"bootloader" : get_version("./startup.lua"), "bootloader" : get_version("./startup.lua"),
"comms" : get_version("./scada-common/comms.lua", True), "comms" : get_version("./scada-common/comms.lua", True),
"graphics" : get_version("./graphics/core.lua", True), "graphics" : get_version("./graphics/core.lua", True),
"lockbox" : get_version("./lockbox/init.lua", True),
"reactor-plc" : get_version("./reactor-plc/startup.lua"), "reactor-plc" : get_version("./reactor-plc/startup.lua"),
"rtu" : get_version("./rtu/startup.lua"), "rtu" : get_version("./rtu/startup.lua"),
"supervisor" : get_version("./supervisor/startup.lua"), "supervisor" : get_version("./supervisor/startup.lua"),
@ -70,11 +71,11 @@ def make_manifest(size):
"pocket" : list_files("./pocket"), "pocket" : list_files("./pocket"),
}, },
"depends" : { "depends" : {
"reactor-plc" : [ "system", "common", "graphics" ], "reactor-plc" : [ "system", "common", "graphics", "lockbox" ],
"rtu" : [ "system", "common", "graphics" ], "rtu" : [ "system", "common", "graphics", "lockbox" ],
"supervisor" : [ "system", "common", "graphics" ], "supervisor" : [ "system", "common", "graphics", "lockbox" ],
"coordinator" : [ "system", "common", "graphics" ], "coordinator" : [ "system", "common", "graphics", "lockbox" ],
"pocket" : [ "system", "common", "graphics" ] "pocket" : [ "system", "common", "graphics", "lockbox" ]
}, },
"sizes" : { "sizes" : {
# manifest file estimate # manifest file estimate

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
local Lockbox = {}; local Lockbox = {};
-- cc-mek-scada lockbox version -- cc-mek-scada lockbox version
Lockbox.VERSION = "1.0" Lockbox.version = "1.0"
--[[ --[[
package.path = "./?.lua;" package.path = "./?.lua;"