trynd / wren

Linux boot platform that provides a portable, multi-system, run-in-memory Linux environment.
GNU General Public License v3.0
0 stars 1 forks source link

BUG: update-grub.sh ignores a save's updated initrd.img without a matching saved kernel image #1

Closed codewithmichael closed 9 years ago

codewithmichael commented 9 years ago

Currently update-grub.sh finds existing save directories and adds menuentry sections for them in the output as expected, but unless there is a kernel image file (vmlinuz) in the save directory, any initramfs images (initrd.img) are ignored.

It works fine when generating a new Grub configuration after a kernel update (because both files are copied into the save directory), but a basic system update that just rebuilds the initramfs image requires manually editing the grub.cfg file.

update-grub.sh should recognize a standalone initrd.img file within the save directory so long as it matches the version number on the kernel image in the boot/images/ directory.

codewithmichael commented 9 years ago

The problem exists in the generate function in version 0.1.0, copy/update-grub.sh between lines 141-153:

    kernel="${directory}/$PLATFORM_IMAGE_KERNEL"
    versioned_kernel=
    kernel_version=
    if test ! -f "${MOUNT_DEVICE%/}$kernel"; then
        versioned_kernel=`getNewestExistingVersionedFilePath "${MOUNT_DEVICE%/}$kernel"` \
            && kernel_version="${versioned_kernel#${MOUNT_DEVICE%/}$kernel}" \
            && kernel="$kernel$kernel_version" \
            || { generate "$heading" "$fallback_directory" "$options" ; return $? ; }
    fi

    initrd="${directory}/$PLATFORM_IMAGE_INITRD$kernel_version"
    test -f "${MOUNT_DEVICE%/}$initrd" \
        || { generate "$heading" "$fallback_directory" "$options" ; return $? ; }

If a kernel image isn't found in the save directory, the generate function is just called recursively using $fallback_directory, which in this case is the boot/images/ directory. Since the initrd image location is determined after the kernel image location, it's never even hitting the point where it looks for the initrd image in the save directory.

codewithmichael commented 9 years ago

I believe I've corrected this issue in pull request #3.

codewithmichael commented 9 years ago

Fixed by pull request #3. Merged into v0.1.1