trying new update system mayb

This commit is contained in:
xomf 2024-08-17 23:24:30 -04:00
parent 2e33e98e5e
commit 68a7d4eaa5
4 changed files with 30 additions and 14 deletions

View File

@ -7,7 +7,7 @@ local require = function(path)
return __DEFAULT_IMPORT(path)
end
end
local KEYPADOS_UPDATE_HASH = "PJIEvsAncSvhKOqsLGVlxvzJ"
rawset(__BUNDLER_FILES, "updater.lua", function ()
local utils = require("utils.lua")
local LAST_USED = os.time()
@ -26,10 +26,9 @@ rawset(__BUNDLER_FILES, "updater.lua", function ()
if string.find(update_code_text, "^local __BUNDLER_FILES = {}") then
-- Make backup
fs.copy("startup.lua", "backup.lua")
local startup_file = fs.open("startup.lua", "r")
local startup_contents = startup_file.readAll()
startup_file.close()
if update_code_text ~= startup_contents then
local pattern = 'local KEYPADOS_UPDATE_HASH%s*=%s*"(.-)"'
local foundUpdateHash = inputString:match(pattern)
if KEYPADOS_UPDATE_HASH ~= foundUpdateHash then
local file = fs.open("startup.lua", "w")
file.write(update_code_text)
file.close()
@ -160,13 +159,20 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
ui.enterButton = ui.main:addButton()
:setText(">>>>")
:setBackground(colors.blue)
:setPosition(6,3)
:setPosition(6,2)
:setSize(1.5,3.2)
:onClick(function()
unlockDoor(ui)
end)
local btnX = 1
local btnY = 3
local btnY = 2
ui.main:addButton()
:setPosition(1, 5)
:setText("0")
:setSize(6,1)
:onClick(function()
addToPin(ui, 0)
end)
for i = 1, 9 do
ui.main:addButton()
:setPosition(btnX, btnY)

View File

@ -83,14 +83,22 @@ function mod.InitUi()
ui.enterButton = ui.main:addButton()
:setText(">>>>")
:setBackground(colors.blue)
:setPosition(6,3)
:setPosition(6,2)
:setSize(1.5,3.2)
:onClick(function()
unlockDoor(ui)
end)
local btnX = 1
local btnY = 3
local btnY = 2
ui.main:addButton()
:setPosition(1, 5)
:setText("0")
:setSize(6,1)
:onClick(function()
addToPin(ui, 0)
end)
for i = 1, 9 do
ui.main:addButton()

View File

@ -19,11 +19,10 @@ local function checkForUpdate()
-- Make backup
fs.copy("startup.lua", "backup.lua")
local startup_file = fs.open("startup.lua", "r")
local startup_contents = startup_file.readAll()
startup_file.close()
local pattern = 'local KEYPADOS_UPDATE_HASH%s*=%s*"(.-)"'
local foundUpdateHash = inputString:match(pattern)
if update_code_text ~= startup_contents then
if KEYPADOS_UPDATE_HASH ~= foundUpdateHash then
local file = fs.open("startup.lua", "w")
file.write(update_code_text)
file.close()

5
x.py
View File

@ -1,5 +1,7 @@
#!/usr/bin/python
import string
import random
UPDATE_ID= ''.join(random.choices(string.ascii_letters, k=24))
OUTPUT="keypadOS.lua";
FILES= [
"updater.lua",
@ -31,6 +33,7 @@ def main():
buf += " return __DEFAULT_IMPORT(path)\n";
buf += " end\n";
buf += "end\n";
buf += f'local KEYPADOS_UPDATE_HASH = "{UPDATE_ID}"';
for file in FILES:
print(f"=== FILE: {file}");