diff options
Diffstat (limited to 'classes/image-oci-umoci.inc')
| -rw-r--r-- | classes/image-oci-umoci.inc | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/classes/image-oci-umoci.inc b/classes/image-oci-umoci.inc index fbb77cd0..616c20ae 100644 --- a/classes/image-oci-umoci.inc +++ b/classes/image-oci-umoci.inc | |||
| @@ -589,22 +589,67 @@ IMAGE_CMD:oci() { | |||
| 589 | fi | 589 | fi |
| 590 | 590 | ||
| 591 | elif [ "$oci_layer_type" = "directories" ]; then | 591 | elif [ "$oci_layer_type" = "directories" ]; then |
| 592 | # Copy directories from IMAGE_ROOTFS | 592 | # Copy directories from IMAGE_ROOTFS (delta-only: skip files already in bundle) |
| 593 | for oci_dir in $oci_layer_content; do | 593 | for oci_dir in $oci_layer_content; do |
| 594 | if [ -d "${IMAGE_ROOTFS}$oci_dir" ]; then | 594 | if [ -d "${IMAGE_ROOTFS}$oci_dir" ]; then |
| 595 | mkdir -p "$image_bundle_name/rootfs$(dirname $oci_dir)" | 595 | oci_delta_copied=0 |
| 596 | cp -a "${IMAGE_ROOTFS}$oci_dir" "$image_bundle_name/rootfs$oci_dir" | 596 | oci_delta_skipped=0 |
| 597 | bbnote "OCI: Added directory $oci_dir" | 597 | # Walk the directory and copy only files not in bundle |
| 598 | while IFS= read -r oci_src_file; do | ||
| 599 | oci_rel_path="${oci_src_file#${IMAGE_ROOTFS}}" | ||
| 600 | oci_dst_file="$image_bundle_name/rootfs$oci_rel_path" | ||
| 601 | if [ ! -e "$oci_dst_file" ]; then | ||
| 602 | mkdir -p "$(dirname "$oci_dst_file")" | ||
| 603 | cp -a "$oci_src_file" "$oci_dst_file" | ||
| 604 | oci_delta_copied=$((oci_delta_copied + 1)) | ||
| 605 | else | ||
| 606 | oci_delta_skipped=$((oci_delta_skipped + 1)) | ||
| 607 | fi | ||
| 608 | done < <(find "${IMAGE_ROOTFS}$oci_dir" -type f -o -type l) | ||
| 609 | # Also copy empty directories | ||
| 610 | while IFS= read -r oci_src_dir; do | ||
| 611 | oci_rel_path="${oci_src_dir#${IMAGE_ROOTFS}}" | ||
| 612 | oci_dst_dir="$image_bundle_name/rootfs$oci_rel_path" | ||
| 613 | if [ ! -e "$oci_dst_dir" ]; then | ||
| 614 | mkdir -p "$oci_dst_dir" | ||
| 615 | fi | ||
| 616 | done < <(find "${IMAGE_ROOTFS}$oci_dir" -type d) | ||
| 617 | bbnote "OCI: Added directory $oci_dir (delta: $oci_delta_copied copied, $oci_delta_skipped skipped)" | ||
| 618 | else | ||
| 619 | bbwarn "OCI: Directory not found in IMAGE_ROOTFS: $oci_dir" | ||
| 598 | fi | 620 | fi |
| 599 | done | 621 | done |
| 600 | 622 | ||
| 601 | elif [ "$oci_layer_type" = "files" ]; then | 623 | elif [ "$oci_layer_type" = "files" ]; then |
| 602 | # Copy specific files from IMAGE_ROOTFS | 624 | # Copy specific files from IMAGE_ROOTFS (delta-only: skip files already in bundle) |
| 603 | for oci_file in $oci_layer_content; do | 625 | for oci_file in $oci_layer_content; do |
| 604 | if [ -e "${IMAGE_ROOTFS}$oci_file" ]; then | 626 | if [ -e "${IMAGE_ROOTFS}$oci_file" ]; then |
| 605 | mkdir -p "$image_bundle_name/rootfs$(dirname $oci_file)" | 627 | oci_dst_file="$image_bundle_name/rootfs$oci_file" |
| 606 | cp -a "${IMAGE_ROOTFS}$oci_file" "$image_bundle_name/rootfs$oci_file" | 628 | if [ ! -e "$oci_dst_file" ]; then |
| 607 | bbnote "OCI: Added file $oci_file" | 629 | mkdir -p "$(dirname "$oci_dst_file")" |
| 630 | cp -a "${IMAGE_ROOTFS}$oci_file" "$oci_dst_file" | ||
| 631 | bbnote "OCI: Added file $oci_file" | ||
| 632 | else | ||
| 633 | bbnote "OCI: Skipped file $oci_file (already in bundle)" | ||
| 634 | fi | ||
| 635 | else | ||
| 636 | bbwarn "OCI: File not found in IMAGE_ROOTFS: $oci_file" | ||
| 637 | fi | ||
| 638 | done | ||
| 639 | |||
| 640 | elif [ "$oci_layer_type" = "host" ]; then | ||
| 641 | # Copy files from build machine filesystem (outside Yocto) | ||
| 642 | # Format: source_path:dest_path pairs separated by + (already converted to space) | ||
| 643 | for oci_host_pair in $oci_layer_content; do | ||
| 644 | # Split on last : to handle paths that might contain : | ||
| 645 | oci_host_src="${oci_host_pair%:*}" | ||
| 646 | oci_host_dst="${oci_host_pair##*:}" | ||
| 647 | if [ -e "$oci_host_src" ]; then | ||
| 648 | mkdir -p "$image_bundle_name/rootfs$(dirname $oci_host_dst)" | ||
| 649 | cp -a "$oci_host_src" "$image_bundle_name/rootfs$oci_host_dst" | ||
| 650 | bbnote "OCI: Added from host: $oci_host_src -> $oci_host_dst" | ||
| 651 | else | ||
| 652 | bbfatal "OCI: Host path not found: $oci_host_src" | ||
| 608 | fi | 653 | fi |
| 609 | done | 654 | done |
| 610 | fi | 655 | fi |
