From 16fb7c36ae80a0b735e94d133f372445e05a9912 Mon Sep 17 00:00:00 2001 From: timoxa0 Date: Sat, 2 Nov 2024 21:15:04 +0500 Subject: [PATCH] makelni: add pre/post install hook error messages, add lon-tool --- makelni | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/makelni b/makelni index 77979ba..1d50738 100755 --- a/makelni +++ b/makelni @@ -2,6 +2,8 @@ source ./common.d/functions.sh source ./common.d/variables.sh +require "lon-tool" + if [ "$(id -u)" != "0" ]; then log "$0 must be run as root" exit 3 @@ -26,6 +28,11 @@ lnib_has_errors="n" lnib_has_errors="y" } +[ -z ${imgver+x} ] && { + log "LNIBUILD: missing imgver" ierror + lnib_has_errors="y" +} + [ -z ${image_type+x} ] && { log "LNIBUILD: missing image_type" ierror lnib_has_errors="y" @@ -50,7 +57,8 @@ source "./common.d/common.${image_type}.sh" log "Making image: $name" log "Image type: $image_type" -log "Creating image: $(get_image_path "$name")" +IMAGE_PATH="$(get_image_path "$name")" +log "Creating image: $IMAGE_PATH" create_image "$name" || _shutdown 1 imageroot="$(mount_image "$name")" @@ -62,7 +70,10 @@ prepare_chroot "$imageroot" || _shutdown 1 [[ $(type -t pre_install) == function ]] && { log "Running pre install hook" - pre_install || _shutdown 1 + pre_install || { + log "Failed to execute pre install hook" + _shutdown 1 + } } log "Setting up inet" @@ -92,7 +103,10 @@ gen_fstab "$imageroot" || _shutdown 1 [[ $(type -t post_install) == function ]] && { log "Running post install hook" - post_install || _shutdown 1 + post_install || { + log "Failed to execute post install hook" + _shutdown 1 + } } log "Detaching chroot" @@ -104,4 +118,7 @@ umount_image "$imageroot" || _shutdown 1 log "Trimming image" trim_image "$name" || _shutdown 1 +log "Creating lni image" +lon-tool image create "$IMAGE_PATH "./out/${name}.lni" --name "$name" -v "$imgver" + log "Image build finished"