summaryrefslogtreecommitdiffstats
path: root/_scripts/generate_releases.lua
blob: 0a3b77b391e2e648e5aad03966279ece7b2dfd58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/lua

lyaml = require("lyaml")

url_prefix="http://dl-cdn.alpinelinux.org/alpine"
t = { flavors={} }

-- list those flavors first, the rest will be random
flavor_index = {
	["alpine-standard"] = 1,
	["alpine-extended"] = 2,
	["alpine-netboot"] = 3,
}
numflavors = 3


-- number of different colors for flavors in CSS
num_colors = 7

for i = 1,#arg do
	local f = assert(io.open(arg[i]))

	for _,v in pairs(lyaml.load(f:read("*a"))) do
		local y,m,d = v.date:match("(%d+)-(%d+)-(%d+)")
		v.datestr = os.date("%b %d, %Y", os.time{year=y, month=m, day=d})
		v.iso_url = ("%s/%s/releases/%s/%s"):format(url_prefix,
			v.branch, v.arch, v.iso)
		v.sha256_url = ("%s.sha256"):format(v.iso_url)
		v.sha1_url = ("%s.sha1"):format(v.iso_url)
		v.asc_url = ("%s.asc"):format(v.iso_url)
		v.sig_url = ("%s.sig"):format(v.iso_url)
		v.size_mb=math.floor(v.size/(1024*1024))

		local n = flavor_index[v.flavor]
		if n == nil then
			numflavors = numflavors + 1
			n = numflavors
			flavor_index[v.flavor] = n
		end
		local flavor = t.flavors[n]
		if flavor == nil then
			flavor = {
				archs = {},
				flavor_title = v.title or "",
				flavor_desc = v.desc or "",
				flavor_name = string.lower(v.flavor),
				flavor_color = (flavor_index[v.flavor]-1) % num_colors
			}
			t.flavors[n] = flavor
		end
		table.insert(flavor.archs, v)
	end
end

-- default release
t.default = t.flavors[1].archs[1]

io.write(lyaml.dump{t})