@@ -309,7 +309,7 @@ function run_build() {
309
309
bashio::log.info " Generate repository shadow images"
310
310
docker tag " ${repository} /${image} :${version} " " ${shadow_repository} /${image} :${version} "
311
311
for tag_image in " ${docker_tags[@]} " ; do
312
- bashio::log.info " Create shadow-image tag: ${tag_image} "
312
+ bashio::log.info " Create shadow-image tag: ${shadow_repository} / ${image} : ${ tag_image}"
313
313
docker tag " ${repository} /${image} :${version} " " ${shadow_repository} /${image} :${tag_image} "
314
314
push_images+=(" ${shadow_repository} /${image} :${tag_image} " )
315
315
done
@@ -339,6 +339,28 @@ function run_build() {
339
339
fi
340
340
}
341
341
342
+ function convert_to_json() {
343
+ # Convert [build|config].[yml|yaml] to json in a temp directory
344
+ for file in config build; do
345
+ if bashio::fs.file_exists " ${TARGET} /${file} .yml" ; then
346
+ yq e -N -M -o=json " ${TARGET} /${file} .yml" > " /tmp/build_config/${file} .json"
347
+ elif bashio::fs.file_exists " ${TARGET} /${file} .yaml" ; then
348
+ yq e -N -M -o=json " ${TARGET} /${file} .yaml" > " /tmp/build_config/${file} .json"
349
+ fi
350
+ done
351
+ }
352
+
353
+ function copy_config_tmp() {
354
+ # Copy [build|config].json to a temp directory
355
+ mkdir -p /tmp/build_config
356
+ for file in config build; do
357
+ if bashio::fs.file_exists " ${TARGET} /${file} .json" ; then
358
+ cp " ${TARGET} /${file} .json" " /tmp/build_config/${file} .json"
359
+ fi
360
+ done
361
+ }
362
+
363
+
342
364
343
365
# ### Build functions ####
344
366
@@ -356,13 +378,14 @@ function build_base() {
356
378
local docker_tags=()
357
379
358
380
# Read build.json
359
- if bashio::fs.file_exists " ${TARGET} /build.json" ; then
360
- build_from=" $( jq --raw-output " .build_from.${build_arch} // empty" " ${TARGET} /build.json" ) "
361
- args=" $( jq --raw-output ' .args // empty | keys[]' " ${TARGET} /build.json" ) "
362
- labels=" $( jq --raw-output ' .labels // empty | keys[]' " ${TARGET} /build.json" ) "
363
- raw_image=" $( jq --raw-output ' .image // empty' " ${TARGET} /build.json" ) "
364
- version_tag=" $( jq --raw-output ' .version_tag // false' " ${TARGET} /build.json" ) "
365
- shadow_repository=" $( jq --raw-output ' .shadow_repository // empty' " ${TARGET} /build.json" ) "
381
+ if bashio::fs.file_exists " /tmp/build_config/build.json" ; then
382
+ build_from=" $( jq --raw-output " .build_from.${build_arch} // empty" " /tmp/build_config/build.json" ) "
383
+ args=" $( jq --raw-output ' .args // empty | keys[]' " /tmp/build_config/build.json" ) "
384
+ labels=" $( jq --raw-output ' .labels // empty | keys[]' " /tmp/build_config/build.json" ) "
385
+ raw_image=" $( jq --raw-output ' .image // empty' " /tmp/build_config/build.json" ) "
386
+ version_tag=" $( jq --raw-output ' .version_tag // false' " /tmp/build_config/build.json" ) "
387
+ shadow_repository=" $( jq --raw-output ' .shadow_repository // empty' " /tmp/build_config/build.json" ) "
388
+
366
389
fi
367
390
368
391
# Set defaults build things
@@ -392,15 +415,15 @@ function build_base() {
392
415
# Additional build args
393
416
if bashio::var.has_value " ${args} " ; then
394
417
for arg in ${args} ; do
395
- value=" $( jq --raw-output " .args.${arg} " " ${TARGET} /build.json" ) "
418
+ value=" $( jq --raw-output " .args.${arg} " " /tmp/build_config /build.json" ) "
396
419
docker_cli+=(" --build-arg" " ${arg} =${value} " )
397
420
done
398
421
fi
399
422
400
423
# Additional build labels
401
424
if bashio::var.has_value " ${labels} " ; then
402
425
for label in ${labels} ; do
403
- value=" $( jq --raw-output " .labels.\" ${label} \" " " ${TARGET} /build.json" ) "
426
+ value=" $( jq --raw-output " .labels.\" ${label} \" " " /tmp/build_config /build.json" ) "
404
427
docker_cli+=(" --label" " ${label} =${value} " )
405
428
done
406
429
fi
@@ -439,10 +462,10 @@ function build_addon() {
439
462
local docker_tags=()
440
463
441
464
# Read addon build.json
442
- if bashio::fs.file_exists " $TARGET /build.json" ; then
443
- build_from=" $( jq --raw-output " .build_from.$build_arch // empty" " $TARGET /build.json" ) "
444
- args=" $( jq --raw-output ' .args // empty | keys[]' " $TARGET /build.json" ) "
445
- shadow_repository=" $( jq --raw-output ' .shadow_repository // empty' " ${TARGET} /build.json" ) "
465
+ if bashio::fs.file_exists " /tmp/build_config /build.json" ; then
466
+ build_from=" $( jq --raw-output " .build_from.$build_arch // empty" " /tmp/build_config /build.json" ) "
467
+ args=" $( jq --raw-output ' .args // empty | keys[]' " /tmp/build_config /build.json" ) "
468
+ shadow_repository=" $( jq --raw-output ' .shadow_repository // empty' " /tmp/build_config /build.json" ) "
446
469
fi
447
470
448
471
# Set defaults build things
@@ -453,23 +476,23 @@ function build_addon() {
453
476
# Additional build args
454
477
if [ -n " $args " ]; then
455
478
for arg in $args ; do
456
- value=" $( jq --raw-output " .args.$arg " " $TARGET /build.json" ) "
479
+ value=" $( jq --raw-output " .args.$arg " " /tmp/build_config /build.json" ) "
457
480
docker_cli+=(" --build-arg" " $arg =$value " )
458
481
done
459
482
fi
460
483
461
484
# Read addon config.json
462
- name=" $( jq --raw-output ' .name // empty' " $TARGET /config.json" | sed " s/'//g" ) "
463
- description=" $( jq --raw-output ' .description // empty' " $TARGET /config.json" | sed " s/'//g" ) "
464
- url=" $( jq --raw-output ' .url // empty' " $TARGET /config.json" ) "
465
- raw_image=" $( jq --raw-output ' .image // empty' " $TARGET /config.json" ) "
466
- mapfile -t supported_arch < <( jq --raw-output ' .arch // empty' " $TARGET /config.json" )
485
+ name=" $( jq --raw-output ' .name // empty' " /tmp/build_config /config.json" | sed " s/'//g" ) "
486
+ description=" $( jq --raw-output ' .description // empty' " /tmp/build_config /config.json" | sed " s/'//g" ) "
487
+ url=" $( jq --raw-output ' .url // empty' " /tmp/build_config /config.json" ) "
488
+ raw_image=" $( jq --raw-output ' .image // empty' " /tmp/build_config /config.json" ) "
489
+ mapfile -t supported_arch < <( jq --raw-output ' .arch // empty' " /tmp/build_config /config.json" )
467
490
468
491
# Read version from config.json when VERSION is not set
469
492
if [ -n " $VERSION " ]; then
470
493
version=" $VERSION "
471
494
else
472
- version=" $( jq --raw-output ' .version' " $TARGET /config.json" ) "
495
+ version=" $( jq --raw-output ' .version' " /tmp/build_config /config.json" ) "
473
496
fi
474
497
475
498
# Check arch
@@ -513,13 +536,13 @@ function build_generic() {
513
536
local docker_tags=()
514
537
515
538
# Read build.json
516
- if bashio::fs.file_exists " $TARGET /build.json" ; then
517
- build_from=" $( jq --raw-output " .build_from.$build_arch // empty" " $TARGET /build.json" ) "
518
- args=" $( jq --raw-output ' .args // empty | keys[]' " $TARGET /build.json" ) "
519
- labels=" $( jq --raw-output ' .labels // empty | keys[]' " $TARGET /build.json" ) "
520
- raw_image=" $( jq --raw-output ' .image // empty' " $TARGET /build.json" ) "
521
- version_tag=" $( jq --raw-output ' .version_tag // false' " $TARGET /build.json" ) "
522
- shadow_repository=" $( jq --raw-output ' .shadow_repository // empty' " ${TARGET} /build.json" ) "
539
+ if bashio::fs.file_exists " /tmp/build_config /build.json" ; then
540
+ build_from=" $( jq --raw-output " .build_from.$build_arch // empty" " /tmp/build_config /build.json" ) "
541
+ args=" $( jq --raw-output ' .args // empty | keys[]' " /tmp/build_config /build.json" ) "
542
+ labels=" $( jq --raw-output ' .labels // empty | keys[]' " /tmp/build_config /build.json" ) "
543
+ raw_image=" $( jq --raw-output ' .image // empty' " /tmp/build_config /build.json" ) "
544
+ version_tag=" $( jq --raw-output ' .version_tag // false' " /tmp/build_config /build.json" ) "
545
+ shadow_repository=" $( jq --raw-output ' .shadow_repository // empty' " /tmp/build_config /build.json" ) "
523
546
fi
524
547
525
548
# Set defaults build things
@@ -539,15 +562,15 @@ function build_generic() {
539
562
# Additional build args
540
563
if bashio::var.has_value " $args " ; then
541
564
for arg in $args ; do
542
- value=" $( jq --raw-output " .args.$arg " " $TARGET /build.json" ) "
565
+ value=" $( jq --raw-output " .args.$arg " " /tmp/build_config /build.json" ) "
543
566
docker_cli+=(" --build-arg" " $arg =$value " )
544
567
done
545
568
fi
546
569
547
570
# Additional build labels
548
571
if bashio::var.has_value " $labels " ; then
549
572
for label in $labels ; do
550
- value=" $( jq --raw-output " .labels.\" $label \" " " $TARGET /build.json" ) "
573
+ value=" $( jq --raw-output " .labels.\" $label \" " " /tmp/build_config /build.json" ) "
551
574
docker_cli+=(" --label" " $label =$value " )
552
575
done
553
576
fi
@@ -584,13 +607,13 @@ function build_machine() {
584
607
local docker_tags=()
585
608
586
609
# Read build.json
587
- if bashio::fs.file_exists " ${TARGET} /build.json" ; then
588
- build_from=" $( jq --raw-output " .build_from.${build_arch} // empty" " ${TARGET} /build.json" ) "
589
- args=" $( jq --raw-output ' .args // empty | keys[]' " ${TARGET} /build.json" ) "
590
- labels=" $( jq --raw-output ' .labels // empty | keys[]' " ${TARGET} /build.json" ) "
591
- raw_image=" $( jq --raw-output ' .image // empty' " ${TARGET} /build.json" ) "
592
- version_tag=" $( jq --raw-output ' .version_tag // false' " ${TARGET} /build.json" ) "
593
- shadow_repository=" $( jq --raw-output ' .shadow_repository // empty' " ${TARGET} /build.json" ) "
610
+ if bashio::fs.file_exists " /tmp/build_config /build.json" ; then
611
+ build_from=" $( jq --raw-output " .build_from.${build_arch} // empty" " /tmp/build_config /build.json" ) "
612
+ args=" $( jq --raw-output ' .args // empty | keys[]' " /tmp/build_config /build.json" ) "
613
+ labels=" $( jq --raw-output ' .labels // empty | keys[]' " /tmp/build_config /build.json" ) "
614
+ raw_image=" $( jq --raw-output ' .image // empty' " /tmp/build_config /build.json" ) "
615
+ version_tag=" $( jq --raw-output ' .version_tag // false' " /tmp/build_config /build.json" ) "
616
+ shadow_repository=" $( jq --raw-output ' .shadow_repository // empty' " /tmp/build_config /build.json" ) "
594
617
fi
595
618
596
619
# Modify build_from
@@ -614,15 +637,15 @@ function build_machine() {
614
637
# Additional build args
615
638
if bashio::var.has_value " ${args} " ; then
616
639
for arg in ${args} ; do
617
- value=" $( jq --raw-output " .args.${arg} " " ${TARGET} /build.json" ) "
640
+ value=" $( jq --raw-output " .args.${arg} " " /tmp/build_config /build.json" ) "
618
641
docker_cli+=(" --build-arg" " ${arg} =${value} " )
619
642
done
620
643
fi
621
644
622
645
# Additional build labels
623
646
if bashio::var.has_value " ${labels} " ; then
624
647
for label in ${labels} ; do
625
- value=" $( jq --raw-output " .labels.\" ${label} \" " " ${TARGET} /build.json" ) "
648
+ value=" $( jq --raw-output " .labels.\" ${label} \" " " /tmp/build_config /build.json" ) "
626
649
docker_cli+=(" --label" " ${label} =${value} " )
627
650
done
628
651
fi
@@ -904,6 +927,12 @@ mkdir -p /data
904
927
init_crosscompile
905
928
start_docker
906
929
930
+ # Convert configuration files to json if needed
931
+ convert_to_json
932
+
933
+ # Copy configuration files to tmp
934
+ copy_config_tmp
935
+
907
936
# Login into dockerhub & setup CodeNotary
908
937
if [ -n " $DOCKER_USER " ] && [ -n " $DOCKER_PASSWORD " ]; then
909
938
docker login -u " $DOCKER_USER " -p " $DOCKER_PASSWORD "
0 commit comments