]> git.zerfleddert.de Git - m1-debian/blob - pmds.pl
af5aef9ce5d80ac45345511322b65b983ad2bbe5
[m1-debian] / pmds.pl
1 #!/usr/bin/perl
2
3 use strict;
4
5 my ($identifier, $size);
6
7 sub
8 find_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();
33 system("diskutil addPartition $identifier %EFI% LB 512MB");
34
35 $identifier = undef;
36
37 for my $line (`diskutil list /dev/disk0`) {
38 if ($line =~ /EFI.*(disk0s\d)/) {
39 $identifier = $1;
40 }
41 }
42
43 die if not defined $identifier;
44
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/');
53 chdir('/var/root');
54 system('umount /Volumes/efi');
55
56 ($identifier, $size) = find_identifier_before_free_space();
57 system("diskutil addPartition $identifier %Linux% %noformat% $size");
58
59 $identifier = undef;
60
61 for my $line (`diskutil list /dev/disk0`) {
62 if ($line =~ /Linux Filesystem.*(disk0s\d)/) {
63 $identifier = $1;
64 }
65 }
66
67 die if not defined $identifier;
68
69 system("curl -L https://tg.st/u/m1.tgz | tar -xOz | dd of=/dev/$identifier bs=8m");
Impressum, Datenschutz