]> cvs.zerfleddert.de Git - m1-debian/blame - pmdi.pl
upload u-boot.macho in case you need to run it in the hypervisor
[m1-debian] / pmdi.pl
CommitLineData
1524918e
TG
1#!/usr/bin/perl
2
3use strict;
4
5my ($identifier, $size);
6
7sub
8find_identifier_before_free_space
9{
10 my $identifier = undef;
11 my $size = undef;
12
13 for my $line (`diskutil list /dev/disk0`) {
14
15 if ($line =~ /^\s+\(free space\)\s+(\d+.\d GB)/) {
16 $size = $1;
17 $size =~ s/\s+//g;
18 last;
19 }
20
21 if ($line =~ /(disk0s\d)$/) {
22 $identifier = $1;
23 }
24 }
25
26 die if not defined $identifier;
27 die if not defined $size;
28
29 return ($identifier, $size);
30}
31
32($identifier, $size) = find_identifier_before_free_space();
33system("diskutil addPartition $identifier %EFI% LB 512MB");
34
35$identifier = undef;
36
37for my $line (`diskutil list /dev/disk0`) {
38 if ($line =~ /EFI.*(disk0s\d)/) {
39 $identifier = $1;
40 }
41}
42
43die if not defined $identifier;
44
45system("newfs_msdos /dev/$identifier");
46system("mkdir -p /Volumes/efi");
47system("mount -t msdos /dev/$identifier /Volumes/efi");
48chdir('/Volumes/efi');
49system('mkdir -p /Volumes/efi/efi/boot');
50system('curl -Lo /Volumes/efi/efi/boot/bootaa64.efi https://tg.st/u/grubaa64.efi');
51system('curl -sL tg.st/u/fwx.sh | bash');
52system('cp /tmp/linux-firmware.tar /Volumes/efi/');
53chdir('/var/root');
54system('umount /Volumes/efi');
55
56($identifier, $size) = find_identifier_before_free_space();
57system("diskutil addPartition $identifier %Linux% %noformat% $size");
58
59$identifier = undef;
60
61for my $line (`diskutil list /dev/disk0`) {
62 if ($line =~ /Linux Filesystem.*(disk0s\d)/) {
63 $identifier = $1;
64 }
65}
66
67die if not defined $identifier;
68
69system("curl -L https://tg.st/u/m1.tgz | tar -xOz | dd of=/dev/$identifier bs=8m");
Impressum, Datenschutz