2024-02-14 08:35:01 +00:00
|
|
|
#!/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
|
2024-03-04 21:03:48 +00:00
|
|
|
if [[ -z "${arg_fmtconf[fsuuid]:-}" ]]; then
|
|
|
|
arg_fmtconf[fsuuid]=$(uuidgen)
|
|
|
|
arg_orig=(--fmtconf=fsuuid="${arg_fmtconf[fsuuid]}" "${arg_orig[@]}")
|
2024-02-14 08:35:01 +00:00
|
|
|
fi
|
|
|
|
packages+=(erofs-utils)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Overrides ##########################################################
|
|
|
|
|
|
|
|
format_genfstab:erofs() {
|
|
|
|
shellcheck:format_genfstab
|
2024-03-04 21:03:48 +00:00
|
|
|
echo "UUID=${arg_fmtconf[fsuuid]} / erofs defaults 0 1"
|
2024-02-14 08:35:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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 \
|
2024-03-04 21:03:48 +00:00
|
|
|
-U"${arg_fmtconf[fsuuid]}" \
|
|
|
|
${arg_fmtconf[erofs_compression]:+"-z${arg_fmtconf[erofs_compression]}"} \
|
2024-02-14 08:35:01 +00:00
|
|
|
"$tmpdir/erofs.img" "$mount_dev"
|
|
|
|
cp -T "$tmpdir/erofs.img" "$arg_file"
|
|
|
|
)
|
|
|
|
|
|
|
|
shellcheck:format
|