]> code.delx.au - refind/blob - mkcdimage
Improved handling of non-sd?/non-hd? disks in refind-install.
[refind] / mkcdimage
1 #!/bin/bash
2 #
3 # Script to create a bootable CD image file containing rEFInd.
4 # Usage:
5 #
6 # ./mkcdimage {version}
7 #
8 # where {version} is the rEFInd version number.
9 #
10 # This script relies on the mcopy utility.
11 #
12 # The script creates an image file from the binary package
13 # stored in ../snapshots/{version}/refind-bin-{version}.zip
14 # The resulting CD image file is stored in
15 # ../snapshots/{version}/refind-cd-{version}.iso
16
17 StartDir=`pwd`
18 Version=$1
19
20 # Unzip the binary archive file....
21 cd ../snapshots/$Version
22 rm -rf temp
23 mkdir temp
24 cd temp
25 unzip ../refind-bin-$Version.zip
26 cp $StartDir/SHELLS.txt ./refind-bin-$Version
27
28 # Create a boot directory and (temporarily) copy the EFI shell
29 # files to it....
30 mkdir -p refind-bin-$Version/EFI/boot
31 cd refind-bin-$Version/EFI/boot
32 cp $StartDir/shell*.efi ./
33
34 # Create hard links to the rEFInd files so that they'll be suitable for an
35 # EFI-boot CD...
36 ln ../../refind/refind_ia32.efi ./bootia32.efi
37 ln ../../refind/refind_x64.efi ./bootx64.efi
38 ln ../../refind/refind_aa64.efi ./bootaa64.efi
39 cp ../../refind/refind.conf-sample ./refind.conf
40 sed -i '/#showtools/a showtools shell,memtest,gdisk,apple_recovery,csr_rotate,windows_recovery,mok_tool,about,shutdown,reboot,firmware' refind.conf
41 sed -i '/#csr_values/a csr_values 10,77' refind.conf
42 mkdir icons
43 cd icons
44 ln ../../../refind/icons/* ./
45 cd ../
46 mkdir drivers_x64
47 cd drivers_x64
48 ln ../../../refind/drivers_x64/* ./
49 cd ..
50 mkdir drivers_ia32
51 cd drivers_ia32
52 ln ../../../refind/drivers_ia32/* ./
53 cd ..
54 mkdir drivers_aa64
55 cd drivers_aa64
56 ln ../../../refind/drivers_aa64/* ./
57 cd ../../..
58
59 # Get the size of the binaries to go in the El Torito image in kB
60 ToritoSize=`du -s EFI | cut -f 1`
61 let ToritoSize=($ToritoSize)/28
62 let ToritoSize=($ToritoSize)*32
63
64 # Move the EFI shell files back to the root where they belong
65 # (They were in EFI/boot just so they'd get counted in ToritoSize)
66 mv EFI/boot/shell*.efi ./
67
68 # Prepare a FAT filesystem image and populate it with the
69 # EFI boot files....
70 dd if=/dev/zero of=refind-bin-$Version.img bs=1024 count=$ToritoSize
71 mkdosfs -n "ElTorito" refind-bin-$Version.img
72 mcopy -irefind-bin-$Version.img -s EFI shell*.efi ::/
73
74 # Make the ISO-9660 image file....
75 mkisofs -A "Bootable rEFInd" -V "rEFInd_$Version" -volset "rEFInd_$Version" \
76 -J -r -v -x ./lost+found -o ../../refind-cd-$Version.iso \
77 -eltorito-alt-boot -efi-boot refind-bin-$Version.img \
78 -no-emul-boot ./
79
80 # Create a bootable USB flash drive image, using the FAT filesystem
81 # created above and a stored partition table image (plus some empty
82 # sectors)....
83 #
84 rm -f ../../refind-flashdrive-$Version.*
85 let FatSize=`du -s refind-bin-$Version.img | cut -f 1`
86 let FatSize=($FatSize)+2048
87 dd if=/dev/zero of=../../refind-flashdrive-$Version.img bs=1024 count=$FatSize
88 sgdisk -n 1:2048:0 -t 1:EF00 -g ../../refind-flashdrive-$Version.img
89 if [[ $? != 0 ]] ; then
90 echo "sgdisk failed! Exiting!"
91 exit 1
92 fi
93 dd if=refind-bin-$Version.img of=../../refind-flashdrive-$Version.img bs=512 seek=2048 conv=notrunc
94
95 cd ..
96 mkdir refind-flashdrive-$Version
97 ln ../refind-flashdrive-$Version.img refind-flashdrive-$Version
98 cp $StartDir/README-flashdrive.txt $StartDir/COPYING.txt $StartDir/NEWS.txt \
99 $StartDir/CREDITS.txt $StartDir/LICENSE.txt $StartDir/SHELLS.txt refind-flashdrive-$Version
100 zip -9r ../refind-flashdrive-$Version.zip refind-flashdrive-$Version
101
102 cd ../
103
104 # Zip up the optical disc image....
105 rm -f refind-cd-$Version.zip
106 zip -9 refind-cd-$Version.zip refind-cd-$Version.iso
107
108 rm -r temp/