|
Packit |
857059 |
#!/usr/bin/perl
|
|
Packit |
857059 |
# BEGIN_ICS_COPYRIGHT8 ****************************************
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# Copyright (c) 2015-2017, Intel Corporation
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# Redistribution and use in source and binary forms, with or without
|
|
Packit |
857059 |
# modification, are permitted provided that the following conditions are met:
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# * Redistributions of source code must retain the above copyright notice,
|
|
Packit |
857059 |
# this list of conditions and the following disclaimer.
|
|
Packit |
857059 |
# * Redistributions in binary form must reproduce the above copyright
|
|
Packit |
857059 |
# notice, this list of conditions and the following disclaimer in the
|
|
Packit |
857059 |
# documentation and/or other materials provided with the distribution.
|
|
Packit |
857059 |
# * Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
857059 |
# may be used to endorse or promote products derived from this software
|
|
Packit |
857059 |
# without specific prior written permission.
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
857059 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
857059 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Packit |
857059 |
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
Packit |
857059 |
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Packit |
857059 |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Packit |
857059 |
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
Packit |
857059 |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
Packit |
857059 |
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit |
857059 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# END_ICS_COPYRIGHT8 ****************************************
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# [ICS VERSION STRING: unknown]
|
|
Packit |
857059 |
use strict;
|
|
Packit |
857059 |
#use Term::ANSIColor;
|
|
Packit |
857059 |
#use Term::ANSIColor qw(:constants);
|
|
Packit |
857059 |
#use File::Basename;
|
|
Packit |
857059 |
#use Math::BigInt;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# ==========================================================================
|
|
Packit |
857059 |
# Fast Fabric Support tools for OFA (oftools) installation
|
|
Packit |
857059 |
|
|
Packit |
857059 |
sub get_rpms_dir_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
my $srcdir=$ComponentInfo{'oftools'}{'SrcDir'};
|
|
Packit |
857059 |
return "$srcdir/RPMS/*";
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
sub available_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
# TBD - could we move the algorithms for many of these functions into
|
|
Packit |
857059 |
# util_component.pl and simply put a list of rpms in the ComponentInfo
|
|
Packit |
857059 |
# as well as perhaps config files
|
|
Packit |
857059 |
my $srcdir=$ComponentInfo{'oftools'}{'SrcDir'};
|
|
Packit |
857059 |
return ((rpm_resolve("$srcdir/RPMS/*/opa-basic-tools", "any") ne "")
|
|
Packit |
857059 |
&& (rpm_resolve("$srcdir/RPMS/*/opa-address-resolution", "any") ne "" ));
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
sub installed_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
return rpm_is_installed("opa-basic-tools", "any");
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# only called if installed_oftools is true
|
|
Packit |
857059 |
sub installed_version_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
my $version = rpm_query_version_release_pkg("opa-basic-tools");
|
|
Packit |
857059 |
return dot_version("$version");
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# only called if available_oftools is true
|
|
Packit |
857059 |
sub media_version_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
my $srcdir=$ComponentInfo{'oftools'}{'SrcDir'};
|
|
Packit |
857059 |
my $rpmfile = rpm_resolve("$srcdir/RPMS/*/opa-basic-tools", "any");
|
|
Packit |
857059 |
my $version= rpm_query_version_release("$rpmfile");
|
|
Packit |
857059 |
# assume media properly built with matching versions for all rpms
|
|
Packit |
857059 |
return dot_version("$version");
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
sub build_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
my $osver = $_[0];
|
|
Packit |
857059 |
my $debug = $_[1]; # enable extra debug of build itself
|
|
Packit |
857059 |
my $build_temp = $_[2]; # temp area for use by build
|
|
Packit |
857059 |
my $force = $_[3]; # force a rebuild
|
|
Packit |
857059 |
return 0; # success
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
sub need_reinstall_oftools($$)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
my $install_list = shift(); # total that will be installed when done
|
|
Packit |
857059 |
my $installing_list = shift(); # what items are being installed/reinstalled
|
|
Packit |
857059 |
|
|
Packit |
857059 |
return "no";
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
sub preinstall_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
my $install_list = $_[0]; # total that will be installed when done
|
|
Packit |
857059 |
my $installing_list = $_[1]; # what items are being installed/reinstalled
|
|
Packit |
857059 |
|
|
Packit |
857059 |
return 0; # success
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
sub install_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
my $install_list = $_[0]; # total that will be installed when done
|
|
Packit |
857059 |
my $installing_list = $_[1]; # what items are being installed/reinstalled
|
|
Packit |
857059 |
|
|
Packit |
857059 |
my $version=media_version_oftools();
|
|
Packit |
857059 |
chomp $version;
|
|
Packit |
857059 |
printf("Installing $ComponentInfo{'oftools'}{'Name'} $version $DBG_FREE...\n");
|
|
Packit |
857059 |
# TBD - review all components and make installing messages the same
|
|
Packit |
857059 |
#LogPrint "Installing $ComponentInfo{'oftools'}{'Name'} $version $DBG_FREE for $CUR_OS_VER\n";
|
|
Packit |
857059 |
LogPrint "Installing $ComponentInfo{'oftools'}{'Name'} $version $DBG_FREE for $CUR_DISTRO_VENDOR $CUR_VENDOR_VER\n";
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# RHEL7.4 and older in-distro IFS defines opa-address-resolution depends on opa-basic-tools with exact version match
|
|
Packit |
857059 |
# that will fail our installation because of dependency check. We need to use '-nodeps' to force the installation
|
|
Packit |
857059 |
install_comp_rpms('oftools', " -U --nodeps ", $install_list);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# TBD - could we figure out the list of config files from a query of rpm
|
|
Packit |
857059 |
# and then simply iterate on each config file?
|
|
Packit |
857059 |
check_rpm_config_file("/etc/rdma/dsap.conf");
|
|
Packit |
857059 |
|
|
Packit |
857059 |
$ComponentWasInstalled{'oftools'}=1;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
sub postinstall_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
my $install_list = $_[0]; # total that will be installed when done
|
|
Packit |
857059 |
my $installing_list = $_[1]; # what items are being installed/reinstalled
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
sub uninstall_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
my $install_list = $_[0]; # total that will be left installed when done
|
|
Packit |
857059 |
my $uninstalling_list = $_[1]; # what items are being uninstalled
|
|
Packit |
857059 |
|
|
Packit |
857059 |
NormalPrint("Uninstalling $ComponentInfo{'oftools'}{'Name'}...\n");
|
|
Packit |
857059 |
|
|
Packit |
857059 |
uninstall_comp_rpms('oftools', '', $install_list, $uninstalling_list, 'verbose');
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# remove LSF and Moab related files
|
|
Packit |
857059 |
system("rm -rf /usr/lib/opa/LSF_scripts");
|
|
Packit |
857059 |
system("rm -rf /usr/lib/opa/Moab_scripts");
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# may be created by opaverifyhosts
|
|
Packit |
857059 |
system("rm -rf /usr/lib/opa/tools/nodescript.sh");
|
|
Packit |
857059 |
system("rm -rf /usr/lib/opa/tools/nodeverify.sh");
|
|
Packit |
857059 |
|
|
Packit |
857059 |
system "rmdir /usr/lib/opa/tools 2>/dev/null"; # remove only if empty
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# oftools is a prereq of fastfabric can cleanup shared files here
|
|
Packit |
857059 |
system("rm -rf $BASE_DIR/version_ff");
|
|
Packit |
857059 |
system "rmdir $BASE_DIR 2>/dev/null"; # remove only if empty
|
|
Packit |
857059 |
system "rmdir $OPA_CONFIG_DIR 2>/dev/null"; # remove only if empty
|
|
Packit |
857059 |
system("rm -rf /usr/lib/opa/.comp_oftools.pl");
|
|
Packit |
857059 |
system "rmdir /usr/lib/opa 2>/dev/null"; # remove only if empty
|
|
Packit |
857059 |
$ComponentWasInstalled{'oftools'}=0;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
sub check_os_prereqs_oftools
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
return rpm_check_os_prereqs("oftools", "user");
|
|
Packit |
857059 |
}
|