2012-06-18 22:00:32 +04:00
# step 4: build the virtual machine image
2013-05-17 14:41:32 +04:00
IMAGE_PACKAGES = $( DOT_BASE) \
$( SYSTEM_PACKAGES) \
2012-06-18 22:00:32 +04:00
$( COMMON_PACKAGES) \
$( BASE_PACKAGES) \
$( THE_PACKAGES) \
2013-05-17 14:41:32 +04:00
$( call list,$( BASE_LISTS) $( THE_LISTS) )
2012-06-18 22:00:32 +04:00
# intermediate chroot archive
VM_TARBALL := $( IMAGE_OUTDIR) /$( IMAGE_NAME) .tar
2012-06-19 17:51:56 +04:00
VM_RAWDISK := $( IMAGE_OUTDIR) /$( IMAGE_NAME) .raw
2013-05-29 17:56:12 +04:00
VM_FSTYPE ?= ext4
VM_SIZE ?= 0
2012-06-18 22:00:32 +04:00
check-sudo :
@if ! type -t sudo >& /dev/null; then \
echo "** error: sudo not available, see doc/vm.txt" >& 2; \
exit 1; \
fi
2012-06-19 17:51:56 +04:00
prepare-image : check -sudo
2013-05-29 17:56:12 +04:00
@if ! sudo $( TOPDIR) /bin/tar2fs \
" $( VM_TARBALL) " " $( VM_RAWDISK) " $( VM_SIZE) $( VM_FSTYPE) ; then \
echo "** error: sudo tar2fs failed, see also doc/vm.txt" >& 2; \
2012-06-18 22:00:32 +04:00
exit 1; \
fi
2012-06-19 17:51:56 +04:00
convert-image : prepare -image
@case " $( IMAGE_TYPE) " in \
2012-06-26 00:10:27 +04:00
"img" ) mv " $( VM_RAWDISK) " " $( IMAGE_OUTPATH) " ; exit 0; ; \
2012-06-19 17:51:56 +04:00
"vhd" ) VM_FORMAT = "vpc" ; ; \
*) VM_FORMAT = " $( IMAGE_TYPE) " ; \
esac ; \
if ! type -t qemu-img >& /dev/null; then \
echo "** warning: qemu-img not available" >& 2; \
else \
qemu-img convert -O " $$ VM_FORMAT " \
" $( VM_RAWDISK) " " $( IMAGE_OUTPATH) " ; \
2012-06-26 00:10:27 +04:00
rm " $( VM_RAWDISK) " ; \
2015-02-20 19:08:12 +03:00
if [ -z " $( DEBUG) " ] ; then rm " $( VM_TARBALL) " ; fi ; \
2012-06-19 17:51:56 +04:00
fi
2012-06-26 00:22:35 +04:00
run-image-scripts : GLOBAL_CLEANUP_PACKAGES := $( CLEANUP_PACKAGES )
2012-06-18 22:00:32 +04:00
2012-06-19 17:51:56 +04:00
# override
2012-06-18 22:00:32 +04:00
pack-image : MKI_PACK_RESULTS := tar :$( VM_TARBALL )
all : $( GLOBAL_DEBUG ) build -image copy -tree run -image -scripts pack -image \
convert-image postprocess $( GLOBAL_CLEAN_WORKDIR)