@@ -41,6 +41,7 @@ import (
4141var (
4242 VERSION = "dev"
4343 debug = false
44+ enableQemu = false
4445 socketPath = "/run/buildkit/shim.sock"
4546 buildkitdPath = "/usr/bin/buildkitd"
4647 basePath = "/var/lib/container-builder-shim"
@@ -88,6 +89,10 @@ var app = &cobra.Command{
8889 cancellableCtx , cancel := context .WithCancel (ctx )
8990 defer cancel ()
9091
92+ if ! enableQemu {
93+ disableQemu ()
94+ }
95+
9196 errCh := make (chan error )
9297 go func () {
9398 config := buildkit .DefaultConfig
@@ -140,8 +145,26 @@ var app = &cobra.Command{
140145 },
141146}
142147
148+ func disableQemu () {
149+ path := "/usr/bin/buildkit-qemu-x86_64"
150+ disabled := path + ".disabled"
151+
152+ if _ , err := os .Stat (path ); err == nil {
153+ if err := os .Rename (path , disabled ); err != nil {
154+ log .Warnf ("failed to disable %s: %v\n " , path , err )
155+ } else {
156+ log .Infof ("Renamed %s to %s\n " , filepath .Base (path ), filepath .Base (disabled ))
157+ }
158+ } else if os .IsNotExist (err ) {
159+ log .Infof ("%s not found; nothing to do\n " , path )
160+ } else {
161+ log .Warnf ("error checking %s: %v\n " , path , err )
162+ }
163+ }
164+
143165func init () {
144166 app .PersistentFlags ().BoolVarP (& debug , "debug" , "d" , debug , "enable debug logging" )
167+ app .Flags ().BoolVar (& enableQemu , "enableQemu" , enableQemu , "use QEMU instead of Rosetta for amd64 builds" )
145168 app .Flags ().IntVarP (& vsockPort , "vsock-port" , "p" , vsockPort , "vsock port for shim listener" )
146169 app .Flags ().BoolVarP (& vsockMode , "vsock" , "v" , vsockMode , "toggle vsock listener (turns off UDS listener)" )
147170 app .Flags ().StringVarP (& socketPath , "socket" , "s" , socketPath , "socket path for shim listener" )
0 commit comments