1 # Makefile - set up a vkernel environment for testing the vkernel
4 # require it to be specified
5 SRCDIR ?
= ${.CURDIR
}/..
/..
12 .if
${MACHINE_ARCH} == "i386"
18 scratch
: world kernel root
install
19 @echo
"Run the environment with:"
20 @echo
"make VKDIR=${VKDIR} run"
22 quickw
: quickworld quickkernel reinstall reinstallkernel
23 @echo
"Run the environment with:"
24 @echo
"make VKDIR=${VKDIR} run"
26 quick
: quickkernel reinstallkernel
27 @echo
"Run the environment with:"
28 @echo
"make VKDIR=${VKDIR} run"
31 @echo
"Setup Instructions:"
33 @echo
" setenv ROOTSIZE size (optional)"
34 @echo
" setenv VKDIR target_dir"
35 @echo
" setenv FSTYPE fstype (optional. values:hammer, 4.2BSD)"
37 @echo
"Meta target components:"
39 @echo
" help - this help"
40 @echo
" clean - clean up"
41 @echo
" scratch - build and install everything from scratch"
42 @echo
" (this is absolutely everything)"
43 @echo
" quick - incremental kernel build & reinstall"
44 @echo
" quickw - incremental world & kernel build & reinstall"
45 @echo
" run - run vkernel with VKDIR/root.img"
46 @echo
" mount - mount VKDIR/root.img at VKDIR/root"
47 @echo
" umount - unmount"
49 @echo
"Individual target components:"
51 @echo
" world - build the world from scratch"
52 @echo
" root - create a new, empty root.img"
53 @echo
" install - install a world & kernel"
54 @echo
" into root.img"
55 @echo
" leaf - additional customization"
56 @echo
" kernel - build vkernel"
57 @echo
" quickworld - incremental rebuild world"
58 @echo
" quickkernel - incremental rebuild kernel"
59 @echo
" reinstall - reinstall world into root.img"
60 @echo
" (just the installworld piece)"
61 @echo
" reinstallkernel - reinstall kernel into root.img"
64 # Unmount everything, de-configured VN, and clean up.
65 # (check handles umounting/deconfiguring)
68 rm -rf
${VKDIR}/root.img
${VKDIR}/root
70 # Build the world and kernel
74 cd
${SRCDIR} && make
-j
4 buildworld
77 cd
${SRCDIR} && make
-j
4 KERNCONF
=${USEKERNEL} buildkernel
80 cd
${SRCDIR} && make
-j
4 KERNCONF
=${USEKERNEL} nativekernel
82 # Quick build - just rebuild the kernel quickly
86 cd
${SRCDIR} && make
-j
4 quickworld
89 cd
${SRCDIR} && make
-j
4 KERNCONF
=${USEKERNEL} quickkernel
91 # Build and mount an empty filesystem for the emulated root disk
93 # NOTE: root must umount when done because a later dependency may
94 # have a dependency on mount.
97 vnconfig
-c
-T
-S
${ROOTSIZE} -s labels \
98 `cat ${VKDIR}/vn.which` ${VKDIR}/root.img
99 dd if
=/dev
/zero of
=/dev
/`cat ${VKDIR}/vn.which` bs
=32k count
=4
100 fdisk
-IB
`cat ${VKDIR}/vn.which`
101 disklabel
-r
-w
`cat ${VKDIR}/vn.which`s1 auto
102 disklabel
`cat ${VKDIR}/vn.which`s1
> ${VKDIR}/label.tmp
103 echo
'a: * 0 ${FSTYPE}' >> ${VKDIR}/label.tmp
104 disklabel
-R
`cat ${VKDIR}/vn.which`s1
${VKDIR}/label.tmp
105 disklabel
-B
`cat ${VKDIR}/vn.which`s1
106 ${NEWFS_CMD} ${NEWFS_ARGS} /dev
/`cat ${VKDIR}/vn.which`s1a
107 mkdir
-p
${VKDIR}/root
108 vnconfig
-u
`cat ${VKDIR}/vn.which` > /dev
/null
2>&1
111 vnconfig
-c
-s labels
`cat ${VKDIR}/vn.which` ${VKDIR}/root.img
112 . if
${FSTYPE} == "4.2BSD"
113 fsck
-p
/dev
/`cat ${VKDIR}/vn.which`s1a
115 ${MOUNT_CMD} /dev
/`cat ${VKDIR}/vn.which`s1a
${VKDIR}/root
116 @echo
"Mounted ${VKDIR}/root"
120 # Install a fresh world & distribution, and kernel
124 make
-j
4 DESTDIR
=${VKDIR}/root installworld
125 cd
${SRCDIR}/etc
&& \
126 make
-j
4 DESTDIR
=${VKDIR}/root distribution
127 echo
'/dev/vkd0s1a / ufs rw 1 1' > ${VKDIR}/root
/etc
/fstab
128 echo
'proc /proc procfs rw 0 0' >> ${VKDIR}/root
/etc
/fstab
129 echo
'vfs.root.mountfrom="ufs:vkd0s1a"' > ${VKDIR}/root
/boot
/loader.conf
130 #(egrep -v '^console' ${VKDIR}/root/etc/ttys; echo 'console "/usr/libexec/getty Pc" cons25 on secure') > ${VKDIR}/root/etc/ttys.new
131 #mv -f ${VKDIR}/root/etc/ttys.new ${VKDIR}/root/etc/ttys
134 DESTDIR
=${VKDIR}/root KERNCONF
=${USEKERNEL} \
136 cp
${VKDIR}/root
/boot
/kernel
/kernel
${VKDIR}/vkernel
139 echo
'ifconfig_vke0="up"' > ${VKDIR}/root
/etc
/rc.conf
140 echo
'defaultrouter="10.26.0.1"' >> ${VKDIR}/root
/etc
/rc.conf
141 echo
'search dragonflybsd.org backplane.com' > ${VKDIR}/root
/etc
/resolv.conf
142 echo
'nameserver 10.0.0.25' >> ${VKDIR}/root
/etc
/resolv.conf
143 echo
'nameserver 10.0.0.2' >> ${VKDIR}/root
/etc
/resolv.conf
144 echo
'nameserver 8.8.8.8' >> ${VKDIR}/root
/etc
/resolv.conf
146 chmod
644 /build
/vkernel
/root.img
148 # Quick reinstall - just install a new kernel on top of an existing image
152 cd
${SRCDIR} && make
-j
4 DESTDIR
=${VKDIR}/root installworld
154 reinstallkernel
: mount
156 make
-j
4 DESTDIR
=${VKDIR}/root KERNCONF
=${USEKERNEL} \
158 cp
${VKDIR}/root
/boot
/kernel
/kernel
${VKDIR}/vkernel
161 cp
/boot
/loader
${VKDIR}/root
/boot
/loader
164 # Run the vkernel on our image. Make sure we are unmounted so
165 # we do not compete against the emulated kernel when writing to root.img.
166 # (check does this for us)
169 mkdir
-p
/var
/vkernel
170 sysctl vm.vkernel_enable
=1
171 cd
${VKDIR} && .
/vkernel
-m
${PHYSMEM} -n
${NCPUS} \
175 # When running w/ a NFS root
178 NFS_NETMASK?
= 255.255.255.0
179 NFS_ROOT_IP?
= 10.0.0.1
180 NFS_ROOT_PATH?
= /netboot2
183 cd
${VKDIR} && .
/vkernel
-m
${PHYSMEM} -n
${NCPUS} -U
-v \
185 -e
'boot.netif.ip=${NFS_IP}:boot.netif.netmask=${NFS_NETMASK}:boot.netif.name=vke0:boot.nfsroot.server=${NFS_ROOT_IP}:boot.nfsroot.path=${NFS_ROOT_PATH}'
187 # Make sure we are not mounted and the VN device is unconfigured,
189 # Find an unused VN device but do not do anything with it yet.
193 @
(echo
"must specify VKDIR=target or as an environment variable"; /usr
/bin
/false
)
197 @echo
"${VKDIR} found"
202 .if
${FSTYPE} == "hammer"
203 NEWFS_CMD
= newfs_
${FSTYPE}
204 NEWFS_ARGS
= -L VKROOT
-f
205 MOUNT_CMD
= mount_
${FSTYPE}
217 .if exists
(${VKDIR}/vn.which
)
218 -umount
${VKDIR}/root
> /dev
/null
2>&1
219 -vnconfig
-u
`cat ${VKDIR}/vn.which` > /dev
/null
2>&1
220 rm -f
${VKDIR}/vn.which
222 (vnconfig
-l | fgrep
"not in use" > /dev
/null
) || \
223 (echo
"Cannot find unused VN"; /usr
/bin
/false
)
224 vnconfig
-l | fgrep
"not in use" | \
225 cut
-f
1 -d
: | head
-1 > ${VKDIR}/vn.which
226 egrep
'^vn' ${VKDIR}/vn.which
> /dev
/null || \
227 (echo
"VN device selection is bad"; /usr
/bin
/false
)