Makefile.bootimage revision 1.19
11.19Saymeric# $NetBSD: Makefile.bootimage,v 1.19 2018/11/19 20:05:37 aymeric Exp $ 21.1Stsutsui# 31.1Stsutsui# Copyright (c) 2009, 2010, 2011 Izumi Tsutsui. All rights reserved. 41.1Stsutsui# 51.1Stsutsui# Redistribution and use in source and binary forms, with or without 61.1Stsutsui# modification, are permitted provided that the following conditions 71.1Stsutsui# are met: 81.1Stsutsui# 1. Redistributions of source code must retain the above copyright 91.1Stsutsui# notice, this list of conditions and the following disclaimer. 101.1Stsutsui# 2. Redistributions in binary form must reproduce the above copyright 111.1Stsutsui# notice, this list of conditions and the following disclaimer in the 121.1Stsutsui# documentation and/or other materials provided with the distribution. 131.1Stsutsui# 141.1Stsutsui# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 151.1Stsutsui# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 161.1Stsutsui# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 171.1Stsutsui# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 181.1Stsutsui# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 191.1Stsutsui# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 201.1Stsutsui# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 211.1Stsutsui# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 221.1Stsutsui# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 231.1Stsutsui# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 241.1Stsutsui 251.1Stsutsui# 261.1Stsutsui# Makefile to create a bootable FS image for USB flash or emulators 271.1Stsutsui# 281.1Stsutsui 291.1Stsutsui# 301.1Stsutsui# Required variables: 311.1Stsutsui# RELEASEDIR 321.1Stsutsui# Should be defined in nbmake-${MACHINE} 331.1Stsutsui# IMGBASE 341.1Stsutsui# Basename of the image 351.1Stsutsui# 361.1Stsutsui# Optional variables: 371.1Stsutsui# BOOTDISK 381.1Stsutsui# device name of target bootable disk specified in /etc/fstab 391.1Stsutsui# (default: sd0) 401.1Stsutsui# USE_MBR 411.1Stsutsui# set yes if target disk image requires MBR partition 421.6Stsutsui# (default: no) 431.5Stsutsui# MBR_BOOTCODE 441.5Stsutsui# optional MBR bootcode which should be installed by fdisk(8) 451.5Stsutsui# (default: empty) 461.5Stsutsui# - specified MBR_BOOTCODE must exist in ${DESTDIR}/usr/mdec 471.5Stsutsui# - if MBR_BOOTCODE is not specified, 481.5Stsutsui# MBR_DEFAULT_BOOTCODE (default: mbr) will be used 491.5Stsutsui# if the target ${MACHINE} has the one in /usr/mdec 501.1Stsutsui# USE_SUNLABEL 511.1Stsutsui# set yes if target disk image requires Sun's label 521.1Stsutsui# (default: no) 531.1Stsutsui# INSTALLBOOT_AFTER_DISKLABEL (untested) 541.1Stsutsui# set yes if the target ${MACHINE} requires disklabel 551.1Stsutsui# to run installboot(8), like hp300 561.1Stsutsui# (default: empty) 571.1Stsutsui# IMAGEMB 581.1Stsutsui# target image size in MB 591.1Stsutsui# (default: 2048) 601.1Stsutsui# SWAPMB 611.1Stsutsui# swap size in target image in MB 621.1Stsutsui# (default: 128) 631.1Stsutsui# KERN_SET 641.1Stsutsui# kernel set name which should be extracted into image 651.1Stsutsui# (default: kern-GENERIC) 661.1Stsutsui# SETS 671.1Stsutsui# binary sets that should be extracted into image 681.1Stsutsui# (default: modules base etc comp games man misc tests text 691.1Stsutsui# xbase xcomp xetc xfont xserver) 701.1Stsutsui# SETS_DIR 711.1Stsutsui# directory path where binary sets are stored 721.1Stsutsui# (default: ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets) 731.1Stsutsui# IMGFILE_EXTRA 741.1Stsutsui# list of additional files to be copied into images, 751.1Stsutsui# containing one or more tuples of the form: 761.1Stsutsui# FILE TARGETPATH 771.1Stsutsui# for installation image etc. 781.1Stsutsui# (default: empty) 791.1Stsutsui# IMGDIR_EXTRA 801.1Stsutsui# list of additional directories to be copied into images, 811.1Stsutsui# containing one or more tuples of the form: 821.1Stsutsui# DIR TARGETPATH 831.1Stsutsui# for installation image etc. 841.1Stsutsui# (default: empty) 851.6Stsutsui# XXX: currently permissions in IMGDIR_EXTRA are not handled 861.1Stsutsui# IMGDIR_EXCLUDE 871.1Stsutsui# pax(1) options to exclude files which should not copied 881.1Stsutsui# into TARGETPATH in IMGDIR_EXTRA 891.1Stsutsui# (default: empty) 901.1Stsutsui# FSTAB_IN 911.1Stsutsui# template file of /etc/fstab 921.1Stsutsui# (default: ${DISTRIBDIR}/common/bootimage/fstab.in) 931.1Stsutsui# SPEC_IN 941.1Stsutsui# default files of spec file for makefs(8) 951.1Stsutsui# (default: ${DISTRIBDIR}/common/bootimage/spec.in) 961.1Stsutsui# SPEC_EXTRA 971.1Stsutsui# additional files of spec file for makefs(8) 981.1Stsutsui# (default: empty) 991.1Stsutsui# IMGMAKEFSOPTIONS 1001.1Stsutsui# options passed to makefs(8) to create root file system 1011.1Stsutsui# (default: -o bsize=16384,fsize=2048,density=8192) 1021.5Stsutsui# INSTALLBOOTOPTIONS 1031.5Stsutsui# options passed to installboot(8), e.g., -o console=com0 1041.5Stsutsui# (default: empty) 1051.1Stsutsui# PRIMARY_BOOT 1061.1Stsutsui# primary boot loader that should be installed into 1071.1Stsutsui# the target image via installboot(8) 1081.1Stsutsui# (default: empty) 1091.1Stsutsui# SECONDARY_BOOT 1101.1Stsutsui# secondary bootloader that should be put into the target image 1111.1Stsutsui# (default: empty) 1121.1Stsutsui# SECONDARY_BOOT_ARG 1131.1Stsutsui# extra arguments that should be passed to installboot(8) 1141.1Stsutsui# to specify the secondary bootloader 1151.1Stsutsui# (default: empty) 1161.1Stsutsui# DISKPROTO_IN 1171.1Stsutsui# template file of disklabel -R 1181.1Stsutsui# (default: ${DISTRIBDIR}/common/bootimage/diskproto.in 1191.1Stsutsui# or ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in) 1201.1Stsutsui# OMIT_SWAPIMG 1211.1Stsutsui# no need to put swap partition into image (for USB stick) 1221.1Stsutsui# (default: no) 1231.1Stsutsui# 1241.1Stsutsui 1251.1Stsutsui.include <bsd.own.mk> # 1261.1Stsutsui.include <bsd.endian.mk> # for TARGET_ENDIANNESS 1271.1Stsutsui 1281.1Stsutsui.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" 1291.1Stsutsui 1301.13Schristos.if ${MKREPRO_TIMESTAMP:Uno} != "no" 1311.13SchristosMAKEFS_TIMESTAMP=-T "${MKREPRO_TIMESTAMP}" 1321.15SchristosPAX_TIMESTAMP=--timestamp "${MKREPRO_TIMESTAMP}" 1331.15Schristos.endif 1341.12Schristos 1351.1Stsutsui.if empty(IMGBASE) 1361.1Stsutsui.BEGIN: 1371.1Stsutsui @echo "Error: IMGBASE is not set" 1381.1Stsutsui @false 1391.1Stsutsui.endif 1401.1Stsutsui 1411.1Stsutsui# should be defined elsewhere? 1421.1StsutsuiCAT?= cat 1431.1StsutsuiCHMOD?= chmod 1441.1StsutsuiDD?= dd 1451.1StsutsuiMKDIR?= mkdir -p 1461.1StsutsuiRM?= rm 1471.1Stsutsui 1481.1Stsutsui# 1491.1Stsutsui# common definitions for image 1501.1Stsutsui# 1511.1StsutsuiBOOTDISK?= sd0 1521.1StsutsuiUSE_MBR?= no 1531.1StsutsuiUSE_SUNLABEL?= no 1541.1StsutsuiINSTALLBOOT_AFTER_DISKLABEL?= no 1551.1Stsutsui 1561.1Stsutsui# 1571.1Stsutsui# size parameters for image 1581.1Stsutsui# 1591.1StsutsuiIMAGEMB?= 2048 # 2048MB 1601.1StsutsuiSWAPMB?= 128 # 128MB 1611.1Stsutsui 1621.3Stsutsui# XXX: SWAPMB could be zero and expr(1) returns exit status 1 in that case 1631.1StsutsuiIMAGESECTORS!= expr ${IMAGEMB} \* 1024 \* 1024 / 512 1641.3StsutsuiSWAPSECTORS!= expr ${SWAPMB} \* 1024 \* 1024 / 512 || true 1651.1Stsutsui 1661.1Stsutsui.if ${USE_MBR} == "no" 1671.1StsutsuiLABELSECTORS?= 0 1681.1Stsutsui.else 1691.1Stsutsui#LABELSECTORS?= 63 # historical 1701.1Stsutsui#LABELSECTORS?= 32 # 16KB aligned 1711.1StsutsuiLABELSECTORS?= 2048 # 1MB aligned for modern flash devices 1721.1Stsutsui.endif 1731.1Stsutsui 1741.1StsutsuiFSSECTORS!= expr ${IMAGESECTORS} - ${SWAPSECTORS} - ${LABELSECTORS} 1751.1StsutsuiFSSIZE!= expr ${FSSECTORS} \* 512 1761.1Stsutsui 1771.1Stsutsui# parameters for disklabel and MBR 1781.1StsutsuiHEADS= 64 1791.1StsutsuiSECTORS= 32 1801.1StsutsuiCYLINDERS!= expr ${IMAGESECTORS} / \( ${HEADS} \* ${SECTORS} \) 1811.1StsutsuiSECPERCYLINDERS!= expr ${HEADS} \* ${SECTORS} 1821.1StsutsuiMBRHEADS= 255 1831.1StsutsuiMBRSECTORS= 63 1841.1StsutsuiMBRCYLINDERS!= expr ${IMAGESECTORS} / \( ${MBRHEADS} \* ${MBRSECTORS} \) 1851.1StsutsuiMBRNETBSD= 169 1861.1Stsutsui 1871.1StsutsuiBSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS} 1881.1StsutsuiFSOFFSET= ${LABELSECTORS} 1891.1StsutsuiSWAPOFFSET!= expr ${LABELSECTORS} + ${FSSECTORS} 1901.1Stsutsui 1911.1Stsutsui# parameters for sunlabel 1921.1StsutsuiFSCYLINDERS!= expr ${FSSECTORS} / \( ${HEADS} \* ${SECTORS} \) 1931.3StsutsuiSWAPCYLINDERS!= expr ${SWAPSECTORS} / \( ${HEADS} \* ${SECTORS} \) || true 1941.1Stsutsui 1951.1Stsutsui 1961.1Stsutsui# 1971.1Stsutsui# definitions to create root fs 1981.1Stsutsui# 1991.1StsutsuiSETS_DEFAULT= modules base etc comp games man misc tests text 2001.1Stsutsui.if ${MKX11} != "no" 2011.1StsutsuiSETS_DEFAULT+= xbase xcomp xetc xfont xserver 2021.1Stsutsui.endif 2031.1Stsutsui 2041.1StsutsuiKERN_SET?= kern-GENERIC 2051.1StsutsuiSETS?= ${SETS_DEFAULT} 2061.1StsutsuiIMG_SETS= ${KERN_SET} ${SETS} 2071.1StsutsuiSETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets 2081.1Stsutsui 2091.1StsutsuiFSTAB_IN?= ${DISTRIBDIR}/common/bootimage/fstab.in 2101.1StsutsuiSPEC_IN?= ${DISTRIBDIR}/common/bootimage/spec.in 2111.1Stsutsui 2121.1StsutsuiIMGMAKEFSOPTIONS?= -o bsize=16384,fsize=2048,density=8192 2131.1Stsutsui 2141.1StsutsuiWORKDIR?= work 2151.1StsutsuiWORKSPEC?= work.spec 2161.1StsutsuiWORKFSTAB?= work.fstab 2171.1StsutsuiWORKRCCONF?= work.rc.conf 2181.1StsutsuiWORKFS?= work.rootfs 2191.1StsutsuiTARGETFS?= imgroot.fs 2201.19SaymericCOMPRESS_PROGRAM=${"${USE_XZ_SETS:Uno}"!="no":?${TOOL_XZ}:${TOOL_GZIP}} 2211.18SmartinTAR_SUFF= ${"${USE_XZ_SETS:Uno}"!="no":?tar.xz:tgz} 2221.1Stsutsui 2231.1StsutsuiCLEANFILES+= ${WORKSPEC} ${WORKFSTAB} ${WORKRCCONF} ${WORKFS} 2241.1StsutsuiCLEANFILES+= ${TARGETFS} 2251.1Stsutsui 2261.1Stsutsui# 2271.1Stsutsui# create root file system for the image 2281.1Stsutsui# 2291.1Stsutsui${TARGETFS}: prepare_md_post 2301.1Stsutsui @if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \ 2311.1Stsutsui echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \ 2321.1Stsutsui false; \ 2331.1Stsutsui fi; 2341.14Schristos @${MKDIR} ${MKDIRPERM} ${WORKDIR} 2351.1Stsutsui.for set in ${IMG_SETS} 2361.18Smartin @if [ ! -f ${SETS_DIR}/${set}.${TAR_SUFF} ]; then \ 2371.18Smartin echo "Missing ${SETS_DIR}/${set}.${TAR_SUFF}, aborting";\ 2381.1Stsutsui false; \ 2391.1Stsutsui fi 2401.18Smartin @echo Extracting ${set}.${TAR_SUFF} ... 2411.19Saymeric @(cd ${WORKDIR}; ${TOOL_PAX} ${PAX_TIMESTAMP} -rn \ 2421.19Saymeric --use-compress-program=${COMPRESS_PROGRAM:Q} \ 2431.19Saymeric -f ${SETS_DIR}/${set}.${TAR_SUFF} .) 2441.1Stsutsui.endfor 2451.1Stsutsui.if defined(SECONDARY_BOOT) 2461.1Stsutsui @echo Copying secondary boot... 2471.17Spgoyette ${INSTALL} ${COPY} -m 0644 ${WORKDIR}/usr/mdec/${SECONDARY_BOOT} ${WORKDIR} 2481.1Stsutsui.endif 2491.1Stsutsui @echo Preparing /etc/fstab ... 2501.1Stsutsui ${TOOL_SED} "s/@@BOOTDISK@@/${BOOTDISK}/" < ${FSTAB_IN} > ${WORKFSTAB} 2511.14Schristos ${INSTALL} ${COPY} -m 0644 ${WORKFSTAB} ${WORKDIR}/etc/fstab 2521.1Stsutsui @echo Setting rc_configured=YES in /etc/rc.conf ... 2531.1Stsutsui ${TOOL_SED} "s/rc_configured=NO/rc_configured=YES/" \ 2541.1Stsutsui < ${WORKDIR}/etc/rc.conf > ${WORKRCCONF} 2551.14Schristos ${INSTALL} ${COPY} -m 0644 ${WORKRCCONF} ${WORKDIR}/etc/rc.conf 2561.1Stsutsui.if defined(IMGDIR_EXTRA) 2571.1Stsutsui @echo Copying extra dirs... 2581.1Stsutsui.for _SRCDIR _TARGET in ${IMGDIR_EXTRA} 2591.1Stsutsui @if [ ! -d ${_SRCDIR} ]; then \ 2601.1Stsutsui echo "${_SRCDIR} is not directory, aborting"; \ 2611.1Stsutsui false; \ 2621.1Stsutsui fi 2631.14Schristos ${MKDIR} ${MKDIRPERM} ${WORKDIR}/${_TARGET} 2641.1Stsutsui (cd ${_SRCDIR} ; \ 2651.15Schristos ${TOOL_PAX} -rw -pe -v ${PAX_TIMESTAMP} \ 2661.1Stsutsui ${IMGDIR_EXCLUDE} \ 2671.1Stsutsui . ${.OBJDIR}/${WORKDIR}/${_TARGET} ) 2681.1Stsutsui.endfor 2691.1Stsutsui.endif 2701.1Stsutsui.if defined(IMGFILE_EXTRA) 2711.1Stsutsui @echo Copying extra files... 2721.1Stsutsui.for _SRC _TARGET in ${IMGFILE_EXTRA} 2731.1Stsutsui @if [ ! -f ${_SRC} ]; then \ 2741.1Stsutsui echo "${_SRC} in IMGFILE_EXTRA not found, aborting"; \ 2751.1Stsutsui false; \ 2761.1Stsutsui fi 2771.1Stsutsui @if [ -f ${_SRC} ]; then \ 2781.14Schristos echo ${INSTALL} ${COPY} -m 0644 ${_SRC} ${WORKDIR}/${_TARGET}; \ 2791.14Schristos ${INSTALL} ${COPY} -m 0644 ${_SRC} ${WORKDIR}/${_TARGET}; \ 2801.1Stsutsui fi 2811.1Stsutsui.endfor 2821.1Stsutsui.endif 2831.1Stsutsui @echo Preparing spec files for makefs... 2841.1Stsutsui ${RM} -f ${WORKSPEC} 2851.1Stsutsui cat ${WORKDIR}/etc/mtree/* | \ 2861.1Stsutsui ${TOOL_SED} -e 's/ size=[0-9]*//' > ${WORKSPEC} 2871.10Ssnj ${HOST_SH} ${WORKDIR}/dev/MAKEDEV -s all ipty | \ 2881.1Stsutsui ${TOOL_SED} -e '/^\. type=dir/d' -e 's,^\.,./dev,' >> ${WORKSPEC} 2891.1Stsutsui cat ${SPEC_IN} >> ${WORKSPEC} 2901.1Stsutsui.if defined(SECONDARY_BOOT) 2911.1Stsutsui echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \ 2921.1Stsutsui >> ${WORKSPEC} 2931.1Stsutsui.endif 2941.1Stsutsui.if defined(SPEC_EXTRA) 2951.1Stsutsui cat ${SPEC_EXTRA} >> ${WORKSPEC} 2961.1Stsutsui.endif 2971.4Sriz @echo Creating rootfs... 2981.1Stsutsui # XXX /var/spool/ftp/hidden is unreadable 2991.1Stsutsui ${CHMOD} +r ${WORKDIR}/var/spool/ftp/hidden 3001.1Stsutsui ${TOOL_MAKEFS} -M ${FSSIZE} -m ${FSSIZE} \ 3011.1Stsutsui -B ${TARGET_ENDIANNESS} \ 3021.1Stsutsui -F ${WORKSPEC} -N ${WORKDIR}/etc \ 3031.13Schristos ${MAKEFS_TIMESTAMP} \ 3041.1Stsutsui ${IMGMAKEFSOPTIONS} \ 3051.1Stsutsui ${WORKFS} ${WORKDIR} 3061.1Stsutsui.if !empty(PRIMARY_BOOT) && ${INSTALLBOOT_AFTER_DISKLABEL} == "no" 3071.5Stsutsui ${TOOL_INSTALLBOOT} -v -m ${MACHINE} ${INSTALLBOOTOPTIONS} ${WORKFS} \ 3081.1Stsutsui ${WORKDIR}/usr/mdec/${PRIMARY_BOOT} ${SECONDARY_BOOT_ARG} 3091.1Stsutsui.endif 3101.1Stsutsui @echo done. 3111.1Stsutsui mv ${WORKFS} ${.TARGET} 3121.1Stsutsui 3131.1Stsutsui# 3141.1Stsutsui# definitions to create image 3151.1Stsutsui# 3161.1Stsutsui.if ${USE_MBR} != "no" 3171.1StsutsuiDISKPROTO_IN?= ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in 3181.1Stsutsui.else 3191.1StsutsuiDISKPROTO_IN?= ${DISTRIBDIR}/common/bootimage/diskproto.in 3201.1Stsutsui.endif 3211.1Stsutsui 3221.5StsutsuiMBR_DEFAULT_BOOTCODE?= mbr 3231.5Stsutsui 3241.1StsutsuiOMIT_SWAPIMG?= no 3251.1Stsutsui 3261.1StsutsuiWORKMBR?= work.mbr 3271.1StsutsuiWORKSWAP?= work.swap 3281.1StsutsuiWORKLABEL?= work.diskproto 3291.1StsutsuiWORKIMG?= work.img 3301.1Stsutsui 3311.1StsutsuiCLEANFILES+= ${WORKMBR} ${WORKSWAP} 3321.1StsutsuiCLEANFILES+= ${WORKLABEL}.tmp ${WORKLABEL} 3331.1StsutsuiCLEANFILES+= ${WORKIMG} ${IMGBASE}.img 3341.1Stsutsui 3351.1Stsutsui${WORKLABEL}: 3361.1Stsutsui ${TOOL_SED} \ 3371.1Stsutsui -e "s/@@SECTORS@@/${SECTORS}/" \ 3381.1Stsutsui -e "s/@@HEADS@@/${HEADS}/" \ 3391.1Stsutsui -e "s/@@SECPERCYLINDERS@@/${SECPERCYLINDERS}/" \ 3401.1Stsutsui -e "s/@@CYLINDERS@@/${CYLINDERS}/" \ 3411.1Stsutsui -e "s/@@IMAGESECTORS@@/${IMAGESECTORS}/" \ 3421.1Stsutsui -e "s/@@FSSECTORS@@/${FSSECTORS}/" \ 3431.1Stsutsui -e "s/@@FSOFFSET@@/${FSOFFSET}/" \ 3441.1Stsutsui -e "s/@@SWAPSECTORS@@/${SWAPSECTORS}/" \ 3451.1Stsutsui -e "s/@@SWAPOFFSET@@/${SWAPOFFSET}/" \ 3461.1Stsutsui -e "s/@@BSDPARTSECTORS@@/${BSDPARTSECTORS}/" \ 3471.1Stsutsui < ${DISKPROTO_IN} > ${WORKLABEL}.tmp 3481.1Stsutsui mv ${WORKLABEL}.tmp ${WORKLABEL} 3491.1Stsutsui 3501.1Stsutsui${IMGBASE}.img: ${TARGETFS} ${WORKLABEL} 3511.5Stsutsui.if ${USE_MBR} != "no" 3521.1Stsutsui @echo creating MBR labels... 3531.1Stsutsui ${DD} if=/dev/zero of=${WORKMBR} seek=$$((${IMAGESECTORS} - 1)) count=1 3541.5Stsutsui ${TOOL_FDISK} -f -i -u \ 3551.1Stsutsui -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS} \ 3561.1Stsutsui -0 -a -s ${MBRNETBSD}/${FSOFFSET}/${BSDPARTSECTORS} \ 3571.1Stsutsui -F ${WORKMBR} 3581.5Stsutsui.if empty(MBR_BOOTCODE) 3591.5Stsutsui @if [ -f ${WORKDIR}/usr/mdec/${MBR_DEFAULT_BOOTCODE} ]; then \ 3601.5Stsutsui echo ${TOOL_FDISK} -f \ 3611.5Stsutsui -i -c ${WORKDIR}/usr/mdec/${MBR_DEFAULT_BOOTCODE} \ 3621.5Stsutsui -F ${WORKMBR}; \ 3631.5Stsutsui ${TOOL_FDISK} -f \ 3641.5Stsutsui -i -c ${WORKDIR}/usr/mdec/${MBR_DEFAULT_BOOTCODE} \ 3651.5Stsutsui -F ${WORKMBR}; \ 3661.5Stsutsui fi 3671.5Stsutsui.else 3681.5Stsutsui @if [ ! -f ${WORKDIR}/usr/mdec/${MBR_BOOTCODE} ]; then \ 3691.5Stsutsui echo "${MBR_BOOTCODE} is not found in DESTDIR/usr/mdec, aborting"; \ 3701.5Stsutsui false; \ 3711.5Stsutsui fi 3721.5Stsutsui ${TOOL_FDISK} -f -i -c ${WORKDIR}/usr/mdec/${MBR_BOOTCODE} \ 3731.5Stsutsui -F ${WORKMBR} 3741.5Stsutsui.endif 3751.1Stsutsui ${DD} if=${WORKMBR} count=${LABELSECTORS} | \ 3761.1Stsutsui ${CAT} - ${TARGETFS} > ${WORKIMG} 3771.1Stsutsui.else 3781.14Schristos ${INSTALL} ${COPY} -m 0644 ${TARGETFS} ${WORKIMG} 3791.1Stsutsui.endif 3801.1Stsutsui.if ${OMIT_SWAPIMG} == "no" 3811.1Stsutsui ${DD} if=/dev/zero of=${WORKSWAP} seek=$$((${SWAPSECTORS} - 1)) count=1 3821.1Stsutsui ${CAT} ${WORKSWAP} >> ${WORKIMG} 3831.1Stsutsui.endif 3841.1Stsutsui.if ${USE_SUNLABEL} != "no" 3851.1Stsutsui @echo Creating sun disklabel... 3861.1Stsutsui printf 'V ncyl %d\nV nhead %d\nV nsect %d\na %d %d/0/0\nb %d %d/0/0\nW\n' \ 3871.1Stsutsui ${CYLINDERS} ${HEADS} ${SECTORS} \ 3881.1Stsutsui ${FSOFFSET} ${FSCYLINDERS} ${FSCYLINDERS} ${SWAPCYLINDERS} | \ 3891.1Stsutsui ${TOOL_SUNLABEL} -nq ${WORKIMG} 3901.1Stsutsui.endif 3911.1Stsutsui ${TOOL_DISKLABEL} -R -F ${WORKIMG} ${WORKLABEL} 3921.1Stsutsui.if !empty(PRIMARY_BOOT) && ${INSTALLBOOT_AFTER_DISKLABEL} != "no" 3931.11Sriastrad ${TOOL_INSTALLBOOT} -v -m ${MACHINE} ${INSTALLBOOTOPTIONS} ${WORKIMG} \ 3941.1Stsutsui ${WORKDIR}/usr/mdec/${PRIMARY_BOOT} 3951.1Stsutsui.endif 3961.1Stsutsui mv ${WORKIMG} ${.TARGET} 3971.1Stsutsui 3981.1Stsutsui 3991.1StsutsuiCLEANFILES+= ${IMGBASE}.img.gz ${IMGBASE}.img.gz.tmp 4001.1Stsutsui 4011.1Stsutsui${IMGBASE}.img.gz: ${IMGBASE}.img 4021.9Sapb ${TOOL_GZIP_N} -9c ${IMGBASE}.img > ${.TARGET}.tmp 4031.1Stsutsui mv ${.TARGET}.tmp ${.TARGET} 4041.1Stsutsui 4051.1Stsutsuiclean: 4061.1Stsutsui @if [ -d ${WORKDIR}/var/spool/ftp/hidden ]; then \ 4071.1Stsutsui ${CHMOD} +r ${WORKDIR}/var/spool/ftp/hidden; \ 4081.1Stsutsui fi # XXX 4091.1Stsutsui ${RM} -fr ${WORKDIR} 4101.1Stsutsui 4111.1Stsutsuiprepare_md_post: .PHONY 4121.1Stsutsuiimage_md_post: .PHONY 4131.1Stsutsuiimage_md_pre: .PHONY 4141.1Stsutsui 4151.1Stsutsui.include <bsd.prog.mk> 416