Blame CommonInstall/comp_qlgc_fm.pl

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
# OPA FM for OFA installation
Packit 857059
Packit 857059
# autostart functions are per subcomponent
Packit 857059
# determine if the given capability is configured for Autostart at boot
Packit 857059
sub IsAutostart2_opafm()
Packit 857059
{
Packit 857059
	return IsAutostart("opafm");
Packit 857059
}
Packit 857059
sub autostart_desc_opafm()
Packit 857059
{
Packit 857059
	return "$ComponentInfo{'opafm'}{'Name'} (opafm)";
Packit 857059
}
Packit 857059
# enable autostart for the given capability
Packit 857059
sub enable_autostart2_opafm()
Packit 857059
{
Packit 857059
	enable_autostart("opafm");
Packit 857059
}
Packit 857059
# disable autostart for the given capability
Packit 857059
sub disable_autostart2_opafm()
Packit 857059
{
Packit 857059
	disable_autostart("opafm");
Packit 857059
}
Packit 857059
Packit 857059
sub get_rpms_dir_opafm
Packit 857059
{
Packit 857059
	my $srcdir=$ComponentInfo{'opafm'}{'SrcDir'};
Packit 857059
	return "$srcdir/RPMS/*";
Packit 857059
}
Packit 857059
Packit 857059
sub available_opafm
Packit 857059
{
Packit 857059
	my $srcdir=$ComponentInfo{'opafm'}{'SrcDir'};
Packit 857059
	return (rpm_resolve("$srcdir/RPMS/*/opa-fm", "any") ne "");
Packit 857059
}
Packit 857059
Packit 857059
sub installed_opafm
Packit 857059
{
Packit 857059
	return rpm_is_installed("opa-fm", "any");
Packit 857059
}
Packit 857059
Packit 857059
# only called if installed_opafm is true
Packit 857059
sub installed_version_opafm
Packit 857059
{
Packit 857059
	my $version = rpm_query_version_release_pkg("opa-fm");
Packit 857059
	return dot_version("$version");
Packit 857059
}
Packit 857059
Packit 857059
# only called if available_opafm is true
Packit 857059
sub media_version_opafm
Packit 857059
{
Packit 857059
	my $srcdir=$ComponentInfo{'opafm'}{'SrcDir'};
Packit 857059
	my $rpmfile = rpm_resolve("$srcdir/RPMS/*/opa-fm", "any");
Packit 857059
	my $version= rpm_query_version_release("$rpmfile");
Packit 857059
	# assume media properly built with matching versions
Packit 857059
	return dot_version("$version");
Packit 857059
}
Packit 857059
Packit 857059
sub build_opafm
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
	my $srcdir=$ComponentInfo{'opafm'}{'SrcDir'};
Packit 857059
Packit 857059
	return 0;	# success
Packit 857059
}
Packit 857059
Packit 857059
sub need_reinstall_opafm($$)
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_opafm
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
	my $srcdir=$ComponentInfo{'opafm'}{'SrcDir'};
Packit 857059
Packit 857059
	return 0;	# success
Packit 857059
}
Packit 857059
Packit 857059
sub install_opafm
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_opafm();
Packit 857059
	chomp $version;
Packit 857059
Packit 857059
	printf("Installing $ComponentInfo{'opafm'}{'Name'} $version $DBG_FREE...\n");
Packit 857059
	LogPrint "Installing $ComponentInfo{'opafm'}{'Name'} $version $DBG_FREE for $CUR_OS_VER\n";
Packit 857059
Packit 857059
	# because RPM will change autostart settings of opafm we need to save
Packit 857059
	# and restore the settings
Packit 857059
	my $fm_start = IsAutostart2_opafm();
Packit 857059
Packit 857059
	# Install the rpm
Packit 857059
	install_comp_rpms('opafm', " -U ", $install_list);
Packit 857059
Packit 857059
	check_rpm_config_file("$CONFIG_DIR/opa-fm/opafm.xml", "/etc/sysconfig");
Packit 857059
	check_rpm_config_file("$CONFIG_DIR/opa-fm/opafm_pp.xml");
Packit 857059
	check_dir("/usr/lib/opa");
Packit 857059
Packit 857059
	if ($fm_start) {
Packit 857059
		enable_autostart("opafm");
Packit 857059
	} else {
Packit 857059
		disable_autostart("opafm");
Packit 857059
	}
Packit 857059
Packit 857059
	$ComponentWasInstalled{'opafm'}=1;
Packit 857059
}
Packit 857059
Packit 857059
sub postinstall_opafm
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_opafm
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{'opafm'}{'Name'}...\n");
Packit 857059
Packit 857059
	uninstall_comp_rpms('opafm', '', $install_list, $uninstalling_list, 'verbose');
Packit 857059
	# just in case, newer rpms should clean these up
Packit 857059
	system("rm -rf /usr/lib/opa/.comp_opafm.pl");
Packit 857059
	system("rmdir -p /opt/iba/fm_tools 2>/dev/null");  # remove only if empty
Packit 857059
	system("rm -rf /usr/lib/opa-fm");
Packit 857059
	$ComponentWasInstalled{'opafm'}=0;
Packit 857059
}
Packit 857059
Packit 857059
sub check_os_prereqs_opafm
Packit 857059
{
Packit 857059
	return rpm_check_os_prereqs("opafm", "user");
Packit 857059
}
Packit 857059