Skip to content
Snippets Groups Projects

Make compatible with cryptsetup's encrypt hook

Closed Tallero Tallero requested to merge tallero/mkinitcpio-archiso:crypto into master
Compare and Show latest version
1 file
+ 26
14
Compare changes
  • Side-by-side
  • Inline
+ 26
14
@@ -85,7 +85,13 @@ _mnt_fs() {
img="/run/archiso/copytoram/${img_fullname}"
msg "done."
fi
img_loopdev="$(losetup --find --show --read-only -- "${img}")"
# shellcheck disable=SC2154
if [ -e "${root}" ]; then
img_loopdev="${root}"
else
img_loopdev="$(losetup --find --show --read-only -- "${img}")"
fi
_mnt_dev "${img_loopdev}" "${mnt}" "-r" "defaults"
}
@@ -98,7 +104,7 @@ _mnt_dev() {
msg ":: Mounting '${dev}' to '${mnt}'"
while ! poll_device "${dev}" 30; do
while ! [ -d "${dev}" ] && ! poll_device "${dev}" 30; do
echo "ERROR: '${dev}' device did not show up after 30 seconds..."
echo " Falling back to interactive prompt"
echo " You can try to fix the problem manually, log out when you are finished"
@@ -134,6 +140,17 @@ _verify_signature() {
return ${_status}
}
_archisodevice() {
# shellcheck disable=SC2154
if [ -e "${root}" ]; then
archisodevice="/run/cryptdev"
bootmnt_opts="bind"
else
archisodevice="/dev/disk/by-uuid/${archisouuid}"
bootmnt_opts="defaults"
fi
}
run_hook() {
[ -z "${arch}" ] && arch="$(uname -m)"
[ -z "${copytoram_size}" ] && copytoram_size="75%"
@@ -141,7 +158,7 @@ run_hook() {
[ -z "${dm_snap_prefix}" ] && dm_snap_prefix="arch"
# shellcheck disable=SC2154
# defined via initcpio's parse_cmdline()
[ -z "${archisodevice}" ] && archisodevice="/dev/disk/by-label/${archisolabel}"
[ -z "${archisodevice}" ] && _archisodevice
[ -z "${cow_spacesize}" ] && cow_spacesize="256M"
# shellcheck disable=SC2154
# defined via initcpio's parse_cmdline()
@@ -154,6 +171,8 @@ run_hook() {
cow_persistent="N"
fi
# shellcheck disable=SC2154
# defined via initcpio's parse_cmdline()
[ -z "${cow_flags}" ] && cow_flags="defaults"
[ -z "${cow_directory}" ] && cow_directory="persistent_${archisolabel}/${arch}"
[ -z "${cow_chunksize}" ] && cow_chunksize="8"
@@ -168,17 +187,10 @@ run_hook() {
archiso_mount_handler() {
local newroot="${1}"
local airootfs sigfile fs_img
local bootmnt="/run/archiso/bootmnt"
local bootmnt_opts="-r defaults"
# shellcheck disable=SC2154
if [ -f "${root}" ]; then
bootmnt="/run/cryptdev"
bootmnt_opts="-r bind"
fi
bootmnt="/run/archiso/bootmnt"
if ! mountpoint -q "${bootmnt}"; then
_mnt_dev "${archisodevice}" "${bootmnt}" "${bootmnt_opts}"
_mnt_dev "${archisodevice}" "${bootmnt}" "-r" "${bootmnt_opts}"
fi
local airootfs_dir="${bootmnt}/${archisobasedir}/${arch}"
@@ -188,7 +200,7 @@ archiso_mount_handler() {
elif [ -f "${airootfs_dir}/airootfs.erofs" ]; then
airootfs="${airootfs_dir}/airootfs.erofs"
fi
# shellcheck disable=SC2154
# defined via initcpio's parse_cmdline()
if [ "${checksum}" = "y" ]; then
@@ -243,7 +255,7 @@ archiso_mount_handler() {
chmod 0700 "/run/archiso/cowspace/${cow_directory}"
# shellcheck disable=SC2154
if [ -f "${airootfs}" ]; then
if [ -f "${airootfs}" ]; then
fs_img="${airootfs}"
elif [ -f "${root}" ]; then
fs_img="${root}"
Loading