summaryrefslogtreecommitdiff
path: root/parabolaiso/initcpio/hooks/parabolaiso
diff options
context:
space:
mode:
Diffstat (limited to 'parabolaiso/initcpio/hooks/parabolaiso')
-rw-r--r--parabolaiso/initcpio/hooks/parabolaiso52
1 files changed, 44 insertions, 8 deletions
diff --git a/parabolaiso/initcpio/hooks/parabolaiso b/parabolaiso/initcpio/hooks/parabolaiso
index 10ba4e5..8f532c3 100644
--- a/parabolaiso/initcpio/hooks/parabolaiso
+++ b/parabolaiso/initcpio/hooks/parabolaiso
@@ -81,12 +81,36 @@ _mnt_sfs() {
_mnt_dev "${sfs_dev}" "${mnt}" "-r" "defaults"
}
+# args: /path/to/image_file, mountpoint
+_mnt_erofs() {
+ local img="${1}"
+ local mnt="${2}"
+ local img_fullname="${img##*/}"
+ local erofs_dev
+
+ # shellcheck disable=SC2154
+ # defined via initcpio's parse_cmdline()
+ if [ "${copytoram}" = "y" ]; then
+ msg -n ":: Copying EROFS image to RAM..."
+ if ! cp -- "${img}" "/run/parabolaiso/copytoram/${img_fullname}" ; then
+ echo "ERROR: while copy '${img}' to '/run/parabolaiso/copytoram/${img_fullname}'"
+ launch_interactive_shell
+ fi
+ img="/run/parabolaiso/copytoram/${img_fullname}"
+ msg "done."
+ fi
+ erofs_dev="$(losetup --find --show --read-only -- "${img}")"
+ echo "${erofs_dev}" >> /run/parabolaiso/used_block_devices
+ _mnt_dev "${erofs_dev}" "${mnt}" "-r" "defaults" "erofs"
+}
+
# args: device, mountpoint, flags, opts
_mnt_dev() {
local dev="${1}"
local mnt="${2}"
local flg="${3}"
local opts="${4}"
+ local fstype="${5:-auto}"
mkdir -p "${mnt}"
@@ -99,7 +123,7 @@ _mnt_dev() {
launch_interactive_shell
done
- if mount -o "${opts}" "${flg}" "${dev}" "${mnt}"; then
+ if mount -t "${fstype}" -o "${opts}" "${flg}" "${dev}" "${mnt}"; then
msg ":: Device '${dev}' mounted successfully."
else
echo "ERROR; Failed to mount '${dev}'"
@@ -120,8 +144,9 @@ _verify_checksum() {
_verify_signature() {
local _status
+ local sigfile="${1}"
cd "/run/parabolaiso/bootmnt/${parabolaisobasedir}/${arch}" || exit 1
- gpg --homedir /gpg --status-fd 1 --verify airootfs.sfs.sig 2>/dev/null | grep -qE '^\[GNUPG:\] GOODSIG'
+ gpg --homedir /gpg --status-fd 1 --verify "${sigfile}" 2>/dev/null | grep -qE '^\[GNUPG:\] GOODSIG'
_status=$?
cd -- "${OLDPWD}" || exit 1
return ${_status}
@@ -160,6 +185,7 @@ run_hook() {
# args: /path/to/newroot
parabolaiso_mount_handler() {
local newroot="${1}"
+ local sigfile
if ! mountpoint -q "/run/parabolaiso/bootmnt"; then
_mnt_dev "${parabolaisodevice}" "/run/parabolaiso/bootmnt" "-r" "defaults"
@@ -190,15 +216,20 @@ parabolaiso_mount_handler() {
# defined via initcpio's parse_cmdline()
if [ "${verify}" = "y" ]; then
if [ -f "/run/parabolaiso/bootmnt/${parabolaisobasedir}/${arch}/airootfs.sfs.sig" ]; then
+ sigfile="airootfs.sfs.sig"
+ elif [ -f "/run/parabolaiso/bootmnt/${parabolaisobasedir}/${arch}/airootfs.erofs.sig" ]; then
+ sigfile="airootfs.erofs.sig"
+ fi
+ if [ -n "${sigfile}" ]; then
msg -n ":: Signature verification requested, please wait..."
- if _verify_signature; then
+ if _verify_signature "${sigfile}"; then
msg "done. Signature is OK, continue booting."
else
echo "ERROR: one or more files are corrupted"
launch_interactive_shell
fi
else
- echo "ERROR: verify=y option specified but ${parabolaisobasedir}/${arch}/airootfs.sfs.sig not found"
+ echo "ERROR: verify=y option specified but GPG signature not found in ${parabolaisobasedir}/${arch}/"
launch_interactive_shell
fi
fi
@@ -221,15 +252,20 @@ parabolaiso_mount_handler() {
mkdir -p "/run/parabolaiso/cowspace/${cow_directory}"
chmod 0700 "/run/parabolaiso/cowspace/${cow_directory}"
- _mnt_sfs "/run/parabolaiso/bootmnt/${parabolaisobasedir}/${arch}/airootfs.sfs" "/run/parabolaiso/sfs/airootfs"
- if [ -f "/run/parabolaiso/sfs/airootfs/airootfs.img" ]; then
- _mnt_dmsnapshot "/run/parabolaiso/sfs/airootfs/airootfs.img" "${newroot}" "/"
+ if [ -f "/run/parabolaiso/bootmnt/${parabolaisobasedir}/${arch}/airootfs.sfs" ]; then
+ _mnt_sfs "/run/parabolaiso/bootmnt/${parabolaisobasedir}/${arch}/airootfs.sfs" "/run/parabolaiso/airootfs"
+ elif [ -f "/run/parabolaiso/bootmnt/${parabolaisobasedir}/${arch}/airootfs.erofs" ]; then
+ _mnt_erofs "/run/parabolaiso/bootmnt/${parabolaisobasedir}/${arch}/airootfs.erofs" "/run/parabolaiso/airootfs"
+ fi
+ if [ -f "/run/parabolaiso/airootfs/airootfs.img" ]; then
+ _mnt_dmsnapshot "/run/parabolaiso/airootfs/airootfs.img" "${newroot}" "/"
else
- _mnt_overlayfs "/run/parabolaiso/sfs/airootfs" "${newroot}" "/"
+ _mnt_overlayfs "/run/parabolaiso/airootfs" "${newroot}" "/"
fi
if [ "${copytoram}" = "y" ]; then
umount -d /run/parabolaiso/bootmnt
+ rmdir /run/parabolaiso/bootmnt
fi
}