From b7faf7dc7922ed8ca82440d33a75be2acdb0553e Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 15 Jan 2016 18:15:37 -0500 Subject: cmd/mkinitramfs: Implement --- diff --git a/locale/en_US.sh b/locale/en_US.sh index b33e5ce..dd86723 100644 --- a/locale/en_US.sh +++ b/locale/en_US.sh @@ -111,6 +111,7 @@ msg_prokit_cmd_mkinitramfs_summary='generate an initramfs containing an '\ 'installed system' msg_prokit_cmd_mkinitramfs_usage='-l -i '\ '' +msg_prokit_cmd_mkinitramfs_kernel_not_found='No Linux image found' # src/profile.sh msg_prokit_profile_not_found='Profile "%s" not found' 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() -- cgit v0.9.1