Squashed commit of the following:
commit51f79d4749Author: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 19:14:15 2025 +0100 reduce useless downloads commit86d335f53eAuthor: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 19:13:26 2025 +0100 fix everywhere commit3d23d1b618Author: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 19:10:54 2025 +0100 update hashes commitbbf2d23eb4Author: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 19:10:30 2025 +0100 try this instead commit5c0cf083d9Author: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 19:05:42 2025 +0100 istg if that was the problem commitac23c993d0Author: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 18:44:26 2025 +0100 Fix other dumb mistake commit610893222bAuthor: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 18:43:41 2025 +0100 Fix dumb mistake commitbb0ee3e64eAuthor: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 18:42:33 2025 +0100 Try fixing sha256 not loading commitb0f8c1267aMerge:e079d7517e3a3bAuthor: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 17:46:06 2025 +0100 Merge branch 'main' of git.colon-three.com:kodi/snowier commite079d75fabAuthor: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 17:45:55 2025 +0100 Add debug print commit17e3a3b5a8Author: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 15:51:28 2025 +0100 Second attempt to fix sha256 commitd575f3c98cAuthor: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 15:39:40 2025 +0100 Fix typo commitf8ef3b0210Author: Kodi Craft <kodi@kdcf.me> Date: Tue Mar 25 15:38:42 2025 +0100 Try using different implementation of sha256
This commit is contained in:
27
install.lua
27
install.lua
@@ -2,8 +2,7 @@ local repoRoot = "https://git.colon-three.com/kodi/snowier/raw/branch/main/"
|
||||
|
||||
local URLs = {
|
||||
fileIndex = repoRoot .. "index.json",
|
||||
-- Implementation of sha256 pulled from here
|
||||
sha2 = "https://raw.githubusercontent.com/Egor-Skriptunoff/pure_lua_SHA/refs/heads/master/sha2.lua"
|
||||
sha256 = repoRoot .. "sha256.lua"
|
||||
}
|
||||
|
||||
local log = {}
|
||||
@@ -13,6 +12,11 @@ function log.info(value)
|
||||
print("[I] " .. value)
|
||||
end
|
||||
|
||||
--- @param value string
|
||||
function log.debug(value)
|
||||
print("[D] " .. value)
|
||||
end
|
||||
|
||||
--- @param value string
|
||||
function log.error(value)
|
||||
printError("[E] " .. value)
|
||||
@@ -21,19 +25,20 @@ end
|
||||
local function main()
|
||||
log.info("Starting installer")
|
||||
|
||||
if not fs.exists("sha2.lua") then
|
||||
log.info("Downloading sha2.lua")
|
||||
local sharequest = http.get(URLs.sha2)
|
||||
local shafile = fs.open("sha2.lua", "w")
|
||||
if not fs.exists("sha256.lua") then
|
||||
log.info("Downloading sha256.lua")
|
||||
local sharequest = http.get(URLs.sha256)
|
||||
local shafile = fs.open("sha256.lua", "w")
|
||||
shafile.write(sharequest.readAll())
|
||||
shafile.close()
|
||||
sharequest.close()
|
||||
end
|
||||
local hash = require("sha2")
|
||||
package.path = package.path .. ";/?;/?.lua" -- hack to solve 'wget run'
|
||||
local hash = require("sha256")
|
||||
|
||||
log.info("Downloading index file")
|
||||
local indexrequest = http.get(URLs.fileIndex)
|
||||
local index = textutils.unserializeJson(request.readAll())
|
||||
local index = textutils.unserializeJSON(indexrequest.readAll())
|
||||
indexrequest.close()
|
||||
|
||||
if (index == nil) then
|
||||
@@ -51,9 +56,9 @@ local function main()
|
||||
toDownload[#toDownload+1] = v
|
||||
else
|
||||
local destfile = fs.open(v.dest, "r")
|
||||
local filehash = hash.sha256(destfile.readAll())
|
||||
local filehash = hash.sha256(destfile.readAll() .. "\n") -- newline is weird hack because of awkward hashes
|
||||
destfile.close()
|
||||
if filehash ~= v.sha256 then
|
||||
if filehash ~= v.hash then
|
||||
toDownload[#toDownload+1] = v
|
||||
end
|
||||
end
|
||||
@@ -73,7 +78,7 @@ local function main()
|
||||
-- Check the validity of the hash, this acts both as a checksum
|
||||
-- and a way to raise an error if the index is incorrect
|
||||
tempfile = fs.open("/tmp/" .. v.hash .. ".lua", "r")
|
||||
local filehash = hash.sha256(tempfile.readAll())
|
||||
local filehash = hash.sha256(tempfile.readAll() .. "\n") -- newline is weird hack because of awkward hashes
|
||||
tempfile.close()
|
||||
if filehash ~= v.hash then
|
||||
log.error("File " .. v.dest .. " (from " .. v.src .. ") has a mismatched hash.")
|
||||
|
||||
5691
sha256.lua
Normal file
5691
sha256.lua
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
open index.json
|
||||
| each {|entry|
|
||||
{src: $entry.src, dest: $entry.dest,
|
||||
hash: (cat $entry.src | hash sha256)}
|
||||
hash: (open $entry.src | hash sha256)}
|
||||
}
|
||||
| collect
|
||||
| save -f index.json
|
||||
|
||||
Reference in New Issue
Block a user