# $NetBSD: wii.conf,v 1.3.2.2 2024/02/03 11:47:06 martin Exp $
# Nintendo Wii customization script used by mkimage
#
board=wii
resize=true
swap=true
swap_size_MB=128
swap_file=/swap

. ${DIR}/conf/evbppc.conf

kernel_WII="WII"

make_label() {
	make_label_evbppc
}

make_fstab() {
	make_fstab_evbppc

	cat >> ${mnt}/etc/fstab << EOF
${swap_file} none swap sw,priority=1 0 0
EOF
}

customize() {
	customize_evbppc
	cat >> "${mnt}/etc/rc.conf" << EOF
mdnsd=YES
devpubd=YES
wscons=YES
makemandb=NO
EOF
}

populate() {
	echo "${bar} looking for kernel in ${kernel} ${bar}"
	k="${kernel}/netbsd-WII.gz"

	# install files to /boot partition
	tgt="apps/netbsd/boot.elf"
	echo "${bar} installing ${k} to /boot/${tgt} ${bar}"
	mkdir -p "${mnt}/boot/apps/netbsd"
	case "${k}" in
	*.gz)
		${GZIP_CMD} -dc "${k}" > "${mnt}/boot/${tgt}"
		;;
	*)
		cp "${k}" "${mnt}/boot/${tgt}"
		;;
	esac

	# Metadata for HBC
	cp ${DIR}/files/evbppc_wii_meta.xml ${mnt}/boot/apps/netbsd/meta.xml
	cp ${DIR}/files/evbppc_wii_icon.png ${mnt}/boot/apps/netbsd/icon.png

	# Add swap space
	rm -f ${mnt}${swap_file}
	dd if=/dev/zero of=${mnt}${swap_file} bs=1 count=1 \
	    seek=$((${swap_size_MB} * 1024 * 1024 - 1))
	echo ".${swap_file} type=file uname=root gname=wheel mode=0600" \
            >> "$tmp/selected_sets"
}
