#!/usr/bin/env bash # SPDX-License-Identifier: GPL-2.0-only build() { local fsck='' added=0 add_fsck() { case "$1" in ext[234]) add_binary e2fsck add_symlink /usr/bin/fsck.ext2 e2fsck add_symlink /usr/bin/fsck.ext3 e2fsck add_symlink /usr/bin/fsck.ext4 e2fsck if [[ -e /etc/e2fsck.conf ]]; then add_file /etc/e2fsck.conf fi ;; xfs) add_binary fsck.xfs add_binary xfs_repair ;; *) if compgen -c "fsck.$1" &>/dev/null; then add_binary "fsck.$1" else return 1 fi ;; esac } # fs_autodetect_failed is assigned in the autodetect hook # shellcheck disable=SC2154 if (( ! fs_autodetect_failed )) && [[ -n "${rootfstype}${usrfstype}" ]]; then if [[ -n "$rootfstype" ]]; then add_fsck "$rootfstype" && (( ++added )) fi if [[ -n "$usrfstype" && "$usrfstype" != "$rootfstype" ]]; then add_fsck "$usrfstype" && (( ++added )) fi else for fsck in $(compgen -c fsck.); do add_fsck "${fsck#fsck.}" && (( ++added )) done fi if (( ! added )); then warning "No fsck helpers found. fsck will not be run on boot." return fi add_binary fsck } help() { cat <