Module Name: src Committed By: christos Date: Fri Dec 27 19:02:19 UTC 2024
Modified Files: src/distrib/utils/embedded: mkimage src/distrib/utils/embedded/conf: evbarm.conf evbmips.conf evbppc.conf riscv.conf x86.conf Log Message: Remove duplicated code, handle minwrites in _normal the same way we handle it in _gpt. Initial patch from jmmv@. To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/distrib/utils/embedded/mkimage cvs rdiff -u -r1.42 -r1.43 src/distrib/utils/embedded/conf/evbarm.conf cvs rdiff -u -r1.4 -r1.5 src/distrib/utils/embedded/conf/evbmips.conf cvs rdiff -u -r1.1 -r1.2 src/distrib/utils/embedded/conf/evbppc.conf cvs rdiff -u -r1.2 -r1.3 src/distrib/utils/embedded/conf/riscv.conf cvs rdiff -u -r1.11 -r1.12 src/distrib/utils/embedded/conf/x86.conf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/utils/embedded/mkimage diff -u src/distrib/utils/embedded/mkimage:1.84 src/distrib/utils/embedded/mkimage:1.85 --- src/distrib/utils/embedded/mkimage:1.84 Mon Aug 12 14:45:51 2024 +++ src/distrib/utils/embedded/mkimage Fri Dec 27 14:02:19 2024 @@ -1,5 +1,5 @@ #!/bin/sh -# $NetBSD: mkimage,v 1.84 2024/08/12 18:45:51 skrll Exp $ +# $NetBSD: mkimage,v 1.85 2024/12/27 19:02:19 christos Exp $ # # Copyright (c) 2013, 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -112,6 +112,72 @@ getsectors() { echo $((m * v / 512)) } +minwrites_fstab_entries() { + $minwrites || return 0 + cat << EOF +tmpfs /var/log tmpfs rw,union,-s32M +tmpfs /var/run tmpfs rw,union,-s1M +tmpfs /var/mail tmpfs rw,union,-s10M +tmpfs /var/spool/postfix tmpfs rw,union,-s20M +tmpfs /var/db/postfix tmpfs rw,union,-s1M +tmpfs /var/chroot tmpfs rw,union,-s10M +EOF +} + +make_fstab_gpt() { + local boot=$1 + local rootopts= + if $minwrites; then + rootopts=,log,nodevmtime + fi + + cat > ${mnt}/etc/fstab << EOF +# NetBSD /etc/fstab +# See /usr/share/examples/fstab/ for more examples. +NAME=${gpt_label_ffs:-netbsd-root} / ffs rw,noatime${rootopts} 1 1 +NAME=${gpt_label_boot:-$boot} /boot msdos rw 1 1 +ptyfs /dev/pts ptyfs rw +procfs /proc procfs rw +tmpfs /var/shm tmpfs rw,-m1777,-sram%25 +EOF + minwrites_fstab_entries >> ${mnt}/etc/fstab +} + +# From Richard Neswold's: +# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html +# Also for the postfix stuff below +make_fstab_normal() { + local rootopts= + if $minwrites; then + rootopts=,nodevmtime + fi + cat > ${mnt}/etc/fstab << EOF +# NetBSD /etc/fstab +# See /usr/share/examples/fstab/ for more examples. +ROOT.a / ffs rw,log,noatime,$rootopts 1 1 +ROOT.e /boot msdos rw 1 1 +ptyfs /dev/pts ptyfs rw +procfs /proc procfs rw +tmpfs /tmp tmpfs rw,-s32M +tmpfs /var/shm tmpfs rw,-m1777,-sram%25 +EOF + minwrites_fstab_entries >> ${mnt}/etc/fstab +} + +make_fstab_default() { + if $gpt; then + make_fstab_gpt "$@" + else + make_fstab_normal + fi + echo "./etc/fstab type=file uname=root gname=wheel mode=0644" \ + >> "$tmp/selected_sets" + + # Missing mount points from fstab + echo "./proc type=dir uname=root gname=wheel mode=0755" \ + >> "$tmp/selected_sets" +} + usage() { cat << EOF 1>&2 Usage: $PROG -h <host-arch> [-bdmx] [-B <byte-order>] [-K <kerneldir>] [-S <srcdir>] [-D <destdir>] [-c <custom-files-dir>] [-s <Mb size>] [<image>] Index: src/distrib/utils/embedded/conf/evbarm.conf diff -u src/distrib/utils/embedded/conf/evbarm.conf:1.42 src/distrib/utils/embedded/conf/evbarm.conf:1.43 --- src/distrib/utils/embedded/conf/evbarm.conf:1.42 Tue Sep 26 20:24:13 2023 +++ src/distrib/utils/embedded/conf/evbarm.conf Fri Dec 27 14:02:19 2024 @@ -1,4 +1,4 @@ -# $NetBSD: evbarm.conf,v 1.42 2023/09/27 00:24:13 riastradh Exp $ +# $NetBSD: evbarm.conf,v 1.43 2024/12/27 19:02:19 christos Exp $ # evbarm shared config # image=$HOME/${board}.img @@ -65,66 +65,8 @@ drivedata: 0 EOF } -make_fstab_evbarm_gpt() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -NAME=${gpt_label_ffs:-netbsd-root} / ffs rw,noatime 1 1 -NAME=${gpt_label_boot:-EFI} /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - -make_fstab_evbarm_normal() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -ROOT.a / ffs rw,noatime 1 1 -ROOT.e /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - -# From Richard Neswold's: -# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html -# Also for the postfix stuff below -make_fstab_evbarm_minwrites() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -ROOT.a / ffs rw,log,noatime,nodevmtime 1 1 -ROOT.e /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /tmp tmpfs rw,-s32M -tmpfs /var/log tmpfs rw,union,-s32M -tmpfs /var/run tmpfs rw,union,-s1M -tmpfs /var/mail tmpfs rw,union,-s10M -tmpfs /var/spool/postfix tmpfs rw,union,-s20M -tmpfs /var/db/postfix tmpfs rw,union,-s1M -tmpfs /var/chroot tmpfs rw,union,-s10M -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - make_fstab_evbarm() { - if $gpt; then - make_fstab_evbarm_gpt - elif $minwrites; then - make_fstab_evbarm_minwrites - else - make_fstab_evbarm_normal - fi - echo "./etc/fstab type=file uname=root gname=wheel mode=0644" \ - >> "$tmp/selected_sets" - - # Missing mount points from fstab - echo "./proc type=dir uname=root gname=wheel mode=0755" \ - >> "$tmp/selected_sets" + make_fstab_default EFI } customize_evbarm() { Index: src/distrib/utils/embedded/conf/evbmips.conf diff -u src/distrib/utils/embedded/conf/evbmips.conf:1.4 src/distrib/utils/embedded/conf/evbmips.conf:1.5 --- src/distrib/utils/embedded/conf/evbmips.conf:1.4 Tue Sep 26 20:24:13 2023 +++ src/distrib/utils/embedded/conf/evbmips.conf Fri Dec 27 14:02:19 2024 @@ -1,4 +1,4 @@ -# $NetBSD: evbmips.conf,v 1.4 2023/09/27 00:24:13 riastradh Exp $ +# $NetBSD: evbmips.conf,v 1.5 2024/12/27 19:02:19 christos Exp $ # evbmips shared config # image=$HOME/${board}.img @@ -65,66 +65,8 @@ drivedata: 0 EOF } -make_fstab_evbmips_gpt() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -NAME=${gpt_label_ffs:-netbsd-root} / ffs rw,noatime 1 1 -NAME=${gpt_label_boot:-boot} /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - -make_fstab_evbmips_normal() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -ROOT.a / ffs rw,noatime 1 1 -ROOT.e /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - -# From Richard Neswold's: -# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html -# Also for the postfix stuff below -make_fstab_evbmips_minwrites() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -ROOT.a / ffs rw,log,noatime,nodevmtime 1 1 -ROOT.e /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /tmp tmpfs rw,-s32M -tmpfs /var/log tmpfs rw,union,-s32M -tmpfs /var/run tmpfs rw,union,-s1M -tmpfs /var/mail tmpfs rw,union,-s10M -tmpfs /var/spool/postfix tmpfs rw,union,-s20M -tmpfs /var/db/postfix tmpfs rw,union,-s1M -tmpfs /var/chroot tmpfs rw,union,-s10M -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - make_fstab_evbmips() { - if $gpt; then - make_fstab_evbmips_gpt - elif $minwrites; then - make_fstab_evbmips_minwrites - else - make_fstab_evbmips_normal - fi - echo "./etc/fstab type=file uname=root gname=wheel mode=0644" \ - >> "$tmp/selected_sets" - - # Missing mount points from fstab - echo "./proc type=dir uname=root gname=wheel mode=0755" \ - >> "$tmp/selected_sets" + make_fstab_default boot } customize_evbmips() { Index: src/distrib/utils/embedded/conf/evbppc.conf diff -u src/distrib/utils/embedded/conf/evbppc.conf:1.1 src/distrib/utils/embedded/conf/evbppc.conf:1.2 --- src/distrib/utils/embedded/conf/evbppc.conf:1.1 Sat Jan 20 16:35:59 2024 +++ src/distrib/utils/embedded/conf/evbppc.conf Fri Dec 27 14:02:19 2024 @@ -1,4 +1,4 @@ -# $NetBSD: evbppc.conf,v 1.1 2024/01/20 21:35:59 jmcneill Exp $ */ +# $NetBSD: evbppc.conf,v 1.2 2024/12/27 19:02:19 christos Exp $ */ # evbppc shared config # image=$HOME/${board}.img @@ -65,66 +65,8 @@ drivedata: 0 EOF } -make_fstab_evbppc_gpt() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -NAME=${gpt_label_ffs:-netbsd-root} / ffs rw,noatime 1 1 -NAME=${gpt_label_boot:-boot} /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - -make_fstab_evbppc_normal() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -ROOT.a / ffs rw,noatime 1 1 -ROOT.e /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - -# From Richard Neswold's: -# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html -# Also for the postfix stuff below -make_fstab_evbppc_minwrites() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -ROOT.a / ffs rw,log,noatime,nodevmtime 1 1 -ROOT.e /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /tmp tmpfs rw,-s32M -tmpfs /var/log tmpfs rw,union,-s32M -tmpfs /var/run tmpfs rw,union,-s1M -tmpfs /var/mail tmpfs rw,union,-s10M -tmpfs /var/spool/postfix tmpfs rw,union,-s20M -tmpfs /var/db/postfix tmpfs rw,union,-s1M -tmpfs /var/chroot tmpfs rw,union,-s10M -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - make_fstab_evbppc() { - if $gpt; then - make_fstab_evbppc_gpt - elif $minwrites; then - make_fstab_evbppc_minwrites - else - make_fstab_evbppc_normal - fi - echo "./etc/fstab type=file uname=root gname=wheel mode=0644" \ - >> "$tmp/selected_sets" - - # Missing mount points from fstab - echo "./proc type=dir uname=root gname=wheel mode=0755" \ - >> "$tmp/selected_sets" + make_fstab_default boot } customize_evbppc() { Index: src/distrib/utils/embedded/conf/riscv.conf diff -u src/distrib/utils/embedded/conf/riscv.conf:1.2 src/distrib/utils/embedded/conf/riscv.conf:1.3 --- src/distrib/utils/embedded/conf/riscv.conf:1.2 Tue Sep 26 20:24:13 2023 +++ src/distrib/utils/embedded/conf/riscv.conf Fri Dec 27 14:02:19 2024 @@ -1,4 +1,4 @@ -# $NetBSD: riscv.conf,v 1.2 2023/09/27 00:24:13 riastradh Exp $ +# $NetBSD: riscv.conf,v 1.3 2024/12/27 19:02:19 christos Exp $ # riscv shared config # image=$HOME/${board}.img @@ -63,42 +63,8 @@ drivedata: 0 EOF } -make_fstab_riscv_gpt() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -NAME=${gpt_label_ffs:-netbsd-root} / ffs rw,noatime 1 1 -NAME=${gpt_label_boot:-EFI} /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - -make_fstab_riscv_normal() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -ROOT.a / ffs rw,noatime 1 1 -ROOT.e /boot msdos rw 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /var/shm tmpfs rw,-m1777,-sram%25 -EOF -} - make_fstab_riscv() { - if $gpt; then - make_fstab_riscv_gpt - else - make_fstab_riscv_normal - fi - echo "./etc/fstab type=file uname=root gname=wheel mode=0644" \ - >> "$tmp/selected_sets" - - # Missing mount points from fstab - echo "./proc type=dir uname=root gname=wheel mode=0755" \ - >> "$tmp/selected_sets" + make_fstab_default EFI } customize_riscv() { Index: src/distrib/utils/embedded/conf/x86.conf diff -u src/distrib/utils/embedded/conf/x86.conf:1.11 src/distrib/utils/embedded/conf/x86.conf:1.12 --- src/distrib/utils/embedded/conf/x86.conf:1.11 Tue Sep 26 20:24:13 2023 +++ src/distrib/utils/embedded/conf/x86.conf Fri Dec 27 14:02:19 2024 @@ -1,4 +1,4 @@ -# $NetBSD: x86.conf,v 1.11 2023/09/27 00:24:13 riastradh Exp $ +# $NetBSD: x86.conf,v 1.12 2024/12/27 19:02:19 christos Exp $ # x86 shared config # @@ -53,47 +53,8 @@ drivedata: 0 EOF } -make_fstab_normal() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -/dev/${rootdev}0a / ffs rw,log 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -EOF -} - -# From Richard Neswold's: -# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html -# Also for the postfix stuff below -make_fstab_minwrites() { - cat > ${mnt}/etc/fstab << EOF -# NetBSD /etc/fstab -# See /usr/share/examples/fstab/ for more examples. -/dev/${rootdev}0a / ffs rw,log,noatime,nodevmtime 1 1 -ptyfs /dev/pts ptyfs rw -procfs /proc procfs rw -tmpfs /tmp tmpfs rw,-s32M -tmpfs /var/log tmpfs rw,union,-s32M -tmpfs /var/run tmpfs rw,union,-s1M -tmpfs /var/mail tmpfs rw,union,-s10M -tmpfs /var/spool/postfix tmpfs rw,union,-s20M -tmpfs /var/db/postfix tmpfs rw,union,-s1M -tmpfs /var/chroot tmpfs rw,union,-s10M -EOF -} - make_fstab() { - if $minwrites; then - make_fstab_minwrites - else - make_fstab_normal - fi - echo "./etc/fstab type=file uname=root gname=wheel mode=0755" \ - >> "$tmp/selected_sets" - - echo "./proc type=dir uname=root gname=wheel mode=0755" \ - >> "$tmp/selected_sets" + make_fstab_default EFI } customize() {