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
2019-05-07 19:17:55 +03:00
i f d e f E F I _ B O O T L O A D E R
VM_BOOTLOADER = $( EFI_BOOTLOADER)
e l s e
VM_BOOTLOADER = $( BASE_BOOTLOADER)
e n d i f
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
2019-05-19 09:23:16 +03:00
VM_GZIP_COMMAND ?= gzip
VM_XZ_COMMAND ?= xz -T0
2019-05-19 12:39:04 +03:00
# tavolga
RECOVERY_LINE ?= Press ENTER to start
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; \
2019-05-19 09:23:16 +03:00
fi
check-qemu :
@if ! type -t qemu-img >& /dev/null; then \
echo "** error: qemu-img not available" >& 2; \
2012-06-18 22:00:32 +04:00
exit 1; \
fi
2019-06-19 16:45:15 +03:00
tar2fs : check -sudo prepare -tarball -qemu
2019-05-19 09:23:16 +03:00
@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 \
2019-05-07 19:17:55 +03:00
" $( VM_TARBALL) " " $( VM_RAWDISK) " " $( VM_SIZE) " " $( VM_FSTYPE) " \
" $( VM_BOOTLOADER) " ; 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
2019-06-19 16:45:15 +03:00
# copy $(BUILDDIR)/.work/chroot/.host/qemu* into chroot if qemu is used
prepare-tarball-qemu :
2019-05-19 09:23:16 +03:00
@( cd " $( BUILDDIR) /.work/chroot/ " ; \
tar -rf " $( VM_TARBALL) " ./.host/qemu*) || :
convert-image/tar :
mv " $( VM_TARBALL) " " $( IMAGE_OUTPATH) "
convert-image/tar.gz :
$( VM_GZIP_COMMAND) < " $( VM_TARBALL) " > " $( IMAGE_OUTPATH) "
convert-image/tar.xz :
$( VM_XZ_COMMAND) < " $( VM_TARBALL) " > " $( IMAGE_OUTPATH) "
convert-image/img : tar 2fs
mv " $( VM_RAWDISK) " " $( IMAGE_OUTPATH) "
c o n v e r t - i m a g e / q c o w 2 c o n v e r t - i m a g e / q c o w 2 c c o n v e r t - i m a g e / v m d k \
convert-image/vdi convert-image/vhd: check-qemu tar2fs
2017-12-04 20:02:19 +03:00
@VM_COMPRESS= ; \
case " $( IMAGE_TYPE) " in \
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 ; \
2019-05-19 09:23:16 +03:00
qemu-img convert $$ VM_COMPRESS -O " $$ VM_FORMAT " \
" $( VM_RAWDISK) " " $( IMAGE_OUTPATH) "
2019-05-19 12:39:04 +03:00
# for tavolga
convert-image/recovery.tar :
build-recovery-tar \
--image-name $( IMAGE_NAME) \
--date $( DATE) \
--compress-command '$(VM_GZIP_COMMAND)' \
--rootfs " $( VM_TARBALL) " \
--output " $( IMAGE_OUTPATH) " \
--line '$(RECOVERY_LINE)'
2019-05-19 09:23:16 +03:00
post-convert :
@rm -f " $( VM_RAWDISK) " ; \
if [ " 0 $( DEBUG) " -le 1 ] ; then rm -f " $( VM_TARBALL) " ; fi
2019-06-19 16:45:15 +03:00
convert-image : convert -image /$( IMAGE_TYPE ) post -convert ; @:
2012-06-19 17:51:56 +04:00
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)