diff options
author | P. J. McDermott <pj@pehjota.net> | 2016-01-15 18:15:37 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2016-01-15 18:15:37 (EST) |
commit | b7faf7dc7922ed8ca82440d33a75be2acdb0553e (patch) | |
tree | 2d66af87ddbeaf487ebcf282aff13bb7e288b919 /src | |
parent | 7ae658b2878d6ca88475062e4ede0dd120103b62 (diff) |
cmd/mkinitramfs: Implement
Diffstat (limited to 'src')
-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() |