summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/prokit-mkinitramfs.8in3
-rw-r--r--src/cmd/mkinitramfs.sh11
2 files changed, 14 insertions, 0 deletions
diff --git a/man/prokit-mkinitramfs.8in b/man/prokit-mkinitramfs.8in
index 3f3b1f2..cc6d5d1 100644
--- a/man/prokit-mkinitramfs.8in
+++ b/man/prokit-mkinitramfs.8in
@@ -11,6 +11,9 @@ prokit-mkinitramfs \- Generate an initramfs containing an installed system
.SH DESCRIPTION
\fBprokit mkinitramfs\fP generates an initial RAM-based file system image
containing an installed system found at \fIroot\fP.
+.P
+If \fIroot\fP is a block device node, the block device is mounted and the
+initial RAM-based file system is generated from the device's file system.
.SH OPTIONS
.TP
diff --git a/src/cmd/mkinitramfs.sh b/src/cmd/mkinitramfs.sh
index 7dd0502..a68467d 100644
--- a/src/cmd/mkinitramfs.sh
+++ b/src/cmd/mkinitramfs.sh
@@ -25,6 +25,7 @@ cmd_mkinitramfs_main()
local linux_output=
local initramfs_output=
local root=
+ local dev=
if ! get_options "${@}"; then
print_cmd_usage 'mkinitramfs' >&2
@@ -48,18 +49,28 @@ cmd_mkinitramfs_main()
linux_output="${cmd_mkinitramfs_opt_l}"
initramfs_output="${cmd_mkinitramfs_opt_i}"
root="${1}"
+ shift 1
+
+ dev=''
+ if is_block "${root}"; then
+ dev="${root}"
+ root="$(block_mount "${dev}")"
+ fi
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
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
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}"
+
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
}
cmd_mkinitramfs_register()