]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - release/scripts/split-file.sh
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / release / scripts / split-file.sh
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # Bail if things fail and be verbose about what we are doing
7 set -ex
8
9 # Arguments are as follows: file destdir chunksize description
10 FILE=$1; shift
11 DEST=$1; shift
12 CHUNK_SIZE=$1; shift
13 DESCR=$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
19 rm -rf ${DEST} || true
20 mkdir -p ${DEST}
21
22 # Split the file into pieces
23 prefix=`basename $FILE`
24 dd 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
28 files=`ls ${DEST}/${prefix}.*`
29 first=`echo "${files}" | head -1`
30 bootchunk="${DEST}/${prefix}.boot"
31 dd if=${FILE} of=${bootchunk} bs=16k count=1
32
33 # Create the split index file
34 echo `basename ${bootchunk}` "\"Boot floppy\"" > ${DEST}/${prefix}.split
35 i=1
36 for file in ${files}; do
37         echo `basename ${file}` "\"${DESCR} floppy ${i}\"" >> ${DEST}/${prefix}.split
38         i=$(($i + 1))
39 done