#!/bin/bash ############################################################################## # Copyright © 2002, Philip Howard, All rights reserved, See GPL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to # The Free Software Foundation, Inc. # 59 Temple Place, Suite 330 # Boston, MA 02111-1307, USA. ############################################################################## # script buildiso # # package BICK - Bootable Image Construction Kit - for Linux # # purpose To take one or more specified file trees, merge them into a # combined file tree for a CDROM, and construct a bootable # ISO-9660 image for recording bootable CDRs. # # usage shell command # # syntax buildiso [options] # # The project name is the last path component of the current # directory, and is used to create the ISO file name. # # variables Variables may be set by any of the following means: # 1. In environment variables. # 2. In the file "./config" using bash syntax. # 3. As symlinks named "var.name". # # name.conf A bash script that sets variables # name.intel32 The directory tree for INTEL32 files # name.sparc32 The directory tree for SPARC32 files # # name.dir The directory where CD files are built # name.iso The output ISO image file # name.log A detailed log file # name.tmp Temporary workspace # # options # -cdopt Build the system so that the /opt directory is mounted from # the CDROM instead of being loaded into tmpfs. # -cdusr Build the system so that the /usr directory is mounted from # the CDROM instead of being loaded into tmpfs. # -devfs Build initial ramdisks without /dev/console which assumes # that the kernel will automatically mount devfs. Your kernel # will have to be compiled with that feature for this to work. # # required cdinit version included with BICK # syslinux version 1.41 or later, 1.62 preferred # mkisofs version 1.12b5 or 1.12b6 (patched with SILO for Sparc32) ############################################################################## umask 022 version="0.8.0" #----------------------------------------------------------------------------- # Define function to set configurations that are not yet set. #----------------------------------------------------------------------------- function doconfig { #----------------------------------------------------------------------------- # dtform format for timestamp in messages #----------------------------------------------------------------------------- cset dtform "%H:%M:%S" cset lister "find . -mindepth 1 -printf '%5m %-8u %-8g %10s %TY-%Tm-%Td.%TH:%TM:%TS %P\n'" cset verbose "false" #----------------------------------------------------------------------------- # tmpdir temporary directory name # isodir directory of files built here for the ISO filesystem # isoimg ISO image file output name # mntpnt where to mount filesystems #----------------------------------------------------------------------------- cset tmpdir "tmp" cset isodir "${tmpdir}/dir" cset isoimg "${name}.iso" cset mntpnt "${tmpdir}/mnt" cset devfs "false" #----------------------------------------------------------------------------- # xxtree root tree of files to be built into the ISO image. #----------------------------------------------------------------------------- sdir intel32tree "root-intel32" sdir sparc32tree "root-sparc32" #----------------------------------------------------------------------------- # cdlist1 listing of CD tree before building ISO-9660 image # cdlist2 listing of built and mounted CD ISO-9660 image #----------------------------------------------------------------------------- cset cdlist1 "${tmpdir}/cdlist1" cset cdlist2 "${tmpdir}/cdlist2" #----------------------------------------------------------------------------- # xxparm additional kernel boot parameters to use #----------------------------------------------------------------------------- cset intel32parm "bickrootfs=tmpfs" cset sparc32parm "bickrootfs=tmpfs" #----------------------------------------------------------------------------- # xxbootmsg optional file with platform specific boot message #----------------------------------------------------------------------------- sfile intel32bmsg "boot.msg-intel32" sfile sparc32bmsg "boot.msg-sparc32" #----------------------------------------------------------------------------- # xxcdinit location of cdinit directories and files for this architecture #----------------------------------------------------------------------------- sdir intel32cdinit "cdinit" sfile intel32cdinit1 "${intel32cdinit}/cdinit1-intel32" sfile intel32cdinit2 "${intel32cdinit}/cdinit2-intel32" sfile intel32cdinit3 "${intel32cdinit}/cdinit3-intel32" sdir sparc32cdinit "cdinit" sfile sparc32cdinit1 "${sparc32cdinit}/cdinit1-sparc32" sfile sparc32cdinit2 "${sparc32cdinit}/cdinit2-sparc32" sfile sparc32cdinit3 "${sparc32cdinit}/cdinit3-sparc32" #----------------------------------------------------------------------------- # xxkernel location of kernel image file for this architecture #----------------------------------------------------------------------------- sfile intel32kern "kernel-intel32" sfile sparc32kern "kernel-sparc32-sun4" sfile sparc32kernc "kernel-sparc32-sun4c" sfile sparc32kerndm "kernel-sparc32-sun4dm" sfile sparc32kernu "kernel-sparc32-sun4u" #----------------------------------------------------------------------------- # Xtlist where to write listing of tar file # Xrdisk initial ramdisk image file # Xrlist where to write listing of created ramdisk # Xrsize initial ramdisk image size in K bytes # Xdsize minimum kernel ramdisk size in K bytes #----------------------------------------------------------------------------- cset intel32tlist "${tmpdir}/intel32-tar.lst" cset sparc32tlist "${tmpdir}/sparc32-tar.lst" cset intel32rdisk "${tmpdir}/intel32-ramdisk.img" cset sparc32rdisk "${tmpdir}/sparc32-ramdisk.img" cset intel32rlist "${tmpdir}/intel32-ramdisk.lst" cset sparc32rlist "${tmpdir}/sparc32-ramdisk.lst" cset intel32rsize 128 cset sparc32rsize 256 cset intel32dsize 4096 cset sparc32dsize 4096 #----------------------------------------------------------------------------- # Configure the El Torito emulated boot floppy. # # bootimg INTEL32 El Torito boot floppy image file name # bootcat INTEL32 El Torito boot catalog file name # bflisting where to write file listing of boot floppy # bfsize size of El Torito emulated floppy # bfnumfats number of file allocation tables # bffatsize number of bits in allocation entries # bfvolname filesystem volume name # bfrootdir number of entries in root directory # bfsecsize logical sector size # bfclusecs number of sectors per cluster in FAT filesystem #----------------------------------------------------------------------------- cset intel32boot "intel32/boot" cset bootimg "${intel32boot}/boot.img" cset bootcat "${intel32boot}/boot.cat" cset bflisting "${tmpdir}/intel32-bootflp.lst" cset bfsize 1440 cset bfnumfats 2 cset bffatsize 12 cset bfvolname "syslinux" cset bfrootdir 112 cset bfsecsize 512 defaultbfclusecs=1 [ $bfsize -gt 1440 ] && defaultbfclusecs=2 cset bfclusecs $defaultbfclusecs #----------------------------------------------------------------------------- # Configure the SYSLINUX boot loader. # # syslinux location of syslinux directory for INTEL32 # sxkernel name of kernel file in syslinux floppy filesystem # sxloader name of loader file in syslinux floppy filesystem # sxconfig name of config file in syslinux floppy filesystem # sxinitrd name of initrd file in syslinux floppy filesystem # sxmsgfile name of boot message file in floppy filesystem # sxtimeout boot prompt timeout wait in 0.1 second units # ivgamode kernel parameter vga mode #----------------------------------------------------------------------------- sdir syslinux "syslinux" cset sxkernel "linux" cset sxloader "ldlinux.sys" cset sxconfig "syslinux.cfg" cset sxinitrd "ramdisk.img" cset sxmsgfile "boot.msg" cset sxtimeout 150 cset ivgamode "ext" #----------------------------------------------------------------------------- # Configure SPARC32 SILO boot loader. # # silodir location of silo directory for SPARC32 # silocfg name of the SILO config file # sparc32boot on CD destination directory for boot files # siloisoone name of the SILO first stage boot loader file in the ISO # siloisotwo name of the SILO second stage boot loader file in the ISO # silosrcone path to get the SILO first stage boot loader file # silosrctwo path to get the SILO second stage boot loader file #----------------------------------------------------------------------------- sdir silodir "silo" cset sparc32boot "sparc32/boot" cset silocfg "${sparc32boot}/silo.conf" cset siloisoone "${sparc32boot}/cd.b" cset siloisotwo "${sparc32boot}/second.b" cset silobmsg "${sparc32boot}/boot.msg" cset silosrcone "silo/first/cd.b" cset silosrctwo "silo/second/second.b" #----------------------------------------------------------------------------- # opt...... various mkisofs options #----------------------------------------------------------------------------- cset optabstract "" cset optappid "CDROM by BICK ${version}" cset optbiblio "" cset optcopyright "" cset optpubid "CDROM by BICK ${version}" cset optprepid "CDROM by BICK ${version}" cset optsysid "" cset optvolid "" cset optdeepr true cset optjoliet false cset optrr true cset optpad true cset optverbose false return 0 } #----------------------------------------------------------------------------- # Define function to set variables if not currently set. #----------------------------------------------------------------------------- function cset { local vname="${1}" local vdflt="${2}" local value eval 'value="${'"${vname}"'}"' [ -z "${value}" ] && value="${vdflt}" eval "${vname}="'"${value}"' return 0 } #----------------------------------------------------------------------------- # Define function to search for a resource file. The configured value or # default is the name to search for if a full path is not given. #----------------------------------------------------------------------------- function search { local found="" local ntype="${1}" local vname="${2}" local vdflt="${3}" local value eval 'value="${'"${vname}"'}"' [ -z "${value}" ] && value="${vdflt}" for n in "${value}" "../${value}" "bick/${value}" "bick/../${value}" "../bick/${value}" "../bick/../${value}"; do if [ "${ntype}" = "file" ]; then if [ -f "${n}" -a -r "${n}" ]; then found="${n}" break fi elif [ "${ntype}" = "dir" ]; then if [ -d "${n}" -a -x "${n}" ]; then found="${n}" break fi fi done if [ -n "${found}" ]; then b=$( exec basename "${found}" ) d=$( exec dirname "${found}" ) d=$( cd "${d}" && exec pwd ) found="${d}/${b}" fi eval "${vname}="'"${found}"' return 0 } function sdir { search dir $* return $? } function sfile { search file $* return $? } #----------------------------------------------------------------------------- # Define functions to control message output. # File descriptor 3 writes to the detail log. #----------------------------------------------------------------------------- function msg { echo "`exec date +${dtform}` ${1}" echo "`exec date +${dtform}` ${1}" >&3 return 0 } function logmsg { $verbose && echo "`exec date +${dtform}` ${1}" echo "`exec date +${dtform}` ${1}" >&3 return 0 } function errmsg { echo "`exec date +${dtform}` ERROR: ${1}" >&2 echo "`exec date +${dtform}` ERROR: ${1}" >&3 return 0 } function help { echo "" echo "=============================================================================" echo "syntax buildiso [options] name" echo "" echo " name The specified name is used to identify several files and" echo " directories used to build the ISO image:" echo " name.conf A bash script that sets variables" echo " name.iso The output ISO image file" echo " name.log A detailed log file" echo " name.intel32 The directory tree for INTEL32 files" echo " name.sparc32 The directory tree for SPARC32 files" echo " name.tmp Temporary workspace" echo "" echo " options" echo " -cdopt Build the system so that the /opt directory is mounted from" echo " the CDROM instead of being loaded into tmpfs." echo " -cdusr Build the system so that the /usr directory is mounted from" echo " the CDROM instead of being loaded into tmpfs." echo " -devfs Build initial ramdisks without /dev/console which assumes" echo " that the kernel will automatically mount devfs. Your kernel" echo " will have to be compiled with that feature for this to work." echo "=============================================================================" echo "" return 0 } #----------------------------------------------------------------------------- # Make sure enabled as root. #----------------------------------------------------------------------------- if [ "`exec whoami`" != "root" ]; then echo '' >&2 echo '=============================================================================' >&2 echo 'Building a bootable ISO CD image involves copying files while keeping various' >&2 echo 'ownerships, copying or creating special device files, and mounting/unmounting' >&2 echo 'working filesystem images, therefore root authority is required by buildiso' >&2 echo '' >&2 echo 'You must login as root or use the su(1) command to gain the needed authority' >&2 echo 'to perform the necessary system functions involved.' >&2 echo '=============================================================================' >&2 echo '' >&2 exit 1 fi #----------------------------------------------------------------------------- # Do general initialization. #----------------------------------------------------------------------------- abort=false if [ -z "${ACTIVELOGFILE}" ]; then export ACTIVELOGFILE="log" exec $0 $* 2>&1 3>"${ACTIVELOGFILE}" exit $? fi echo '=====================================================================' echo "BICK is Copyright © 2002, Philip Howard, All rights reserved, See GPL" echo "BICK ${version}, the CD/ISO Bootable Image Construction Kit, for Linux 2.4" echo '=====================================================================' startsecs=$( exec date '+%s' ) name=$( exec basename $( exec pwd ) ) #----------------------------------------------------------------------------- # Check for options. #----------------------------------------------------------------------------- devfs=false cdusr=false cdopt=false while [ -n "${1}" ]; do if [ "X${1}" = "X-v" ]; then verbose=true elif [ "X${1}" = "X-V" ]; then optverbose=true elif [ "X${1}" = "X-devfs" ]; then devfs=true elif [ "X${1}" = "X-cdopt" ]; then cdopt=true elif [ "X${1}" = "X-cdusr" ]; then cdusr=true else errmsg "unknown option: '${1}'" abort=true fi shift continue done if $abort; then errmsg "aborting due to errors" exit 1 fi #----------------------------------------------------------------------------- # Load user configuration and defaults. #----------------------------------------------------------------------------- if [ -r "config" ]; then source "config" fi doconfig #----------------------------------------------------------------------------- # end of configuration #----------------------------------------------------------------------------- if $abort; then errmsg "aborting due to errors" exit 1 fi #----------------------------------------------------------------------------- # Make sure all required components are present before starting. #----------------------------------------------------------------------------- function checkfile { if [ ! -r "${1}" ]; then errmsg "file '${1}' not found" abort=true fi } function checkdir { if [ ! -d "${1}" ]; then errmsg "directory '${1}' not found or not a directory" abort=true elif [ ! -x "${1}" -a ! -r "${1}" ]; then errmsg "directory '${1}' not asscessible" abort=true fi } #----------------------------------------------------------------------------- # Check for which platform source directories exist. #----------------------------------------------------------------------------- intel32=false if [ -d "${intel32tree}" ]; then intel32=true fi sparc32=false if [ -d "${sparc32tree}" ]; then sparc32=true fi if [ "${intel32}${sparc32}" = "falsefalse" ]; then errmsg "Neither INTEL32 nor SPARC32 directories exist for '${name}'" exit 1 fi #----------------------------------------------------------------------------- # Check platform specific files. #----------------------------------------------------------------------------- if $intel32; then checkfile "${intel32kern}" checkdir "${intel32cdinit}" checkfile "${intel32cdinit1}" checkfile "${intel32cdinit2}" checkfile "${intel32cdinit3}" checkdir "${syslinux}" checkfile "${syslinux}/ldlinux.sys" checkfile "${syslinux}/syslinux" fi if $sparc32; then checkfile "${sparc32kern}" checkfile "${sparc32kernc}" checkfile "${sparc32kerndm}" checkfile "${sparc32kernu}" checkdir "${sparc32cdinit}" checkfile "${sparc32cdinit1}" checkfile "${sparc32cdinit2}" checkfile "${sparc32cdinit3}" fi if $abort; then errmsg "aborting due to errors" exit 1 fi #----------------------------------------------------------------------------- # make sure there are no interfering filesystems mounted #----------------------------------------------------------------------------- function checkmount { local full="`exec pwd`/${1}" umount "${full}" 1>/dev/null 2>/dev/null n=$( egrep "^${full} " < /proc/mounts | exec wc -l ) if [ $n != 0 ]; then errmsg "filesystem already mounted: ${full}" abort=true fi n=$( egrep " ${full} " < /proc/mounts | exec wc -l ) if [ $n != 0 ]; then errmsg "filesystem already mounted: ${full}" abort=true fi } checkmount "${mntpnt}" $intel32 && checkmount "${intel32rdisk}" $sparc32 && checkmount "${sparc32rdisk}" if $abort; then errmsg "aborting due to errors" exit 1 fi #----------------------------------------------------------------------------- # if a target file exists, remove it #----------------------------------------------------------------------------- function dodelete { local full="`exec pwd`/${1}" if [ -e "${full}" ]; then msg "removing '${full}'" if [ -f "${full}" ]; then ( echo -n > "${full}" ) fi rm -fr "${full}" if [ -e "${full}" ]; then errmsg "Unable to remove '${full}'" abort=true fi fi } dodelete "${isoimg}" dodelete "${isodir}" dodelete "${tmpdir}" if $abort; then errmsg "aborting due to errors" exit 1 fi #----------------------------------------------------------------------------- # Make the temporary and ISO directories. #----------------------------------------------------------------------------- mkdir -m 0755 "${tmpdir}" mkdir -m 0755 "${isodir}" #----------------------------------------------------------------------------- # Initialize the mkisofs options. #----------------------------------------------------------------------------- opt="" graft="" ############################################################################## # BEGIN INTEL ############################################################################## if $intel32; then #----------------------------------------------------------------------------- # Make CD directories for the INTEL32 platform. #----------------------------------------------------------------------------- mkdir -m 0755 -p "${isodir}/intel32" if [ $? != 0 ]; then errmsg "error making directory '${isodir}/intel32' for INTEL32" exit 1 fi mkdir -m 0755 -p "${isodir}/${intel32boot}" if [ $? != 0 ]; then errmsg "error making directory '${isodir}/${intel32boot}' for INTEL32" exit 1 fi #----------------------------------------------------------------------------- # Copy the cdinit2 program into the CDROM boot area. #----------------------------------------------------------------------------- msg "copying '${intel32cdinit2}' into '${isodir}/${intel32boot}/cdinit2'" cp -p "${intel32cdinit2}" "${isodir}/${intel32boot}/cdinit2" if [ $? != 0 ]; then errmsg "error copying '${intel32cdinit2}' to '${isodir}/${intel32boot}/cdinit2'" exit 1 fi #----------------------------------------------------------------------------- # Copy the cdinit3 program into /sbin to be included in the tar file. #----------------------------------------------------------------------------- msg "copying '${intel32cdinit3}' into '${intel32tree}/sbin'" cp -p "${intel32cdinit3}" "${intel32tree}/sbin/cdinit3" if [ $? != 0 ]; then errmsg "error copying '${intel32cdinit3}' to '${intel32tree}/sbin/cdinit3'" exit 1 fi #----------------------------------------------------------------------------- # Collect files destined for ramfs/tmpfs into a tar file. # All files except those in /opt or /usr are destined for ramfs/tmpfs. # The /opt and /usr files will be on the mounted CD and symlinked in. #----------------------------------------------------------------------------- msg "building the root.tar file for INTEL32" tlist="" for tname in $( exec ls -1A "${intel32tree}" ); do [ "${tname}" = "cdrom" ] && continue [ "${tname}" = "lost+found" ] && continue $cdopt && [ "${tname}" = "opt" ] && continue $cdusr && [ "${tname}" = "usr" ] && continue if [ -z "${tlist}" ]; then tlist="${tname}" else tlist="${tlist} ${tname}" fi done ( cd "${intel32tree}" && exec tar cf - $tlist ) > "${isodir}/${intel32boot}/root.tar" if [ $? != 0 ]; then errmsg "error building root.tar file for INTEL32" exit 1 fi ls -ld "${isodir}/${intel32boot}/root.tar" tar tvf - < "${isodir}/${intel32boot}/root.tar" > "${intel32tlist}" #----------------------------------------------------------------------------- # We need tar on the CDROM, since it is used to load the root.tar file, # so make sure it is there. #----------------------------------------------------------------------------- [ -d "${isodir}/intel32/bin" ] || mkdir -p "${isodir}/intel32/bin" cp -p "${intel32tree}/bin/tar" "${isodir}/intel32/bin/tar" if [ $? != 0 ]; then errmsg "error copying '${intel32tree}/bin/tar' -> '${isodir}/intel32/bin/tar'" exit 1 fi [ -d "${isodir}/intel32/lib" ] || mkdir -p "${isodir}/intel32/lib" cp -p "${intel32tree}/lib/ld-linux.so.2" "${isodir}/intel32/lib/ld-linux.so.2" if [ $? != 0 ]; then errmsg "error copying '${intel32tree}/lib/ld-linux.so.2' -> '${isodir}/intel32/lib/ld-linux.so.2'" exit 1 fi cp -p "${intel32tree}/lib/libc.so.6" "${isodir}/intel32/lib/libc.so.6" if [ $? != 0 ]; then errmsg "error copying '${intel32tree}/lib/libc.so.6' -> '${isodir}/intel32/lib/libc.so.6'" exit 1 fi #----------------------------------------------------------------------------- # Collect usr and opt trees into a platform specific directory on the CD. #----------------------------------------------------------------------------- $cdopt && [ -d "${intel32tree}/opt" ] && graft="${graft} 'intel32/opt/=${intel32tree}/opt'" $cdusr && [ -d "${intel32tree}/usr" ] && graft="${graft} 'intel32/usr/=${intel32tree}/usr'" ############################################################################## # Prepare the ramdisk image for INTEL32. # # This is the image that will be /dev/ram mounted as / when the kernel starts # the first init program. This image is included inside the Syslinux floppy # filesystem image as a compressed file, and is read by ldlinux.sys (of the # syslinux package) and passed to the kernel to mount. It will contain the # /dev/console device node and the /sbin/init program as cdinit stage 1. ############################################################################## #----------------------------------------------------------------------------- # Fill out the ramdisk image file to the requested size. #----------------------------------------------------------------------------- if [ $intel32rsize -le 128 ]; then e2opt="-N 32" else e2opt="-i 1024" fi e2opt="${e2opt} -F -q -b 1024 -m 0 -L ramdisk -M /" msg "initializing the INTEL32 ramdisk image to ${intel32rsize}K bytes (ext2)" dd if=/dev/zero of="${intel32rdisk}" bs=1024 count="${intel32rsize}" 2>/dev/null if [ $? != 0 ]; then dd if=/dev/zero of="${intel32rdisk}" bs=1024 count="${intel32rsize}" errmsg "unable to setup the INTEL32 ramdisk image file '${intel32rdisk}'" exit 1 fi mke2fs -q $e2opt "${intel32rdisk}" "${intel32rsize}" 2>/dev/null if [ $? != 0 ]; then mke2fs $e2opt "${intel32rdisk}" "${intel32rsize}" errmsg "unable to format the INTEL32 ramdisk image file '${intel32rdisk}'" exit 1 fi tune2fs -e panic -i 0 "${intel32rdisk}" 1>/dev/null 2>/dev/null if [ $? != 0 ]; then tune2fs -e panic -i 0 "${intel32rdisk}" errmsg "unable to tweak the INTEL32 ramdisk image file '${intel32rdisk}'" exit 1 fi #----------------------------------------------------------------------------- # Mount the ramdisk image to enable populating it. #----------------------------------------------------------------------------- msg "mounting empty INTEL32 ramdisk image '${intel32rdisk}' to populate it" [ -d "${mntpnt}" ] || mkdir "${mntpnt}" mount -o loop,rw,noatime "${intel32rdisk}" "${mntpnt}" if [ $? != 0 ]; then errmsg "unable to mount empty INTEL32 ramdisk image '${intel32rdisk}' at '${mntpnt}'" exit 1 fi #----------------------------------------------------------------------------- # Remove lost+found which is of no use on a ramdisk filesystem. #----------------------------------------------------------------------------- if [ -d "${mntpnt}/lost+found" ]; then rmdir "${mntpnt}/lost+found" if [ $? != 0 ]; then errmsg "lost+found exits in INTEL32 ramdisk but cannot be removed" exit 1 fi fi #----------------------------------------------------------------------------- # Populate the ramdisk filesystem with the following: # /dev/console the kernel opens this file before starting init # /sbin/init this will be cdinit1 running as init first #----------------------------------------------------------------------------- msg "populating INTEL32 ramdisk filesystem" if ! $devfs; then mkdir -m 0755 "${mntpnt}/dev" mknod "${mntpnt}/dev/console" c 5 1 if [ ! -c "${mntpnt}/dev/console" ]; then errmsg "error creating device node /dev/console (5,1) in the INTEL32 ramdisk filesystem" exit 1 fi ls -ld "${mntpnt}/dev/console" fi mkdir -m 0755 "${mntpnt}/sbin" cp -p "${intel32cdinit1}" "${mntpnt}/sbin/init" if [ ! -f "${mntpnt}/sbin/init" -a ! -r "${mntpnt}/sbin/init" -a ! -x "${mntpnt}/sbin/init" ]; then errmsg "error copying '${intel32cdinit1}' to /sbin/init in the INTEL32 ramdisk filesystem" exit 1 fi ls -ld "${mntpnt}/sbin/init" #----------------------------------------------------------------------------- # Save a listing of the files in the ramdisk filesystem. #----------------------------------------------------------------------------- ( cd "${mntpnt}" && eval "${lister}" ) | tee "${intel32rlist}" >&3 #----------------------------------------------------------------------------- # Log the usage of the ramdisk filesystem. #----------------------------------------------------------------------------- ( df "${mntpnt}" ; df -i "${mntpnt}" ) | egrep "Mounted|${mntpnt}" >&3 #----------------------------------------------------------------------------- # Unmount the ramdisk filesystem to close the ramdisk image file. #----------------------------------------------------------------------------- msg "unmounting '${mntpnt}' to close the INTEL32 ramdisk image" umount "${mntpnt}" if [ $? != 0 ]; then errmsg "error unmounting INTEL32 ramdisk filesystem" exit 1 fi ############################################################################## # Prepare the INTEL32 floppy emulation boot image. # # This is the boot image that El Torito ISO extension capable i386 PC BIOSes # will emulate as a floppy to accomplish the booting. This image contains # a boot sector created by syslinux, which bootstraps the file ldlinux.sys, # which in turn loads the kernel and ramdisk images. ############################################################################## #----------------------------------------------------------------------------- # Initialize the boot image file. #----------------------------------------------------------------------------- msg "initializing the INTEL32 boot floppy image to ${bfsize}K bytes as fat12" mkdir -p "${isodir}/${bootimg}" rmdir "${isodir}/${bootimg}" mkdosfs -C -f "${bfnumfats}" -F "${bffatsize}" -n "${bfvolname}" -r "${bfrootdir}" -s "${bfclusecs}" -S "${bfsecsize}" "${isodir}/${bootimg}" "${bfsize}" 1>/dev/null 2>/dev/null if [ $? != 0 ]; then mkdosfs -C -f "${bfnumfats}" -F "${bffatsize}" -n "${bfvolname}" -r "${bfrootdir}" -s "${bfclusecs}" -S "${bfsecsize}" "${isodir}/${bootimg}" "${bfsize}" errmsg "unable to format INTEL32 boot floppy image '${isodir}/${bootimg}'" exit 1 fi chmod 644 "${isodir}/${bootimg}" if [ $? != 0 ]; then errmsg "unable to chmod INTEL32 boot floppy image '${isodir}/${bootimg}'" exit 1 fi #----------------------------------------------------------------------------- # Mount the floppy-like boot image filesystem. #----------------------------------------------------------------------------- msg "mounting empty INTEL32 boot floppy image" [ -d "${mntpnt}" ] || mkdir "${mntpnt}" mount -o loop,rw "${isodir}/${bootimg}" "${mntpnt}" if [ $? != 0 ]; then errmsg "error mounting empty INTEL32 boot floppy image '${isodir}/${bootimg}' at '${mntpnt}'" exit 1 fi #----------------------------------------------------------------------------- # Copy the ldlinux.sys file into the boot image filesystem. #----------------------------------------------------------------------------- msg "building the INTEL32 boot floppy filesystem:" msg " copying '${syslinux}/ldlinux.sys' -> '${mntpnt}/${sxloader}'" cp "${syslinux}/ldlinux.sys" "${mntpnt}/${sxloader}" if [ $? != 0 ]; then errmsg "error copying '${syslinux}/ldlinux.sys' -> '${mntpnt}/${sxloader}'" exit 1 fi #----------------------------------------------------------------------------- # If the initial ramdisk size built above is larger than the specified or # default ramdisk size, then set the specified size to the built size in # the kernel boot parameters. #----------------------------------------------------------------------------- bprs="" if [ -z "${intel32dsize}" ]; then if [ $intel32rsize -gt 4096 ]; then bprs=" ramdisk_size=${intel32rsize}" fi else if [ $intel32rsize -gt $intel32dsize ]; then bprs=" ramdisk_size=${intel32rsize}" fi fi #----------------------------------------------------------------------------- # Copy or build a syslinux.cfg file into the boot image filesystem. #----------------------------------------------------------------------------- msg " building -> '${mntpnt}/${sxconfig}'" cat < "${mntpnt}/${sxconfig}" default ${sxkernel} prompt 1 timeout ${sxtimeout} display ${sxmsgfile} label ${sxkernel} kernel ${sxkernel} append${bprs} vga=${ivgamode} initrd=${sxinitrd} root=/dev/ram0 ${intel32parm} EOF if [ $? != 0 ]; then errmsg "error building -> '${mntpnt}/${sxconfig}'" exit 1 fi #----------------------------------------------------------------------------- # Copy or build a boot message file into the boot image filesystem. #----------------------------------------------------------------------------- if [ -r "${intel32bmsg}" ]; then msg " copying '${intel32bmsg}' -> '${mntpnt}/${sxmsgfile}'" cp "${intel32bmsg}" "${mntpnt}/${sxmsgfile}" if [ $? != 0 ]; then errmsg "error copying '${intel32bmsg}' -> '${mntpnt}/${sxmsgfile}'" exit 1 fi else msg " building boot message -> '${mntpnt}/${sxmsgfile}'" echo '=============================================================================' >"${mntpnt}/${sxmsgfile}" echo "This CD image built on `exec date +%Y/%m/%d` by:" >>"${mntpnt}/${sxmsgfile}" echo "BICK ${version} - Bootable Image Construction Kit" >>"${mntpnt}/${sxmsgfile}" echo '=============================================================================' >>"${mntpnt}/${sxmsgfile}" fi #----------------------------------------------------------------------------- # Copy the kernel image file into the boot image filesystem. #----------------------------------------------------------------------------- msg " copying INTEL32 kernel image '${intel32kern}' -> '${mntpnt}/${sxkernel}'" cp "${intel32kern}" "${mntpnt}/${sxkernel}" if [ $? != 0 ]; then errmsg "error copying INTEL32 kernel image '${intel32kern}' -> '${mntpnt}/${sxkernel}'" exit 1 fi #----------------------------------------------------------------------------- # Compress the ramdisk image into the boot image filesystem. # Be careful. This may not fit if a custom ramdisk is provided. #----------------------------------------------------------------------------- msg "compressing the INTEL32 ramdisk image into the INTEL32 boot filesystem" gzip -9 < "${intel32rdisk}" > "${mntpnt}/${sxinitrd}" if [ $? != 0 ]; then echo "" >&2 errmsg "Error during compression of ramdisk image into boot filesystem" errmsg "The total compressed ramdisk size is `gzip -9 < ${intel32rdisk} | exec wc -c` bytes" errmsg "The boot image filesystem free space is shown below:" df "${mntpnt}" >&2 df "${mntpnt}" >&3 echo "" >&2 umount "${mntpnt}" exit 1 fi #----------------------------------------------------------------------------- # Save a listing of the files in the boot image filesystem. #----------------------------------------------------------------------------- msg "listing the files in INTEL32 boot filesystem -> '${bflisting}'" ( cd "${mntpnt}" ; eval "${lister}" ) | tee "${bflisting}" >&3 #----------------------------------------------------------------------------- # Log the usage of the boot image filesystem. #----------------------------------------------------------------------------- ( df "${mntpnt}" ; df -i "${mntpnt}" ) | egrep "Mounted|${mntpnt}" >&3 #----------------------------------------------------------------------------- # Unmount the boot image filesystem to close the boot image file. #----------------------------------------------------------------------------- msg "unmounting '${mntpnt}' to close the '${isodir}/${bootimg}' image" umount "${mntpnt}" if [ $? != 0 ]; then errmsg "error unmounting '${mntpnt}' to close the '${isodir}/${bootimg}' image" exit 1 fi #----------------------------------------------------------------------------- # Run syslinux to convert the boot image file into a bootable one. #----------------------------------------------------------------------------- msg "making the INTEL32 boot image bootable with syslinux" "${syslinux}/syslinux" "${isodir}/${bootimg}" if [ $? != 0 ]; then errmsg "error making the INTEL32 boot image bootable with syslinux" exit 1 fi ############################################################################## fi ############################################################################## # END INTEL ############################################################################## ############################################################################## # BEGIN SPARC32 ############################################################################## if $sparc32; then #----------------------------------------------------------------------------- # Make CD directories for the SPARC32 platform. #----------------------------------------------------------------------------- mkdir -m 0755 -p "${isodir}/sparc32" if [ $? != 0 ]; then errmsg "error making directory '${isodir}/sparc32' for SPARC32" exit 1 fi mkdir -m 0755 -p "${isodir}/${sparc32boot}" if [ $? != 0 ]; then errmsg "error making directory '${isodir}/${sparc32boot}' for SPARC32" exit 1 fi #----------------------------------------------------------------------------- # Copy the cdinit2 program into the CDROM boot area. #----------------------------------------------------------------------------- msg "copying '${sparc32cdinit2}' into '${isodir}/${sparc32boot}/cdinit2'" cp -p "${sparc32cdinit2}" "${isodir}/${sparc32boot}/cdinit2" if [ $? != 0 ]; then errmsg "error copying '${sparc32cdinit2}' into '${isodir}/${sparc32boot}/cdinit2'" exit 1 fi #----------------------------------------------------------------------------- # Copy the cdinit3 program into /sbin to be included in the tar file. #----------------------------------------------------------------------------- msg "copying '${sparc32cdinit3}' into '${sparc32tree}/sbin'" cp -p "${sparc32cdinit3}" "${sparc32tree}/sbin/cdinit3" if [ $? != 0 ]; then errmsg "error copying '${sparc32cdinit3}' to '${sparc32tree}/sbin/cdinit3'" exit 1 fi #----------------------------------------------------------------------------- # Collect files destined for ramfs/tmpfs into a tar file. # All files except those in /opt or /usr are destined for ramfs/tmpfs. # The /opt and /usr files will be on the mounted CD and symlinked in. #----------------------------------------------------------------------------- msg "building the root.tar file for SPARC32" tlist="" for tname in $( exec ls -1A "${sparc32tree}" ); do [ "${tname}" = "cdrom" ] && continue [ "${tname}" = "lost+found" ] && continue $cdopt && [ "${tname}" = "opt" ] && continue $cdusr && [ "${tname}" = "usr" ] && continue if [ -z "${tlist}" ]; then tlist="${tname}" else tlist="${tlist} ${tname}" fi done ( cd "${sparc32tree}" && exec tar cf - $tlist ) > "${isodir}/${sparc32boot}/root.tar" if [ $? != 0 ]; then errmsg "error building root.tar file for SPARC32" exit 1 fi ls -ld "${isodir}/${sparc32boot}/root.tar" tar tvf - < "${isodir}/${sparc32boot}/root.tar" > "${sparc32tlist}" #----------------------------------------------------------------------------- # We need tar on the CDROM, since it is used to load the root.tar file, # so make sure it is there. #----------------------------------------------------------------------------- [ -d "${isodir}/sparc32/bin" ] || mkdir -p "${isodir}/sparc32/bin" cp -p "${sparc32tree}/bin/tar" "${isodir}/sparc32/bin/tar" if [ $? != 0 ]; then errmsg "error copying '${sparc32tree}/bin/tar' -> '${isodir}/sparc32/bin/tar'" exit 1 fi [ -d "${isodir}/sparc32/lib" ] || mkdir -p "${isodir}/sparc32/lib" cp -p "${sparc32tree}/lib/ld-linux.so.2" "${isodir}/sparc32/lib/ld-linux.so.2" if [ $? != 0 ]; then errmsg "error copying '${sparc32tree}/lib/ld-linux.so.2' -> '${isodir}/sparc32/lib/ld-linux.so.2'" exit 1 fi cp -p "${sparc32tree}/lib/libc.so.6" "${isodir}/sparc32/lib/libc.so.6" if [ $? != 0 ]; then errmsg "error copying '${sparc32tree}/lib/libc.so.6' -> '${isodir}/sparc32/lib/libc.so.6'" exit 1 fi #----------------------------------------------------------------------------- # Collect usr and opt trees into a platform specific directory on the CD. #----------------------------------------------------------------------------- $cdopt && [ -d "${sparc32tree}/opt" ] && graft="${graft} 'sparc32/opt/=${sparc32tree}/opt'" $cdusr && [ -d "${sparc32tree}/usr" ] && graft="${graft} 'sparc32/usr/=${sparc32tree}/usr'" ############################################################################## # Prepare the ramdisk image for SPARC32. # # This is the image that will be /dev/ram mounted as / when the kernel starts # the first init program. ############################################################################## #----------------------------------------------------------------------------- # Fill out the ramdisk image file to the requested size. #----------------------------------------------------------------------------- if [ $sparc32rsize -le 128 ]; then e2opt="-N 32" else e2opt="-i 1024" fi e2opt="${e2opt} -F -q -b 1024 -m 0 -L ramdisk -M /" msg "initializing the SPARC32 ramdisk image to ${sparc32rsize}K bytes (ext2)" dd if=/dev/zero of="${sparc32rdisk}" bs=1024 count="${sparc32rsize}" 2>/dev/null if [ $? != 0 ]; then dd if=/dev/zero of="${sparc32rdisk}" bs=1024 count="${sparc32rsize}" errmsg "unable to setup the SPARC32 ramdisk image file '${sparc32rdisk}'" exit 1 fi mke2fs -q $e2opt "${sparc32rdisk}" "${sparc32rsize}" 2>/dev/null if [ $? != 0 ]; then mke2fs $e2opt "${sparc32rdisk}" "${sparc32rsize}" errmsg "unable to format the SPARC32 ramdisk image file '${sparc32rdisk}'" exit 1 fi tune2fs -e panic -i 0 "${sparc32rdisk}" 1>/dev/null 2>/dev/null if [ $? != 0 ]; then tune2fs -e panic -i 0 "${sparc32rdisk}" errmsg "unable to tweak the SPARC32 ramdisk image file '${sparc32rdisk}'" exit 1 fi #----------------------------------------------------------------------------- # Mount the ramdisk image to enable populating it. #----------------------------------------------------------------------------- msg "mounting empty SPARC32 ramdisk image '${sparc32rdisk}' to populate it" mount -o loop,rw,noatime "${sparc32rdisk}" "${mntpnt}" if [ $? != 0 ]; then errmsg "unable to mount empty SPARC32 ramdisk image '${sparc32rdisk}' at '${mntpnt}'" exit 1 fi #----------------------------------------------------------------------------- # Remove lost+found which is of no use on a ramdisk filesystem. #----------------------------------------------------------------------------- if [ -d "${mntpnt}/lost+found" ]; then rmdir "${mntpnt}/lost+found" if [ $? != 0 ]; then errmsg "lost+found exits in SPARC32 ramdisk but cannot be removed" exit 1 fi fi #----------------------------------------------------------------------------- # Populate the ramdisk filesystem with the following: # /dev/console the kernel opens this file before starting init # /sbin/init this will be cdinit1 running as init first #----------------------------------------------------------------------------- msg "populating SPARC32 ramdisk filesystem" if ! $devfs; then ( cd "${mntpnt}" && mkdir -m 0755 dev sbin && cd dev && mknod console c 5 1 ) if [ ! -c "${mntpnt}/dev/console" ]; then errmsg "error creating device node /dev/console (5,1) in the SPARC32 ramdisk filesystem" exit 1 fi fi cp -p "${sparc32cdinit1}" "${mntpnt}/sbin/init" if [ ! -f "${mntpnt}/sbin/init" -a ! -r "${mntpnt}/sbin/init" -a ! -x "${mntpnt}/sbin/init" ]; then errmsg "error copying '${sparc32cdinit1}' to /sbin/init in the SPARC32 ramdisk filesystem" exit 1 fi #----------------------------------------------------------------------------- # Save a listing of the files in the ramdisk filesystem. #----------------------------------------------------------------------------- ( cd "${mntpnt}" && eval "${lister}" ) | tee "${sparc32rlist}" >&3 #----------------------------------------------------------------------------- # Log the usage of the ramdisk filesystem. #----------------------------------------------------------------------------- ( df "${mntpnt}" ; df -i "${mntpnt}" ) | egrep "Mounted|${mntpnt}" >&3 #----------------------------------------------------------------------------- # Unmount the ramdisk filesystem to close the ramdisk image file. #----------------------------------------------------------------------------- msg "unmounting '${mntpnt}' to close the SPARC32 ramdisk image" umount "${mntpnt}" if [ $? != 0 ]; then errmsg "error unmounting SPARC32 ramdisk filesystem" exit 1 fi #----------------------------------------------------------------------------- # Compress the ramdisk and copy to the location SILO will load it from. #----------------------------------------------------------------------------- msg "compressing SPARC32 ramdisk image to '${isodir}/${sparc32boot}/initrd-sparc32.gz'" gzip -9 < "${sparc32rdisk}" > "${isodir}/${sparc32boot}/initrd-sparc32.gz" if [ $? != 0 ]; then errmsg "error compressing SPARC32 ramdisk image to '${isodir}/${sparc32boot}/initrd-sparc32.gz'" errmsg " input file from '${sparc32rdisk}'" exit 1 fi #----------------------------------------------------------------------------- # Set up SILO. #----------------------------------------------------------------------------- msg "copying the SPARC32 SILO first stage boot loader to the ISO directory" cp -p "${silosrcone}" "${isodir}/${siloisoone}" if [ $? != 0 ]; then errmsg "error copying the SPARC32 SILO first stage boot loader to the ISO directory" errmsg " copying from '${silosrcone}' to '${isodir}/${siloisoone}'" exit 1 fi msg "copying the SPARC32 SILO second stage boot loader to the ISO directory" cp -p "${silosrctwo}" "${isodir}/${siloisotwo}" if [ $? != 0 ]; then errmsg "error copying the SPARC32 SILO second stage boot loader to the ISO directory" errmsg " copying from '${silosrctwo}' to '${isodir}/${siloisotwo}'" exit 1 fi #----------------------------------------------------------------------------- # Build the SILO config file dynamically for the kernels that are available. #----------------------------------------------------------------------------- msg "building the SPARC32 SILO config file" cat <"${isodir}/${sparc32boot}/silo.conf" partition=1 default=linux read-only message=/${silobmsg} root=/dev/ram0 timeout = 50 EOF if [ -n "${sparc32kern}" -a -r "${sparc32kern}" ]; then cp -p "${sparc32kern}" "${isodir}/${sparc32boot}/vmlinux-sun4" echo "image[sun4]=/${sparc32boot}/vmlinux-sun4" >>"${isodir}/${sparc32boot}/silo.conf" echo " label=linux" >>"${isodir}/${sparc32boot}/silo.conf" # echo ' append="ramdisk_size=5120k"' >>"${isodir}/${sparc32boot}/silo.conf" echo ' append="'"${sparc32parm}"'"' >>"${isodir}/${sparc32boot}/silo.conf" echo " initrd=/${sparc32boot}/initrd-sparc32.gz" >>"${isodir}/${sparc32boot}/silo.conf" fi if [ -n "${sparc32kernc}" -a -r "${sparc32kernc}" ]; then cp -p "${sparc32kernc}" "${isodir}/${sparc32boot}/vmlinux-sun4c" echo "image[sun4c]=/${sparc32boot}/vmlinux-sun4c" >>"${isodir}/${sparc32boot}/silo.conf" echo " label=linux" >>"${isodir}/${sparc32boot}/silo.conf" # echo ' append="ramdisk_size=5120k"' >>"${isodir}/${sparc32boot}/silo.conf" echo ' append="'"${sparc32parm}"'"' >>"${isodir}/${sparc32boot}/silo.conf" echo " initrd=/${sparc32boot}/initrd-sparc32.gz" >>"${isodir}/${sparc32boot}/silo.conf" fi if [ -n "${sparc32kerndm}" -a -r "${sparc32kerndm}" ]; then cp -p "${sparc32kerndm}" "${isodir}/${sparc32boot}/vmlinux-sun4dm" echo "image[sun4d,sun4m]=/${sparc32boot}/vmlinux-sun4dm" >>"${isodir}/${sparc32boot}/silo.conf" echo " label=linux" >>"${isodir}/${sparc32boot}/silo.conf" # echo ' append="ramdisk_size=5120k"' >>"${isodir}/${sparc32boot}/silo.conf" echo ' append="'"${sparc32parm}"'"' >>"${isodir}/${sparc32boot}/silo.conf" echo " initrd=/${sparc32boot}/initrd-sparc32.gz" >>"${isodir}/${sparc32boot}/silo.conf" fi if [ -n "${sparc32kernu}" -a -r "${sparc32kernu}" ]; then cp -p "${sparc32kernu}" "${isodir}/${sparc32boot}/vmlinux-sun4u" echo "image[sun4u]=/${sparc32boot}/vmlinux-sun4u" >>"${isodir}/${sparc32boot}/silo.conf" echo " label=linux" >>"${isodir}/${sparc32boot}/silo.conf" # echo ' append="ramdisk_size=5120k"' >>"${isodir}/${sparc32boot}/silo.conf" echo ' append="'"${sparc32parm}"'"' >>"${isodir}/${sparc32boot}/silo.conf" echo " initrd=/${sparc32boot}/initrd-sparc32.gz" >>"${isodir}/${sparc32boot}/silo.conf" fi #----------------------------------------------------------------------------- # Copy or build a boot message file into the boot image filesystem. #----------------------------------------------------------------------------- if [ -r "${sparc32bmsg}" ]; then msg " copying '${sparc32bmsg}' -> '${isodir}/${silobmsg}'" cp "${sparc32bmsg}" "${isodir}/${silobmsg}" if [ $? != 0 ]; then errmsg "error copying '${sparc32bmsg}' -> '${isodir}/${silobmsg}'" exit 1 fi else msg " building boot message -> '${isodir}/${silobmsg}'" echo '=============================================================================' >"${isodir}/${silobmsg}" echo "This CD image built on `exec date +%Y/%m/%d` by:" >>"${isodir}/${silobmsg}" echo "BICK ${version} - Bootable Image Construction Kit" >>"${isodir}/${silobmsg}" echo '=============================================================================' >>"${isodir}/${silobmsg}" fi ############################################################################## fi ############################################################################## # END SPARC32 ############################################################################## ############################################################################## # Build the ISO-9660 CDROM image. ############################################################################## #----------------------------------------------------------------------------- # Save a listing of the files in the CDROM tree. #----------------------------------------------------------------------------- msg "listing the files in the CDROM tree -> '${cdlist1}'" ( cd "${isodir}" && eval "${lister}" ) | tee "${cdlist1}" >&3 #----------------------------------------------------------------------------- # Build the mkisofs command. #----------------------------------------------------------------------------- cmd="mkisofs -o '${isoimg}'" $intel32 && [ -n "${bootimg}" ] && cmd="${cmd} -b '${bootimg}'" $intel32 && [ -n "${bootcat}" ] && cmd="${cmd} -c '${bootcat}'" $sparc32 && [ -n "${silocfg}" ] && cmd="${cmd} -s '/${silocfg}'" $sparc32 && [ -n "${siloisoone}" ] && cmd="${cmd} -S '/${siloisoone}'" $sparc32 && [ -n "${siloisotwo}" ] && cmd="${cmd} -B '${siloisotwo}'" [ -n "${optabstract}" ] && cmd="${cmd} -abstract '${optabstract}'" [ -n "${optappid}" ] && cmd="${cmd} -A '${optappid}'" [ -n "${optbiblio}" ] && cmd="${cmd} -biblio '${optbiblio}'" [ -n "${optcopyright}" ] && cmd="${cmd} -copyright '${optcopyright}'" [ -n "${optpubid}" ] && cmd="${cmd} -P '${optpubid}'" [ -n "${optprepid}" ] && cmd="${cmd} -p '${optprepid}'" [ -n "${optsysid}" ] && cmd="${cmd} -sysid '${optsysid}'" [ -n "${optvolid}" ] && cmd="${cmd} -V '${optvolid}'" $optdeepr && cmd="${cmd} -D" $optjoliet && cmd="${cmd} -J" $optrr && cmd="${cmd} -r" $optpad && cmd="${cmd} -pad" $optverbose || cmd="${cmd} -quiet" cmd="${cmd} '${isodir}'${graft} 2>&1 1>&3" #----------------------------------------------------------------------------- # Run mkisofs to build the actual ISO-9660 CDROM image. #----------------------------------------------------------------------------- msg "finally building the actual ISO-9660 CDROM image with this command:" echo '' echo "${cmd}" eval "${cmd}" if [ $? != 0 ]; then errmsg "error in mkisofs while building the actual ISO-9660 CDROM image" exit 1 fi echo '' #----------------------------------------------------------------------------- # Calculate and display the size of the new CDROM image in sectors. #----------------------------------------------------------------------------- bytes=$( exec find "${isoimg}" -type f -printf '%s\n' ) secs=$[ $bytes / 2048 ] check=$[ $secs * 2048 ] diff=$[ $bytes - $check ] msg "ISO-9660 CDROM image '${isoimg}' is now complete!" msg " size is ${bytes} bytes (${secs} 2K sectors)" echo '' #----------------------------------------------------------------------------- # Check for possible problems with the CDROM image. #----------------------------------------------------------------------------- if [ $diff -gt 0 ]; then s="s" [ $diff -eq 1 ] && s="" echo '' echo "${0}: **** WARNING ****" echo "${0}: number of bytes (${bytes}) is not an exact multiple of 2K sectors" echo "${0}: ${bytes} bytes is ${secs} 2K sectors + ${diff} extra byte${s}" echo "${0}: **** WARNING ****" echo "${0}: aborting..." echo '' exit 1 fi if [ $secs -gt 333000 ]; then echo '' echo "${0}: **** WARNING ****" echo "${0}: number of sectors (${secs}) exceeds usual maximum of 333000" echo "${0}: verify that your CDR media is large enough for this size" echo "${0}: **** WARNING ****" echo "${0}: continuing..." echo '' fi #----------------------------------------------------------------------------- # Show the file. #----------------------------------------------------------------------------- ls -ld "${isoimg}" ls -ld "${isoimg}" >&3 echo '' #----------------------------------------------------------------------------- # Mount it to see if it works. #----------------------------------------------------------------------------- msg "test mounting the new ISO-9660 CDROM image" mount -o loop,ro "${isoimg}" "${mntpnt}" if [ $? != 0 ]; then errmsg "mount of new ISO-9660 CDROM image failed" exit 1 fi #----------------------------------------------------------------------------- # Save a listing of the files in the CDROM image. #----------------------------------------------------------------------------- msg "listing the files in the CDROM image -> '${cdlist2}'" ( cd "${mntpnt}" && eval "${lister}" ) | tee "${cdlist2}" >&3 #----------------------------------------------------------------------------- # Unmount the CDROM filesystem. #----------------------------------------------------------------------------- msg "unmounting the new ISO-9660 CDROM image" umount "${mntpnt}" if [ $? != 0 ]; then errmsg "unmount of new ISO-9660 CDROM image failed" exit 1 fi #----------------------------------------------------------------------------- # Calculate the time all this took to do. #----------------------------------------------------------------------------- t=$[ $( exec date '+%s' ) - $startsecs ] h=$[ $t / 3600 ] s=$[ $t - $h * 3600 ] m=$[ $s / 60 ] s=$[ $s - $m * 60 ] o="total working time is" [ $h -eq 1 ] && o="${o} 1 hour" [ $h -gt 1 ] && o="${o} ${h} hours" [ $m -eq 1 ] && o="${o} 1 minute" [ $m -gt 1 ] && o="${o} ${m} minutes" [ $s -eq 1 ] && o="${o} 1 second" [ $s -gt 1 ] && o="${o} ${s} seconds" msg "${o}" echo '' exit 0