@@ -10,35 +10,69 @@ import (
10
10
"net/http"
11
11
"os"
12
12
"path/filepath"
13
+ "runtime"
13
14
"strings"
14
15
15
16
"github.com/fatih/color"
16
17
17
18
_ "embed"
18
19
)
19
20
20
- const (
21
- vmLinuxKernelURL string = "https://s3.amazonaws.com/spec.ccfc.min/firecracker-ci/v1.5/x86_64/vmlinux-5.10.186"
22
- vmLinuxKernelSHA256 string = "d48d320e320a8cf970184e79e66a833b044a049a4c2c645b9a1abefdb2fe7b31"
21
+ func init () {
22
+ switch runtime .GOARCH {
23
+ case "amd64" :
24
+ vmLinuxKernelURL = "https://s3.amazonaws.com/spec.ccfc.min/firecracker-ci/v1.5/x86_64/vmlinux-5.10.186"
25
+ vmLinuxKernelSHA256 = "d48d320e320a8cf970184e79e66a833b044a049a4c2c645b9a1abefdb2fe7b31"
23
26
24
- cniPluginsTarballURL string = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz"
25
- cniPluginsTarballSHA256 string = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz.sha256"
26
- // TODO: once awslabs fixes their release action, this URL needs to be changed
27
- tcRedirectCNIPluginURL string = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-amd64"
28
- tcRedirectCNIPluginSHA256 string = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-amd64.sha256"
27
+ cniPluginsTarballURL = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz"
28
+ cniPluginsTarballSHA256 = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz.sha256"
29
+ // TODO: once awslabs fixes their release action, this URL needs to be changed
30
+ tcRedirectCNIPluginURL = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-amd64"
31
+ tcRedirectCNIPluginSHA256 = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-amd64.sha256"
29
32
30
- firecrackerTarballURL string = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-x86_64.tgz"
31
- firecrackerTarballSHA256 string = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-x86_64.tgz.sha256.txt"
33
+ firecrackerTarballURL = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-x86_64.tgz"
34
+ firecrackerTarballSHA256 = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-x86_64.tgz.sha256.txt"
32
35
33
- rootfsGzipURL string = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz"
34
- rootfsGzipSHA256 string = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz.sha256"
35
- )
36
+ rootfsGzipURL = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz"
37
+ rootfsGzipSHA256 = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz.sha256"
38
+ case "arm64" :
39
+ vmLinuxKernelURL = "https://s3.amazonaws.com/spec.ccfc.min/firecracker-ci/v1.5/aarch64/vmlinux-5.10.186"
40
+ vmLinuxKernelSHA256 = ""
41
+
42
+ cniPluginsTarballURL = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-arm64-v1.3.0.tgz"
43
+ cniPluginsTarballSHA256 = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-arm64-v1.3.0.tgz.sha256"
44
+
45
+ tcRedirectCNIPluginURL = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-arm64"
46
+ tcRedirectCNIPluginSHA256 = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-arm64.sha256"
47
+
48
+ firecrackerTarballURL = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-aarch64.tgz"
49
+ firecrackerTarballSHA256 = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-aarch64.tgz.sha256.txt"
50
+
51
+ rootfsGzipURL = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz"
52
+ rootfsGzipSHA256 = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz.sha256"
53
+ }
54
+ }
36
55
37
56
var (
38
57
cyan = color .New (color .FgCyan ).SprintFunc ()
39
58
red = color .New (color .FgRed ).SprintFunc ()
40
59
magenta = color .New (color .FgMagenta ).SprintFunc ()
41
60
green = color .New (color .FgHiGreen ).SprintFunc ()
61
+
62
+ vmLinuxKernelURL string
63
+ vmLinuxKernelSHA256 string
64
+
65
+ cniPluginsTarballURL string
66
+ cniPluginsTarballSHA256 string
67
+
68
+ tcRedirectCNIPluginURL string
69
+ tcRedirectCNIPluginSHA256 string
70
+
71
+ firecrackerTarballURL string
72
+ firecrackerTarballSHA256 string
73
+
74
+ rootfsGzipURL string
75
+ rootfsGzipSHA256 string
42
76
)
43
77
44
78
type initFunc func (* requirement , * NodeConfiguration ) error
@@ -240,6 +274,7 @@ func writeCniConf(r *requirement, c *NodeConfiguration) error {
240
274
}
241
275
242
276
func downloadKernel (r * requirement , _ * NodeConfiguration ) error {
277
+ _ = vmLinuxKernelSHA256 // TODO: implement sha verification
243
278
for _ , f := range r .files {
244
279
// TODO: this is a hack for now
245
280
if f .description != "VMLinux Kernel" {
@@ -271,6 +306,7 @@ func downloadKernel(r *requirement, _ *NodeConfiguration) error {
271
306
}
272
307
273
308
func downloadFirecracker (_ * requirement , _ * NodeConfiguration ) error {
309
+ _ = firecrackerTarballSHA256
274
310
// TODO: firecracker repo made the sha difficult to use
275
311
rawData , err := decompressTarFromURL (firecrackerTarballURL , "" )
276
312
if err != nil {
@@ -286,7 +322,7 @@ func downloadFirecracker(_ *requirement, _ *NodeConfiguration) error {
286
322
return err
287
323
}
288
324
289
- if header .Name == "release-v1.5.0-x86_64/firecracker-v1.5.0-x86_64" {
325
+ if header .Name == "release-v1.5.0-x86_64/firecracker-v1.5.0-x86_64" || header . Name == "release-v1.5.0-aarch64/firecracker-v1.5.0-aarch64" {
290
326
outFile , err := os .Create ("/usr/local/bin/firecracker" )
291
327
if err != nil {
292
328
fmt .Println (err )
@@ -350,6 +386,7 @@ func downloadCNIPlugins(r *requirement, c *NodeConfiguration) error {
350
386
}
351
387
352
388
func downloadTCRedirectTap (r * requirement , _ * NodeConfiguration ) error {
389
+ _ = tcRedirectCNIPluginSHA256
353
390
respBin , err := http .Get (tcRedirectCNIPluginURL )
354
391
if err != nil {
355
392
return err
@@ -377,6 +414,7 @@ func downloadTCRedirectTap(r *requirement, _ *NodeConfiguration) error {
377
414
}
378
415
379
416
func downloadRootFS (r * requirement , _ * NodeConfiguration ) error {
417
+ _ = rootfsGzipSHA256
380
418
for _ , f := range r .files {
381
419
// TODO: this is a hack for now
382
420
if f .description != "Root Filesystem Template" {
@@ -407,7 +445,7 @@ func downloadRootFS(r *requirement, _ *NodeConfiguration) error {
407
445
return nil
408
446
}
409
447
410
- func decompressTarFromURL (url string , urlSha string ) (* tar.Reader , error ) {
448
+ func decompressTarFromURL (url string , _ string ) (* tar.Reader , error ) {
411
449
respTar , err := http .Get (url )
412
450
if err != nil {
413
451
return nil , err
0 commit comments