From 62ff40bedf31e12f64867e77c4e8c1e837e713ed Mon Sep 17 00:00:00 2001 From: primate Date: Wed, 18 Sep 2024 13:17:25 -0400 Subject: [PATCH] Updated with Quebec A --- src/__xtz/sources.hjson | 22 +++++++------ src/__xtz/update-sources.lua | 63 ++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 src/__xtz/update-sources.lua diff --git a/src/__xtz/sources.hjson b/src/__xtz/sources.hjson index e909580..eb7b7d5 100644 --- a/src/__xtz/sources.hjson +++ b/src/__xtz/sources.hjson @@ -1,16 +1,20 @@ // SOURCE: https://gitlab.com/tezos/tezos/-/releases -// PROTOCOLS: PsParisC +// PROTOCOLS: PsParisC, PsquebeC { linux-arm64: { - accuser: https://gitlab.com/tezos/tezos/-/package_files/133747971/download - node: https://gitlab.com/tezos/tezos/-/package_files/133747938/download - client: https://gitlab.com/tezos/tezos/-/package_files/133747755/download - baker: https://gitlab.com/tezos/tezos/-/package_files/133747991/download + baker-next: https://gitlab.com/tezos/tezos/-/package_files/148375495/download + accuser: https://gitlab.com/tezos/tezos/-/package_files/148375523/download + baker: https://gitlab.com/tezos/tezos/-/package_files/148375530/download + node: https://gitlab.com/tezos/tezos/-/package_files/148375455/download + accuser-next: https://gitlab.com/tezos/tezos/-/package_files/148375474/download + client: https://gitlab.com/tezos/tezos/-/package_files/148375314/download } linux-x86_64: { - accuser: https://gitlab.com/tezos/tezos/-/package_files/133747113/download - node: https://gitlab.com/tezos/tezos/-/package_files/133747102/download - client: https://gitlab.com/tezos/tezos/-/package_files/133747025/download - baker: https://gitlab.com/tezos/tezos/-/package_files/133747130/download + baker-next: https://gitlab.com/tezos/tezos/-/package_files/148373029/download + accuser: https://gitlab.com/tezos/tezos/-/package_files/148373065/download + baker: https://gitlab.com/tezos/tezos/-/package_files/148373115/download + node: https://gitlab.com/tezos/tezos/-/package_files/148372947/download + accuser-next: https://gitlab.com/tezos/tezos/-/package_files/148372983/download + client: https://gitlab.com/tezos/tezos/-/package_files/148372743/download } } \ No newline at end of file diff --git a/src/__xtz/update-sources.lua b/src/__xtz/update-sources.lua new file mode 100644 index 0000000..a59c57e --- /dev/null +++ b/src/__xtz/update-sources.lua @@ -0,0 +1,63 @@ +-- SOURCE: https://gitlab.com/tezos/tezos/-/releases +-- eli src/__xtz/update-sources.lua https://gitlab.com/tezos/tezos/-/packages/25835249 PtParisB + +local hjson = require "hjson" +local args = table.pack(...) +if #args < 2 then + print("Usage: update-sources [protocols]") + return +end + +local source = args[1] +local protocol = args[2] +local protocolNext +if #args > 2 then + protocolNext = args[3] +end + +--- extract package id from url source - https://gitlab.com/tezos/tezos/-/packages/25835249 +local packageId = source:match("packages/(%d+)") +if not packageId then + print("Invalid source url") + return +end + +local response = net.download_string("https://gitlab.com/api/v4/projects/3836952/packages/" .. + packageId .. "/package_files?per_page=100") +local files = hjson.parse(response) + +local currentSources = hjson.parse(fs.read_file("src/__xtz/sources.hjson")) +for platform, sources in pairs(currentSources) do + local newSources = {} + -- extract arch from linux-x86_64 + local arch = platform:match("linux%-(.*)") + for sourceId, _ in pairs(sources) do + -- build asset id => -octez- + local assetIds = { [sourceId] = arch .. "-octez-" .. sourceId } + if sourceId:match("baker") or sourceId:match("accuser") then + assetIds[sourceId] = arch .. "-octez-" .. sourceId .. "-" .. protocol + if protocolNext then + assetIds[sourceId .. "-next"] = arch .. "-octez-" .. sourceId .. "-" .. protocolNext + end + end + + for assetId, assetName in pairs(assetIds) do + -- lookup file id + for _, file in ipairs(files) do + if file.file_name == assetName then + -- update source url + -- https://gitlab.com/tezos/tezos/-/package_files//download + newSources[assetId] = "https://gitlab.com/tezos/tezos/-/package_files/" .. file.id .. "/download" + break + end + end + end + end + currentSources[platform] = newSources +end + +local newContent = "// SOURCE: https://gitlab.com/tezos/tezos/-/releases\n" +newContent = newContent .. "// PROTOCOLS: " .. string.join(", ", protocol, protocolNext) .. "\n" +newContent = newContent .. hjson.stringify(currentSources, { separator = true }) + +fs.write_file("src/__xtz/sources.hjson", newContent)