1#!/bin/sh 2# 3# $FreeBSD: stable/9/release/scripts/split-file.sh 134353 2004-08-26 19:15:20Z ru $ 4# 5 6# Bail if things fail and be verbose about what we are doing 7set -ex 8 9# Arguments are as follows: file destdir chunksize description 10FILE=$1; shift 11DEST=$1; shift 12CHUNK_SIZE=$1; shift 13DESCR=$1; shift 14 15# Make sure we can read the file. 16[ -r ${FILE} ] 17 18# Create clean working area to stick file chunks and list in 19rm -rf ${DEST} || true 20mkdir -p ${DEST} 21 22# Split the file into pieces 23prefix=`basename $FILE` 24dd if=${FILE} bs=16k iseek=1 | split -b ${CHUNK_SIZE}k - ${DEST}/${prefix}. 25 26# Create a special file for the first 16k that gets stuck on the boot 27# floppy 28files=`ls ${DEST}/${prefix}.*` 29first=`echo "${files}" | head -1` 30bootchunk="${DEST}/${prefix}.boot" 31dd if=${FILE} of=${bootchunk} bs=16k count=1 32 33# Create the split index file 34echo `basename ${bootchunk}` "\"Boot floppy\"" > ${DEST}/${prefix}.split 35i=1 36for file in ${files}; do 37 echo `basename ${file}` "\"${DESCR} floppy ${i}\"" >> ${DEST}/${prefix}.split 38 i=$(($i + 1)) 39done 40