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
2017-08-21 21:39:52 +03:00
IMAGE_PACKAGES_REGEXP = $( THE_PACKAGES_REGEXP) \
2018-02-14 18:33:46 +03:00
$( BASE_PACKAGES_REGEXP)
2017-08-21 21:39:52 +03:00
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
2019-01-09 14:12:47 +03:00
@# need to copy $( BUILDDIR) /.work/chroot/.host/qemu* into chroot
@#if qemu is used
@( cd " $( BUILDDIR) /.work/chroot/ " ; \
tar -rf " $( VM_TARBALL) " ./.host/qemu*) || :; \
if [ -x /usr/share/mkimage-profiles/bin/tar2fs ] ; then \
2018-12-10 12:10:13 +03:00
TOPDIR = /usr/share/mkimage-profiles; \
2016-11-07 13:20:09 +03:00
fi ; \
2018-12-10 12:10:13 +03:00
if ! sudo $$ TOPDIR/bin/tar2fs \
" $( VM_TARBALL) " " $( VM_RAWDISK) " $( VM_SIZE) $( VM_FSTYPE) ; then \
2017-01-14 12:06:30 +03:00
echo "** error: sudo tar2fs failed, see build log" >& 2; \
2012-06-18 22:00:32 +04:00
exit 1; \
fi
2012-06-19 17:51:56 +04:00
convert-image : prepare -image
2017-12-04 20:02:19 +03:00
@VM_COMPRESS= ; \
case " $( IMAGE_TYPE) " in \
2019-02-22 11:42:23 +03:00
"img" ) \
mv " $( VM_RAWDISK) " " $( IMAGE_OUTPATH) " ; \
if [ " 0 $( DEBUG) " -le 1 ] ; then rm " $( VM_TARBALL) " ; fi ; \
exit 0; ; \
2012-06-19 17:51:56 +04:00
"vhd" ) VM_FORMAT = "vpc" ; ; \
2017-12-04 20:02:19 +03:00
"qcow2c" ) VM_FORMAT = "qcow2" ; VM_COMPRESS = "-c" ; ; \
2012-06-19 17:51:56 +04:00
*) VM_FORMAT = " $( IMAGE_TYPE) " ; \
esac ; \
if ! type -t qemu-img >& /dev/null; then \
2017-12-04 19:41:17 +03:00
echo "** error: qemu-img not available" >& 2; \
exit 1; \
2012-06-19 17:51:56 +04:00
else \
2017-12-04 20:02:19 +03:00
qemu-img convert $$ VM_COMPRESS -O " $$ VM_FORMAT " \
2012-06-19 17:51:56 +04:00
" $( VM_RAWDISK) " " $( IMAGE_OUTPATH) " ; \
2012-06-26 00:10:27 +04:00
rm " $( VM_RAWDISK) " ; \
2017-08-21 21:09:32 +03:00
if [ " 0 $( DEBUG) " -le 1 ] ; 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 )
2018-02-15 16:57:50 +03:00
all : $( GLOBAL_DEBUG ) \
build-image copy-subdirs copy-tree run-image-scripts pack-image \
2012-06-18 22:00:32 +04:00
convert-image postprocess $( GLOBAL_CLEAN_WORKDIR)