b3d9b9 add helper functions to get kernel path by kernel release and the path of current running kernel

1 file Authored by Coiby Xu 2 years ago, Committed by liutgnu 2 years ago,
1 file changed. 30 lines added. 0 lines removed.
    add helper functions to get kernel path by kernel release and the path of current running kernel
    
    Resolves: bz1895258
    Upstream: Fedora
    Conflict: None
    
    commit 945cbbd59b34739c4a6b2f228c33f76e2981a18a
    Author: Coiby Xu <coxu@redhat.com>
    Date:   Tue Dec 7 15:16:07 2021 +0800
    
        add helper functions to get kernel path by kernel release and the path of current running kernel
    
        grubby --info=kernel-path or --add-kernel=kernel-path accepts a kernel
        path (e.g. /boot/vmlinuz-5.14.14-200.fc34.x86_64) instead of kernel release
        (e.g 5.14.14-200.fc34.x86_64). So we need to know the kernel path given
        a kernel release. Although for Fedora/RHEL, the kernel path is
        "/boot/vmlinuz-<KERNEL_RELEASE>", a path kernel could also be
        /boot/<machine-id>/<KERNEL_RELEASE>/vmlinuz. So the most reliable way to
        find the kernel path given a kernel release is to use "grubby --info".
    
        For osbuild, a kernel path may not yet exist but it's valid for
        "grubby --update-kernel=KERNEL_PATH". For example, "grubby -info" may
        output something as follows,
    
        index=0
        kernel="/var/cache/osbuild-worker/osbuild-store/tmp/tmp2prywdy5object/tree/boot/vmlinuz-5.15.10-100.fc34.x86_64"
        args="ro no_timer_check net.ifnames=0 console=tty1 console=ttyS0,115200n8"
        root="UUID=76a22bf4-f153-4541-b6c7-0332c0dfaeac"
        initrd="/var/cache/osbuild-worker/osbuild-store/tmp/tmp2prywdy5object/tree/boot/initramfs-5.15.10-100.fc34.x86_64.img"
    
        There is no need to check if path like
        /var/cache/osbuild-worker/osbuild-store/tmp/tmp2prywdy5object/tree/boot/vmlinuz-5.15.10-100.fc34.x86_64
        physically exists.
    
        Note these helper functions doesn't support CoreOS/Atomic/Silverblue
        since grubby isn't used by them.
    
        Reviewed-by: Pingfan Liu <piliu@redhat.com>
        Reviewed-by: Philipp Rudo <prudo@redhat.com>
        Signed-off-by: Coiby Xu <coxu@redhat.com>
    
    Signed-off-by: Coiby Xu <coxu@redhat.com>
    
        
file modified
+30 -0