3 # SPDX-License-Identifier: MIT
7 my ($identifier, $size);
10 find_identifier_before_free_space
12 my $identifier = undef;
15 for my $line (`diskutil list /dev/disk0`) {
17 if ($line =~ /^\s+\(free space\)\s+(\d+.\d GB)/) {
23 if ($line =~ /(disk0s\d)$/) {
28 die if not defined $identifier;
29 die if not defined $size;
31 return ($identifier, $size);
34 ($identifier, $size) = find_identifier_before_free_space
();
35 system("diskutil addPartition $identifier %EFI% LB 512MB");
39 for my $line (`diskutil list /dev/disk0`) {
40 if ($line =~ /EFI.*(disk0s\d)/) {
45 die if not defined $identifier;
47 system("newfs_msdos /dev/$identifier");
48 system("mkdir -p /Volumes/efi");
49 system("mount -t msdos /dev/$identifier /Volumes/efi");
50 chdir('/Volumes/efi');
51 system('mkdir -p /Volumes/efi/efi/boot');
52 system('curl -Lo /Volumes/efi/efi/boot/bootaa64.efi https://tg.st/u/grubaa64.efi');
53 system('curl -sL tg.st/u/fwx.sh | bash');
54 system('cp /tmp/linux-firmware.tar /Volumes/efi/');
56 system('umount /Volumes/efi');
58 ($identifier, $size) = find_identifier_before_free_space
();
59 system("diskutil addPartition $identifier %Linux% %noformat% $size");
63 for my $line (`diskutil list /dev/disk0`) {
64 if ($line =~ /Linux Filesystem.*(disk0s\d)/) {
69 die if not defined $identifier;
71 system("curl -L https://tg.st/u/m1.tgz | tar -xOz | dd of=/dev/$identifier bs=8m");