]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - LiveCD/livecd.sh
Update CI Script
[Ventoy.git] / LiveCD / livecd.sh
1 #!/bin/bash
2
3 if [ "$1" = "CI" ]; then
4 OPT='-dR'
5 else
6 OPT='-a'
7 fi
8
9 VENTOY_PATH=$PWD/../
10
11 if ! [ -f $VENTOY_PATH/INSTALL/grub/grub.cfg ]; then
12 echo "no grub.cfg detected"
13 exit 1
14 fi
15
16 version=$(grep 'set.*VENTOY_VERSION=' $VENTOY_PATH/INSTALL/grub/grub.cfg | awk -F'"' '{print $2}')
17
18 if ! [ -e $VENTOY_PATH/INSTALL/ventoy-${version}-linux.tar.gz ]; then
19 echo "no ventoy-${version}-linux.tar.gz detected"
20 exit 1
21 fi
22
23 rm -rf ISO_TMP
24 cp $OPT ISO ISO_TMP
25
26 cp $OPT VTOY VTOY_TMP
27
28 ls -la
29 if ! [ -d ISO_TMP ]; then
30 echo "Copy ISO_TMP failed"
31 exit 1
32 fi
33
34 if ! [ -d VTOY_TMP ]; then
35 echo "Copy VTOY_TMP failed"
36 exit 1
37 fi
38
39 mkdir -p ISO_TMP/EFI/ventoy
40 cd VTOY_TMP
41
42 gcc -O2 -m32 ./ventoy/disksize.c -o ./ventoy/disksize
43 rm -f ./ventoy/disksize.c
44 find . | cpio -o -H newc | gzip -c -9 > ../ISO_TMP/EFI/ventoy/ventoy.gz
45 cd .. && rm -rf VTOY_TMP
46
47
48 cp $OPT $VENTOY_PATH/INSTALL/ventoy-${version}-linux.tar.gz ISO_TMP/EFI/ventoy/
49 cp $OPT GRUB/cdrom.img ISO_TMP/EFI/boot/
50 cp $OPT GRUB/bootx64.efi ISO_TMP/EFI/boot/
51
52
53 rm -rf efimnt
54 rm -f efi.img
55 mkdir -p efimnt
56
57 dd if=/dev/zero of=efi.img bs=1M count=2
58 mkfs.vfat efi.img
59 mount efi.img efimnt
60 mkdir -p efimnt/EFI/boot
61 cp $OPT GRUB/bootx64.efi efimnt/EFI/boot/
62 umount efimnt
63
64 sync
65 cp $OPT efi.img ISO_TMP/EFI/boot/
66
67 rm -rf efimnt
68 rm -f efi.img
69
70
71 cd ISO_TMP
72
73 sed "s/xxx/$version/g" -i EFI/boot/grub.cfg
74
75 rm -f ../ventoy-${version}-livecd.iso
76
77 xorriso -as mkisofs -allow-lowercase --sort-weight 0 / --sort-weight 1 /EFI -v -R -J -V 'VentoyLiveCD' -P 'VENTOY COMPATIBLE' -p 'https://www.ventoy.net' -sysid 'Ventoy' -A 'VentoyLiveCD' -b EFI/boot/cdrom.img --grub2-boot-info --grub2-mbr ../GRUB/boot_hybrid.img -c EFI/boot/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e EFI/boot/efi.img -no-emul-boot -append_partition 2 0xEF EFI/boot/efi.img -o ../ventoy-${version}-livecd.iso .
78
79 cd ../
80 rm -rf ISO_TMP
81