Skip to content

Commit

Permalink
Updated with Quebec A
Browse files Browse the repository at this point in the history
  • Loading branch information
primate committed Sep 18, 2024
1 parent fd75482 commit 62ff40b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/__xtz/sources.hjson
Original file line number Diff line number Diff line change
@@ -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
}
}
63 changes: 63 additions & 0 deletions src/__xtz/update-sources.lua
Original file line number Diff line number Diff line change
@@ -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 <source-url> [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 => <arch>-octez-<sourceId>
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/<id>/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)

0 comments on commit 62ff40b

Please sign in to comment.