<commit_before>#!/bin/bash
# Script to build AMD SEV Tool

###############################################################################
# Copyright 2018 Advanced Micro Devices, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################

# Set to 1 to enable debugging or pass -d or --debug.
if [ "$(echo $1 | grep -E '^\-{0,2}d(ebug)?$')" != "" ]
then
    DEBUGGING=1
else
    DEBUGGING=0
fi

# If dependancies are needed
NEED_DEPS=0
INSTALLER=""
SSL_DEV=""

if [ ${DEBUGGING} -eq 1 ]
then
  debug()
  {
    echo -n "[ DEBUG ] LINE "
    echo "$@"
  }
else
  debug()
  {
    echo -n ""
  }
fi

OS_RELEASE=$(cat /etc/os-release)
debug $LINENO ":" "OS_RELEASE => " ${OS_RELEASE}

# Regular Expression to read /etc/os-release for major distributions.
ID_RE='ID\(\_LIKE\)\?\=\"\?[[:alpha:]]\+\([[:space:]][[:alpha:]]\*\)\?\"\?'

debug $LINENO ":" "ID_RE => ${ID_RE}"

# Read /etc/os-release to find the distribution base.
DIST_BASE=$(cat /etc/os-release | grep "${ID_RE}")

debug $LINENO ":" "DIST_BASE =>" ${DIST_BASE}
if [ "$(echo ${DIST_BASE} | grep 'suse')" != "" ] ||
   [ "$(echo ${DIST_BASE} | grep 'sles')" != "" ]
then
    # Cover all SLE and openSUSE distributions.
    debug $LINENO ":" "Distribution recognized as SUSE based"

    INSTALLER="zypper"
    SSL_DEV="libopenssl-devel"
    GCC_CPP="gcc-c++"
elif [ "$(echo ${DIST_BASE} | grep 'debian')" != "" ] ||
     [ "$(echo ${DIST_BASE} | grep 'ubuntu')" != "" ]
then
    # Cover all Debian and Ubuntu based distributions.
    debug $LINENO ":" "Distribution recognized as Debian or Ubuntu based"

    INSTALLER="apt-get"
    SSL_DEV="libssl-dev"
    GCC_CPP="g++"
elif [ "$(echo ${DIST_BASE} | grep 'fedora')" != "" ] ||
     [ "$(echo ${DIST_BASE} | grep 'rhel')" != "" ]
then
    # Cover all Redhat based distributions.
    debug $LINENO ":" "Distribution recognized as Fedora or Rhel based"

    INSTALLER="yum"
    SSL_DEV="openssl-devel"
    GCC_CPP="gcc-c++"
else
    debug $LINENO ":" "Regular expression could not match: \n" "${OS_RELEASE}"
    echo "Distribution not recognized. Please manually install "\
         "libelf libraries, make, zip, gcc, g++, git, wget, and libssl-dev." >&2
    exit 1
fi

debug $LINENO ":" "Checking for dependencies..."

# Check for all required dependancies
if [ "${INSTALLER}" = "zypper" ] || [ "${INSTALLER}" = "yum" ]<commit_msg>Fixing unrecognized distribution requirement list<commit_after>#!/bin/bash
# Script to build AMD SEV Tool

###############################################################################
# Copyright 2018 Advanced Micro Devices, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################

# Set to 1 to enable debugging or pass -d or --debug.
if [ "$(echo $1 | grep -E '^\-{0,2}d(ebug)?$')" != "" ]
then
    DEBUGGING=1
else
    DEBUGGING=0
fi

# If dependancies are needed
NEED_DEPS=0
INSTALLER=""
SSL_DEV=""

if [ ${DEBUGGING} -eq 1 ]
then
  debug()
  {
    echo -n "[ DEBUG ] LINE "
    echo "$@"
  }
else
  debug()
  {
    echo -n ""
  }
fi

OS_RELEASE=$(cat /etc/os-release)
debug $LINENO ":" "OS_RELEASE => " ${OS_RELEASE}

# Regular Expression to read /etc/os-release for major distributions.
ID_RE='ID\(\_LIKE\)\?\=\"\?[[:alpha:]]\+\([[:space:]][[:alpha:]]\*\)\?\"\?'

debug $LINENO ":" "ID_RE => ${ID_RE}"

# Read /etc/os-release to find the distribution base.
DIST_BASE=$(cat /etc/os-release | grep "${ID_RE}")

debug $LINENO ":" "DIST_BASE =>" ${DIST_BASE}
if [ "$(echo ${DIST_BASE} | grep 'suse')" != "" ] ||
   [ "$(echo ${DIST_BASE} | grep 'sles')" != "" ]
then
    # Cover all SLE and openSUSE distributions.
    debug $LINENO ":" "Distribution recognized as SUSE based"

    INSTALLER="zypper"
    SSL_DEV="libopenssl-devel"
    GCC_CPP="gcc-c++"
elif [ "$(echo ${DIST_BASE} | grep 'debian')" != "" ] ||
     [ "$(echo ${DIST_BASE} | grep 'ubuntu')" != "" ]
then
    # Cover all Debian and Ubuntu based distributions.
    debug $LINENO ":" "Distribution recognized as Debian or Ubuntu based"

    INSTALLER="apt-get"
    SSL_DEV="libssl-dev"
    GCC_CPP="g++"
elif [ "$(echo ${DIST_BASE} | grep 'fedora')" != "" ] ||
     [ "$(echo ${DIST_BASE} | grep 'rhel')" != "" ]
then
    # Cover all Redhat based distributions.
    debug $LINENO ":" "Distribution recognized as Fedora or Rhel based"

    INSTALLER="yum"
    SSL_DEV="openssl-devel"
    GCC_CPP="gcc-c++"
else
    debug $LINENO ":" "Regular expression could not match: \n" "${OS_RELEASE}"
    echo "Distribution not recognized. Please manually install "\
         "libelf libraries, make, zip, gcc, g++, git, wget, autoconf, and libssl-dev." >&2
    exit 1
fi

debug $LINENO ":" "Checking for dependencies..."

# Check for all required dependancies
if [ "${INSTALLER}" = "zypper" ] || [ "${INSTALLER}" = "yum" ]
{'fraction_non_alphanumeric': 0.2113085070037581, 'fraction_numerical': 0.0061496412709258624, 'mean_word_length': 3.8468543046357615, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '755025', 'n_tokens_mistral': 2006, 'n_tokens_neox': 1834, 'n_words': 601}