build_fn: fix image path

This commit is contained in:
timoxa0 2024-11-02 21:51:44 +05:00
parent bb8a5520ad
commit 1799df1479

View file

@ -26,7 +26,7 @@ setup_inet()
create_image() create_image()
{ {
name="$(get_image_path "$1")" local name="$(get_image_path "$1")"
if [ -z "$2" ]; then if [ -z "$2" ]; then
size="$DEFAULT_IMAGE_SIZE" size="$DEFAULT_IMAGE_SIZE"
else else
@ -41,13 +41,16 @@ create_image()
log "Failed to cretae image [$name]" ierror log "Failed to cretae image [$name]" ierror
return 1 return 1
} }
mkfs.ext4 "$name" log "Creating ext4 fs on $name" internal
mkfs.ext4 "$name" || {
log "Failed to create new fs" ierror
}
} }
trim_image() trim_image()
{ {
{ {
name="$1" local name="$(get_image_path "$1")"
e2fsck -f "$name" e2fsck -f "$name"
resize2fs -M "$name" resize2fs -M "$name"
} || { } || {
@ -62,8 +65,10 @@ mount_image()
{ {
local mountdir="$(mktemp --tmpdir=./tmp/ -d)" local mountdir="$(mktemp --tmpdir=./tmp/ -d)"
local mountdir="$(realpath "$mountdir")" local mountdir="$(realpath "$mountdir")"
local name="$(get_image_path "$1")"
mount -o loop "$1" "$mountdir" || { mount -o loop "$name" "$mountdir" || {
log "Failed to mount image" ierror log "Failed to mount image" ierror
return 1 return 1
} }