Squashed commit of the following:
commit 51f79d47499502ea5c06e703de5941f083db4a0a
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 19:14:15 2025 +0100
reduce useless downloads
commit 86d335f53e5b9c71f3cf97765e6bfbb1a57a387c
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 19:13:26 2025 +0100
fix everywhere
commit 3d23d1b618a19b2a209abc494080ef7ece6428e7
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 19:10:54 2025 +0100
update hashes
commit bbf2d23eb4956b60daabac1bd7fe8cd895ad8df6
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 19:10:30 2025 +0100
try this instead
commit 5c0cf083d9df6fa1de78291e66762b5da9c180b2
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 19:05:42 2025 +0100
istg if that was the problem
commit ac23c993d069e225bde115a268f5bc9eacd03f13
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 18:44:26 2025 +0100
Fix other dumb mistake
commit 610893222b87fcb4d6786e36319cb1628a687423
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 18:43:41 2025 +0100
Fix dumb mistake
commit bb0ee3e64e64034a2c6f3acb24b96a2b0d12f27d
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 18:42:33 2025 +0100
Try fixing sha256 not loading
commit b0f8c1267a3e9aa72d620e5e462bd63aa3700420
Merge: e079d75 17e3a3b
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 17:46:06 2025 +0100
Merge branch 'main' of git.colon-three.com:kodi/snowier
commit e079d75fabdde8244bada41ed5ca4f4034103027
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 17:45:55 2025 +0100
Add debug print
commit 17e3a3b5a82f5d489d8e4e3585e92f35eeefeb89
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 15:51:28 2025 +0100
Second attempt to fix sha256
commit d575f3c98ce010bbfbaf0b38766f239543fec0d0
Author: Kodi Craft <kodi@kdcf.me>
Date: Tue Mar 25 15:39:40 2025 +0100
Fix typo
commit f8ef3b0210db94b9741f6e5d3b8fb6167c260cfc
Author: 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:
parent
e87d00fce2
commit
c7d7f9be98
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user