aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-01-23 15:49:17 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-01-23 15:49:17 +0000
commit573817bc72b5f3273bcf2bca6e2d98e105c976b5 (patch)
tree4247f6a199896108f7ce7f8d1a1fb724c15d7ce4 /Makefile
parent4afda13f9e30f96932b1d1ab28ef014a9ebaaa29 (diff)
downloadlh-bootstrap-573817bc72b5f3273bcf2bca6e2d98e105c976b5.tar.xz
Add run-qemu and disk image creation
Disk image creation depends on libguestfs, which is a huge dependency, but people will only run it on dev machines already, and it saves reinventing the wheel.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile38
1 files changed, 12 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index c7489ec..1367fe2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,31 +7,6 @@
# used by make to handle dependencies. Each of these files is
# being touched at the end of each recipe to update its date,
# since make relies on dates to handle updates of targets.
-#
-# * why these "exec" at the beginning at each line?
-# => make spawns a shell for every line in every recipe.
-# The "exec" keyword at the beginning of the recipe lines
-# is just a small optimization: it ensures that the shell
-# doesn't stay around while the recipe line is running,
-# so it saves a little RAM and CPU. On most build machines,
-# this should not be noticeable.
-#
-# * why these "setuidgid $(NORMALUSER)" ?
-# => to drop privileges, from root to a normal user, for recipes
-# that do not need root privileges. The user's name is defined in
-# lh-config.
-#
-# * why do we need to be root?
-# => Because some unavoidable operations in the build process need root privileges:
-# + correctly handling several different uids for the target.
-# + manipulating and deleting a loopback device, to create the disk images.
-#
-# * why is skarnet.org often an order-only prerequisite in the sub-Makefiles?
-# => When it's the case, it means the build process, not the target,
-# depends on a skarnet.org tool (for instance s6-touch) built for the
-# BUILD machine. There's no need to rebuild everything if the tool
-# changes, since the HOST image does not depend on its details; we
-# just need to ensure that the tool is there.
ifndef LH_MAKE_MARKER
@@ -45,7 +20,7 @@ NORMALUSER_GID := $(shell id -g $(NORMALUSER))
it: all
-.PHONY: it all rootfs kernel clean distclean
+.PHONY: it all rootfs kernel qemu-boot clean distclean
all: $(OUTPUT)/tmp/.lh_rootfs_installed $(OUTPUT)/build-host/kernel/.lh_installed
@@ -83,6 +58,17 @@ $(OUTPUT)/tmp/.lh_rootfs_installed: $(OUTPUT)/tmp/.lh_layout_installed $(OUTPUT)
exec setuidgid $(NORMALUSER) touch $@
+# The qemu disk image (requires qemu and libguestfs-tools)
+
+$(OUTPUT)/tmp/.lh_diskimage_done: $(OUTPUT)/tmp/.lh_rootfs_installed
+ exec setuidgid $(NORMALUSER) qemu-img create -f qcow2 $(OUTPUT)/disk-image.qcow2 1G
+ exec virt-make-fs --format=qcow2 --size=2G --type=ext4 $(OUTPUT)/rootfs $(OUTPUT)/disk-image.qcow2
+ exec setuidgid $(NORMALUSER) touch $@
+
+qemu-boot: $(OUTPUT)/build-host/kernel/.lh_installed $(OUTPUT)/tmp/.lh_diskimage_done run-qemu
+ exec ./run-qemu
+
+
# Subsystems
## libc, toolchains, utilities, for the build itself, or for building the host