]> code.delx.au - refind/blob - mkcdimage
Added AARCH64 support to 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 cp ../../refind/refind.conf-sample ./refind.conf
39 sed -i '/#showtools/a showtools shell,memtest,gdisk,apple_recovery,csr_rotate,windows_recovery,mok_tool,about,shutdown,reboot,firmware' refind.conf
40 sed -i '/#csr_values/a csr_values 10,77' refind.conf
41 mkdir icons
42 cd icons
43 ln ../../../refind/icons/* ./
44 cd ../
45 mkdir drivers_x64
46 cd drivers_x64
47 ln ../../../refind/drivers_x64/* ./
48 cd ..
49 mkdir drivers_ia32
50 cd drivers_ia32
51 ln ../../../refind/drivers_ia32/* ./
52 cd ../../..
53
54 # Get the size of the binaries to go in the El Torito image in kB
55 ToritoSize=`du -s EFI | cut -f 1`
56 let ToritoSize=($ToritoSize)/28
57 let ToritoSize=($ToritoSize)*32
58
59 # Move the EFI shell files back to the root where they belong
60 # (They were in EFI/boot just so they'd get counted in ToritoSize)
61 mv EFI/boot/shell*.efi ./
62
63 # Prepare a FAT filesystem image and populate it with the
64 # EFI boot files....
65 dd if=/dev/zero of=refind-bin-$Version.img bs=1024 count=$ToritoSize
66 mkdosfs -n "ElTorito" refind-bin-$Version.img
67 mcopy -irefind-bin-$Version.img -s EFI shell*.efi ::/
68
69 # Make the ISO-9660 image file....
70 mkisofs -A "Bootable rEFInd" -V "rEFInd_$Version" -volset "rEFInd_$Version" \
71 -J -r -v -x ./lost+found -o ../../refind-cd-$Version.iso \
72 -eltorito-alt-boot -efi-boot refind-bin-$Version.img \
73 -no-emul-boot ./
74
75 # Create a bootable USB flash drive image, using the FAT filesystem
76 # created above and a stored partition table image (plus some empty
77 # sectors)....
78 #
79 rm -f ../../refind-flashdrive-$Version.*
80 let FatSize=`du -s refind-bin-$Version.img | cut -f 1`
81 let FatSize=($FatSize)+2048
82 dd if=/dev/zero of=../../refind-flashdrive-$Version.img bs=1024 count=$FatSize
83 sgdisk -n 1:2048:0 -t 1:EF00 -g ../../refind-flashdrive-$Version.img
84 if [[ $? != 0 ]] ; then
85 echo "sgdisk failed! Exiting!"
86 exit 1
87 fi
88 dd if=refind-bin-$Version.img of=../../refind-flashdrive-$Version.img bs=512 seek=2048 conv=notrunc
89
90 cd ..
91 mkdir refind-flashdrive-$Version
92 ln ../refind-flashdrive-$Version.img refind-flashdrive-$Version
93 cp $StartDir/README-flashdrive.txt $StartDir/COPYING.txt $StartDir/NEWS.txt \
94 $StartDir/CREDITS.txt $StartDir/LICENSE.txt $StartDir/SHELLS.txt refind-flashdrive-$Version
95 zip -9r ../refind-flashdrive-$Version.zip refind-flashdrive-$Version
96
97 cd ../
98
99 # Zip up the optical disc image....
100 rm -f refind-cd-$Version.zip
101 zip -9 refind-cd-$Version.zip refind-cd-$Version.iso
102
103 rm -r temp/