summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--locale/en_US.sh1
-rw-r--r--src/cmd/mkinitramfs.sh39
2 files changed, 39 insertions, 1 deletions
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 <vmlinuz-output> -i <initramfs-output> '\
'<root>'
+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()