diff options
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/mkinitramfs.sh | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/cmd/mkinitramfs.sh b/src/cmd/mkinitramfs.sh index 8983f15..7dd0502 100644 --- a/src/cmd/mkinitramfs.sh +++ b/src/cmd/mkinitramfs.sh @@ -22,7 +22,44 @@ cmd_mkinitramfs_optstring='l:i:' cmd_mkinitramfs_main() { - : Stub + local linux_output= + local initramfs_output= + local root= + + if ! get_options "${@}"; then + print_cmd_usage 'mkinitramfs' >&2 + exit 1 + fi + shift $(($OPTIND - 1)) + + if [ "x${cmd_mkinitramfs_opt_l-}" = 'x' ]; then + print_cmd_usage 'mkinitramfs' >&2 + exit 1 + fi + if [ "x${cmd_mkinitramfs_opt_i-}" = 'x' ]; then + print_cmd_usage 'mkinitramfs' >&2 + exit 1 + fi + if [ ${#} -lt 1 ]; then + print_cmd_usage 'mkinitramfs' >&2 + exit 1 + fi + + linux_output="${cmd_mkinitramfs_opt_l}" + initramfs_output="${cmd_mkinitramfs_opt_i}" + root="${1}" + + profile_set "$(. "${root}/etc/os-release" && printf '%s' "${ID}")" + arch="$(cat "${root}/etc/proteanos_arch")" + plat="$(cat "${root}/etc/proteanos_plat")" + + if ! img="$(profile_find_kernel "${root}" "${arch}" "${plat}")"; then + error 2 "$(get_msg 'cmd_mkinitramfs_kernel_not_found')" + fi + cp -p "${root}/${img}" "${linux_output}" + + (cd "${root}" && profile_make_initramfs "${arch}" "${plat}") \ + >"${initramfs_output}" } cmd_mkinitramfs_register() |