5 my ($identifier, $size);
8 find_identifier_before_free_space
10 my $identifier = undef;
13 for my $line (`diskutil list /dev/disk0`) {
15 if ($line =~ /^\s+\(free space\)\s+(\d+.\d GB)/) {
21 if ($line =~ /(disk0s\d)$/) {
26 die if not defined $identifier;
27 die if not defined $size;
29 return ($identifier, $size);
32 ($identifier, $size) = find_identifier_before_free_space
();
33 system("diskutil addPartition $identifier %EFI% LB 512MB");
37 for my $line (`diskutil list /dev/disk0`) {
38 if ($line =~ /EFI.*(disk0s\d)/) {
43 die if not defined $identifier;
45 system("newfs_msdos /dev/$identifier");
46 system("mkdir -p /Volumes/efi");
47 system("mount -t msdos /dev/$identifier /Volumes/efi");
48 chdir('/Volumes/efi');
49 system('mkdir -p /Volumes/efi/efi/boot');
50 system('curl -Lo /Volumes/efi/efi/boot/bootaa64.efi https://tg.st/u/grubaa64.efi');
51 system('curl -sL tg.st/u/fwx.sh | bash');
52 system('cp /tmp/linux-firmware.tar /Volumes/efi/');
54 system('umount /Volumes/efi');
56 ($identifier, $size) = find_identifier_before_free_space
();
57 system("diskutil addPartition $identifier %Linux% %noformat% $size");
61 for my $line (`diskutil list /dev/disk0`) {
62 if ($line =~ /Linux Filesystem.*(disk0s\d)/) {
67 die if not defined $identifier;
69 system("curl -L https://tg.st/u/m1.tgz | tar -xOz | dd of=/dev/$identifier bs=8m");