| @@ -1,383 +1,378 @@ | | | @@ -1,383 +1,378 @@ |
1 | # $NetBSD: Makefile.bootimage,v 1.1 2012/01/22 03:53:30 tsutsui Exp $ | | 1 | # $NetBSD: Makefile.bootimage,v 1.2 2012/01/22 16:50:00 tsutsui Exp $ |
2 | # | | 2 | # |
3 | # Copyright (c) 2009, 2010, 2011 Izumi Tsutsui. All rights reserved. | | 3 | # Copyright (c) 2009, 2010, 2011 Izumi Tsutsui. All rights reserved. |
4 | # | | 4 | # |
5 | # Redistribution and use in source and binary forms, with or without | | 5 | # Redistribution and use in source and binary forms, with or without |
6 | # modification, are permitted provided that the following conditions | | 6 | # modification, are permitted provided that the following conditions |
7 | # are met: | | 7 | # are met: |
8 | # 1. Redistributions of source code must retain the above copyright | | 8 | # 1. Redistributions of source code must retain the above copyright |
9 | # notice, this list of conditions and the following disclaimer. | | 9 | # notice, this list of conditions and the following disclaimer. |
10 | # 2. Redistributions in binary form must reproduce the above copyright | | 10 | # 2. Redistributions in binary form must reproduce the above copyright |
11 | # notice, this list of conditions and the following disclaimer in the | | 11 | # notice, this list of conditions and the following disclaimer in the |
12 | # documentation and/or other materials provided with the distribution. | | 12 | # documentation and/or other materials provided with the distribution. |
13 | # | | 13 | # |
14 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 14 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
15 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 15 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
16 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 16 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
17 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 17 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
18 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 18 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
19 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 19 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
20 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 20 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
21 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 21 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 22 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
23 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 23 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | | | 24 | |
25 | # | | 25 | # |
26 | # Makefile to create a bootable FS image for USB flash or emulators | | 26 | # Makefile to create a bootable FS image for USB flash or emulators |
27 | # | | 27 | # |
28 | | | 28 | |
29 | # | | 29 | # |
30 | # Required variables: | | 30 | # Required variables: |
31 | # RELEASEDIR | | 31 | # RELEASEDIR |
32 | # Should be defined in nbmake-${MACHINE} | | 32 | # Should be defined in nbmake-${MACHINE} |
33 | # IMGBASE | | 33 | # IMGBASE |
34 | # Basename of the image | | 34 | # Basename of the image |
35 | # | | 35 | # |
36 | # Optional variables: | | 36 | # Optional variables: |
37 | # BOOTDISK | | 37 | # BOOTDISK |
38 | # device name of target bootable disk specified in /etc/fstab | | 38 | # device name of target bootable disk specified in /etc/fstab |
39 | # (default: sd0) | | 39 | # (default: sd0) |
40 | # USE_MBR | | 40 | # USE_MBR |
41 | # set yes if target disk image requires MBR partition | | 41 | # set yes if target disk image requires MBR partition |
42 | # (defautl: no) | | 42 | # (defautl: no) |
43 | # USE_SUNLABEL | | 43 | # USE_SUNLABEL |
44 | # set yes if target disk image requires Sun's label | | 44 | # set yes if target disk image requires Sun's label |
45 | # (default: no) | | 45 | # (default: no) |
46 | # INSTALLBOOT_AFTER_DISKLABEL (untested) | | 46 | # INSTALLBOOT_AFTER_DISKLABEL (untested) |
47 | # set yes if the target ${MACHINE} requires disklabel | | 47 | # set yes if the target ${MACHINE} requires disklabel |
48 | # to run installboot(8), like hp300 | | 48 | # to run installboot(8), like hp300 |
49 | # (default: empty) | | 49 | # (default: empty) |
50 | # IMAGEMB | | 50 | # IMAGEMB |
51 | # target image size in MB | | 51 | # target image size in MB |
52 | # (default: 2048) | | 52 | # (default: 2048) |
53 | # SWAPMB | | 53 | # SWAPMB |
54 | # swap size in target image in MB | | 54 | # swap size in target image in MB |
55 | # (default: 128) | | 55 | # (default: 128) |
56 | # KERN_SET | | 56 | # KERN_SET |
57 | # kernel set name which should be extracted into image | | 57 | # kernel set name which should be extracted into image |
58 | # (default: kern-GENERIC) | | 58 | # (default: kern-GENERIC) |
59 | # SETS | | 59 | # SETS |
60 | # binary sets that should be extracted into image | | 60 | # binary sets that should be extracted into image |
61 | # (default: modules base etc comp games man misc tests text | | 61 | # (default: modules base etc comp games man misc tests text |
62 | # xbase xcomp xetc xfont xserver) | | 62 | # xbase xcomp xetc xfont xserver) |
63 | # SETS_DIR | | 63 | # SETS_DIR |
64 | # directory path where binary sets are stored | | 64 | # directory path where binary sets are stored |
65 | # (default: ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets) | | 65 | # (default: ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets) |
66 | # IMGFILE_EXTRA | | 66 | # IMGFILE_EXTRA |
67 | # list of additional files to be copied into images, | | 67 | # list of additional files to be copied into images, |
68 | # containing one or more tuples of the form: | | 68 | # containing one or more tuples of the form: |
69 | # FILE TARGETPATH | | 69 | # FILE TARGETPATH |
70 | # for installation image etc. | | 70 | # for installation image etc. |
71 | # (default: empty) | | 71 | # (default: empty) |
72 | # IMGDIR_EXTRA | | 72 | # IMGDIR_EXTRA |
73 | # list of additional directories to be copied into images, | | 73 | # list of additional directories to be copied into images, |
74 | # containing one or more tuples of the form: | | 74 | # containing one or more tuples of the form: |
75 | # DIR TARGETPATH | | 75 | # DIR TARGETPATH |
76 | # for installation image etc. | | 76 | # for installation image etc. |
77 | # (default: empty) | | 77 | # (default: empty) |
78 | # XXX: currently permittions in IMGDIR_EXTRA are not handled | | 78 | # XXX: currently permittions in IMGDIR_EXTRA are not handled |
79 | # IMGDIR_EXCLUDE | | 79 | # IMGDIR_EXCLUDE |
80 | # pax(1) options to exclude files which should not copied | | 80 | # pax(1) options to exclude files which should not copied |
81 | # into TARGETPATH in IMGDIR_EXTRA | | 81 | # into TARGETPATH in IMGDIR_EXTRA |
82 | # (default: empty) | | 82 | # (default: empty) |
83 | # FSTAB_IN | | 83 | # FSTAB_IN |
84 | # template file of /etc/fstab | | 84 | # template file of /etc/fstab |
85 | # (default: ${DISTRIBDIR}/common/bootimage/fstab.in) | | 85 | # (default: ${DISTRIBDIR}/common/bootimage/fstab.in) |
86 | # SPEC_IN | | 86 | # SPEC_IN |
87 | # default files of spec file for makefs(8) | | 87 | # default files of spec file for makefs(8) |
88 | # (default: ${DISTRIBDIR}/common/bootimage/spec.in) | | 88 | # (default: ${DISTRIBDIR}/common/bootimage/spec.in) |
89 | # SPEC_EXTRA | | 89 | # SPEC_EXTRA |
90 | # additional files of spec file for makefs(8) | | 90 | # additional files of spec file for makefs(8) |
91 | # (default: empty) | | 91 | # (default: empty) |
92 | # IMGMAKEFSOPTIONS | | 92 | # IMGMAKEFSOPTIONS |
93 | # options passed to makefs(8) to create root file system | | 93 | # options passed to makefs(8) to create root file system |
94 | # (default: -o bsize=16384,fsize=2048,density=8192) | | 94 | # (default: -o bsize=16384,fsize=2048,density=8192) |
95 | # PRIMARY_BOOT | | 95 | # PRIMARY_BOOT |
96 | # primary boot loader that should be installed into | | 96 | # primary boot loader that should be installed into |
97 | # the target image via installboot(8) | | 97 | # the target image via installboot(8) |
98 | # (default: empty) | | 98 | # (default: empty) |
99 | # SECONDARY_BOOT | | 99 | # SECONDARY_BOOT |
100 | # secondary bootloader that should be put into the target image | | 100 | # secondary bootloader that should be put into the target image |
101 | # (default: empty) | | 101 | # (default: empty) |
102 | # SECONDARY_BOOT_ARG | | 102 | # SECONDARY_BOOT_ARG |
103 | # extra arguments that should be passed to installboot(8) | | 103 | # extra arguments that should be passed to installboot(8) |
104 | # to specify the secondary bootloader | | 104 | # to specify the secondary bootloader |
105 | # (default: empty) | | 105 | # (default: empty) |
106 | # DISKPROTO_IN | | 106 | # DISKPROTO_IN |
107 | # template file of disklabel -R | | 107 | # template file of disklabel -R |
108 | # (default: ${DISTRIBDIR}/common/bootimage/diskproto.in | | 108 | # (default: ${DISTRIBDIR}/common/bootimage/diskproto.in |
109 | # or ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in) | | 109 | # or ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in) |
110 | # OMIT_SWAPIMG | | 110 | # OMIT_SWAPIMG |
111 | # no need to put swap partition into image (for USB stick) | | 111 | # no need to put swap partition into image (for USB stick) |
112 | # (default: no) | | 112 | # (default: no) |
113 | # | | 113 | # |
114 | | | 114 | |
115 | .include <bsd.sys.mk> # for HOST_SH | | 115 | .include <bsd.sys.mk> # for HOST_SH |
116 | .include <bsd.own.mk> # | | 116 | .include <bsd.own.mk> # |
117 | .include <bsd.endian.mk> # for TARGET_ENDIANNESS | | 117 | .include <bsd.endian.mk> # for TARGET_ENDIANNESS |
118 | | | 118 | |
119 | .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" | | 119 | .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" |
120 | | | 120 | |
121 | .if empty(IMGBASE) | | 121 | .if empty(IMGBASE) |
122 | .BEGIN: | | 122 | .BEGIN: |
123 | @echo "Error: IMGBASE is not set" | | 123 | @echo "Error: IMGBASE is not set" |
124 | @false | | 124 | @false |
125 | .endif | | 125 | .endif |
126 | .if empty(RELEASEDIR) | | | |
127 | .BEGIN: | | | |
128 | @echo "Error: RELEASEDIR is not set" | | | |
129 | @false | | | |
130 | .endif | | | |
131 | | | 126 | |
132 | # should be defined elsewhere? | | 127 | # should be defined elsewhere? |
133 | CAT?= cat | | 128 | CAT?= cat |
134 | CHMOD?= chmod | | 129 | CHMOD?= chmod |
135 | CP?= cp | | 130 | CP?= cp |
136 | DD?= dd | | 131 | DD?= dd |
137 | MKDIR?= mkdir -p | | 132 | MKDIR?= mkdir -p |
138 | RM?= rm | | 133 | RM?= rm |
139 | | | 134 | |
140 | # | | 135 | # |
141 | # common definitions for image | | 136 | # common definitions for image |
142 | # | | 137 | # |
143 | BOOTDISK?= sd0 | | 138 | BOOTDISK?= sd0 |
144 | USE_MBR?= no | | 139 | USE_MBR?= no |
145 | USE_SUNLABEL?= no | | 140 | USE_SUNLABEL?= no |
146 | INSTALLBOOT_AFTER_DISKLABEL?= no | | 141 | INSTALLBOOT_AFTER_DISKLABEL?= no |
147 | | | 142 | |
148 | # | | 143 | # |
149 | # size parameters for image | | 144 | # size parameters for image |
150 | # | | 145 | # |
151 | IMAGEMB?= 2048 # 2048MB | | 146 | IMAGEMB?= 2048 # 2048MB |
152 | SWAPMB?= 128 # 128MB | | 147 | SWAPMB?= 128 # 128MB |
153 | | | 148 | |
154 | IMAGESECTORS!= expr ${IMAGEMB} \* 1024 \* 1024 / 512 | | 149 | IMAGESECTORS!= expr ${IMAGEMB} \* 1024 \* 1024 / 512 |
155 | SWAPSECTORS!= expr ${SWAPMB} \* 1024 \* 1024 / 512 | | 150 | SWAPSECTORS!= expr ${SWAPMB} \* 1024 \* 1024 / 512 |
156 | | | 151 | |
157 | .if ${USE_MBR} == "no" | | 152 | .if ${USE_MBR} == "no" |
158 | LABELSECTORS?= 0 | | 153 | LABELSECTORS?= 0 |
159 | .else | | 154 | .else |
160 | #LABELSECTORS?= 63 # historical | | 155 | #LABELSECTORS?= 63 # historical |
161 | #LABELSECTORS?= 32 # 16KB aligned | | 156 | #LABELSECTORS?= 32 # 16KB aligned |
162 | LABELSECTORS?= 2048 # 1MB aligned for modern flash devices | | 157 | LABELSECTORS?= 2048 # 1MB aligned for modern flash devices |
163 | .endif | | 158 | .endif |
164 | | | 159 | |
165 | FSSECTORS!= expr ${IMAGESECTORS} - ${SWAPSECTORS} - ${LABELSECTORS} | | 160 | FSSECTORS!= expr ${IMAGESECTORS} - ${SWAPSECTORS} - ${LABELSECTORS} |
166 | FSSIZE!= expr ${FSSECTORS} \* 512 | | 161 | FSSIZE!= expr ${FSSECTORS} \* 512 |
167 | | | 162 | |
168 | # parameters for disklabel and MBR | | 163 | # parameters for disklabel and MBR |
169 | HEADS= 64 | | 164 | HEADS= 64 |
170 | SECTORS= 32 | | 165 | SECTORS= 32 |
171 | CYLINDERS!= expr ${IMAGESECTORS} / \( ${HEADS} \* ${SECTORS} \) | | 166 | CYLINDERS!= expr ${IMAGESECTORS} / \( ${HEADS} \* ${SECTORS} \) |
172 | SECPERCYLINDERS!= expr ${HEADS} \* ${SECTORS} | | 167 | SECPERCYLINDERS!= expr ${HEADS} \* ${SECTORS} |
173 | MBRHEADS= 255 | | 168 | MBRHEADS= 255 |
174 | MBRSECTORS= 63 | | 169 | MBRSECTORS= 63 |
175 | MBRCYLINDERS!= expr ${IMAGESECTORS} / \( ${MBRHEADS} \* ${MBRSECTORS} \) | | 170 | MBRCYLINDERS!= expr ${IMAGESECTORS} / \( ${MBRHEADS} \* ${MBRSECTORS} \) |
176 | MBRNETBSD= 169 | | 171 | MBRNETBSD= 169 |
177 | | | 172 | |
178 | BSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS} | | 173 | BSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS} |
179 | FSOFFSET= ${LABELSECTORS} | | 174 | FSOFFSET= ${LABELSECTORS} |
180 | SWAPOFFSET!= expr ${LABELSECTORS} + ${FSSECTORS} | | 175 | SWAPOFFSET!= expr ${LABELSECTORS} + ${FSSECTORS} |
181 | | | 176 | |
182 | # parameters for sunlabel | | 177 | # parameters for sunlabel |
183 | FSCYLINDERS!= expr ${FSSECTORS} / \( ${HEADS} \* ${SECTORS} \) | | 178 | FSCYLINDERS!= expr ${FSSECTORS} / \( ${HEADS} \* ${SECTORS} \) |
184 | SWAPCYLINDERS!= expr ${SWAPSECTORS} / \( ${HEADS} \* ${SECTORS} \) | | 179 | SWAPCYLINDERS!= expr ${SWAPSECTORS} / \( ${HEADS} \* ${SECTORS} \) |
185 | | | 180 | |
186 | | | 181 | |
187 | # | | 182 | # |
188 | # definitions to create root fs | | 183 | # definitions to create root fs |
189 | # | | 184 | # |
190 | SETS_DEFAULT= modules base etc comp games man misc tests text | | 185 | SETS_DEFAULT= modules base etc comp games man misc tests text |
191 | .if ${MKX11} != "no" | | 186 | .if ${MKX11} != "no" |
192 | SETS_DEFAULT+= xbase xcomp xetc xfont xserver | | 187 | SETS_DEFAULT+= xbase xcomp xetc xfont xserver |
193 | .endif | | 188 | .endif |
194 | | | 189 | |
195 | KERN_SET?= kern-GENERIC | | 190 | KERN_SET?= kern-GENERIC |
196 | SETS?= ${SETS_DEFAULT} | | 191 | SETS?= ${SETS_DEFAULT} |
197 | IMG_SETS= ${KERN_SET} ${SETS} | | 192 | IMG_SETS= ${KERN_SET} ${SETS} |
198 | SETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets | | 193 | SETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets |
199 | | | 194 | |
200 | FSTAB_IN?= ${DISTRIBDIR}/common/bootimage/fstab.in | | 195 | FSTAB_IN?= ${DISTRIBDIR}/common/bootimage/fstab.in |
201 | SPEC_IN?= ${DISTRIBDIR}/common/bootimage/spec.in | | 196 | SPEC_IN?= ${DISTRIBDIR}/common/bootimage/spec.in |
202 | | | 197 | |
203 | IMGMAKEFSOPTIONS?= -o bsize=16384,fsize=2048,density=8192 | | 198 | IMGMAKEFSOPTIONS?= -o bsize=16384,fsize=2048,density=8192 |
204 | | | 199 | |
205 | WORKDIR?= work | | 200 | WORKDIR?= work |
206 | WORKSPEC?= work.spec | | 201 | WORKSPEC?= work.spec |
207 | WORKFSTAB?= work.fstab | | 202 | WORKFSTAB?= work.fstab |
208 | WORKRCCONF?= work.rc.conf | | 203 | WORKRCCONF?= work.rc.conf |
209 | WORKFS?= work.rootfs | | 204 | WORKFS?= work.rootfs |
210 | TARGETFS?= imgroot.fs | | 205 | TARGETFS?= imgroot.fs |
211 | | | 206 | |
212 | CLEANFILES+= ${WORKSPEC} ${WORKFSTAB} ${WORKRCCONF} ${WORKFS} | | 207 | CLEANFILES+= ${WORKSPEC} ${WORKFSTAB} ${WORKRCCONF} ${WORKFS} |
213 | CLEANFILES+= ${TARGETFS} | | 208 | CLEANFILES+= ${TARGETFS} |
214 | | | 209 | |
215 | # | | 210 | # |
216 | # create root file system for the image | | 211 | # create root file system for the image |
217 | # | | 212 | # |
218 | ${TARGETFS}: prepare_md_post | | 213 | ${TARGETFS}: prepare_md_post |
219 | @if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \ | | 214 | @if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \ |
220 | echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \ | | 215 | echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \ |
221 | false; \ | | 216 | false; \ |
222 | fi; | | 217 | fi; |
223 | @${MKDIR} ${WORKDIR} | | 218 | @${MKDIR} ${WORKDIR} |
224 | .for set in ${IMG_SETS} | | 219 | .for set in ${IMG_SETS} |
225 | @if [ ! -f ${SETS_DIR}/${set}.tgz ]; then \ | | 220 | @if [ ! -f ${SETS_DIR}/${set}.tgz ]; then \ |
226 | echo "Missing ${SETS_DIR}/${set}.tgz, aborting"; \ | | 221 | echo "Missing ${SETS_DIR}/${set}.tgz, aborting"; \ |
227 | false; \ | | 222 | false; \ |
228 | fi | | 223 | fi |
229 | @echo Extracting ${set}.tgz ... | | 224 | @echo Extracting ${set}.tgz ... |
230 | @(cd ${WORKDIR}; ${TOOL_PAX} -rnz -f ${SETS_DIR}/${set}.tgz .) | | 225 | @(cd ${WORKDIR}; ${TOOL_PAX} -rnz -f ${SETS_DIR}/${set}.tgz .) |
231 | .endfor | | 226 | .endfor |
232 | .if defined(SECONDARY_BOOT) | | 227 | .if defined(SECONDARY_BOOT) |
233 | @echo Copying secondary boot... | | 228 | @echo Copying secondary boot... |
234 | ${CP} -f ${WORKDIR}/usr/mdec/${SECONDARY_BOOT} ${WORKDIR} | | 229 | ${CP} -f ${WORKDIR}/usr/mdec/${SECONDARY_BOOT} ${WORKDIR} |
235 | .endif | | 230 | .endif |
236 | @echo Preparing /etc/fstab ... | | 231 | @echo Preparing /etc/fstab ... |
237 | ${TOOL_SED} "s/@@BOOTDISK@@/${BOOTDISK}/" < ${FSTAB_IN} > ${WORKFSTAB} | | 232 | ${TOOL_SED} "s/@@BOOTDISK@@/${BOOTDISK}/" < ${FSTAB_IN} > ${WORKFSTAB} |
238 | ${CP} ${WORKFSTAB} ${WORKDIR}/etc/fstab | | 233 | ${CP} ${WORKFSTAB} ${WORKDIR}/etc/fstab |
239 | @echo Setting rc_configured=YES in /etc/rc.conf ... | | 234 | @echo Setting rc_configured=YES in /etc/rc.conf ... |
240 | ${TOOL_SED} "s/rc_configured=NO/rc_configured=YES/" \ | | 235 | ${TOOL_SED} "s/rc_configured=NO/rc_configured=YES/" \ |
241 | < ${WORKDIR}/etc/rc.conf > ${WORKRCCONF} | | 236 | < ${WORKDIR}/etc/rc.conf > ${WORKRCCONF} |
242 | ${CP} ${WORKRCCONF} ${WORKDIR}/etc/rc.conf | | 237 | ${CP} ${WORKRCCONF} ${WORKDIR}/etc/rc.conf |
243 | .if defined(IMGDIR_EXTRA) | | 238 | .if defined(IMGDIR_EXTRA) |
244 | @echo Copying extra dirs... | | 239 | @echo Copying extra dirs... |
245 | .for _SRCDIR _TARGET in ${IMGDIR_EXTRA} | | 240 | .for _SRCDIR _TARGET in ${IMGDIR_EXTRA} |
246 | @if [ ! -d ${_SRCDIR} ]; then \ | | 241 | @if [ ! -d ${_SRCDIR} ]; then \ |
247 | echo "${_SRCDIR} is not directory, aborting"; \ | | 242 | echo "${_SRCDIR} is not directory, aborting"; \ |
248 | false; \ | | 243 | false; \ |
249 | fi | | 244 | fi |
250 | ${MKDIR} ${WORKDIR}/${_TARGET} | | 245 | ${MKDIR} ${WORKDIR}/${_TARGET} |
251 | (cd ${_SRCDIR} ; \ | | 246 | (cd ${_SRCDIR} ; \ |
252 | ${TOOL_PAX} -rw -pe -v \ | | 247 | ${TOOL_PAX} -rw -pe -v \ |
253 | ${IMGDIR_EXCLUDE} \ | | 248 | ${IMGDIR_EXCLUDE} \ |
254 | . ${.OBJDIR}/${WORKDIR}/${_TARGET} ) | | 249 | . ${.OBJDIR}/${WORKDIR}/${_TARGET} ) |
255 | .endfor | | 250 | .endfor |
256 | .endif | | 251 | .endif |
257 | .if defined(IMGFILE_EXTRA) | | 252 | .if defined(IMGFILE_EXTRA) |
258 | @echo Copying extra files... | | 253 | @echo Copying extra files... |
259 | .for _SRC _TARGET in ${IMGFILE_EXTRA} | | 254 | .for _SRC _TARGET in ${IMGFILE_EXTRA} |
260 | @if [ ! -f ${_SRC} ]; then \ | | 255 | @if [ ! -f ${_SRC} ]; then \ |
261 | echo "${_SRC} in IMGFILE_EXTRA not found, aborting"; \ | | 256 | echo "${_SRC} in IMGFILE_EXTRA not found, aborting"; \ |
262 | false; \ | | 257 | false; \ |
263 | fi | | 258 | fi |
264 | @if [ -f ${_SRC} ]; then \ | | 259 | @if [ -f ${_SRC} ]; then \ |
265 | echo ${CP} ${_SRC} ${WORKDIR}/${_TARGET}; \ | | 260 | echo ${CP} ${_SRC} ${WORKDIR}/${_TARGET}; \ |
266 | ${CP} ${_SRC} ${WORKDIR}/${_TARGET}; \ | | 261 | ${CP} ${_SRC} ${WORKDIR}/${_TARGET}; \ |
267 | fi | | 262 | fi |
268 | .endfor | | 263 | .endfor |
269 | .endif | | 264 | .endif |
270 | @echo Preparing spec files for makefs... | | 265 | @echo Preparing spec files for makefs... |
271 | ${RM} -f ${WORKSPEC} | | 266 | ${RM} -f ${WORKSPEC} |
272 | cat ${WORKDIR}/etc/mtree/* | \ | | 267 | cat ${WORKDIR}/etc/mtree/* | \ |
273 | ${TOOL_SED} -e 's/ size=[0-9]*//' > ${WORKSPEC} | | 268 | ${TOOL_SED} -e 's/ size=[0-9]*//' > ${WORKSPEC} |
274 | ${HOST_SH} ${WORKDIR}/dev/MAKEDEV -s all | \ | | 269 | ${HOST_SH} ${WORKDIR}/dev/MAKEDEV -s all | \ |
275 | ${TOOL_SED} -e '/^\. type=dir/d' -e 's,^\.,./dev,' >> ${WORKSPEC} | | 270 | ${TOOL_SED} -e '/^\. type=dir/d' -e 's,^\.,./dev,' >> ${WORKSPEC} |
276 | cat ${SPEC_IN} >> ${WORKSPEC} | | 271 | cat ${SPEC_IN} >> ${WORKSPEC} |
277 | .if defined(SECONDARY_BOOT) | | 272 | .if defined(SECONDARY_BOOT) |
278 | echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \ | | 273 | echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \ |
279 | >> ${WORKSPEC} | | 274 | >> ${WORKSPEC} |
280 | .endif | | 275 | .endif |
281 | .if defined(SPEC_EXTRA) | | 276 | .if defined(SPEC_EXTRA) |
282 | cat ${SPEC_EXTRA} >> ${WORKSPEC} | | 277 | cat ${SPEC_EXTRA} >> ${WORKSPEC} |
283 | .endif | | 278 | .endif |
284 | @echo Createing rootfs... | | 279 | @echo Createing rootfs... |
285 | # XXX /var/spool/ftp/hidden is unreadable | | 280 | # XXX /var/spool/ftp/hidden is unreadable |
286 | ${CHMOD} +r ${WORKDIR}/var/spool/ftp/hidden | | 281 | ${CHMOD} +r ${WORKDIR}/var/spool/ftp/hidden |
287 | ${TOOL_MAKEFS} -M ${FSSIZE} -m ${FSSIZE} \ | | 282 | ${TOOL_MAKEFS} -M ${FSSIZE} -m ${FSSIZE} \ |
288 | -B ${TARGET_ENDIANNESS} \ | | 283 | -B ${TARGET_ENDIANNESS} \ |
289 | -F ${WORKSPEC} -N ${WORKDIR}/etc \ | | 284 | -F ${WORKSPEC} -N ${WORKDIR}/etc \ |
290 | ${IMGMAKEFSOPTIONS} \ | | 285 | ${IMGMAKEFSOPTIONS} \ |
291 | ${WORKFS} ${WORKDIR} | | 286 | ${WORKFS} ${WORKDIR} |
292 | .if !empty(PRIMARY_BOOT) && ${INSTALLBOOT_AFTER_DISKLABEL} == "no" | | 287 | .if !empty(PRIMARY_BOOT) && ${INSTALLBOOT_AFTER_DISKLABEL} == "no" |
293 | ${TOOL_INSTALLBOOT} -vm ${MACHINE} ${WORKFS} \ | | 288 | ${TOOL_INSTALLBOOT} -vm ${MACHINE} ${WORKFS} \ |
294 | ${WORKDIR}/usr/mdec/${PRIMARY_BOOT} ${SECONDARY_BOOT_ARG} | | 289 | ${WORKDIR}/usr/mdec/${PRIMARY_BOOT} ${SECONDARY_BOOT_ARG} |
295 | .endif | | 290 | .endif |
296 | @echo done. | | 291 | @echo done. |
297 | mv ${WORKFS} ${.TARGET} | | 292 | mv ${WORKFS} ${.TARGET} |
298 | | | 293 | |
299 | # | | 294 | # |
300 | # definitions to create image | | 295 | # definitions to create image |
301 | # | | 296 | # |
302 | .if ${USE_MBR} != "no" | | 297 | .if ${USE_MBR} != "no" |
303 | DISKPROTO_IN?= ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in | | 298 | DISKPROTO_IN?= ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in |
304 | .else | | 299 | .else |
305 | DISKPROTO_IN?= ${DISTRIBDIR}/common/bootimage/diskproto.in | | 300 | DISKPROTO_IN?= ${DISTRIBDIR}/common/bootimage/diskproto.in |
306 | .endif | | 301 | .endif |
307 | | | 302 | |
308 | OMIT_SWAPIMG?= no | | 303 | OMIT_SWAPIMG?= no |
309 | | | 304 | |
310 | WORKMBR?= work.mbr | | 305 | WORKMBR?= work.mbr |
311 | WORKSWAP?= work.swap | | 306 | WORKSWAP?= work.swap |
312 | WORKLABEL?= work.diskproto | | 307 | WORKLABEL?= work.diskproto |
313 | WORKIMG?= work.img | | 308 | WORKIMG?= work.img |
314 | | | 309 | |
315 | CLEANFILES+= ${WORKMBR} ${WORKSWAP} | | 310 | CLEANFILES+= ${WORKMBR} ${WORKSWAP} |
316 | CLEANFILES+= ${WORKLABEL}.tmp ${WORKLABEL} | | 311 | CLEANFILES+= ${WORKLABEL}.tmp ${WORKLABEL} |
317 | CLEANFILES+= ${WORKIMG} ${IMGBASE}.img | | 312 | CLEANFILES+= ${WORKIMG} ${IMGBASE}.img |
318 | | | 313 | |
319 | ${WORKLABEL}: | | 314 | ${WORKLABEL}: |
320 | ${TOOL_SED} \ | | 315 | ${TOOL_SED} \ |
321 | -e "s/@@SECTORS@@/${SECTORS}/" \ | | 316 | -e "s/@@SECTORS@@/${SECTORS}/" \ |
322 | -e "s/@@HEADS@@/${HEADS}/" \ | | 317 | -e "s/@@HEADS@@/${HEADS}/" \ |
323 | -e "s/@@SECPERCYLINDERS@@/${SECPERCYLINDERS}/" \ | | 318 | -e "s/@@SECPERCYLINDERS@@/${SECPERCYLINDERS}/" \ |
324 | -e "s/@@CYLINDERS@@/${CYLINDERS}/" \ | | 319 | -e "s/@@CYLINDERS@@/${CYLINDERS}/" \ |
325 | -e "s/@@IMAGESECTORS@@/${IMAGESECTORS}/" \ | | 320 | -e "s/@@IMAGESECTORS@@/${IMAGESECTORS}/" \ |
326 | -e "s/@@FSSECTORS@@/${FSSECTORS}/" \ | | 321 | -e "s/@@FSSECTORS@@/${FSSECTORS}/" \ |
327 | -e "s/@@FSOFFSET@@/${FSOFFSET}/" \ | | 322 | -e "s/@@FSOFFSET@@/${FSOFFSET}/" \ |
328 | -e "s/@@SWAPSECTORS@@/${SWAPSECTORS}/" \ | | 323 | -e "s/@@SWAPSECTORS@@/${SWAPSECTORS}/" \ |
329 | -e "s/@@SWAPOFFSET@@/${SWAPOFFSET}/" \ | | 324 | -e "s/@@SWAPOFFSET@@/${SWAPOFFSET}/" \ |
330 | -e "s/@@BSDPARTSECTORS@@/${BSDPARTSECTORS}/" \ | | 325 | -e "s/@@BSDPARTSECTORS@@/${BSDPARTSECTORS}/" \ |
331 | < ${DISKPROTO_IN} > ${WORKLABEL}.tmp | | 326 | < ${DISKPROTO_IN} > ${WORKLABEL}.tmp |
332 | mv ${WORKLABEL}.tmp ${WORKLABEL} | | 327 | mv ${WORKLABEL}.tmp ${WORKLABEL} |
333 | | | 328 | |
334 | ${IMGBASE}.img: ${TARGETFS} ${WORKLABEL} | | 329 | ${IMGBASE}.img: ${TARGETFS} ${WORKLABEL} |
335 | .if ${LABELSECTORS} != "0" | | 330 | .if ${LABELSECTORS} != "0" |
336 | @echo creating MBR labels... | | 331 | @echo creating MBR labels... |
337 | ${DD} if=/dev/zero of=${WORKMBR} seek=$$((${IMAGESECTORS} - 1)) count=1 | | 332 | ${DD} if=/dev/zero of=${WORKMBR} seek=$$((${IMAGESECTORS} - 1)) count=1 |
338 | ${TOOL_FDISK} -f -u \ | | 333 | ${TOOL_FDISK} -f -u \ |
339 | -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS} \ | | 334 | -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS} \ |
340 | -0 -a -s ${MBRNETBSD}/${FSOFFSET}/${BSDPARTSECTORS} \ | | 335 | -0 -a -s ${MBRNETBSD}/${FSOFFSET}/${BSDPARTSECTORS} \ |
341 | -i -c ${WORKDIR}/usr/mdec/mbr \ | | 336 | -i -c ${WORKDIR}/usr/mdec/mbr \ |
342 | -F ${WORKMBR} | | 337 | -F ${WORKMBR} |
343 | ${DD} if=${WORKMBR} count=${LABELSECTORS} | \ | | 338 | ${DD} if=${WORKMBR} count=${LABELSECTORS} | \ |
344 | ${CAT} - ${TARGETFS} > ${WORKIMG} | | 339 | ${CAT} - ${TARGETFS} > ${WORKIMG} |
345 | .else | | 340 | .else |
346 | ${CP} ${TARGETFS} ${WORKIMG} | | 341 | ${CP} ${TARGETFS} ${WORKIMG} |
347 | .endif | | 342 | .endif |
348 | .if ${OMIT_SWAPIMG} == "no" | | 343 | .if ${OMIT_SWAPIMG} == "no" |
349 | ${DD} if=/dev/zero of=${WORKSWAP} seek=$$((${SWAPSECTORS} - 1)) count=1 | | 344 | ${DD} if=/dev/zero of=${WORKSWAP} seek=$$((${SWAPSECTORS} - 1)) count=1 |
350 | ${CAT} ${WORKSWAP} >> ${WORKIMG} | | 345 | ${CAT} ${WORKSWAP} >> ${WORKIMG} |
351 | .endif | | 346 | .endif |
352 | .if ${USE_SUNLABEL} != "no" | | 347 | .if ${USE_SUNLABEL} != "no" |
353 | @echo Creating sun disklabel... | | 348 | @echo Creating sun disklabel... |
354 | printf 'V ncyl %d\nV nhead %d\nV nsect %d\na %d %d/0/0\nb %d %d/0/0\nW\n' \ | | 349 | printf 'V ncyl %d\nV nhead %d\nV nsect %d\na %d %d/0/0\nb %d %d/0/0\nW\n' \ |
355 | ${CYLINDERS} ${HEADS} ${SECTORS} \ | | 350 | ${CYLINDERS} ${HEADS} ${SECTORS} \ |
356 | ${FSOFFSET} ${FSCYLINDERS} ${FSCYLINDERS} ${SWAPCYLINDERS} | \ | | 351 | ${FSOFFSET} ${FSCYLINDERS} ${FSCYLINDERS} ${SWAPCYLINDERS} | \ |
357 | ${TOOL_SUNLABEL} -nq ${WORKIMG} | | 352 | ${TOOL_SUNLABEL} -nq ${WORKIMG} |
358 | .endif | | 353 | .endif |
359 | ${TOOL_DISKLABEL} -R -F ${WORKIMG} ${WORKLABEL} | | 354 | ${TOOL_DISKLABEL} -R -F ${WORKIMG} ${WORKLABEL} |
360 | .if !empty(PRIMARY_BOOT) && ${INSTALLBOOT_AFTER_DISKLABEL} != "no" | | 355 | .if !empty(PRIMARY_BOOT) && ${INSTALLBOOT_AFTER_DISKLABEL} != "no" |
361 | ${TOOL_INSTALLBOOT} -vm ${MACHINE} ${WORKIMG} \ | | 356 | ${TOOL_INSTALLBOOT} -vm ${MACHINE} ${WORKIMG} \ |
362 | ${WORKDIR}/usr/mdec/${PRIMARY_BOOT} | | 357 | ${WORKDIR}/usr/mdec/${PRIMARY_BOOT} |
363 | .endif | | 358 | .endif |
364 | mv ${WORKIMG} ${.TARGET} | | 359 | mv ${WORKIMG} ${.TARGET} |
365 | | | 360 | |
366 | | | 361 | |
367 | CLEANFILES+= ${IMGBASE}.img.gz ${IMGBASE}.img.gz.tmp | | 362 | CLEANFILES+= ${IMGBASE}.img.gz ${IMGBASE}.img.gz.tmp |
368 | | | 363 | |
369 | ${IMGBASE}.img.gz: ${IMGBASE}.img | | 364 | ${IMGBASE}.img.gz: ${IMGBASE}.img |
370 | ${TOOL_GZIP} -9c ${IMGBASE}.img > ${.TARGET}.tmp | | 365 | ${TOOL_GZIP} -9c ${IMGBASE}.img > ${.TARGET}.tmp |
371 | mv ${.TARGET}.tmp ${.TARGET} | | 366 | mv ${.TARGET}.tmp ${.TARGET} |
372 | | | 367 | |
373 | clean: | | 368 | clean: |
374 | @if [ -d ${WORKDIR}/var/spool/ftp/hidden ]; then \ | | 369 | @if [ -d ${WORKDIR}/var/spool/ftp/hidden ]; then \ |
375 | ${CHMOD} +r ${WORKDIR}/var/spool/ftp/hidden; \ | | 370 | ${CHMOD} +r ${WORKDIR}/var/spool/ftp/hidden; \ |
376 | fi # XXX | | 371 | fi # XXX |
377 | ${RM} -fr ${WORKDIR} | | 372 | ${RM} -fr ${WORKDIR} |
378 | | | 373 | |
379 | prepare_md_post: .PHONY | | 374 | prepare_md_post: .PHONY |
380 | image_md_post: .PHONY | | 375 | image_md_post: .PHONY |
381 | image_md_pre: .PHONY | | 376 | image_md_pre: .PHONY |
382 | | | 377 | |
383 | .include <bsd.prog.mk> | | 378 | .include <bsd.prog.mk> |