Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Log creation info #250

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ createDisk() {
local DISK_SPACE=$2
local DISK_DESC=$3
local DISK_FMT=$4
local DIR SPACE DATA_SIZE
local DATA_SIZE DIR SPACE

DATA_SIZE=$(numfmt --from=iec "$DISK_SPACE")

Expand All @@ -94,7 +94,8 @@ createDisk() {
fi
fi

local FAIL="Could not create a $DISK_SPACE $DISK_FMT file for $DISK_DESC ($DISK_FILE)"
info "Creating a $DISK_TYPE $DISK_DESC image in $DISK_FMT format with a size of $DISK_SPACE..."
local FAIL="Could not create a $DISK_TYPE $DISK_FMT $DISK_DESC image of $DISK_SPACE ($DISK_FILE)"

case "${DISK_FMT,,}" in
raw)
Expand Down Expand Up @@ -158,7 +159,7 @@ resizeDisk() {

local GB=$(( (CUR_SIZE + 1073741823)/1073741824 ))
info "Resizing $DISK_DESC from ${GB}G to $DISK_SPACE..."
local FAIL="Could not resize $DISK_FMT file of $DISK_DESC ($DISK_FILE) from ${GB}G to $DISK_SPACE .."
local FAIL="Could not resize the $DISK_TYPE $DISK_FMT $DISK_DESC image from ${GB}G to $DISK_SPACE ($DISK_FILE)"

case "${DISK_FMT,,}" in
raw)
Expand Down Expand Up @@ -233,7 +234,7 @@ convertDisk() {
# shellcheck disable=SC2086
if ! qemu-img convert -f "$SOURCE_FMT" $CONV_FLAGS -o "$DISK_OPTS" -O "$DST_FMT" -- "$SOURCE_FILE" "$TMP_FILE"; then
rm -f "$TMP_FILE"
error "Failed to convert $DISK_DESC to $DST_FMT format in $DIR, is there enough space available?" && exit 79
error "Failed to convert $DISK_TYPE $DISK_DESC image to $DST_FMT format in $DIR, is there enough space available?" && exit 79
fi

if [[ "$DST_FMT" == "raw" ]]; then
Expand Down Expand Up @@ -340,8 +341,10 @@ fi
DISK_EXT="$(fmt2ext "$DISK_FMT")" || exit $?

if [[ "$ALLOCATE" == [Nn]* ]]; then
DISK_TYPE="growable"
DISK_ALLOC="preallocation=off"
else
DISK_TYPE="preallocated"
DISK_ALLOC="preallocation=falloc"
fi

Expand Down