-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathgenerate.nu
More file actions
executable file
·71 lines (58 loc) · 1.91 KB
/
generate.nu
File metadata and controls
executable file
·71 lines (58 loc) · 1.91 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env nu
const SYSTEMS = ["linux-x86_64" "linux-aarch64"];
def to_sri (hash: string) {
return $"sha512-($hash | decode hex | encode base64)"
}
def fetch_release (version: string, system: string, extension: string) {
let base = $"https://download.cdn.mozilla.net/pub/firefox/releases/($version)"
let filename = $"($system)/en-US/firefox-($version).($extension)"
let row = (
http get $"($base)/SHA512SUMS"
| from ssv -m 1 --noheaders
| where column1 == $filename
)
if ($row | is-not-empty) {
let hash = $row.column0.0
return {
version: $version,
url: $"($base)/($filename)",
hash: (to_sri $hash)
}
} else {
return null
}
}
def fetch_nightly (version: string, system: string) {
let product = $"firefox-($version).en-US.($system)";
let data = http get $"https://download.cdn.mozilla.net/pub/firefox/nightly/latest-mozilla-central/($product).buildhub.json";
let url = $data.download.url
let hash = (
http get $"($url | path dirname)/($product).checksums"
| from ssv -m 1 --noheaders
| where column1 == "sha512"
| where column3 == ($url | path basename)
).column0.0
return {
version: $version,
url: $url,
hash: (to_sri $hash),
date: $data.build.date,
}
}
let versions = (http get "https://product-details.mozilla.org/1.0/firefox_versions.json")
let data = (
$SYSTEMS
| wrap system
| each {|it| {
system: $it.system,
data: {
release: (fetch_release $versions.LATEST_FIREFOX_VERSION $it.system "tar.xz")
esr: (fetch_release $versions.FIREFOX_ESR $it.system "tar.xz")
beta: (fetch_release $versions.LATEST_FIREFOX_RELEASED_DEVEL_VERSION $it.system "tar.xz")
devedition: (fetch_release $versions.FIREFOX_DEVEDITION $it.system "tar.xz")
nightly: (fetch_nightly $versions.FIREFOX_NIGHTLY $it.system)
}
}}
| transpose --header-row --as-record
)
$data | to json | save -f latest.json