From 510875218b04e350b12efb5daab37a33d305e629 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Sun, 12 Jun 2016 18:21:43 +0100 Subject: [PATCH] towards make_qemu_img --- zlibs/customise | 23 +++++++++++++++++++++++ zlibs/helpers | 12 ++++++++++++ 2 files changed, 35 insertions(+) diff --git a/zlibs/customise b/zlibs/customise index 27cca01..9b25863 100644 --- a/zlibs/customise +++ b/zlibs/customise @@ -48,3 +48,26 @@ install_default_kernel(){ umountdevprocsys ${root} notice "default kernel installed" } + + +make_qemu_img(){ + + fn make_qemu_img $@ + local imgfile=$1 + local imgsize=${2:-4G} + local imgformat=${3:-qcow2} + req=(strapdir os release version arch imgfile imgsize) + root=$strapdir + reqck || return 1 + + + check_executable qemu-img || error "Could not find qemu-img!!!" && return 1 + + qemu-img create -f ${imgformat} ${imgfile} ${imgsize} + + if [[ ! -z ${imgfile} ]]; then + notice "QEMU image created in ::1" ${imgfile} + else + warning "Unable to create QEMU image file in ::1" ${imgfile} + fi +} \ No newline at end of file diff --git a/zlibs/helpers b/zlibs/helpers index ed54fd9..461a051 100644 --- a/zlibs/helpers +++ b/zlibs/helpers @@ -174,3 +174,15 @@ silly() { [[ arg1 == "sleep" ]] && sleep $arg2 } + +check_executable() { + fn check_executable $@ + progname=$1 + + if [[ `which $progname | grep "not found" | wc -l` -ge 1 ]]; then + return 0; + else + return 1; + fi + +} \ No newline at end of file