2018-07-11 03:43:31 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-09-21 07:19:40 +03:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2018-07-11 03:43:31 +03:00
|
|
|
OUT=$1
|
|
|
|
IN=$2
|
|
|
|
|
|
|
|
OUTDIR=`dirname $1`
|
|
|
|
|
2018-10-19 03:10:14 +03:00
|
|
|
# Calculate required space
|
2018-10-19 03:08:28 +03:00
|
|
|
SPACE_REQ=$(du -sb "$DIR/../fatbase" | cut -f 1)
|
|
|
|
let "SIZE = ($SPACE_REQ / 1040000)"
|
|
|
|
|
2018-10-19 03:10:14 +03:00
|
|
|
# Minimum size
|
|
|
|
if [ $SIZE -lt 32 ]; then
|
|
|
|
SIZE=32
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Use more sectors-per-cluster for larger disk sizes
|
2018-10-19 03:08:28 +03:00
|
|
|
if [ $SIZE -gt 128 ]; then
|
|
|
|
SPC=4
|
2018-09-21 07:19:40 +03:00
|
|
|
else
|
2018-10-12 12:11:24 +03:00
|
|
|
SPC=1
|
2018-09-21 07:19:40 +03:00
|
|
|
fi
|
|
|
|
|
2018-10-19 03:10:14 +03:00
|
|
|
# Create empty FAT image
|
2018-07-11 03:43:31 +03:00
|
|
|
rm -f $OUT
|
2018-07-14 12:34:10 +03:00
|
|
|
mkdir -p cdrom
|
2018-09-21 07:19:40 +03:00
|
|
|
fallocate -l ${SIZE}M $OUT || dd if=/dev/zero bs=1M count=${SIZE} of=$OUT
|
2018-10-12 12:11:24 +03:00
|
|
|
mkfs.fat -s $SPC -S 2048 $OUT
|
2018-07-11 03:43:31 +03:00
|
|
|
|
|
|
|
#echo "Turning $IN into $OUT"
|
|
|
|
|
2018-10-19 03:10:14 +03:00
|
|
|
# Add files
|
2018-07-11 03:43:31 +03:00
|
|
|
for i in $(find $IN)
|
|
|
|
do
|
|
|
|
if [[ $i == $IN ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
OUT_FILE=`echo $i | sed s"/^$IN/$OUTDIR/"`
|
|
|
|
IN_FILE=`echo $i | sed s"/^$IN//"`
|
|
|
|
#echo $IN_FILE $OUT_FILE
|
|
|
|
if [ -d "$i" ]; then
|
|
|
|
mmd -i $OUT $IN_FILE
|
|
|
|
mkdir -p $OUT_FILE
|
|
|
|
else
|
|
|
|
mcopy -i $OUT $i '::'$IN_FILE
|
|
|
|
touch $OUT_FILE
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-07-11 07:23:04 +03:00
|
|
|
rm -f cdrom/efi/boot/bootia32.efi # Otherwise virtualbox may erroneously try to load from this
|
|
|
|
rm -f cdrom/efi/boot/bootx64.efi # Same
|
2018-07-11 04:55:49 +03:00
|
|
|
|