#!/bin/sh

echoerr() { 
	echo "$@" 1>&2; 
	}
logLine(){
	local wNow=$(date +"%F %T");
	echo "${wNow} | $1";
}
logErr(){
	local wNow=$(date +"%F %T");
	echoerr "${wNow} | >>>>> ERROR: $1"
}
logLineSepBold(){
	logLine "##########################################################################################"
}
logLineSepMedium(){
	logLine "==========================================================================================="
}
logLineSepLight(){
	logLine "-------------------------------------------------------------------------------------------"
}
logTitle() {
	logLine "";
	logLineSepBold;
	logLine "$1";
	logLineSepBold;
	logLine "";
}
logStep() {
	logLine "";
	logLineSepLight;
	logLine "$1";
	logLineSepLight;
	logLine "";
}
logTree(){
	logLine "";
	logLineSepMedium "==========";
	logLine "Tree from  pwd:[`pwd`] : ";
	logLine "`tree . -L 3`";
	logLineSepMedium "==========";
	logLine "";
}
#

logStep "Get the list of libraries using yum"
yum list installed '*-devel*';
if [ $? -ne 0 ]; then
 logErr "Unable to get the list of the '*-devel*' libraries "
 exit 1;
fi



# Load OS info
source /etc/os-release

# Normalize the version
VERSION_MAJOR=$(echo "$VERSION_ID" | cut -d. -f1)

# Check distro and version
if { [[ "$ID" == "rhel" || "$ID" == "ol" ]] && [[ "$VERSION_MAJOR" == "9" ]]; } || \
   { [[ "$ID" == "amzn" && "$VERSION_ID" == "2023" ]]; }; then
    # echo "OS is RHEL 9, Oracle Linux 9, or Amazon Linux 2023"
	# yum list installed 'perl-IPC*';
	# yum list installed 'perl-Perl*';
	yum list installed 'perl-*';
	if [ $? -ne 0 ]; then
	logErr "Unable to get the list of the 'perl-*' libraries "
	exit 1;
	fi
fi

yum list installed 'libxml2*';
if [ $? -ne 0 ]; then
 logErr "Unable to get the list of the 'libxml2*' libraries "
exit 1;
fi

exit 0;
#eof
	
