mirror of
https://github.com/xcat2/xcat-dep.git
synced 2024-11-22 09:31:48 +00:00
89ec0d32cf
This is a work around patch for OpenPOWER firmware which has error to close the sol session. This patch add error handler to inform the bmc to close the intf(lanplus) and sol session gracefully.
132 lines
3.2 KiB
Perl
Executable File
132 lines
3.2 KiB
Perl
Executable File
#! /usr/bin/perl
|
|
|
|
#check the distro
|
|
$cmd = "cat /etc/*release";
|
|
@output = `$cmd`;
|
|
my $os;
|
|
if (grep /Red Hat Enterprise Linux Server release 5\.\d/, @output) {
|
|
$os = "rh5";
|
|
} elsif (grep /Red Hat Enterprise Linux Server release 6\.\d/, @output) {
|
|
$os = "rh6";
|
|
} elsif (grep /Red Hat Enterprise Linux Server release 7\.\d/, @output) {
|
|
$os = "rh7";
|
|
} elsif (grep /SUSE Linux Enterprise Server 10/, @output) {
|
|
$os = "sles10";
|
|
} elsif (grep /SUSE Linux Enterprise Server 11/, @output) {
|
|
$os = "sles11";
|
|
} elsif (grep /SUSE Linux Enterprise Server 12/, @output) {
|
|
$os = "sles12";
|
|
} else {
|
|
print "unknow os\n";
|
|
exit 1;
|
|
}
|
|
|
|
$cmd = "uname -p";
|
|
my $arch = `$cmd`;
|
|
chomp($arch);
|
|
|
|
print "The build env is: $os-$arch\n";
|
|
|
|
# check whether the openssl-devel has been isntalled
|
|
my $cmd = "rpm -qa | grep openssl";
|
|
my @output = `$cmd`;
|
|
if ( ! grep /openssl-devel|libopenssl/, @output ) {
|
|
print "Please installed openssl-devel/libopenssl first. (openssl-devel for rh5/sles10; libopenssl for sles11)\n";
|
|
exit 1;
|
|
}
|
|
|
|
# check the source files
|
|
my $pwd = `pwd`;
|
|
my $version = "1.8.17";
|
|
chomp($pwd);
|
|
if ( (! -f "$pwd/ipmitool-$version.tar.gz")
|
|
|| (! -f "$pwd/ipmitool.spec")
|
|
|| (! -f "$pwd/ipmitool-$version-saneretry.patch")
|
|
|| (! -f "$pwd/ipmitool-$version-rflash.patch")
|
|
|| (! -f "$pwd/ipmitool-$version-signal.patch")) {
|
|
print "missed some necessary files for building.\n";
|
|
exit 1;
|
|
}
|
|
|
|
my $blddir;
|
|
if ($os eq "rh5") {
|
|
$blddir = "/usr/src/redhat";
|
|
} elsif (($os eq "rh6") || ($os eq "rh7")) {
|
|
$blddir = "/root/rpmbuild";
|
|
} elsif ($os =~ /sles1\d/) {
|
|
$blddir = "/usr/src/packages";
|
|
}
|
|
|
|
&runcmd("mkdir -p $blddir/SOURCES");
|
|
&runcmd("mkdir -p $blddir/SPECS");
|
|
&runcmd("mkdir -p $blddir/BUILD");
|
|
&runcmd("mkdir -p $blddir/RPMS");
|
|
|
|
# clean the env
|
|
$cmd = "rm -rf $blddir/SOURCES/ipmitool*";
|
|
&runcmd($cmd);
|
|
$cmd = "rm -rf $blddir/SPECS/ipmitool*";
|
|
&runcmd($cmd);
|
|
$cmd = "rm -rf $blddir/BUILD/ipmitool*";
|
|
&runcmd($cmd);
|
|
$cmd = "rm -rf $blddir/RPMS/$arch/ipmitool*";
|
|
&runcmd($cmd);
|
|
|
|
# copy the build files
|
|
$cmd = "cp -rf ./ipmitool-$version.tar.gz $blddir/SOURCES/";
|
|
&runcmd($cmd);
|
|
|
|
$cmd = "cp -rf ./*.patch $blddir/SOURCES/";
|
|
&runcmd($cmd);
|
|
|
|
$cmd = "cp -rf ./ipmitool.spec $blddir/SPECS/";
|
|
&runcmd($cmd);
|
|
|
|
$cmd = "rpmbuild -bb $blddir/SPECS/ipmitool.spec";
|
|
&runcmd($cmd);
|
|
|
|
#check whether the ssl has been enabled
|
|
my $binfile = "$blddir/BUILD/ipmitool-$version/src/ipmitool";
|
|
$cmd = "ldd $binfile";
|
|
@output = `$cmd`;
|
|
if (! grep /libcrypto.so/, @output) {
|
|
print "The ssl was not enabled.\n";
|
|
exit 1;
|
|
}
|
|
|
|
my $objrpm = "$blddir/RPMS/$arch/ipmitool-xcat-$version-1.$arch.rpm";
|
|
my $dstdir = "/tmp/build/$os/$arch";
|
|
|
|
# check the build result
|
|
if (! -f $objrpm) {
|
|
print "The rpm file was not generated successfully\n";
|
|
exit 1;
|
|
} else {
|
|
$cmd = "mkdir -p $dstdir";
|
|
&runcmd ($cmd);
|
|
$cmd = "cp -rf $objrpm $dstdir";
|
|
&runcmd ($cmd);
|
|
print "The obj file has been built successfully, you can get it here: $dstdir\n";
|
|
exit 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub runcmd () {
|
|
my $cmd = shift;
|
|
print "++++Trying to run command: [$cmd]\n";
|
|
my @output = `$cmd`;
|
|
if ($?) {
|
|
print "A error happened when running the comamnd [$cmd]\n";
|
|
print "error message: @output\n";
|
|
exit 1;
|
|
}
|
|
if ($verbose) {
|
|
print "run cmd message: @output\n";
|
|
}
|
|
}
|