# -*- Mode: shell-script; -*-
################################################################################
#
# Driver for Xilinx network controllers and boards
# Copyright 2021 Xilinx Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation, incorporated herein by reference.
#
################################################################################

err  () { echo >&2 "$*";    }
log  () { err "$p: $*";    }
fail () { log "$*"; exit 1; }
try  () { "$@" || fail "'$*' failed"; }

# Please DO NOT reduce the set of recognised distros, even if we are
# dropping support elsewhere in the codebase.

# ssh to rpmbuild and run this to show some examples
#   grep -Hnr . /mnt/{rhel,sle}*/etc/*-release

auxiliary_disttag() {
  if [ -f /etc/redhat-release ]; then
    awk '
	/Red Hat Linux release/ { gsub(/\./,""); printf "RH%s\n", $5; exit }
	/Red Hat Enterprise Linux release/ { printf "RHEL%s\n", substr($6, 1, 1); exit }
	/Red Hat Enterprise Linux (WS|Server|Client|Workstation)/ { printf "RHEL%s\n", substr($7, 1, 1); exit }
        /CentOS Linux release 7/ { printf "RHEL7\n"; exit }
	' /etc/redhat-release
  else
    echo "unsupportedOS"
    return 1
  fi
  return 0
}
