#!/bin/bash 
commit_id=$1
deploy_path=/ostree/deploy/openkylin/deploy/${commit}.0
chroot $deploy_path


bootcsum=`cat ./vmlinuz ./initramfs.img | sha256sum | cut -f 1 -d ' '`
ostree_path=/

mkinitramfs -o

 
  
# 指定目录  
dir="/ostree/deploy/openkylin/deploy/abc876131bb0eb1ee40b718f0af0eeea680d074bac2657478624cb72ce165873.0/usr/lib/modules/"  
  
# 查找所有子目录中的 vmlinuz 和 initramfs.img 文件，并计算它们的 SHA256 校验和  
find "$dir" -type f \( -name "vmlinuz" -o -name "initramfs.img" \) -exec sha256sum {} \;

  
# 定义目标目录  
TARGET_DIR="/ostree/deploy/openkylin/deploy/abc876131bb0eb1ee40b718f0af0eeea680d074bac2657478624cb72ce165873.0/usr/lib/modules/"  
  
# 遍历目录下的所有子目录  
for dir in "$TARGET_DIR"/*; do  
    if [[ -d "$dir" ]]; then  
        # 进入子目录  
        cd "$dir" || continue  
  
        # 获取子目录名称  
        subdir_name=$(basename "$dir")  
  
        # 检查是否存在 vmlinuz 和 initramfs.img 文件  
        if [[ -f "vmlinuz" && -f "initramfs.img" ]]; then  
            # 计算并打印 SHA256 校验和  
            echo "Subdirectory: $subdir_name"  
            sha256sum "vmlinuz" "initramfs.img"  
            echo "------------------------------"  
        fi  
    fi  
done