xref: /freebsd/release/Makefile.firecracker (revision 525fe93dc7487a1e63a90f6a2b956abc601963c1)
1#
2# Makefile for creating FreeBSD/Firecracker artifacts
3#
4
5CLEANDIRS+=	${TARGET}/firecracker-kern ${TARGET}/firecracker-world
6
7# Bits related to hardware which won't exist in a VM.
8WITHOUT_VM_ENOENT=WITHOUT_APM=YES WITHOUT_BLUETOOTH=YES WITHOUT_CXGBETOOL=YES \
9    WITHOUT_FLOPPY=YES WITHOUT_GPIO=YES WITHOUT_MLX5TOOL=YES WITHOUT_USB=YES \
10    WITHOUT_USB_GADGET_EXAMPLES=YES WITHOUT_VT=YES WITHOUT_WIRELESS=YES
11# Bits related to software which doesn't exist in Firecracker specifically.
12WITHOUT_FC_ENOENT=WITHOUT_ACPI=YES WITHOUT_BOOT=YES WITHOUT_BHYVE=YES \
13    WITHOUT_EFI=YES WITHOUT_FDT=YES WITHOUT_HYPERV=YES \
14    WITHOUT_LEGACY_CONSOLE=YES WITHOUT_SYSCONS=YES
15# Bits which take up a lot of space and probably won't be wanted inside a
16# Firecracker VM.
17WITHOUT_FC_FEATURES=WITHOUT_DEBUG_FILES=YES WITHOUT_INCLUDES=YES \
18    WITHOUT_INSTALLLIB=YES WITHOUT_TESTS=YES WITHOUT_TOOLCHAIN=YES
19# All the excluded bits
20WITHOUTS?=${WITHOUT_VM_ENOENT} ${WITHOUT_FC_ENOENT} ${WITHOUT_FC_FEATURES}
21
22firecracker:	firecracker-freebsd-kern.bin firecracker-freebsd-rootfs.bin
23
24FCKDIR=	${.OBJDIR}/${TARGET}/firecracker-kern
25firecracker-freebsd-kern.bin:
26.if !defined(DESTDIR) || !exists(${DESTDIR})
27	@echo "--------------------------------------------------------------"
28	@echo ">>> DESTDIR must point to destination for Firecracker binaries"
29	@echo "--------------------------------------------------------------"
30	@false
31.endif
32	mkdir -p ${FCKDIR}
33	${MAKE} -C ${WORLDDIR} DESTDIR=${FCKDIR} \
34	    KERNCONF=FIRECRACKER TARGET=${TARGET} installkernel
35	cp ${FCKDIR}/boot/kernel/kernel ${DESTDIR}/freebsd-kern.bin
36
37FCWDIR=	${.OBJDIR}/${TARGET}/firecracker-world
38FCROOTFSSZ?=	1g
39firecracker-freebsd-rootfs.bin:
40	mkdir -p ${FCWDIR}
41	${MAKE} -C ${WORLDDIR} DESTDIR=${FCWDIR} \
42	    ${WITHOUTS} TARGET=${TARGET} installworld distribution distrib-dirs
43	echo '/dev/ufs/rootfs / ufs rw 1 1' > ${FCWDIR}/etc/fstab
44	echo 'hostname="freebsd"' >> ${FCWDIR}/etc/rc.conf
45	echo 'ifconfig_vtnet0="inet 10.0.0.2 netmask 255.255.0.0"' >> ${FCWDIR}/etc/rc.conf
46	echo 'defaultrouter="10.0.0.1"' >> ${FCWDIR}/etc/rc.conf
47	echo 'sshd_enable="YES"' >> ${FCWDIR}/etc/rc.conf
48	echo 'sshd_rsa_enable="NO"' >> ${FCWDIR}/etc/rc.conf
49	echo 'growfs_enable="YES"' >> ${FCWDIR}/etc/rc.conf
50	echo 'nameserver 8.8.8.8' >> ${FCWDIR}/etc/resolv.conf
51	sed -i '' -e '/periodic/s/^/#/' ${FCWDIR}/etc/crontab
52	pw -R ${FCWDIR} groupadd freebsd -g 1001
53	mkdir -p ${FCWDIR}/home/freebsd
54	pw -R ${FCWDIR} useradd freebsd -m -M 0755 -w yes -n freebsd \
55	    -u 1001 -g 1001 -G 0 -c "FreeBSD User" -d /home/freebsd -s /bin/sh
56	pw -R ${FCWDIR} usermod root -w yes
57	touch ${FCWDIR}/firstboot
58	makefs -s ${FCROOTFSSZ} -o label=rootfs -o version=2 -o softupdates=1 \
59	    ${DESTDIR}/freebsd-rootfs.bin ${FCWDIR}
60