osi-tools/lib/mk/format-erofs.sh

59 lines
1.6 KiB
Bash
Raw Permalink Normal View History

#!/hint/bash
# Copyright (C) 2023-2024 Umorpha Systems
# SPDX-License-Identifier: AGPL-3.0-or-later
source "${install_prefix}/lib/mk/shellcheck.sh"
formats+=('erofs')
format_is_block['erofs']='false'
# Option parsing #####################################################
format_options['erofs']='fsuuid erofs_compression'
format_checkconf:erofs() {
shellcheck:format_checkconf
if $arg_edit; then
argparse:error '--conf=format=erofs does not support --edit'
fi
if [[ ${arg_conf[bootloader]} != none ]]; then
argparse:error '--conf=format=erofs requires --conf=bootloader=none'
fi
if [[ -z "${arg_fmtconf[fsuuid]:-}" ]]; then
arg_fmtconf[fsuuid]=$(uuidgen)
arg_orig=(--fmtconf=fsuuid="${arg_fmtconf[fsuuid]}" "${arg_orig[@]}")
fi
packages+=(erofs-utils)
}
# Overrides ##########################################################
format_genfstab:erofs() {
shellcheck:format_genfstab
echo "UUID=${arg_fmtconf[fsuuid]} / erofs defaults 0 1"
}
# format_is_block[…]='false' settings ################################
format_wants_tmpfs['erofs']='true'
format_after_clamps_mtime['erofs']='true'
format_before:erofs() {
:
}
format_after:erofs() (
shellcheck:format_after
local tmpdir
tmpdir=$(mktemp -dt -- "${0##*/}.erofs.XXXXXXXXXX")
trap "rm -f -- ${tmpdir@Q}/erofs.img; rmdir -- ${tmpdir@Q}" EXIT
osi.sh:sudo mkfs.erofs \
-U"${arg_fmtconf[fsuuid]}" \
${arg_fmtconf[erofs_compression]:+"-z${arg_fmtconf[erofs_compression]}"} \
"$tmpdir/erofs.img" "$mount_dev"
cp -T "$tmpdir/erofs.img" "$arg_file"
)
shellcheck:format