@@ -360,23 +360,15 @@ pub fn run(
360
360
let context = config. dockerfile_context ( target) ?;
361
361
let name = config. image ( target) ?;
362
362
363
- let mut build = Dockerfile :: File {
363
+ let build = Dockerfile :: File {
364
364
path : & path,
365
365
context : context. as_deref ( ) ,
366
366
name : name. as_deref ( ) ,
367
367
} ;
368
368
369
- if config. dockerfile_provide_base ( target) . unwrap_or_default ( ) {
370
- let mut content = format ! ( "FROM {image}\n " ) ;
371
- content. push_str ( & crate :: file:: read ( & path) ?) ;
372
- build = Dockerfile :: Custom {
373
- content,
374
- from_file : true ,
375
- } ;
376
- }
377
-
378
369
image = build
379
370
. build (
371
+ config,
380
372
& engine,
381
373
& host_root,
382
374
config. dockerfile_build_args ( target) ?. unwrap_or_default ( ) ,
@@ -397,10 +389,10 @@ ARG CROSS_DEB_ARCH=
397
389
ARG CROSS_CMD
398
390
RUN eval "${{CROSS_CMD}}""#
399
391
) ,
400
- from_file : false ,
401
392
} ;
402
393
custom
403
394
. build (
395
+ config,
404
396
& engine,
405
397
& host_root,
406
398
Some ( ( "CROSS_CMD" , pre_build. join ( "\n " ) ) ) ,
@@ -428,14 +420,14 @@ pub enum Dockerfile<'a> {
428
420
} ,
429
421
Custom {
430
422
content : String ,
431
- /// if `true`, the name of the file will be slightly different
432
- from_file : bool ,
433
423
} ,
434
424
}
435
425
436
426
impl < ' a > Dockerfile < ' a > {
427
+ #[ allow( clippy:: too_many_arguments) ]
437
428
pub fn build (
438
429
& self ,
430
+ config : & Config ,
439
431
engine : & Path ,
440
432
host_root : & Path ,
441
433
build_args : impl IntoIterator < Item = ( impl AsRef < str > , impl AsRef < str > ) > ,
@@ -454,20 +446,23 @@ impl<'a> Dockerfile<'a> {
454
446
}
455
447
456
448
if let Some ( arch) = target_triple. deb_arch ( ) {
457
- docker_build. args ( [ "--build-arg" , & format ! ( "CROSS_DEB_ARCH={}" , arch) ] ) ;
449
+ docker_build. args ( [ "--build-arg" , & format ! ( "CROSS_DEB_ARCH={arch}" ) ] ) ;
450
+ }
451
+
452
+ if let Ok ( cross_base_image) = image ( config, target_triple) {
453
+ docker_build. args ( [
454
+ "--build-arg" ,
455
+ & format ! ( "CROSS_BASE_IMAGE={cross_base_image}" ) ,
456
+ ] ) ;
458
457
}
459
458
460
459
let path = match self {
461
460
Dockerfile :: File { path, .. } => PathBuf :: from ( path) ,
462
- Dockerfile :: Custom { content, from_file } => {
461
+ Dockerfile :: Custom { content } => {
463
462
let path = host_root
464
463
. join ( "target" )
465
464
. join ( target_triple. to_string ( ) )
466
- . join ( format ! (
467
- "Dockerfile.{}{}" ,
468
- target_triple,
469
- if !from_file { "-custom" } else { "" }
470
- ) ) ;
465
+ . join ( format ! ( "Dockerfile.{}" , target_triple, ) ) ;
471
466
{
472
467
let mut file = file:: write_file ( & path, true ) ?;
473
468
file. write_all ( content. as_bytes ( ) ) ?;
0 commit comments