Add "live-image" and "install-image" target support to build.sh. trunk
authortsutsui <tsutsui@NetBSD.org>
Sun, 22 Jan 2012 03:53:29 +0000
branchtrunk
changeset 208380 29aa4f884bd4
parent 208379 90b3277d752e
child 208381 e877fe21880a
Add "live-image" and "install-image" target support to build.sh. "live-image" target builds pre-installed disk images that can be used on emulators or boot from USB memory sticks to try NetBSD without installation. Currently amd64, i386, pmax, sparc, sparc64, sun2, sun3, and vax (which have working emulators and don't require extra tools like preparing msdosfs or partitioning MD label structures) support this target. "install-image" target builds an bootable installation disk image that can be used as an install CD but burned into USB memory sticks etc. Current only amd64 and i386 (which would support USB boot) have this target. For more details (and known issue) see following posts on netbsd-bugs@: http://mail-index.NetBSD.org/netbsd-bugs/2011/08/06/msg023639.html http://mail-index.NetBSD.org/netbsd-bugs/2011/09/23/msg024207.html http://mail-index.NetBSD.org/netbsd-bugs/2011/12/07/msg025166.html http://mail-index.NetBSD.org/netbsd-bugs/2011/12/08/msg025178.html No particular comments about implementation, and "go ahead" comments from mrg@, riz@ and christos@. Closes PR toolchain/45153 and PR misc/45155.
BUILDING
Makefile
build.sh
distrib/Makefile
distrib/Makefile.inc
distrib/amd64/Makefile
distrib/amd64/installimage/Makefile
distrib/amd64/installimage/boot.cfg.in
distrib/amd64/installimage/etc.rc
distrib/amd64/installimage/etc.ttys
distrib/amd64/installimage/install.sh
distrib/amd64/installimage/spec.inst
distrib/amd64/liveimage/Makefile
distrib/amd64/liveimage/Makefile.liveimage
distrib/amd64/liveimage/emuimage/Makefile
distrib/amd64/liveimage/usbimage/Makefile
distrib/common/Makefile.bootcd
distrib/common/bootimage/Makefile.bootimage
distrib/common/bootimage/Makefile.installimage
distrib/common/bootimage/Makefile.liveimage
distrib/common/bootimage/diskproto.in
distrib/common/bootimage/diskproto.mbr.in
distrib/common/bootimage/diskproto.noswap.in
distrib/common/bootimage/diskproto.noswap.mbr.in
distrib/common/bootimage/fstab.in
distrib/common/bootimage/fstab.install.in
distrib/common/bootimage/spec.in
distrib/i386/Makefile
distrib/i386/installimage/Makefile
distrib/i386/installimage/boot.cfg.in
distrib/i386/installimage/etc.rc
distrib/i386/installimage/etc.ttys
distrib/i386/installimage/install.sh
distrib/i386/installimage/spec.inst
distrib/i386/liveimage/Makefile
distrib/i386/liveimage/Makefile.liveimage
distrib/i386/liveimage/emuimage/Makefile
distrib/i386/liveimage/usbimage/Makefile
distrib/pmax/Makefile
distrib/pmax/liveimage/Makefile
distrib/pmax/liveimage/emuimage/Makefile
distrib/sparc/Makefile
distrib/sparc/liveimage/Makefile
distrib/sparc/liveimage/emuimage/Makefile
distrib/sparc64/Makefile
distrib/sparc64/liveimage/Makefile
distrib/sparc64/liveimage/emuimage/Makefile
distrib/sun2/Makefile
distrib/sun2/liveimage/Makefile
distrib/sun2/liveimage/emuimage/Makefile
distrib/sun3/Makefile
distrib/sun3/liveimage/Makefile
distrib/sun3/liveimage/emuimage/Makefile
distrib/vax/Makefile
distrib/vax/liveimage/Makefile
distrib/vax/liveimage/emuimage/Makefile
etc/Makefile
--- a/BUILDING	Sun Jan 22 03:48:51 2012 +0000
+++ b/BUILDING	Sun Jan 22 03:53:29 2012 +0000
@@ -627,6 +627,41 @@
                    ity, which is not part of NetBSD, but which can be
                    installed from pkgsrc/sysutils/cdrtools.
 
+     install-image Create a bootable NetBSD installation disk image in the
+                   RELEASEDIR/RELEASEMACHINEDIR/installation/installimage
+                   directory.  The bootable installation disk image is
+                   suitable to USB flash memory sticks etc. for machines which
+                   may support boot from such USB devices.  File system in the
+                   bootable disk image will have a layout as described in
+                   release(7).
+
+                   The installation image is bootable, and will automatically
+                   run the sysinst(8) menu-based installation program, which
+                   can be used to install or upgrade a NetBSD system.
+                   Bootable installation images also contain tools that may be
+                   useful in repairing a damaged NetBSD installation.
+
+                   Before ``make install-image'' is attempted, RELEASEDIR must
+                   be populated by ``make release'' or equivalent and
+                   RELEASEDIR binaries must be built with ``MKUNPRIVED=yes''
+                   to refer permission information from specfiles.
+
+     live-image    Create NetBSD live images in the
+                   RELEASEDIR/RELEASEMACHINEDIR/installation/liveimage
+                   directory.  The live image contains all necessary files
+                   to boot NetBSD upto multi user mode, including all files
+                   which should be extracted during installation, NetBSD
+                   disklabel, and bootloaders etc.
+
+                   The live image is suitable for misc emulators like QEMU,
+                   and also usuful to try NetBSD on real machines with USB
+                   flash memory sticks without installation.
+
+                   Before ``make live-image'' is attempted, RELEASEDIR must be
+                   populated by ``make release'' or equivalent and RELEASEDIR
+                   binaries must be built with ``MKUNPRIVED=yes'' to refer
+                   permission information from specfiles.
+
      regression-tests
                    Can only be run after building the regression tests in the
                    directory ``regress''.  Runs those compiled regression
@@ -738,6 +773,10 @@
      iso-image-source
                    Perform ``make iso-image-source''.
 
+     install-image Perform ``make install-image''.
+
+     live-image    Perform ``make live-image''.
+
      The following command line options alter the behaviour of the build.sh
      operations described above:
 
--- a/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.289 2011/09/09 14:23:37 apb Exp $
+#	$NetBSD: Makefile,v 1.290 2012/01/22 03:53:32 tsutsui Exp $
 
 #
 # This is the top-level makefile for building NetBSD. For an outline of
@@ -71,6 +71,16 @@
 #	Create CD-ROM image with source in RELEASEDIR/iso.
 #	RELEASEDIR must already have been populated by
 #	`make release sourcesets' or equivalent.
+#   live-image:
+#	Create bootable live image for emulators or USB stick etc.
+#	in RELEASEDIR/liveimage.
+#	RELEASEDIR must already have been populated by `make release'
+#	or equivalent.
+#   install-image:
+#	Create bootable installation image for USB stick etc.
+#	in RELEASEDIR/installimage.
+#	RELEASEDIR must already have been populated by `make release'
+#	or equivalent.
 #
 # Targets invoked by `make build,' in order:
 #   cleandir:        cleans the tree.
@@ -402,6 +412,24 @@
 	@printf "make ${.TARGET} finished at: " && date
 
 #
+# Create bootable live images.
+#
+
+live-image: .PHONY
+	${MAKEDIRTARGET} etc live-image
+	@echo   "make ${.TARGET} started at:  ${START_TIME}"
+	@printf "make ${.TARGET} finished at: " && date
+
+#
+# Create bootable installation images.
+#
+
+install-image: .PHONY
+	${MAKEDIRTARGET} etc install-image
+	@echo   "make ${.TARGET} started at:  ${START_TIME}"
+	@printf "make ${.TARGET} finished at: " && date
+
+#
 # Special components of the "make build" process.
 #
 
--- a/build.sh	Sun Jan 22 03:48:51 2012 +0000
+++ b/build.sh	Sun Jan 22 03:53:29 2012 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/env sh
-#	$NetBSD: build.sh,v 1.252 2011/12/05 23:04:39 jym Exp $
+#	$NetBSD: build.sh,v 1.253 2012/01/22 03:53:32 tsutsui Exp $
 #
 # Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -864,6 +864,10 @@
                         RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.
     iso-image           Create CD-ROM image in RELEASEDIR/iso.
     iso-image-source    Create CD-ROM image with source in RELEASEDIR/iso.
+    live-image          Create bootable live image in
+                        RELEASEDIR/RELEASEMACHINEDIR/installation/liveimage.
+    install-image       Create bootable installation image in
+                        RELEASEDIR/RELEASEMACHINEDIR/installation/installimage.
     params              Display various make(1) parameters.
 
  Options:
@@ -1135,6 +1139,14 @@
 			op=iso_image_source   # used as part of a variable name
 			;;
 
+		live-image)
+			op=live_image	# used as part of a variable name
+			;;
+
+		install-image)
+			op=install_image # used as part of a variable name
+			;;
+
 		kernel=*|releasekernel=*)
 			arg=${op#*=}
 			op=${op%%=*}
@@ -1632,7 +1644,7 @@
 	eval cat <<EOF ${makewrapout}
 #! ${HOST_SH}
 # Set proper variables to allow easy "make" building of a NetBSD subtree.
-# Generated from:  \$NetBSD: build.sh,v 1.252 2011/12/05 23:04:39 jym Exp $
+# Generated from:  \$NetBSD: build.sh,v 1.253 2012/01/22 03:53:32 tsutsui Exp $
 # with these arguments: ${_args}
 #
 
@@ -1960,6 +1972,17 @@
 			statusmsg "Successful make ${op}"
 			;;
 
+		live-image)
+			${runcmd} "${makewrapper}" ${parallel} ${op} ||
+			    bomb "Failed to make ${op}"
+			statusmsg "Successful make ${op}"
+			;;
+
+		install-image)
+			${runcmd} "${makewrapper}" ${parallel} ${op} ||
+			    bomb "Failed to make ${op}"
+			statusmsg "Successful make ${op}"
+			;;
 		kernel=*)
 			arg=${op#*=}
 			buildkernel "${arg}"
--- a/distrib/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.17 2012/01/04 03:43:34 riz Exp $
+#	$NetBSD: Makefile,v 1.18 2012/01/22 03:53:32 tsutsui Exp $
 
 .include <bsd.own.mk>
 
@@ -18,5 +18,7 @@
 
 TARGETS+=release
 TARGETS+=iso_image
+TARGETS+=live_image
+TARGETS+=install_image
 
 .include <bsd.subdir.mk>
--- a/distrib/Makefile.inc	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/Makefile.inc	Sun Jan 22 03:53:29 2012 +0000
@@ -1,5 +1,7 @@
-#	$NetBSD: Makefile.inc,v 1.9 2007/03/06 21:56:47 bouyer Exp $
+#	$NetBSD: Makefile.inc,v 1.10 2012/01/22 03:53:32 tsutsui Exp $
 
 .include "../Makefile.inc"
 
 iso_image: .PHONY
+live_image: .PHONY
+install_image: .PHONY
--- a/distrib/amd64/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/amd64/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2011/01/18 00:22:56 jym Exp $
+#	$NetBSD: Makefile,v 1.6 2012/01/22 03:53:32 tsutsui Exp $
 
 SUBDIR=
 SUBDIR+=	ramdisks
@@ -8,9 +8,17 @@
 SUBDIR+=	.WAIT
 SUBDIR+=	cdroms
 SUBDIR+=	floppies
+SUBDIR+=	liveimage
+SUBDIR+=	installimage
 TARGETS+=	release 
 
 iso_image:
 	${MAKEDIRTARGET} cdroms iso_image
 
+live_image:
+	${MAKEDIRTARGET} liveimage live_image
+
+install_image:
+	${MAKEDIRTARGET} installimage install_image
+
 .include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/installimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,41 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:29 tsutsui Exp $
+
+.include <bsd.own.mk>
+
+INSTIMGBASE=	amd64inst		# gives ${IMGBASE}.img
+
+BOOTDISK=	sd0			# for USB flash etc.
+IMAGEMB=	550			# for all installation binaries
+
+PRIMARY_BOOT=		bootxx_ffsv1
+SECONDARY_BOOT=		boot
+SECONDARY_BOOT_ARG=	# unnecessary
+
+USE_MBR=		yes
+
+CLEANFILES+=	boot.cfg
+
+prepare_md_post:
+	${TOOL_SED}							\
+	    -e "s/@@MACHINE@@/${MACHINE}/"				\
+	    -e "s/@@VERSION@@/${DISTRIBVER}/"				\
+	    < ${.CURDIR}/boot.cfg.in > boot.cfg
+
+DISTRIBDIR!= cd ${.CURDIR}/../.. ; pwd
+SYSINSTDIR!= cd ${DISTRIBDIR}/utils/sysinst/arch/${MACHINE} && ${PRINTOBJDIR}
+
+SPEC_EXTRA=		${.CURDIR}/spec.inst
+IMGFILE_EXTRA=								\
+	${DISTRIBDIR}/common/10-resolv.conf	libexec/dhcpcd-hooks	\
+	${DISTRIBDIR}/common/99-print-sysinst	libexec/dhcpcd-hooks	\
+	${.CURDIR}/etc.ttys		etc/ttys			\
+	${.CURDIR}/etc.rc		etc/rc				\
+	${.CURDIR}/install.sh		.				\
+	${.OBJDIR}/boot.cfg		.				\
+	${SYSINSTDIR}/sysinstmsgs.de	.				\
+	${SYSINSTDIR}/sysinstmsgs.es	.				\
+	${SYSINSTDIR}/sysinstmsgs.fr	.				\
+	${SYSINSTDIR}/sysinstmsgs.pl	.				\
+	${SYSINSTDIR}/sysinst		.
+
+.include "${DISTRIBDIR}/common/bootimage/Makefile.installimage"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/installimage/boot.cfg.in	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,12 @@
+banner=Welcome to the NetBSD/@@MACHINE@@ @@VERSION@@ installation image
+banner================================================================================
+banner=
+banner=ACPI (Advanced Configuration and Power Interface) should work on all modern
+banner=and legacy hardware.  However if you do encounter a problem while booting,
+banner=try disabling it and report a bug at http://www.NetBSD.org/.
+menu=Install NetBSD:boot netbsd
+menu=Install NetBSD (no ACPI):boot netbsd -2
+menu=Install NetBSD (no ACPI, no SMP):boot netbsd -12
+menu=Drop to boot prompt:prompt
+timeout=30
+clear=1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/installimage/etc.rc	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,52 @@
+# $NetBSD: etc.rc,v 1.1 2012/01/22 03:53:29 tsutsui Exp $
+#
+# Copyright (c) 1997 Perry E. Metzger
+# Copyright (c) 1994 Christopher G. Demetriou
+# All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#          This product includes software developed for the
+#          NetBSD Project.  See http://www.NetBSD.org/ for
+#          information about NetBSD.
+# 4. The name of the author may not be used to endorse or promote products
+#    derived from this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# 
+# <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
+
+PATH=/sbin:/bin:/usr/bin:/usr/sbin:/
+export PATH
+
+# hack to get around bugs in kernfs's rootdev/rrootdev lookup.
+ls -l /dev/* > /dev/null 2>&1
+
+mount -u /
+mount -t tmpfs tmpfs /tmp
+
+# create a gettytab to autologin and run sysinst
+echo "# Autostart sysinst" > /tmp/gettytab
+echo -n "sysinst:al=root:lo=/install.sh:im=:sp#" >> /tmp/gettytab
+stty speed >> /tmp/gettytab
+cp /tmp/gettytab /etc
+
+# done, move on to multiuser mode
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/installimage/etc.ttys	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: etc.ttys,v 1.1 2012/01/22 03:53:29 tsutsui Exp $
+#
+# re-launch the sysinst wrapper script on console
+#
+# name	getty				type	status		comments
+#
+console	"/usr/libexec/getty sysinst"	wsvt25	on secure
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/installimage/install.sh	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,115 @@
+#! /bin/sh -m
+# $NetBSD: install.sh,v 1.1 2012/01/22 03:53:29 tsutsui Exp $
+#
+# -
+#  Copyright (c) 2010 The NetBSD Foundation, Inc.
+#  All rights reserved.
+# 
+#  This code is derived from software contributed to The NetBSD Foundation
+#  by Martin Husemann <martin@NetBSD.org>.
+# 
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+# 
+#  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+#  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+#  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+#  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+#  POSSIBILITY OF SUCH DAMAGE.
+
+
+# setup basic environment
+PATH=/sbin:/bin:/usr/bin:/usr/sbin:/
+export PATH
+
+termfile=/tmp/sysinst.term
+
+# Check if we are on a framebuffer or on serial console and default
+# the terminal type accordingly.
+# There is no /var/db/dev.db, so sysctl might not map the devicename properly;
+# ttyE0 is 90,0 -> 0x5a00
+case $(sysctl -nx kern.consdev) in
+ 002f000000000000)
+    TERM=wsvt25
+    ;;
+ *)
+    if [ -r ${termfile} ]; then
+	. ${termfile}
+    else
+	TERM=vt220
+    fi
+    ;;
+esac
+
+export TERM
+HOME=/
+export HOME
+BLOCKSIZE=1k
+export BLOCKSIZE
+EDITOR=ed
+export EDITOR
+SHELL=/bin/sh
+export SHELL
+
+umask 022
+
+stty newcrt werase ^W intr ^C kill ^U erase ^?
+if [ $TERM != "wsvt25" ]; then
+	cat << "EOM"
+
+
+You are using a serial console, we do not know your terminal emulation.
+Please select one, typical values are:
+
+	vt100
+	ansi
+	xterm
+
+EOM
+	echo -n "Terminal type (just hit ENTER for '$TERM'): "
+	read ans
+	if [ -n "$ans" ];then
+	    TERM=$ans
+	fi
+fi
+
+# run the installation or upgrade script.
+cd /
+cmd=./sysinst
+
+while [ -n "${cmd}" ]
+do
+	${cmd}
+	if [ $? = 4 ]; then
+		echo "Oops, something went wrong - we will try again"
+		exit
+	else
+		if [ -n "$(jobs)" ]; then
+			tput clear
+			echo "You have stopped sysinst, return to it by" \
+				"typing 'exit' or ^D."
+			${SHELL} -i
+			cmd="fg"
+		else
+			cmd=""
+		fi
+	fi
+done
+
+# remember terminal type, now that we know it for sure
+echo "TERM=${TERM}" > ${termfile}
+echo
+echo "To return to the installer, quit this shell by typing 'exit' or ^D."
+exec ${SHELL}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/installimage/spec.inst	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,18 @@
+# $NetBSD: spec.inst,v 1.1 2012/01/22 03:53:29 tsutsui Exp $
+./mnt2			type=dir mode=0755 uname=root gname=wheel
+./targetroot		type=dir mode=0755 uname=root gname=wheel
+
+./libexec/dhcpcd-hooks/10-resolv.conf	type=file mode=0444 uname=root gname=wheel
+./libexec/dhcpcd-hooks/99-print-sysinst	type=file mode=0444 uname=root gname=wheel
+
+./install.sh		type=file mode=0755 uname=root gname=wheel
+./sysinst		type=file mode=0755 uname=root gname=wheel
+./sysinstmsgs.de	type=file mode=0444 uname=root gname=wheel
+./sysinstmsgs.es	type=file mode=0444 uname=root gname=wheel
+./sysinstmsgs.fr	type=file mode=0444 uname=root gname=wheel
+./sysinstmsgs.pl	type=file mode=0444 uname=root gname=wheel
+
+# for sysinst "install from local directory" default
+./release		type=link mode=0755 uname=root gname=wheel link=.
+
+# XXX what to do for files in ${RELEASEMACHINEDIR}?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/liveimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1 2012/01/22 03:53:29 tsutsui Exp $
+
+SUBDIR=
+SUBDIR+=	emuimage
+SUBDIR+=	usbimage
+
+TARGETS+=	release live_image
+
+.include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/liveimage/Makefile.liveimage	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,13 @@
+#	$NetBSD: Makefile.liveimage,v 1.1 2012/01/22 03:53:29 tsutsui Exp $
+
+.include <bsd.own.mk>
+
+KERN_SET=		kern-GENERIC
+BOOTDISK?=		wd0		# for emulators
+PRIMARY_BOOT=		bootxx_ffsv1
+SECONDARY_BOOT=		boot
+SECONDARY_BOOT_ARG=	# unnecessary
+
+USE_MBR=		yes
+
+.include "${.CURDIR}/../../../common/bootimage/Makefile.liveimage"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/liveimage/emuimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,7 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:29 tsutsui Exp $
+
+LIVEIMGBASE=	amd64emu		# gives ${IMGBASE}.img
+
+BOOTDISK=	wd0			# for QEMU etc.
+
+.include "${.CURDIR}/../Makefile.liveimage"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/liveimage/usbimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,9 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:29 tsutsui Exp $
+
+LIVEIMGBASE=	amd64live		# gives ${IMGBASE}.img
+
+BOOTDISK=	sd0			# for USB flash etc.
+IMAGEMB=	1536            	# 2GB USB flash memories aren't 2GiB
+OMIT_SWAPIMG=	yes			# no need to write swap
+
+.include "${.CURDIR}/../Makefile.liveimage"
--- a/distrib/common/Makefile.bootcd	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/common/Makefile.bootcd	Sun Jan 22 03:53:29 2012 +0000
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.bootcd,v 1.18 2012/01/14 22:56:30 jmcneill Exp $
+#	$NetBSD: Makefile.bootcd,v 1.19 2012/01/22 03:53:32 tsutsui Exp $
 #
 # Makefile snipped to create a CD/DVD ISO
 #
@@ -48,6 +48,12 @@
 .if defined(CDRELEASE_NOISOS)
 CDRELEASE_EXCLUDE=	-s ',./installation/cdrom.*,,gp'
 .endif
+.if !defined(CDRELEASE_LIVEIMAGE)
+CDRELEASE_EXCLUDE+=	-s ',./installation/liveimage.*,,gp'
+.endif
+.if !defined(CDRELEASE_INSTALLIMAGE)
+CDRELEASE_EXCLUDE+=	-s ',./installation/installimage.*,,gp'
+.endif
 
 .include <bsd.sys.mk>		# for HOST_SH
 .include <bsd.own.mk> 		# For PRINTOBJDIR
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/Makefile.bootimage	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,383 @@
+#	$NetBSD: Makefile.bootimage,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+#
+# Copyright (c) 2009, 2010, 2011 Izumi Tsutsui.  All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#
+# Makefile to create a bootable FS image for USB flash or emulators
+#
+
+#
+# Required variables:
+#	RELEASEDIR
+#		Should be defined in nbmake-${MACHINE}
+#	IMGBASE
+#		Basename of the image
+#
+# Optional variables:
+#	BOOTDISK
+#		device name of target bootable disk specified in /etc/fstab
+#		(default: sd0)
+#	USE_MBR
+#		set yes if target disk image requires MBR partition
+#		(defautl: no)
+#	USE_SUNLABEL
+#		set yes if target disk image requires Sun's label
+#		(default: no)
+#	INSTALLBOOT_AFTER_DISKLABEL (untested)
+#		set yes if the target ${MACHINE} requires disklabel
+#		to run installboot(8), like hp300
+#		(default: empty)
+#	IMAGEMB
+#		target image size in MB
+#		(default: 2048)
+#	SWAPMB
+#		swap size in target image in MB
+#		(default: 128)
+#	KERN_SET
+#		kernel set name which should be extracted into image
+#		(default: kern-GENERIC)
+#	SETS
+#		binary sets that should be extracted into image
+#		(default: modules base etc comp games man misc tests text
+#			  xbase xcomp xetc xfont xserver)
+#	SETS_DIR
+#		directory path where binary sets are stored
+#		(default: ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets)
+#	IMGFILE_EXTRA
+#		list of additional files to be copied into images,
+#		containing one or more tuples of the form:
+#			FILE	TARGETPATH
+#		for installation image etc.
+#		(default: empty)
+#	IMGDIR_EXTRA
+#		list of additional directories to be copied into images,
+#		containing one or more tuples of the form:
+#			DIR	TARGETPATH
+#		for installation image etc.
+#		(default: empty)
+#		XXX: currently permittions in IMGDIR_EXTRA are not handled
+#	IMGDIR_EXCLUDE
+#		pax(1) options to exclude files which should not copied
+#		into TARGETPATH in IMGDIR_EXTRA
+#		(default: empty)
+#	FSTAB_IN
+#		template file of /etc/fstab
+#		(default: ${DISTRIBDIR}/common/bootimage/fstab.in)
+#	SPEC_IN
+#		default files of spec file for makefs(8)
+#		(default: ${DISTRIBDIR}/common/bootimage/spec.in)
+#	SPEC_EXTRA
+#		additional files of spec file for makefs(8)
+#		(default: empty)
+#	IMGMAKEFSOPTIONS
+#		options passed to makefs(8) to create root file system
+#		(default: -o bsize=16384,fsize=2048,density=8192)
+#	PRIMARY_BOOT
+#		primary boot loader that should be installed into
+#		the target image via installboot(8)
+#		(default: empty)
+#	SECONDARY_BOOT
+#		secondary bootloader that should be put into the target image
+#		(default: empty)
+#	SECONDARY_BOOT_ARG
+#		extra arguments that should be passed to installboot(8)
+#		to specify the secondary bootloader
+#		(default: empty)
+#	DISKPROTO_IN
+#		template file of disklabel -R
+#		(default: ${DISTRIBDIR}/common/bootimage/diskproto.in
+#		       or ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in)
+#	OMIT_SWAPIMG
+#		no need to put swap partition into image (for USB stick)
+#		(default: no)
+#
+
+.include <bsd.sys.mk>		# for HOST_SH
+.include <bsd.own.mk> 		#
+.include <bsd.endian.mk>	# for TARGET_ENDIANNESS
+
+.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
+
+.if empty(IMGBASE)
+.BEGIN:
+	@echo "Error: IMGBASE is not set"
+	@false
+.endif
+.if empty(RELEASEDIR)
+.BEGIN:
+	@echo "Error: RELEASEDIR is not set"
+	@false
+.endif
+
+# should be defined elsewhere? 
+CAT?=		cat
+CHMOD?=		chmod
+CP?=		cp
+DD?=		dd
+MKDIR?=		mkdir -p
+RM?=		rm
+
+#
+# common definitions for image
+#
+BOOTDISK?=	sd0
+USE_MBR?=	no
+USE_SUNLABEL?=	no
+INSTALLBOOT_AFTER_DISKLABEL?=	no
+
+#
+# size parameters for image
+#
+IMAGEMB?=	2048		# 2048MB
+SWAPMB?=	128		# 128MB
+
+IMAGESECTORS!=	expr ${IMAGEMB} \* 1024 \* 1024 / 512
+SWAPSECTORS!=	expr ${SWAPMB} \* 1024 \* 1024 / 512
+
+.if ${USE_MBR} == "no"
+LABELSECTORS?=	0
+.else
+#LABELSECTORS?=	63	# historical
+#LABELSECTORS?=	32	# 16KB aligned
+LABELSECTORS?=	2048	# 1MB aligned for modern flash devices
+.endif
+
+FSSECTORS!=	expr ${IMAGESECTORS} - ${SWAPSECTORS} - ${LABELSECTORS}
+FSSIZE!=	expr ${FSSECTORS} \* 512
+
+# parameters for disklabel and MBR
+HEADS=		64
+SECTORS=	32
+CYLINDERS!=	expr ${IMAGESECTORS} / \( ${HEADS} \* ${SECTORS} \)
+SECPERCYLINDERS!= expr ${HEADS} \* ${SECTORS}
+MBRHEADS=	255
+MBRSECTORS=	63
+MBRCYLINDERS!=	expr ${IMAGESECTORS} / \( ${MBRHEADS} \* ${MBRSECTORS} \)
+MBRNETBSD=	169
+
+BSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS}
+FSOFFSET=	${LABELSECTORS}
+SWAPOFFSET!=	expr ${LABELSECTORS} + ${FSSECTORS}
+
+# parameters for sunlabel
+FSCYLINDERS!=	expr ${FSSECTORS} / \( ${HEADS} \* ${SECTORS} \)
+SWAPCYLINDERS!=	expr ${SWAPSECTORS} / \( ${HEADS} \* ${SECTORS} \)
+
+
+#
+# definitions to create root fs
+#
+SETS_DEFAULT=	modules base etc comp games man misc tests text
+.if ${MKX11} != "no"
+SETS_DEFAULT+=	xbase xcomp xetc xfont xserver
+.endif
+
+KERN_SET?=	kern-GENERIC
+SETS?=		${SETS_DEFAULT}
+IMG_SETS=	${KERN_SET} ${SETS}
+SETS_DIR?=	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
+
+FSTAB_IN?=	${DISTRIBDIR}/common/bootimage/fstab.in
+SPEC_IN?=	${DISTRIBDIR}/common/bootimage/spec.in
+
+IMGMAKEFSOPTIONS?=	-o bsize=16384,fsize=2048,density=8192
+
+WORKDIR?=       work
+WORKSPEC?=      work.spec
+WORKFSTAB?=	work.fstab
+WORKRCCONF?=	work.rc.conf
+WORKFS?=        work.rootfs
+TARGETFS?=      imgroot.fs
+
+CLEANFILES+=	${WORKSPEC} ${WORKFSTAB} ${WORKRCCONF} ${WORKFS}
+CLEANFILES+=	${TARGETFS}
+
+#
+# create root file system for the image
+#
+${TARGETFS}: prepare_md_post
+	@if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then 		\
+		echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \
+		false; 							\
+	fi;
+	@${MKDIR} ${WORKDIR}
+.for set in ${IMG_SETS}
+	@if [ ! -f ${SETS_DIR}/${set}.tgz ]; then 			\
+		echo "Missing ${SETS_DIR}/${set}.tgz, aborting";	\
+		false; 							\
+	fi
+	@echo Extracting ${set}.tgz ...
+	@(cd ${WORKDIR}; ${TOOL_PAX} -rnz -f ${SETS_DIR}/${set}.tgz .)
+.endfor
+.if defined(SECONDARY_BOOT)
+	@echo Copying secondary boot...
+	${CP} -f ${WORKDIR}/usr/mdec/${SECONDARY_BOOT} ${WORKDIR}
+.endif
+	@echo Preparing /etc/fstab ...
+	${TOOL_SED} "s/@@BOOTDISK@@/${BOOTDISK}/" < ${FSTAB_IN} > ${WORKFSTAB}
+	${CP} ${WORKFSTAB} ${WORKDIR}/etc/fstab
+	@echo Setting rc_configured=YES in /etc/rc.conf ...
+	${TOOL_SED} "s/rc_configured=NO/rc_configured=YES/"		\
+	    < ${WORKDIR}/etc/rc.conf > ${WORKRCCONF}
+	${CP} ${WORKRCCONF} ${WORKDIR}/etc/rc.conf
+.if defined(IMGDIR_EXTRA)
+	@echo Copying extra dirs...
+.for _SRCDIR _TARGET in ${IMGDIR_EXTRA}
+	@if [ ! -d ${_SRCDIR} ]; then 					\
+		echo "${_SRCDIR} is not directory, aborting";		\
+		false; 							\
+	fi
+	${MKDIR} ${WORKDIR}/${_TARGET}
+	(cd ${_SRCDIR} ;						\
+	    ${TOOL_PAX} -rw -pe	-v					\
+	    ${IMGDIR_EXCLUDE}						\
+	    . ${.OBJDIR}/${WORKDIR}/${_TARGET} )
+.endfor
+.endif
+.if defined(IMGFILE_EXTRA)
+	@echo Copying extra files...
+.for _SRC _TARGET in ${IMGFILE_EXTRA}
+	@if [ ! -f ${_SRC} ]; then 					\
+		echo "${_SRC} in IMGFILE_EXTRA not found, aborting";	\
+		false; 							\
+	fi
+	@if [ -f ${_SRC} ]; then 					\
+		echo ${CP} ${_SRC} ${WORKDIR}/${_TARGET};		\
+		${CP} ${_SRC} ${WORKDIR}/${_TARGET};			\
+	fi
+.endfor
+.endif
+	@echo Preparing spec files for makefs...
+	${RM} -f ${WORKSPEC}
+	cat ${WORKDIR}/etc/mtree/* |					\
+	    ${TOOL_SED} -e 's/ size=[0-9]*//' > ${WORKSPEC}
+	${HOST_SH} ${WORKDIR}/dev/MAKEDEV -s all |			\
+	    ${TOOL_SED} -e '/^\. type=dir/d' -e 's,^\.,./dev,' >> ${WORKSPEC}
+	cat ${SPEC_IN} >> ${WORKSPEC}
+.if defined(SECONDARY_BOOT)
+	echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \
+	    >> ${WORKSPEC}
+.endif
+.if defined(SPEC_EXTRA)
+	cat ${SPEC_EXTRA} >> ${WORKSPEC}
+.endif
+	@echo Createing rootfs...
+	# XXX /var/spool/ftp/hidden is unreadable
+	${CHMOD} +r ${WORKDIR}/var/spool/ftp/hidden
+	${TOOL_MAKEFS} -M ${FSSIZE} -m ${FSSIZE}			\
+	    -B ${TARGET_ENDIANNESS}					\
+	    -F ${WORKSPEC} -N ${WORKDIR}/etc				\
+	    ${IMGMAKEFSOPTIONS}						\
+	    ${WORKFS} ${WORKDIR}
+.if !empty(PRIMARY_BOOT) && ${INSTALLBOOT_AFTER_DISKLABEL} == "no"
+	${TOOL_INSTALLBOOT} -vm ${MACHINE} ${WORKFS} \
+	    ${WORKDIR}/usr/mdec/${PRIMARY_BOOT} ${SECONDARY_BOOT_ARG}
+.endif
+	@echo done.
+	mv ${WORKFS} ${.TARGET}
+
+#
+# definitions to create image
+#
+.if ${USE_MBR} != "no"
+DISKPROTO_IN?=	${DISTRIBDIR}/common/bootimage/diskproto.mbr.in
+.else
+DISKPROTO_IN?=	${DISTRIBDIR}/common/bootimage/diskproto.in
+.endif
+
+OMIT_SWAPIMG?=	no
+
+WORKMBR?=	work.mbr
+WORKSWAP?=	work.swap
+WORKLABEL?=	work.diskproto
+WORKIMG?=	work.img
+
+CLEANFILES+=	${WORKMBR} ${WORKSWAP}
+CLEANFILES+=	${WORKLABEL}.tmp ${WORKLABEL}
+CLEANFILES+=	${WORKIMG} ${IMGBASE}.img
+
+${WORKLABEL}:
+	${TOOL_SED}							\
+	    -e "s/@@SECTORS@@/${SECTORS}/"				\
+	    -e "s/@@HEADS@@/${HEADS}/"					\
+	    -e "s/@@SECPERCYLINDERS@@/${SECPERCYLINDERS}/"		\
+	    -e "s/@@CYLINDERS@@/${CYLINDERS}/"				\
+	    -e "s/@@IMAGESECTORS@@/${IMAGESECTORS}/"			\
+	    -e "s/@@FSSECTORS@@/${FSSECTORS}/"				\
+	    -e "s/@@FSOFFSET@@/${FSOFFSET}/"				\
+	    -e "s/@@SWAPSECTORS@@/${SWAPSECTORS}/"			\
+	    -e "s/@@SWAPOFFSET@@/${SWAPOFFSET}/"			\
+	    -e "s/@@BSDPARTSECTORS@@/${BSDPARTSECTORS}/"		\
+	    < ${DISKPROTO_IN} > ${WORKLABEL}.tmp
+	mv ${WORKLABEL}.tmp ${WORKLABEL}
+
+${IMGBASE}.img:	${TARGETFS} ${WORKLABEL}
+.if ${LABELSECTORS} != "0"
+	@echo creating MBR labels...
+	${DD} if=/dev/zero of=${WORKMBR} seek=$$((${IMAGESECTORS} - 1)) count=1
+	${TOOL_FDISK} -f -u \
+	    -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS}		\
+	    -0 -a -s ${MBRNETBSD}/${FSOFFSET}/${BSDPARTSECTORS}		\
+	    -i -c ${WORKDIR}/usr/mdec/mbr				\
+	    -F ${WORKMBR}
+	${DD} if=${WORKMBR} count=${LABELSECTORS} |			\
+	    ${CAT} - ${TARGETFS} > ${WORKIMG}
+.else
+	${CP} ${TARGETFS} ${WORKIMG}
+.endif
+.if ${OMIT_SWAPIMG} == "no"
+	${DD} if=/dev/zero of=${WORKSWAP} seek=$$((${SWAPSECTORS} - 1)) count=1
+	${CAT} ${WORKSWAP} >> ${WORKIMG}
+.endif
+.if ${USE_SUNLABEL} != "no"
+	@echo Creating sun disklabel...
+	printf 'V ncyl %d\nV nhead %d\nV nsect %d\na %d %d/0/0\nb %d %d/0/0\nW\n' \
+	    ${CYLINDERS} ${HEADS} ${SECTORS} \
+	    ${FSOFFSET} ${FSCYLINDERS} ${FSCYLINDERS} ${SWAPCYLINDERS} | \
+	    ${TOOL_SUNLABEL} -nq ${WORKIMG}
+.endif
+	${TOOL_DISKLABEL} -R -F ${WORKIMG} ${WORKLABEL}
+.if !empty(PRIMARY_BOOT) && ${INSTALLBOOT_AFTER_DISKLABEL} != "no"
+	${TOOL_INSTALLBOOT}  -vm ${MACHINE} ${WORKIMG}			\
+	    ${WORKDIR}/usr/mdec/${PRIMARY_BOOT}
+.endif
+	mv ${WORKIMG} ${.TARGET}
+
+
+CLEANFILES+=	${IMGBASE}.img.gz ${IMGBASE}.img.gz.tmp
+
+${IMGBASE}.img.gz:	${IMGBASE}.img
+	${TOOL_GZIP} -9c ${IMGBASE}.img > ${.TARGET}.tmp
+	mv ${.TARGET}.tmp ${.TARGET}
+
+clean:
+	@if [ -d ${WORKDIR}/var/spool/ftp/hidden ]; then 		\
+		${CHMOD} +r ${WORKDIR}/var/spool/ftp/hidden;		\
+	fi	# XXX
+	${RM} -fr ${WORKDIR}
+
+prepare_md_post: .PHONY
+image_md_post: .PHONY
+image_md_pre: .PHONY
+
+.include <bsd.prog.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/Makefile.installimage	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,63 @@
+#	$NetBSD: Makefile.installimage,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+#
+# Common Makefile to create a bootable installation image for USB flash etc.
+#
+
+#
+# Required variables:
+#	INSTIMGBASE
+#		Basename of the liveimage
+#
+# See Makefile.bootimage for other variables.
+#
+
+.if empty(INSTIMGBASE)
+.BEGIN:
+	@echo "Error: INSTIMGBASE is not set"
+	@false
+.endif
+.if empty(RELEASEDIR)
+.BEGIN:
+	@echo "Error: RELEASEDIR is not set"
+	@false
+.endif
+
+SWAPMB=		0			# no swap
+OMIT_SWAPIMG=	yes			# nothing to write
+
+KERN_SET?=	kern-GENERIC
+SETS?=		modules base etc
+
+FSTAB_IN?=	${NETBSDSRCDIR}/distrib/common/bootimage/fstab.install.in
+
+.if ${USE_MBR} != "no"
+DISKPROTO_IN?=	${NETBSDSRCDIR}/distrib/common/bootimage/diskproto.noswap.mbr.in
+.else
+DISKPROTO_IN?=	${NETBSDSRCDIR}/distrib/common/bootimage/diskproto.noswap.in
+.endif
+
+# XXX: no permittion info for makefs(8)
+IMGDIR_EXTRA=	${RELEASEDIR}/${RELEASEMACHINEDIR}	${RELEASEMACHINEDIR}
+IMGDIR_EXCLUDE= 	-s ',./installation/cdrom.*,,gp'
+IMGDIR_EXCLUDE+=	-s ',./installation/liveimage.*,,gp'
+IMGDIR_EXCLUDE+=	-s ',./installation/installimage.*,,gp'
+
+IMGBASE=        ${INSTIMGBASE}
+
+.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage"
+
+# INSTIMG_RELEASEDIR specifies where to install ${INSTIMGBASE}.img.gz.
+# This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc
+# but also set default here for manual builds.
+INSTIMG_RELEASEDIR?=	${RELEASEMACHINEDIR}/installation/installimage
+
+# should be defined elsewhere? 
+MKDIR?=		mkdir -p
+
+install_image: ${IMGBASE}.img.gz
+	${MKDIR} ${INSTIMG_RELEASEDIR}
+	${RELEASE_INSTALL} ${IMGBASE}.img.gz ${INSTIMG_RELEASEDIR}
+	# note ${MAKESUM} will be calculated in src/etc/Makefile
+
+release:
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/Makefile.liveimage	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,43 @@
+#	$NetBSD: Makefile.liveimage,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+#
+# Common Makefile to create a bootable FS image for USB flash or emulators
+#
+
+#
+# Required variables:
+#	LIVEIMGBASE
+#		Basename of the liveimage
+#
+# See Makefile.bootimage for other variables.
+#
+
+.if empty(LIVEIMGBASE)
+.BEGIN:
+	@echo "Error: LIVEIMGBASE is not set"
+	@false
+.endif
+.if empty(RELEASEDIR)
+.BEGIN:
+	@echo "Error: RELEASEDIR is not set"
+	@false
+.endif
+
+IMGBASE=	${LIVEIMGBASE}
+
+.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage"
+
+# LIVEIMG_RELEASEDIR specifies where to install ${LIVEIMGBASE}.img.gz.
+# This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc
+# but also set default here for manual builds.
+LIVEIMG_RELEASEDIR?=	${RELEASEMACHINEDIR}/installation/liveimage
+
+# should be defined elsewhere? 
+MKDIR?=		mkdir -p
+
+live_image: ${IMGBASE}.img.gz
+	${MKDIR} ${LIVEIMG_RELEASEDIR}
+	${RELEASE_INSTALL} ${IMGBASE}.img.gz ${LIVEIMG_RELEASEDIR}
+	# note ${MAKESUM} will be calculated in src/etc/Makefile
+
+release:
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/diskproto.in	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,24 @@
+# $NetBSD: diskproto.in,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+type: ESDI
+disk: image
+label: 
+flags:
+bytes/sector: 512
+sectors/track: @@SECTORS@@
+tracks/cylinder: @@HEADS@@
+sectors/cylinder: @@SECPERCYLINDERS@@
+cylinders: @@CYLINDERS@@
+total sectors: @@IMAGESECTORS@@
+rpm: 3600
+interleave: 1
+trackskew: 0
+cylinderskew: 0
+headswitch: 0           # microseconds
+track-to-track seek: 0  # microseconds
+drivedata: 0 
+
+8 partitions:
+#        size    offset     fstype [fsize bsize cpg/sgs]
+a:    @@FSSECTORS@@ @@FSOFFSET@@ 4.2BSD 1024 8192 16
+b:    @@SWAPSECTORS@@ @@SWAPOFFSET@@ swap
+c:    @@IMAGESECTORS@@ 0 unused 0 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/diskproto.mbr.in	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,25 @@
+# $NetBSD: diskproto.mbr.in,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+type: ESDI
+disk: image
+label: 
+flags:
+bytes/sector: 512
+sectors/track: @@SECTORS@@
+tracks/cylinder: @@HEADS@@
+sectors/cylinder: @@SECPERCYLINDERS@@
+cylinders: @@CYLINDERS@@
+total sectors: @@IMAGESECTORS@@
+rpm: 3600
+interleave: 1
+trackskew: 0
+cylinderskew: 0
+headswitch: 0           # microseconds
+track-to-track seek: 0  # microseconds
+drivedata: 0 
+
+8 partitions:
+#        size    offset     fstype [fsize bsize cpg/sgs]
+a:    @@FSSECTORS@@ @@FSOFFSET@@ 4.2BSD 1024 8192 16
+b:    @@SWAPSECTORS@@ @@SWAPOFFSET@@ swap
+c:    @@BSDPARTSECTORS@@ @@FSOFFSET@@ unused 0 0
+d:    @@IMAGESECTORS@@ 0 unused 0 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/diskproto.noswap.in	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,23 @@
+# $NetBSD: diskproto.noswap.in,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+type: ESDI
+disk: image
+label: 
+flags:
+bytes/sector: 512
+sectors/track: @@SECTORS@@
+tracks/cylinder: @@HEADS@@
+sectors/cylinder: @@SECPERCYLINDERS@@
+cylinders: @@CYLINDERS@@
+total sectors: @@IMAGESECTORS@@
+rpm: 3600
+interleave: 1
+trackskew: 0
+cylinderskew: 0
+headswitch: 0           # microseconds
+track-to-track seek: 0  # microseconds
+drivedata: 0 
+
+8 partitions:
+#        size    offset     fstype [fsize bsize cpg/sgs]
+a:    @@FSSECTORS@@ @@FSOFFSET@@ 4.2BSD 1024 8192 16
+c:    @@IMAGESECTORS@@ 0 unused 0 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/diskproto.noswap.mbr.in	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,24 @@
+# $NetBSD: diskproto.noswap.mbr.in,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+type: ESDI
+disk: image
+label: 
+flags:
+bytes/sector: 512
+sectors/track: @@SECTORS@@
+tracks/cylinder: @@HEADS@@
+sectors/cylinder: @@SECPERCYLINDERS@@
+cylinders: @@CYLINDERS@@
+total sectors: @@IMAGESECTORS@@
+rpm: 3600
+interleave: 1
+trackskew: 0
+cylinderskew: 0
+headswitch: 0           # microseconds
+track-to-track seek: 0  # microseconds
+drivedata: 0 
+
+8 partitions:
+#        size    offset     fstype [fsize bsize cpg/sgs]
+a:    @@FSSECTORS@@ @@FSOFFSET@@ 4.2BSD 1024 8192 16
+c:    @@BSDPARTSECTORS@@ @@FSOFFSET@@ unused 0 0
+d:    @@IMAGESECTORS@@ 0 unused 0 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/fstab.in	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,5 @@
+/dev/@@BOOTDISK@@a	/		ffs	rw,log		1 1
+/dev/@@BOOTDISK@@b	none		none	sw		0 0
+ptyfs		/dev/pts	ptyfs	rw		0 0
+kernfs		/kern		kernfs	rw,noauto	0 0
+procfs		/proc		procfs	rw,noauto	0 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/fstab.install.in	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,2 @@
+/dev/@@BOOTDISK@@a	/		ffs	rw,log		1 1
+tmpfs			/tmp		tmpfs	rw		0 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/spec.in	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,5 @@
+# $NetBSD: spec.in,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+./netbsd	type=file mode=0755 uname=root gname=wheel
+./kern		type=dir mode=0755 uname=root gname=wheel
+./proc		type=dir mode=0755 uname=root gname=wheel
+./tmp		type=dir mode=1777 uname=root gname=wheel
--- a/distrib/i386/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/i386/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2008/12/01 10:11:26 ad Exp $
+#	$NetBSD: Makefile,v 1.9 2012/01/22 03:53:32 tsutsui Exp $
 
 SUBDIR=
 SUBDIR+=	ramdisks
@@ -8,9 +8,17 @@
 SUBDIR+=	.WAIT
 SUBDIR+=	cdroms
 SUBDIR+=	floppies
+SUBDIR+=	liveimage
+SUBDIR+=	installimage
 TARGETS+=	release
 
 iso_image:
 	${MAKEDIRTARGET} cdroms iso_image
 
+live_image:
+	${MAKEDIRTARGET} liveimage live_image
+
+install_image:
+	${MAKEDIRTARGET} installimage install_image
+
 .include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/i386/installimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,41 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+
+.include <bsd.own.mk>
+
+INSTIMGBASE=	i386inst		# gives ${IMGBASE}.img
+
+BOOTDISK=	sd0			# for USB flash etc.
+IMAGEMB=	512			# for all installation binaries
+
+PRIMARY_BOOT=		bootxx_ffsv1
+SECONDARY_BOOT=		boot
+SECONDARY_BOOT_ARG=	# unnecessary
+
+USE_MBR=		yes
+
+CLEANFILES+=	boot.cfg
+
+prepare_md_post:
+	${TOOL_SED}							\
+	    -e "s/@@MACHINE@@/${MACHINE}/"				\
+	    -e "s/@@VERSION@@/${DISTRIBVER}/"				\
+	    < ${.CURDIR}/boot.cfg.in > boot.cfg
+
+DISTRIBDIR!= cd ${.CURDIR}/../.. ; pwd
+SYSINSTDIR!= cd ${DISTRIBDIR}/utils/sysinst/arch/${MACHINE} && ${PRINTOBJDIR}
+
+SPEC_EXTRA=		${.CURDIR}/spec.inst
+IMGFILE_EXTRA=								\
+	${DISTRIBDIR}/common/10-resolv.conf	libexec/dhcpcd-hooks	\
+	${DISTRIBDIR}/common/99-print-sysinst	libexec/dhcpcd-hooks	\
+	${.CURDIR}/etc.ttys		etc/ttys			\
+	${.CURDIR}/etc.rc		etc/rc				\
+	${.CURDIR}/install.sh		.				\
+	${.OBJDIR}/boot.cfg		.				\
+	${SYSINSTDIR}/sysinstmsgs.de	.				\
+	${SYSINSTDIR}/sysinstmsgs.es	.				\
+	${SYSINSTDIR}/sysinstmsgs.fr	.				\
+	${SYSINSTDIR}/sysinstmsgs.pl	.				\
+	${SYSINSTDIR}/sysinst		.
+
+.include "${DISTRIBDIR}/common/bootimage/Makefile.installimage"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/i386/installimage/boot.cfg.in	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,12 @@
+banner=Welcome to the NetBSD/@@MACHINE@@ @@VERSION@@ installation image
+banner================================================================================
+banner=
+banner=ACPI (Advanced Configuration and Power Interface) should work on all modern
+banner=and legacy hardware.  However if you do encounter a problem while booting,
+banner=try disabling it and report a bug at http://www.NetBSD.org/.
+menu=Install NetBSD:boot netbsd
+menu=Install NetBSD (no ACPI):boot netbsd -2
+menu=Install NetBSD (no ACPI, no SMP):boot netbsd -12
+menu=Drop to boot prompt:prompt
+timeout=30
+clear=1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/i386/installimage/etc.rc	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,52 @@
+# $NetBSD: etc.rc,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+#
+# Copyright (c) 1997 Perry E. Metzger
+# Copyright (c) 1994 Christopher G. Demetriou
+# All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#          This product includes software developed for the
+#          NetBSD Project.  See http://www.NetBSD.org/ for
+#          information about NetBSD.
+# 4. The name of the author may not be used to endorse or promote products
+#    derived from this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# 
+# <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
+
+PATH=/sbin:/bin:/usr/bin:/usr/sbin:/
+export PATH
+
+# hack to get around bugs in kernfs's rootdev/rrootdev lookup.
+ls -l /dev/* > /dev/null 2>&1
+
+mount -u /
+mount -t tmpfs tmpfs /tmp
+
+# create a gettytab to autologin and run sysinst
+echo "# Autostart sysinst" > /tmp/gettytab
+echo -n "sysinst:al=root:lo=/install.sh:im=:sp#" >> /tmp/gettytab
+stty speed >> /tmp/gettytab
+cp /tmp/gettytab /etc
+
+# done, move on to multiuser mode
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/i386/installimage/etc.ttys	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: etc.ttys,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+#
+# re-launch the sysinst wrapper script on console
+#
+# name	getty				type	status		comments
+#
+console	"/usr/libexec/getty sysinst"	wsvt25	on secure
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/i386/installimage/install.sh	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,115 @@
+#! /bin/sh -m
+# $NetBSD: install.sh,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+#
+# -
+#  Copyright (c) 2010 The NetBSD Foundation, Inc.
+#  All rights reserved.
+# 
+#  This code is derived from software contributed to The NetBSD Foundation
+#  by Martin Husemann <martin@NetBSD.org>.
+# 
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+# 
+#  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+#  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+#  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+#  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+#  POSSIBILITY OF SUCH DAMAGE.
+
+
+# setup basic environment
+PATH=/sbin:/bin:/usr/bin:/usr/sbin:/
+export PATH
+
+termfile=/tmp/sysinst.term
+
+# Check if we are on a framebuffer or on serial console and default
+# the terminal type accordingly.
+# There is no /var/db/dev.db, so sysctl might not map the devicename properly;
+# ttyE0 is 90,0 -> 0x5a00
+case $(sysctl -nx kern.consdev) in
+ 002f000000000000)
+    TERM=wsvt25
+    ;;
+ *)
+    if [ -r ${termfile} ]; then
+	. ${termfile}
+    else
+	TERM=vt220
+    fi
+    ;;
+esac
+
+export TERM
+HOME=/
+export HOME
+BLOCKSIZE=1k
+export BLOCKSIZE
+EDITOR=ed
+export EDITOR
+SHELL=/bin/sh
+export SHELL
+
+umask 022
+
+stty newcrt werase ^W intr ^C kill ^U erase ^?
+if [ $TERM != "wsvt25" ]; then
+	cat << "EOM"
+
+
+You are using a serial console, we do not know your terminal emulation.
+Please select one, typical values are:
+
+	vt100
+	ansi
+	xterm
+
+EOM
+	echo -n "Terminal type (just hit ENTER for '$TERM'): "
+	read ans
+	if [ -n "$ans" ];then
+	    TERM=$ans
+	fi
+fi
+
+# run the installation or upgrade script.
+cd /
+cmd=./sysinst
+
+while [ -n "${cmd}" ]
+do
+	${cmd}
+	if [ $? = 4 ]; then
+		echo "Oops, something went wrong - we will try again"
+		exit
+	else
+		if [ -n "$(jobs)" ]; then
+			tput clear
+			echo "You have stopped sysinst, return to it by" \
+				"typing 'exit' or ^D."
+			${SHELL} -i
+			cmd="fg"
+		else
+			cmd=""
+		fi
+	fi
+done
+
+# remember terminal type, now that we know it for sure
+echo "TERM=${TERM}" > ${termfile}
+echo
+echo "To return to the installer, quit this shell by typing 'exit' or ^D."
+exec ${SHELL}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/i386/installimage/spec.inst	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,18 @@
+# $NetBSD: spec.inst,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+./mnt2			type=dir mode=0755 uname=root gname=wheel
+./targetroot		type=dir mode=0755 uname=root gname=wheel
+
+./libexec/dhcpcd-hooks/10-resolv.conf	type=file mode=0444 uname=root gname=wheel
+./libexec/dhcpcd-hooks/99-print-sysinst	type=file mode=0444 uname=root gname=wheel
+
+./install.sh		type=file mode=0755 uname=root gname=wheel
+./sysinst		type=file mode=0755 uname=root gname=wheel
+./sysinstmsgs.de	type=file mode=0444 uname=root gname=wheel
+./sysinstmsgs.es	type=file mode=0444 uname=root gname=wheel
+./sysinstmsgs.fr	type=file mode=0444 uname=root gname=wheel
+./sysinstmsgs.pl	type=file mode=0444 uname=root gname=wheel
+
+# for sysinst "install from local directory" default
+./release		type=link mode=0755 uname=root gname=wheel link=.
+
+# XXX what to do for files in ${RELEASEMACHINEDIR}?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/i386/liveimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+
+SUBDIR=
+SUBDIR+=	emuimage
+SUBDIR+=	usbimage
+
+TARGETS+=	release live_image
+
+.include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/i386/liveimage/Makefile.liveimage	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,13 @@
+#	$NetBSD: Makefile.liveimage,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+
+.include <bsd.own.mk>
+
+KERN_SET=		kern-GENERIC
+BOOTDISK?=		wd0		# for emulators
+PRIMARY_BOOT=		bootxx_ffsv1
+SECONDARY_BOOT=		boot
+SECONDARY_BOOT_ARG=	# unnecessary
+
+USE_MBR=		yes
+
+.include "${.CURDIR}/../../../common/bootimage/Makefile.liveimage"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/i386/liveimage/emuimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,7 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+
+LIVEIMGBASE=	i386emu			# gives ${IMGBASE}.img
+
+BOOTDISK=	wd0			# for QEMU etc.
+
+.include "${.CURDIR}/../Makefile.liveimage"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/i386/liveimage/usbimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,9 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+
+LIVEIMGBASE=	i386live		# gives ${IMGBASE}.img
+
+BOOTDISK=	sd0			# for USB flash etc.
+IMAGEMB=	1536            	# 2GB USB flash memories aren't 2GiB
+OMIT_SWAPIMG=	yes			# no need to write swap
+
+.include "${.CURDIR}/../Makefile.liveimage"
--- a/distrib/pmax/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/pmax/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,9 +1,12 @@
-#	$NetBSD: Makefile,v 1.4 2007/03/06 21:57:15 bouyer Exp $
+#	$NetBSD: Makefile,v 1.5 2012/01/22 03:53:32 tsutsui Exp $
 
-SUBDIR=		ramdisk .WAIT instkernel .WAIT cdroms
+SUBDIR=		ramdisk .WAIT instkernel .WAIT cdroms liveimage
 TARGETS+=	release
 
 iso_image:
 	${MAKEDIRTARGET} cdroms iso_image
 
+live_image:
+	${MAKEDIRTARGET} liveimage live_image
+
 .include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/pmax/liveimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+
+SUBDIR=
+SUBDIR+=	emuimage
+
+TARGETS+=	release live_image
+
+.include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/pmax/liveimage/emuimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,12 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+LIVEIMGBASE=	pmaxlive			# gives ${IMGBASE}.img
+
+.include <bsd.own.mk>
+
+KERN_SET=		kern-GENERIC
+BOOTDISK=		sd0
+PRIMARY_BOOT=		bootxx_ffs
+#SECONDARY_BOOT=	# boot.pmax is extracted from base.tgz
+SECONDARY_BOOT_ARG=	# nothing
+
+.include "${.CURDIR}/../../../common/bootimage/Makefile.liveimage"
--- a/distrib/sparc/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/sparc/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,9 +1,12 @@
-#	$NetBSD: Makefile,v 1.7 2007/03/06 21:57:23 bouyer Exp $
+#	$NetBSD: Makefile,v 1.8 2012/01/22 03:53:33 tsutsui Exp $
 
-SUBDIR=		instfs ramdisk .WAIT bootfs .WAIT cdroms
+SUBDIR=		instfs ramdisk .WAIT bootfs .WAIT cdroms liveimage
 TARGETS+=	release
 
 iso_image:
 	${MAKEDIRTARGET} cdroms iso_image
 
+live_image:
+	${MAKEDIRTARGET} liveimage live_image
+
 .include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sparc/liveimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+
+SUBDIR=
+SUBDIR+=	emuimage
+
+TARGETS+=	release live_image
+
+.include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sparc/liveimage/emuimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,15 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:31 tsutsui Exp $
+
+LIVEIMGBASE=	sparcemu		# gives ${IMGBASE}.img
+
+.include <bsd.own.mk>
+
+KERN_SET=		kern-GENERIC
+BOOTDISK=		sd0
+PRIMARY_BOOT=		bootxx
+SECONDARY_BOOT=		boot
+SECONDARY_BOOT_ARG=	/${SECONDARY_BOOT}
+
+USE_SUNLABEL=		yes
+
+.include "${.CURDIR}/../../../common/bootimage/Makefile.liveimage"
--- a/distrib/sparc64/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/sparc64/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,9 +1,12 @@
-#	$NetBSD: Makefile,v 1.7 2007/03/06 21:57:24 bouyer Exp $
+#	$NetBSD: Makefile,v 1.8 2012/01/22 03:53:33 tsutsui Exp $
 
-SUBDIR=		instfs .WAIT xminiroot bootfs .WAIT cdroms
+SUBDIR=		instfs .WAIT xminiroot bootfs .WAIT cdroms liveimage
 TARGETS+=	release
 
 iso_image:
 	${MAKEDIRTARGET} cdroms iso_image
 
+live_image:
+	${MAKEDIRTARGET} liveimage live_image
+
 .include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sparc64/liveimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2012/01/22 03:53:31 tsutsui Exp $
+
+SUBDIR=
+SUBDIR+=	emuimage
+
+TARGETS+=	release live_image
+
+.include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sparc64/liveimage/emuimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,16 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:31 tsutsui Exp $
+
+LIVEIMGBASE=	sparc64emu		# gives ${IMGBASE}.img
+
+.include <bsd.own.mk>
+
+KERN_SET=		kern-GENERIC
+BOOTDISK=		sd0		# for QEMU
+#BOOTDISK=		wd0		# for Ultra5/10 image?
+PRIMARY_BOOT=		bootblk
+#SECONDARY_BOOT=	# nothing
+#SECONDARY_BOOT_ARG=	# unnecessary
+
+USE_SUNLABEL=		yes
+
+.include "${.CURDIR}/../../../common/bootimage/Makefile.liveimage"
--- a/distrib/sun2/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/sun2/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,6 +1,6 @@
-#	$NetBSD: Makefile,v 1.9 2008/06/23 02:16:54 matt Exp $
+#	$NetBSD: Makefile,v 1.10 2012/01/22 03:53:33 tsutsui Exp $
 
-SUBDIR=		ramdisk miniroot cdroms
+SUBDIR=		ramdisk miniroot cdroms liveimage
 TARGETS+=	release
 
 .include <bsd.own.mk>
@@ -19,4 +19,7 @@
 iso_image:
 	${MAKEDIRTARGET} cdroms iso_image
 
+live_image:
+	${MAKEDIRTARGET} liveimage live_image
+
 .include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sun2/liveimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2012/01/22 03:53:31 tsutsui Exp $
+
+SUBDIR=
+SUBDIR+=	emuimage
+
+TARGETS+=	release live_image
+
+.include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sun2/liveimage/emuimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,15 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:31 tsutsui Exp $
+
+LIVEIMGBASE=	sun2emu			# gives ${IMGBASE}.img
+
+.include <bsd.own.mk>
+
+KERN_SET=		kern-GENERIC
+BOOTDISK=		sd0
+PRIMARY_BOOT=		bootxx
+SECONDARY_BOOT=		ufsboot
+SECONDARY_BOOT_ARG=	/${SECONDARY_BOOT}
+
+#USE_SUNLABEL=		yes		# sun2 PROM doesn't read sunlabel
+
+.include "${.CURDIR}/../../../common/bootimage/Makefile.liveimage"
--- a/distrib/sun3/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/sun3/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,6 +1,6 @@
-#	$NetBSD: Makefile,v 1.10 2008/06/23 02:16:54 matt Exp $
+#	$NetBSD: Makefile,v 1.11 2012/01/22 03:53:33 tsutsui Exp $
 
-SUBDIR=		ramdisk miniroot .WAIT cdroms
+SUBDIR=		ramdisk miniroot .WAIT cdroms liveimage
 TARGETS+=	release
 
 .include <bsd.own.mk>
@@ -22,4 +22,7 @@
 iso_image:
 	${MAKEDIRTARGET} cdroms iso_image
 
+live_image:
+	${MAKEDIRTARGET} liveimage live_image
+
 .include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sun3/liveimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2012/01/22 03:53:31 tsutsui Exp $
+
+SUBDIR=
+SUBDIR+=	emuimage
+
+TARGETS+=	release live_image
+
+.include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sun3/liveimage/emuimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,15 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:31 tsutsui Exp $
+
+LIVEIMGBASE=	sun3emu			# gives ${IMGBASE}.img
+
+.include <bsd.own.mk>
+
+KERN_SET=		kern-GENERIC
+BOOTDISK=		sd0
+PRIMARY_BOOT=		bootxx
+SECONDARY_BOOT=		ufsboot
+SECONDARY_BOOT_ARG=	/${SECONDARY_BOOT}
+
+USE_SUNLABEL=		yes
+
+.include "${.CURDIR}/../../../common/bootimage/Makefile.liveimage"
--- a/distrib/vax/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/distrib/vax/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.18 2008/06/23 02:16:54 matt Exp $
+#	$NetBSD: Makefile,v 1.19 2012/01/22 03:53:33 tsutsui Exp $
 
 .include <bsd.own.mk>
 .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
 
-SUBDIR=		ramdisk .WAIT ramdisk-kernel .WAIT floppy cdroms
+SUBDIR=		ramdisk .WAIT ramdisk-kernel .WAIT floppy cdroms liveimage
 TARGETS+=	release
 
 release: check_RELEASEDIR .WAIT ${DESTDIR}/usr/mdec/boot
@@ -13,4 +13,7 @@
 iso_image:
 	${MAKEDIRTARGET} cdroms iso_image
 
+live_image:
+	${MAKEDIRTARGET} liveimage live_image
+
 .include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/vax/liveimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2012/01/22 03:53:31 tsutsui Exp $
+
+SUBDIR=
+SUBDIR+=	emuimage
+
+TARGETS+=	release live_image
+
+.include <bsd.subdir.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/vax/liveimage/emuimage/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -0,0 +1,13 @@
+#	$NetBSD: Makefile,v 1.1 2012/01/22 03:53:32 tsutsui Exp $
+LIVEIMGBASE=	vaxlive			# gives ${IMGBASE}.img
+
+.include <bsd.own.mk>
+
+KERN_SET=		kern-GENERIC
+BOOTDISK=		ra0
+IMAGEMB=		1024		# ra0 can't handle 2GB image
+PRIMARY_BOOT=		xxboot
+#SECONDARY_BOOT=	# boot is extracted from base.tgz
+SECONDARY_BOOT_ARG=	# nothing
+
+.include "${.CURDIR}/../../../common/bootimage/Makefile.liveimage"
--- a/etc/Makefile	Sun Jan 22 03:48:51 2012 +0000
+++ b/etc/Makefile	Sun Jan 22 03:53:29 2012 +0000
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.395 2012/01/15 17:36:55 joerg Exp $
+#	$NetBSD: Makefile,v 1.396 2012/01/22 03:53:33 tsutsui Exp $
 #	from: @(#)Makefile	8.7 (Berkeley) 5/25/95
 
 # Environment variables without default values:
@@ -475,6 +475,33 @@
 #	(empty -- look in the machine-dependent Makefile.inc)
 
 
+# live-image --
+#	Standalone target to create live images after the release was composed.
+#	Should be run after "make release" in src and xsrc.
+#	LIVEIMG_RELEASEDIR specifies where to install live images and
+#	it can be set in MD etc.${MACHINE}/Makefile.inc.
+#
+LIVEIMG_RELEASEDIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/liveimage
+
+live-image: .PHONY check_DESTDIR check_RELEASEDIR
+	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib live_image \
+	    LIVEIMG_RELEASEDIR=${LIVEIMG_RELEASEDIR}
+	${MAKESUMS} -t ${LIVEIMG_RELEASEDIR} '*.img.gz'
+
+# install-image --
+#	Standalone target to create installation images
+#	after the release was composed.
+#	Should be run after "make release" in src and xsrc.
+#	INSTIMG_RELEASEDIR specifies where to install live images and
+#	it can be set in MD etc.${MACHINE}/Makefile.inc.
+#
+INSTIMG_RELEASEDIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/installimage
+
+install-image: .PHONY check_DESTDIR check_RELEASEDIR
+	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib install_image \
+	    INSTIMG_RELEASEDIR=${INSTIMG_RELEASEDIR}
+	${MAKESUMS} -t ${INSTIMG_RELEASEDIR} '*.img.gz'
+
 # snap_pre --
 #	Create ${RELEASEDIR} and necessary subdirectories.
 #