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