Home | History | Annotate | Line # | Download | only in conf
evbarm.conf revision 1.43
      1 # $NetBSD: evbarm.conf,v 1.43 2024/12/27 19:02:19 christos Exp $
      2 # evbarm shared config
      3 #
      4 image=$HOME/${board}.img
      5 
      6 MACHINE=evbarm
      7 
      8 extra=48		# spare space
      9 init=32
     10 boot=$((192 - ${init}))
     11 ffsoffset=$(( (${init} + ${boot}) / 2 ))m
     12 
     13 size=0		# autocompute
     14 msdosid=12
     15 
     16 if $gpt; then
     17 	partition_type="gpt"
     18 else
     19 	partition_type="disklabel"
     20 fi
     21 
     22 mkdir -p ${mnt}/boot
     23 
     24 make_label_evbarm() {
     25 	# compute all sizes in terms of sectors
     26 	local totalsize=$(( ${size} / 512 ))
     27 
     28 	local bootsize=$(( ${boot} * 1024 ))
     29 
     30 	local bootoffset=$(( ${init} * 1024 ))
     31 
     32 	local asize=$(( ${totalsize} - ${bootsize} - ${bootoffset} ))
     33 	local aoffset=$(( ${bootoffset} + ${bootsize} ))
     34 
     35 	local bps=512
     36 	local spt=32
     37 	local tpc=64
     38 	local spc=2048
     39 	local cylinders=$(( ${totalsize} / ${spc} ))
     40 
     41 	cat << EOF
     42 type: SCSI
     43 disk: STORAGE DEVICE
     44 label: fictitious
     45 flags: removable
     46 bytes/sector: ${bps}
     47 sectors/track: ${spt}
     48 tracks/cylinder: ${tpc}
     49 sectors/cylinder: ${spc}
     50 cylinders: ${cylinders}
     51 total sectors: ${totalsize}
     52 rpm: 3600
     53 interleave: 1
     54 trackskew: 0
     55 cylinderskew: 0
     56 headswitch: 0           # microseconds
     57 track-to-track seek: 0  # microseconds
     58 drivedata: 0 
     59 
     60 8 partitions:
     61 #     size         offset        fstype [fsize bsize cpg/sgs]
     62  a:   ${asize}     ${aoffset}    4.2BSD  ${fsize} ${bsize} 0  # 
     63  c:   ${totalsize} 0             unused      0     0          #
     64  e:   ${bootsize}  ${bootoffset} MSDOS                        #
     65 EOF
     66 }
     67 
     68 make_fstab_evbarm() {
     69 	make_fstab_default EFI
     70 }
     71 
     72 customize_evbarm() {
     73 	if $minwrites; then
     74 		mkdir ${mnt}/etc/postfix
     75 		(umask 022
     76 		sed -e 's/fifo/unix/' < ${release}/etc/postfix/master.cf > \
     77 		    ${mnt}/etc/postfix/master.cf)
     78 	fi
     79 	
     80 	cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf
     81 	cat >> ${mnt}/etc/rc.conf << EOF
     82 dev_exists() {
     83 	if /sbin/drvctl -l \$1 >/dev/null 2>&1 ; then
     84 		printf YES
     85 	else
     86 		printf NO
     87 	fi
     88 }
     89 
     90 is_cloud() {
     91 	ret=NO
     92 
     93 	# AWS EC2
     94 	if [ "\$(dev_exists ena0)" = "YES" ]; then
     95 		ret=YES
     96 	fi
     97 
     98 	# Oracle OCI
     99 	case "\$(/sbin/sysctl -n machdep.dmi.chassis-asset-tag 2>/dev/null)" in
    100 	OracleCloud*)
    101 		ret=YES
    102 		;;
    103 	esac
    104 
    105 	printf \$ret
    106 }
    107 
    108 rc_configured=YES
    109 hostname=${hostname:-${board}}
    110 no_swap=YES
    111 savecore=NO
    112 sshd=YES
    113 dhcpcd=YES
    114 ntpd=YES
    115 ntpd_flags="-g"
    116 creds_msdos=YES
    117 creds_msdos_partition=/boot
    118 certctl_init=YES
    119 EOF
    120 
    121 	if $resize; then
    122 		cat >> ${mnt}/etc/rc.conf << EOF
    123 resize_${partition_type}=YES
    124 resize_root=YES
    125 resize_root_flags="-p"
    126 resize_root_postcmd="/sbin/reboot -n"
    127 EOF
    128 	fi
    129 
    130 	echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" \
    131 	    >> "$tmp/selected_sets"
    132 
    133 	mkdir ${mnt}/etc/rc.d
    134 	for _f in resize_${partition_type} creds_msdos; do
    135 		cp ${DIR}/files/${_f} ${mnt}/etc/rc.d/${_f}
    136 		echo "./etc/rc.d/${_f} type=file uname=root gname=wheel mode=0555" \
    137 		    >> "$tmp/selected_sets"
    138 	done
    139 
    140 	if [ ! -f ${release}/dev/MAKEDEV ]; then
    141 		echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2
    142 		exit 1
    143 	fi
    144 	echo "${bar} running MAKEDEV ${bar}"
    145 	${HOST_SH} ${release}/dev/MAKEDEV -s all | sed -e 's:^\./:\./dev/:' \
    146 	    >> "$tmp/selected_sets"
    147 
    148 	echo "${bar} fixing up permissions"
    149 	echo "./boot type=dir uname=root gname=wheel mode=0755" \
    150 	    >> "$tmp/selected_sets"
    151 }
    152