| 1 |
#!/bin/bash |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
TEMPDIR="$1" |
|---|
| 24 |
STARTISO="$2" |
|---|
| 25 |
FINISHISO="$3" |
|---|
| 26 |
|
|---|
| 27 |
if [ -z "$TEMPDIR" -o -z "$STARTISO" -o -z "$FINISHISO" ]; then |
|---|
| 28 |
echo "Usage: $0 tmpdirectory starting.iso destination.iso" |
|---|
| 29 |
echo |
|---|
| 30 |
echo "e.g. $0 /tmp/ /mnt/hda5/lunix.iso/MorphixBase-0.5-pre2.iso /mnt/hda5/lunix.iso/MorphixTestConvert2.iso" |
|---|
| 31 |
echo |
|---|
| 32 |
echo "This script generates a new iso, with boot.img" |
|---|
| 33 |
echo "based upon a iso with an uncompressed /boot" |
|---|
| 34 |
echo |
|---|
| 35 |
echo "In other words, Morphix_0.5 -> an iso with boot.img" |
|---|
| 36 |
echo "Disk space is required to store a new iso" |
|---|
| 37 |
echo "Requires GRUB to be installed" |
|---|
| 38 |
echo |
|---|
| 39 |
exit |
|---|
| 40 |
fi |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
mkdir $TEMPDIR/convert_morphix_base |
|---|
| 44 |
mkdir $TEMPDIR/convert_morphix_base/base |
|---|
| 45 |
mkdir $TEMPDIR/convert_morphix_base/iso |
|---|
| 46 |
mkdir $TEMPDIR/convert_morphix_base/boot |
|---|
| 47 |
mkdir $TEMPDIR/convert_morphix_base/misc |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
mount $STARTISO $TEMPDIR/convert_morphix_base/iso -o loop |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
dd if=/dev/zero of=$TEMPDIR/convert_morphix_base/base/boot.img bs=1k count=2880 |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
mkfs.msdos -C $TEMPDIR/convert_morphix_base/base/boot.img 2880 |
|---|
| 58 |
mount $TEMPDIR/convert_morphix_base/base/boot.img $TEMPDIR/convert_morphix_base/boot -o loop |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
mkdir $TEMPDIR/convert_morphix_base/boot/boot |
|---|
| 62 |
mkdir $TEMPDIR/convert_morphix_base/boot/boot/grub |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
GRUB_LOCATE=/boot/grub |
|---|
| 68 |
cp $GRUB_LOCATE/stage1 $TEMPDIR/convert_morphix_base/boot/boot/grub |
|---|
| 69 |
cp $GRUB_LOCATE/stage2 $TEMPDIR/convert_morphix_base/boot/boot/grub |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
cp $TEMPDIR/convert_morphix_base/iso/boot/miniroot.gz $TEMPDIR/convert_morphix_base/boot/boot/ |
|---|
| 76 |
cp $TEMPDIR/convert_morphix_base/iso/boot/vmlinuz $TEMPDIR/convert_morphix_base/boot/boot/ |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
for i in $(ls /tmp/convert_morphix_base/iso/boot/grub/); |
|---|
| 80 |
do |
|---|
| 81 |
if [ "$i" == "stage1" ] |
|---|
| 82 |
then |
|---|
| 83 |
echo "Not copying file: $i" |
|---|
| 84 |
elif [ "$i" == "stage2" ] |
|---|
| 85 |
then |
|---|
| 86 |
echo "Not copying file: $i" |
|---|
| 87 |
elif [ "$i" == "iso9660_stage1_5" ] |
|---|
| 88 |
then |
|---|
| 89 |
echo "Not copying file: $i" |
|---|
| 90 |
else |
|---|
| 91 |
cp $TEMPDIR/convert_morphix_base/iso/boot/grub/$i $TEMPDIR/convert_morphix_base/boot/boot/grub/ 2>/dev/null |
|---|
| 92 |
fi |
|---|
| 93 |
done |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
for i in $(ls $TEMPDIR/convert_morphix_base/iso/boot/grub/*.lst); |
|---|
| 101 |
do |
|---|
| 102 |
BASENAME=${i |
|---|
| 103 |
sed -e 's/(cd)/(fd0)/g' $TEMPDIR/convert_morphix_base/iso/boot/grub/$BASENAME > $TEMPDIR/convert_morphix_base/boot/boot/grub/$BASENAME |
|---|
| 104 |
done |
|---|
| 105 |
|
|---|
| 106 |
for i in $(ls $TEMPDIR/convert_morphix_base/iso/boot/grub/texts.*); |
|---|
| 107 |
do |
|---|
| 108 |
BASENAME=${i |
|---|
| 109 |
sed -e 's/(cd)/(fd0)/g' $TEMPDIR/convert_morphix_base/iso/boot/grub/$BASENAME > $TEMPDIR/convert_morphix_base/boot/boot/grub/$BASENAME |
|---|
| 110 |
done |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
umount $TEMPDIR/convert_morphix_base/base/boot.img |
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
echo "device (fd0) $TEMPDIR/convert_morphix_base/base/boot.img " > $TEMPDIR/convert_morphix_base/misc/grub_commands |
|---|
| 117 |
echo "root (fd0)" >> $TEMPDIR/convert_morphix_base/misc/grub_commands |
|---|
| 118 |
echo "setup (fd0) " >> $TEMPDIR/convert_morphix_base/misc/grub_commands |
|---|
| 119 |
echo "quit" >> $TEMPDIR/convert_morphix_base/misc/grub_commands |
|---|
| 120 |
cat $TEMPDIR/convert_morphix_base/misc/grub_commands | grub --batch |
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
mkisofs -graft-points -pad -l -r -J -v -V "Morphix LiveCD" -b base/boot.img -c base/boot.cat -hide -rr -moved -o $FINISHISO $TEMPDIR/convert_morphix_base/iso /base/=$TEMPDIR/convert_morphix_base/base/ |
|---|
| 124 |
|
|---|
| 125 |
umount $STARTISO |
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
rm $TEMPDIR/convert_morphix_base/ -R |
|---|