cork/downloadimage: Add new platform qemu_uefi
We now release UEFI binaries to be used with QEMU, so add a new
download target 'qemu_uefi' that includes those binaries.
@@ -58,12 +58,12 @@ func init() {
downloadImageCmd.Flags().BoolVar(&downloadImageVerify,
"verify", true, "verify")
downloadImageCmd.Flags().Var(&downloadImagePlatformList,
- "platform", "Choose qemu, gce, or aws. Multiple platforms can be specified by repeating the flag")
+ "platform", "Choose qemu, qemu_uefi, gce, or aws. Multiple platforms can be specified by repeating the flag")
root.AddCommand(downloadImageCmd)
}
-type platformList []string // satisfies pflag.Value interface
+type platformList [][]string // satisfies pflag.Value interface
func (platforms *platformList) String() string {
return fmt.Sprintf("%v", *platforms)
@@ -78,21 +78,22 @@ func (platforms *platformList) Type() string {
// separated flags without spaces will also be parsed correctly.
func (platforms *platformList) Set(value string) error {
- // maps names of platforms to filename prefix
- platformMap := map[string]string{
- "qemu": "_image.bin.bz2",
- "gce": "_gce.tar.gz",
- "aws": "_ami_image.bin.bz2",
+ // Maps names of platforms to a list of file suffixes to download.
+ platformMap := map[string][]string{
+ "qemu": {"_image.bin.bz2"},
+ "qemu_uefi": {"_qemu_uefi_efi_code.fd", "_qemu_uefi_efi_vars.fd", "_image.bin.bz2"},
+ "gce": {"_gce.tar.gz"},
+ "aws": {"_ami_image.bin.bz2"},
}
values := strings.Split(value, ",")
for _, platform := range values {
- prefix, ok := platformMap[platform]
+ suffixes, ok := platformMap[platform]
if !ok {
plog.Fatalf("platform not supported: %v", platform)
}
- *platforms = append(*platforms, prefix)
+ *platforms = append(*platforms, suffixes)
}
return nil
}
@@ -156,7 +157,8 @@ func runDownloadImage(cmd *cobra.Command, args []string) {
plog.Fatalf("downloading version.txt: %v", err)
}
- for _, suffix := range downloadImagePlatformList {
+ for _, suffixes := range downloadImagePlatformList {
+ for _, suffix := range suffixes {
fileName := downloadImagePrefix + suffix
filePath := filepath.Join(downloadImageCacheDir, fileName)
@@ -177,3 +179,4 @@ func runDownloadImage(cmd *cobra.Command, args []string) {
}
}
}
+}
