Sun Jan 22 16:50:00 2012 UTC ()
Fix checks for RELEASEDIR (and xxxxIMGBASE) variables to perform it
only on live_image or install_image targets.  PR toolchain/45864


(tsutsui)
diff -r1.1 -r1.2 src/distrib/common/bootimage/Makefile.bootimage
diff -r1.1 -r1.2 src/distrib/common/bootimage/Makefile.installimage
diff -r1.1 -r1.2 src/distrib/common/bootimage/Makefile.liveimage

cvs diff -r1.1 -r1.2 src/distrib/common/bootimage/Makefile.bootimage (switch to unified diff)

--- src/distrib/common/bootimage/Makefile.bootimage 2012/01/22 03:53:30 1.1
+++ src/distrib/common/bootimage/Makefile.bootimage 2012/01/22 16:50:00 1.2
@@ -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?
133CAT?= cat 128CAT?= cat
134CHMOD?= chmod 129CHMOD?= chmod
135CP?= cp 130CP?= cp
136DD?= dd 131DD?= dd
137MKDIR?= mkdir -p 132MKDIR?= mkdir -p
138RM?= rm 133RM?= rm
139 134
140# 135#
141# common definitions for image 136# common definitions for image
142# 137#
143BOOTDISK?= sd0 138BOOTDISK?= sd0
144USE_MBR?= no 139USE_MBR?= no
145USE_SUNLABEL?= no 140USE_SUNLABEL?= no
146INSTALLBOOT_AFTER_DISKLABEL?= no 141INSTALLBOOT_AFTER_DISKLABEL?= no
147 142
148# 143#
149# size parameters for image 144# size parameters for image
150# 145#
151IMAGEMB?= 2048 # 2048MB 146IMAGEMB?= 2048 # 2048MB
152SWAPMB?= 128 # 128MB 147SWAPMB?= 128 # 128MB
153 148
154IMAGESECTORS!= expr ${IMAGEMB} \* 1024 \* 1024 / 512 149IMAGESECTORS!= expr ${IMAGEMB} \* 1024 \* 1024 / 512
155SWAPSECTORS!= expr ${SWAPMB} \* 1024 \* 1024 / 512 150SWAPSECTORS!= expr ${SWAPMB} \* 1024 \* 1024 / 512
156 151
157.if ${USE_MBR} == "no" 152.if ${USE_MBR} == "no"
158LABELSECTORS?= 0 153LABELSECTORS?= 0
159.else 154.else
160#LABELSECTORS?= 63 # historical 155#LABELSECTORS?= 63 # historical
161#LABELSECTORS?= 32 # 16KB aligned 156#LABELSECTORS?= 32 # 16KB aligned
162LABELSECTORS?= 2048 # 1MB aligned for modern flash devices 157LABELSECTORS?= 2048 # 1MB aligned for modern flash devices
163.endif 158.endif
164 159
165FSSECTORS!= expr ${IMAGESECTORS} - ${SWAPSECTORS} - ${LABELSECTORS} 160FSSECTORS!= expr ${IMAGESECTORS} - ${SWAPSECTORS} - ${LABELSECTORS}
166FSSIZE!= expr ${FSSECTORS} \* 512 161FSSIZE!= expr ${FSSECTORS} \* 512
167 162
168# parameters for disklabel and MBR 163# parameters for disklabel and MBR
169HEADS= 64 164HEADS= 64
170SECTORS= 32 165SECTORS= 32
171CYLINDERS!= expr ${IMAGESECTORS} / \( ${HEADS} \* ${SECTORS} \) 166CYLINDERS!= expr ${IMAGESECTORS} / \( ${HEADS} \* ${SECTORS} \)
172SECPERCYLINDERS!= expr ${HEADS} \* ${SECTORS} 167SECPERCYLINDERS!= expr ${HEADS} \* ${SECTORS}
173MBRHEADS= 255 168MBRHEADS= 255
174MBRSECTORS= 63 169MBRSECTORS= 63
175MBRCYLINDERS!= expr ${IMAGESECTORS} / \( ${MBRHEADS} \* ${MBRSECTORS} \) 170MBRCYLINDERS!= expr ${IMAGESECTORS} / \( ${MBRHEADS} \* ${MBRSECTORS} \)
176MBRNETBSD= 169 171MBRNETBSD= 169
177 172
178BSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS} 173BSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS}
179FSOFFSET= ${LABELSECTORS} 174FSOFFSET= ${LABELSECTORS}
180SWAPOFFSET!= expr ${LABELSECTORS} + ${FSSECTORS} 175SWAPOFFSET!= expr ${LABELSECTORS} + ${FSSECTORS}
181 176
182# parameters for sunlabel 177# parameters for sunlabel
183FSCYLINDERS!= expr ${FSSECTORS} / \( ${HEADS} \* ${SECTORS} \) 178FSCYLINDERS!= expr ${FSSECTORS} / \( ${HEADS} \* ${SECTORS} \)
184SWAPCYLINDERS!= expr ${SWAPSECTORS} / \( ${HEADS} \* ${SECTORS} \) 179SWAPCYLINDERS!= expr ${SWAPSECTORS} / \( ${HEADS} \* ${SECTORS} \)
185 180
186 181
187# 182#
188# definitions to create root fs 183# definitions to create root fs
189# 184#
190SETS_DEFAULT= modules base etc comp games man misc tests text 185SETS_DEFAULT= modules base etc comp games man misc tests text
191.if ${MKX11} != "no" 186.if ${MKX11} != "no"
192SETS_DEFAULT+= xbase xcomp xetc xfont xserver 187SETS_DEFAULT+= xbase xcomp xetc xfont xserver
193.endif 188.endif
194 189
195KERN_SET?= kern-GENERIC 190KERN_SET?= kern-GENERIC
196SETS?= ${SETS_DEFAULT} 191SETS?= ${SETS_DEFAULT}
197IMG_SETS= ${KERN_SET} ${SETS} 192IMG_SETS= ${KERN_SET} ${SETS}
198SETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets 193SETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
199 194
200FSTAB_IN?= ${DISTRIBDIR}/common/bootimage/fstab.in 195FSTAB_IN?= ${DISTRIBDIR}/common/bootimage/fstab.in
201SPEC_IN?= ${DISTRIBDIR}/common/bootimage/spec.in 196SPEC_IN?= ${DISTRIBDIR}/common/bootimage/spec.in
202 197
203IMGMAKEFSOPTIONS?= -o bsize=16384,fsize=2048,density=8192 198IMGMAKEFSOPTIONS?= -o bsize=16384,fsize=2048,density=8192
204 199
205WORKDIR?= work 200WORKDIR?= work
206WORKSPEC?= work.spec 201WORKSPEC?= work.spec
207WORKFSTAB?= work.fstab 202WORKFSTAB?= work.fstab
208WORKRCCONF?= work.rc.conf 203WORKRCCONF?= work.rc.conf
209WORKFS?= work.rootfs 204WORKFS?= work.rootfs
210TARGETFS?= imgroot.fs 205TARGETFS?= imgroot.fs
211 206
212CLEANFILES+= ${WORKSPEC} ${WORKFSTAB} ${WORKRCCONF} ${WORKFS} 207CLEANFILES+= ${WORKSPEC} ${WORKFSTAB} ${WORKRCCONF} ${WORKFS}
213CLEANFILES+= ${TARGETFS} 208CLEANFILES+= ${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"
303DISKPROTO_IN?= ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in 298DISKPROTO_IN?= ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in
304.else 299.else
305DISKPROTO_IN?= ${DISTRIBDIR}/common/bootimage/diskproto.in 300DISKPROTO_IN?= ${DISTRIBDIR}/common/bootimage/diskproto.in
306.endif 301.endif
307 302
308OMIT_SWAPIMG?= no 303OMIT_SWAPIMG?= no
309 304
310WORKMBR?= work.mbr 305WORKMBR?= work.mbr
311WORKSWAP?= work.swap 306WORKSWAP?= work.swap
312WORKLABEL?= work.diskproto 307WORKLABEL?= work.diskproto
313WORKIMG?= work.img 308WORKIMG?= work.img
314 309
315CLEANFILES+= ${WORKMBR} ${WORKSWAP} 310CLEANFILES+= ${WORKMBR} ${WORKSWAP}
316CLEANFILES+= ${WORKLABEL}.tmp ${WORKLABEL} 311CLEANFILES+= ${WORKLABEL}.tmp ${WORKLABEL}
317CLEANFILES+= ${WORKIMG} ${IMGBASE}.img 312CLEANFILES+= ${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
367CLEANFILES+= ${IMGBASE}.img.gz ${IMGBASE}.img.gz.tmp 362CLEANFILES+= ${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
373clean: 368clean:
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
379prepare_md_post: .PHONY 374prepare_md_post: .PHONY
380image_md_post: .PHONY 375image_md_post: .PHONY
381image_md_pre: .PHONY 376image_md_pre: .PHONY
382 377
383.include <bsd.prog.mk> 378.include <bsd.prog.mk>

cvs diff -r1.1 -r1.2 src/distrib/common/bootimage/Makefile.installimage (switch to unified diff)

--- src/distrib/common/bootimage/Makefile.installimage 2012/01/22 03:53:30 1.1
+++ src/distrib/common/bootimage/Makefile.installimage 2012/01/22 16:50:00 1.2
@@ -1,63 +1,62 @@ @@ -1,63 +1,62 @@
1# $NetBSD: Makefile.installimage,v 1.1 2012/01/22 03:53:30 tsutsui Exp $ 1# $NetBSD: Makefile.installimage,v 1.2 2012/01/22 16:50:00 tsutsui Exp $
2# 2#
3# Common Makefile to create a bootable installation image for USB flash etc. 3# Common Makefile to create a bootable installation image for USB flash etc.
4# 4#
5 5
6# 6#
7# Required variables: 7# Required variables:
8# INSTIMGBASE 8# INSTIMGBASE
9# Basename of the liveimage 9# Basename of the liveimage
10# 10#
11# See Makefile.bootimage for other variables. 11# See Makefile.bootimage for other variables.
12# 12#
13 13
14.if empty(INSTIMGBASE) 14.if !target(check_INSTIMGBASE)
15.BEGIN: 15check_INSTIMGBASE: .PHONY .NOTMAIN
 16.if !defined(INSTIMGBASE)
16 @echo "Error: INSTIMGBASE is not set" 17 @echo "Error: INSTIMGBASE is not set"
17 @false 18 @false
 19.else
 20 @true
18.endif 21.endif
19.if empty(RELEASEDIR) 
20.BEGIN: 
21 @echo "Error: RELEASEDIR is not set" 
22 @false 
23.endif 22.endif
24 23
25SWAPMB= 0 # no swap 24SWAPMB= 0 # no swap
26OMIT_SWAPIMG= yes # nothing to write 25OMIT_SWAPIMG= yes # nothing to write
27 26
28KERN_SET?= kern-GENERIC 27KERN_SET?= kern-GENERIC
29SETS?= modules base etc 28SETS?= modules base etc
30 29
31FSTAB_IN?= ${NETBSDSRCDIR}/distrib/common/bootimage/fstab.install.in 30FSTAB_IN?= ${NETBSDSRCDIR}/distrib/common/bootimage/fstab.install.in
32 31
33.if ${USE_MBR} != "no" 32.if ${USE_MBR} != "no"
34DISKPROTO_IN?= ${NETBSDSRCDIR}/distrib/common/bootimage/diskproto.noswap.mbr.in 33DISKPROTO_IN?= ${NETBSDSRCDIR}/distrib/common/bootimage/diskproto.noswap.mbr.in
35.else 34.else
36DISKPROTO_IN?= ${NETBSDSRCDIR}/distrib/common/bootimage/diskproto.noswap.in 35DISKPROTO_IN?= ${NETBSDSRCDIR}/distrib/common/bootimage/diskproto.noswap.in
37.endif 36.endif
38 37
39# XXX: no permittion info for makefs(8) 38# XXX: no permittion info for makefs(8)
40IMGDIR_EXTRA= ${RELEASEDIR}/${RELEASEMACHINEDIR} ${RELEASEMACHINEDIR} 39IMGDIR_EXTRA= ${RELEASEDIR}/${RELEASEMACHINEDIR} ${RELEASEMACHINEDIR}
41IMGDIR_EXCLUDE= -s ',./installation/cdrom.*,,gp' 40IMGDIR_EXCLUDE= -s ',./installation/cdrom.*,,gp'
42IMGDIR_EXCLUDE+= -s ',./installation/liveimage.*,,gp' 41IMGDIR_EXCLUDE+= -s ',./installation/liveimage.*,,gp'
43IMGDIR_EXCLUDE+= -s ',./installation/installimage.*,,gp' 42IMGDIR_EXCLUDE+= -s ',./installation/installimage.*,,gp'
44 43
45IMGBASE= ${INSTIMGBASE} 44IMGBASE= ${INSTIMGBASE}
46 45
47.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage" 46.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage"
48 47
49# INSTIMG_RELEASEDIR specifies where to install ${INSTIMGBASE}.img.gz. 48# INSTIMG_RELEASEDIR specifies where to install ${INSTIMGBASE}.img.gz.
50# This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc 49# This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc
51# but also set default here for manual builds. 50# but also set default here for manual builds.
52INSTIMG_RELEASEDIR?= ${RELEASEMACHINEDIR}/installation/installimage 51INSTIMG_RELEASEDIR?= ${RELEASEMACHINEDIR}/installation/installimage
53 52
54# should be defined elsewhere?  53# should be defined elsewhere?
55MKDIR?= mkdir -p 54MKDIR?= mkdir -p
56 55
57install_image: ${IMGBASE}.img.gz 56install_image: check_INSTIMGBASE check_RELEASEDIR ${IMGBASE}.img.gz
58 ${MKDIR} ${INSTIMG_RELEASEDIR} 57 ${MKDIR} ${INSTIMG_RELEASEDIR}
59 ${RELEASE_INSTALL} ${IMGBASE}.img.gz ${INSTIMG_RELEASEDIR} 58 ${RELEASE_INSTALL} ${IMGBASE}.img.gz ${INSTIMG_RELEASEDIR}
60 # note ${MAKESUM} will be calculated in src/etc/Makefile 59 # note ${MAKESUM} will be calculated in src/etc/Makefile
61 60
62release: 61release:
63 62

cvs diff -r1.1 -r1.2 src/distrib/common/bootimage/Makefile.liveimage (switch to unified diff)

--- src/distrib/common/bootimage/Makefile.liveimage 2012/01/22 03:53:30 1.1
+++ src/distrib/common/bootimage/Makefile.liveimage 2012/01/22 16:50:00 1.2
@@ -1,43 +1,42 @@ @@ -1,43 +1,42 @@
1# $NetBSD: Makefile.liveimage,v 1.1 2012/01/22 03:53:30 tsutsui Exp $ 1# $NetBSD: Makefile.liveimage,v 1.2 2012/01/22 16:50:00 tsutsui Exp $
2# 2#
3# Common Makefile to create a bootable FS image for USB flash or emulators 3# Common Makefile to create a bootable FS image for USB flash or emulators
4# 4#
5 5
6# 6#
7# Required variables: 7# Required variables:
8# LIVEIMGBASE 8# LIVEIMGBASE
9# Basename of the liveimage 9# Basename of the liveimage
10# 10#
11# See Makefile.bootimage for other variables. 11# See Makefile.bootimage for other variables.
12# 12#
13 13
14.if empty(LIVEIMGBASE) 14.if !target(check_LIVEIMGBASE)
15.BEGIN: 15check_LIVEIMGBASE: .PHONY .NOTMAIN
 16.if !defined(LIVEIMGBASE)
16 @echo "Error: LIVEIMGBASE is not set" 17 @echo "Error: LIVEIMGBASE is not set"
17 @false 18 @false
 19.else
 20 @true
18.endif 21.endif
19.if empty(RELEASEDIR) 
20.BEGIN: 
21 @echo "Error: RELEASEDIR is not set" 
22 @false 
23.endif 22.endif
24 23
25IMGBASE= ${LIVEIMGBASE} 24IMGBASE= ${LIVEIMGBASE}
26 25
27.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage" 26.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage"
28 27
29# LIVEIMG_RELEASEDIR specifies where to install ${LIVEIMGBASE}.img.gz. 28# LIVEIMG_RELEASEDIR specifies where to install ${LIVEIMGBASE}.img.gz.
30# This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc 29# This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc
31# but also set default here for manual builds. 30# but also set default here for manual builds.
32LIVEIMG_RELEASEDIR?= ${RELEASEMACHINEDIR}/installation/liveimage 31LIVEIMG_RELEASEDIR?= ${RELEASEMACHINEDIR}/installation/liveimage
33 32
34# should be defined elsewhere?  33# should be defined elsewhere?
35MKDIR?= mkdir -p 34MKDIR?= mkdir -p
36 35
37live_image: ${IMGBASE}.img.gz 36live_image: check_LIVEIMGBASE check_RELEASEDIR ${IMGBASE}.img.gz
38 ${MKDIR} ${LIVEIMG_RELEASEDIR} 37 ${MKDIR} ${LIVEIMG_RELEASEDIR}
39 ${RELEASE_INSTALL} ${IMGBASE}.img.gz ${LIVEIMG_RELEASEDIR} 38 ${RELEASE_INSTALL} ${IMGBASE}.img.gz ${LIVEIMG_RELEASEDIR}
40 # note ${MAKESUM} will be calculated in src/etc/Makefile 39 # note ${MAKESUM} will be calculated in src/etc/Makefile
41 40
42release: 41release:
43 42