old-benchmark-code/kernel/build.pl

104 lines
2.1 KiB
Perl
Executable File

#!/usr/bin/perl
use strict;
print "Running on " . `hostname`;
if ($ARGV[0] eq "--clean") {
my_system("rm -rf linux-3.0.8");
exit;
}
if ( ! -e "linux-3.0.8.tar.xz") {
my $return = system("wget -c http://69.55.54.91/linux-3.0.8.tar.xz");
}
if ( ! -d "linux-3.0.8") {
my_system("tar xfJ linux-3.0.8.tar.xz");
my_system("sync");
}
chdir "linux-3.0.8";
# system("cp /root/benchmarks/kernel/config-3.0.8 .config");
if ($ARGV[0] eq "--mrproper") {
my_system("make mrproper");
}
install_standard("make -v", "make");
install_gcc();
exit if $ARGV[0] eq "--prep";
if ($ARGV[0] eq "--bigconfig") {
my_system("rm .config*");
my_system("cp /root/benchmarks/kernel/config-3.0.8 .config");
my_system("yes \"\" |make oldconfig");
} else {
my_system("make defconfig");
}
my $cpus = `cat /proc/cpuinfo |grep QEMU |wc -l`;
chomp $cpus;
my_system("make -j$cpus");
sub install_gcc {
my $return = system("gcc --version");
print "gcc RETURN: $return\n";
if ($return eq "-1") {
if (-e "/etc/gentoo-release") {
system "emerge gcc";
} elsif (-e "/etc/redhat-release") {
my @parts = split " ", `cat /etc/redhat-release`;
if ($parts[2] eq "5.6") {
my $arch = `uname -m`;
chomp $arch;
if ($arch eq "x86_64") {
system "yum install gcc -y";
} else {
system "yum install gcc -y";
}
}
system "yum install gcc -y";
} else {
system "apt-get -y install gcc";
}
} else {
return;
}
system "gcc --version";
}
sub install_standard {
my ($cmd, $name) = @_;
my $return = system($cmd);
print "gcc RETURN: $return\n";
if ($return eq "-1") {
if (-e "/etc/gentoo-release") {
system "emerge $name";
} elsif (-e "/etc/redhat-release") {
my @parts = split " ", `cat /etc/redhat-release`;
if ($parts[2] eq "5.6") {
my $arch = `uname -m`;
chomp $arch;
if ($arch eq "x86_64") {
system "yum install $name -y";
} else {
system "yum install $name -y";
}
}
system "yum install $name -y";
} else {
system "apt-get -y install $name";
}
} else {
return;
}
system $cmd;
}
sub my_system {
print "RUN: @_\n";
system "@_";
}