Skip to content

[Feature Request]: allow /bin for other distros, hardcoded /usr/bin/run-parts makes build to fail #7430

Open
@amateur80lvl

Description

@amateur80lvl

Hello,
while playing with Devuan daedalus I found bash and run-parts are located in /bin. I know, daedalus seems to be phased out soon and excalibur has everything in place, but I checked other distros not following ubuntu way:

2 of 3, as an excuse for this issue. Ah, plus 0.5 points for Devuan.

This may save time for those who want their Armpines or Armtoos. Below is my fix, I believe you can do that better:

--- a/lib/functions/image/initrd.sh
+++ b/lib/functions/image/initrd.sh
@@ -42,6 +42,15 @@ update_initramfs() {
                exit_with_error "No kernel installed for the version" "${IMAGE_INSTALLED_KERNEL_VERSION}"
        fi
 
+       local bash_location=/usr/bin/bash
+       if [ ! -x "${chroot_target}{bash_location}" ] ; then
+               bash_location=/bin/bash
+       fi
+       local run_parts_location=/usr/bin/run-parts
+       if [ ! -x "${chroot_target}{run_parts_location}" ] ; then
+               run_parts_location=/bin/run-parts
+       fi
+
        # Caching.
        # Find all modules and all firmware in the target.
        # Find all initramfs configuration in /etc
@@ -53,7 +62,7 @@ update_initramfs() {
        mkdir -p "${SRC}/cache/initrd"
        initrd_cache_current_manifest_filepath="${WORKDIR}/initrd.img-${initrd_kern_ver}.${ARMBIAN_BUILD_UUID}.manifest"
        initrd_cache_last_manifest_filepath="${SRC}/cache/initrd/initrd.manifest-${initrd_kern_ver}.last.manifest"
-       initrd_files_to_hash=("${chroot_target}/usr/bin/bash" "${chroot_target}/etc/initramfs")
+       initrd_files_to_hash=("${chroot_target}{bash_location}" "${chroot_target}/etc/initramfs")
        initrd_files_to_hash+=("${chroot_target}/etc/initramfs-tools" "${chroot_target}/usr/share/initramfs-tools/")
        initrd_files_to_hash+=("${chroot_target}/etc/modprobe.d") # for MODULES_BLACKLIST
 
@@ -89,7 +98,7 @@ update_initramfs() {
 
                # Convert to bootscript expected format, by calling into the script manually.
                if [[ -d "${chroot_target}"/etc/initramfs/post-update.d/ ]]; then
-                       chroot_custom "$chroot_target" /usr/bin/run-parts -a "${initrd_kern_ver}" -a "/boot/initrd.img-${initrd_kern_ver}" /etc/initramfs/post-update.d/
+                       chroot_custom "$chroot_target" "${run_parts_location}" -a "${initrd_kern_ver}" -a "/boot/initrd.img-${initrd_kern_ver}" /etc/initramfs/post-update.d/
                fi
        else
                display_alert "Cache miss for initrd cache" "${initrd_cache_key}" "debug"

Funding

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions