@@ -279,9 +279,14 @@ export class Install {
279279 core . info ( limaCfg ) ;
280280 } ) ;
281281
282- const qemuArch = await Install . qemuArch ( ) ;
282+ if ( ! ( await Install . qemuInstalled ( ) ) ) {
283+ await core . group ( 'Installing QEMU' , async ( ) => {
284+ await Exec . exec ( 'brew' , [ 'install' , 'qemu' ] , { env : envs } ) ;
285+ } ) ;
286+ }
287+ const qemuBin = await Install . qemuBin ( ) ;
283288 await core . group ( 'QEMU version' , async ( ) => {
284- await Exec . exec ( `qemu-system- ${ qemuArch } --version` ) ;
289+ await Exec . exec ( qemuBin , [ ' --version' ] ) ;
285290 } ) ;
286291
287292 // lima might already be started on the runner so env var added in download
@@ -617,29 +622,42 @@ EOF`,
617622 return await io
618623 . which ( 'lima' , true )
619624 . then ( res => {
620- core . debug ( `docker.Install.limaAvailable ok: ${ res } ` ) ;
625+ core . debug ( `docker.Install.limaInstalled ok: ${ res } ` ) ;
621626 return true ;
622627 } )
623628 . catch ( error => {
624- core . debug ( `docker.Install.limaAvailable error: ${ error } ` ) ;
629+ core . debug ( `docker.Install.limaInstalled error: ${ error } ` ) ;
625630 return false ;
626631 } ) ;
627632 }
628633
629- private static async qemuArch ( ) : Promise < string > {
634+ private static async qemuBin ( ) : Promise < string > {
630635 switch ( os . arch ( ) ) {
631636 case 'x64' : {
632- return ' x86_64' ;
637+ return `qemu-system- x86_64` ;
633638 }
634639 case 'arm64' : {
635- return ' aarch64' ;
640+ return `qemu-system- aarch64` ;
636641 }
637642 default : {
638- return os . arch ( ) ;
643+ return `qemu-system- ${ os . arch ( ) } ` ;
639644 }
640645 }
641646 }
642647
648+ private static async qemuInstalled ( ) : Promise < boolean > {
649+ return await io
650+ . which ( await Install . qemuBin ( ) , true )
651+ . then ( res => {
652+ core . debug ( `docker.Install.qemuInstalled ok: ${ res } ` ) ;
653+ return true ;
654+ } )
655+ . catch ( error => {
656+ core . debug ( `docker.Install.qemuInstalled error: ${ error } ` ) ;
657+ return false ;
658+ } ) ;
659+ }
660+
643661 public static async getRelease ( version : string ) : Promise < GitHubRelease > {
644662 const url = `https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json` ;
645663 const http : httpm . HttpClient = new httpm . HttpClient ( 'docker-actions-toolkit' ) ;
0 commit comments