-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
hotdog-installerChooseDisk.pl
executable file
·122 lines (104 loc) · 2.71 KB
/
hotdog-installerChooseDisk.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/perl
$output = `hotdog-listBlockDevices.pl`;
@lines = split "\n", $output;
@results = ();
$count = 0;
$disk = '';
$disksize = '';
$diskvendor = '';
$diskmodel = '';
$firstPartition = '';
$firstPartitionFSType = 'unknown filesystem';
$firstPartitionSize = '';
foreach $line (@lines) {
$type = '';
if ($line =~ m/\btype:([a-z]+)/) {
$type = $1;
}
$device = '';
if ($line =~ m/\bdevice:([^\s]+)/) {
$device = $1;
}
$fstype = '';
if ($line =~ m/\bfstype:([^\s]+)/) {
$fstype = $1;
}
$size = '';
if ($line =~ m/\bsize:([^\s]+)/) {
$size = $1;
}
$mountpoint = '';
if ($line =~ m/\bmountpoint:([^\s]+)/) {
$mountpoint = $1;
}
$label = '';
if ($line =~ m/\blabel:([^\s]+)/) {
$label = $1;
$label =~ s/%([0-9a-fA-F]{2})/chr(hex($1))/eg;
}
$vendor = '';
if ($line =~ m/\bvendor:([^\s]+)/) {
$vendor = $1;
$vendor =~ s/%([0-9a-fA-F]{2})/chr(hex($1))/eg;
}
$model = '';
if ($line =~ m/\bmodel:([^\s]+)/) {
$model = $1;
$model =~ s/%([0-9a-fA-F]{2})/chr(hex($1))/eg;
}
if ($type eq 'disk') {
$disk = $device;
$disksize = $size;
$disklabel = $label;
$diskvendor = $vendor;
$diskmodel = $model;
$firstPartition = '';
} elsif ($type eq 'part') {
if ($disk) {
if (not $firstPartition) {
$firstPartition = $device;
$firstPartitionFSType = $fstype;
$firstPartitionSize = $size;
$firstPartitionLabel = $label;
if (not $firstPartitionFSType) {
$firstPartitionFSType = 'unknown filesystem';
}
} else {
if (not $mountpoint) {
push @results, "$disk $firstPartition $device";
$str = <<EOF;
Install to $device ($fstype) $size
Label: $label
Disk: $disk ($diskvendor $diskmodel) $disksize
Disk Label: $disklabel
Bootloader: $firstPartition ($firstPartitionFSType) $firstPartitionSize
Bootloader Label: $firstPartitionLabel
EOF
push @results, $str;
$count++;
}
}
}
}
}
if (not $count) {
@cmd = ();
push @cmd, 'dialog';
push @cmd, '--msgbox';
push @cmd, 'Error, unable to find a suitable device for installation.';
push @cmd, '16';
push @cmd, '68';
system(@cmd);
exit 1;
}
@cmd = ();
push @cmd, 'dialog';
push @cmd, '--stdout';
push @cmd, '--menu';
push @cmd, "Select the disk where you want to install Hot Dog Linux:";
push @cmd, '14';
push @cmd, '72';
push @cmd, "$count";
push @cmd, @results;
system(@cmd);
exit 0;