forked from teleshoes/tpacpi-bat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.pl
executable file
·48 lines (41 loc) · 1.18 KB
/
install.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
#!/usr/bin/perl
use strict;
use warnings;
my $prefix = '/usr';
my $acpiCallGitRepo = 'git://github.com/teleshoes/acpi_call.git';
sub runOrDie(@){
print "@_\n";
system @_;
die "error running '@_'\n" if $? != 0;
}
sub main(@){
runOrDie "sudo", "cp", "tpacpi-bat", "$prefix/bin";
my $localRepo = '/tmp/acpi_call';
if(not -d $localRepo){
runOrDie "git", "clone", $acpiCallGitRepo, $localRepo;
}
chdir $localRepo;
runOrDie "git", "fetch";
runOrDie "git", "reset", "HEAD", "--hard";
runOrDie "git", "clean", "-fd";
runOrDie "git", "checkout", "origin/master";
runOrDie "make";
runOrDie "sudo", "make", "install";
runOrDie "sudo", "depmod";
runOrDie "sudo", "modprobe", "acpi_call";
}
sub versionCmp($$){
my ($v1, $v2) = @_;
die "Malformed kernel version $v1\n" if $v1 !~ /^(\d+)\.(\d+)/;
my ($v1Maj, $v1Min) = ($1, $2);
die "Malformed kernel version $v2\n" if $v2 !~ /^(\d+)\.(\d+)/;
my ($v2Maj, $v2Min) = ($1, $2);
if($v1Maj > $v2Maj or ($v1Maj == $v2Maj and $v1Min > $v2Min)){
return -1;
}elsif($v1Maj < $v2Maj or ($v1Maj == $v2Maj and $v1Min < $v2Min)){
return 1;
}elsif($v1Maj == $v2Maj and $v1Min == $v2Min){
return 0;
}
}
&main(@ARGV);