#!/bin/bash
usage()
{
	cat <<EOF
Usage: $0 [options]

Options:
    -s       Show package name and version number.
    -n       Show numerical version number only.
    -l       List installed packages details (Default option).
EOF
}
if [ "X$1" == "X-s" ]; then echo OFED-internal-4.4-2.0.8:; exit 0; fi
if [ "X$1" == "X-n" ]; then echo 4.4-2.0.8; exit 0; fi
if [ "X$1" != "X-l" ] && [ "X$1" != "X" ]; then usage; exit 1; fi

cat << EOF
OFED-internal-4.4-2.0.8:

ar_mgr:
osm_plugins/ar_mgr/ar_mgr-1.0-0.37.g7078b7d.tar.gz

cc_mgr:
osm_plugins/cc_mgr/cc_mgr-1.0-0.36.g7078b7d.tar.gz

dapl:
dapl.git mlnx_ofed_4_0
commit bdb055900059d1b8d5ee8cdfb457ca653eb9dd2d
dump_pr:
osm_plugins/dump_pr//dump_pr-1.0-0.32.g7078b7d.tar.gz

fabric-collector:
fabric_collector//fabric-collector-1.1.0.MLNX20170103.89bb2aa.tar.gz

hcoll:
mlnx_ofed_hcol/hcoll-4.1.2355-1.src.rpm

ibacm:
mlnx_ofed/ibacm.git mlnx_ofed_4_1
commit 4ae5d193f628c71bac481218bc88d0f77f7eff9a
ibacm_ssa:
mlnx_ofed_ssa/acm/ibacm_ssa-0.0.9.3.MLNX20151203.50eb579.tar.gz

ibdump:
sniffer/sniffer-5.0.0-1/ibdump/linux/ibdump-5.0.0-1.tgz

ibsim:
mlnx_ofed_ibsim/ibsim-0.6mlnx1-0.9.gdc7d44e.tar.gz

ibssa:
mlnx_ofed_ssa/distrib/ibssa-0.0.9.3.MLNX20151203.50eb579.tar.gz

ibutils:
ofed-1.5.3-rpms/ibutils/ibutils-1.5.7.1-0.12.gdcaeae2.tar.gz

ibutils2:
ibutils2/ibutils2-2.1.1-0.96.MLNX20180627.g53bbd74.tar.gz

infiniband-diags:
mlnx_ofed_infiniband_diags/infiniband-diags-5.0.0.MLNX20180711.3f6825b.tar.gz

iser:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_4_4_2
commit ee7aa0ef19b42b607a460dc7cd92fccc514b9041
isert:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_4_4_2
commit ee7aa0ef19b42b607a460dc7cd92fccc514b9041
kernel-mft:
mlnx_ofed_mft/kernel-mft-4.10.0-302.src.rpm

knem:
knem.git mellanox-master
commit 8cf97c177bf09d0e1e4ea667f90599b9e5849ae6
libdisni:
upstream/disni.git master
commit eb4592571c01d1ea569e3473e6cbcbdcec8652cd
libibcm:
mlnx_ofed/libibcm.git mlnx_ofed_4_1
commit e3e9fffe4d2d2f730110a7bdeb7da7b8ea97e51e
libibmad:
mlnx_ofed_libibmad/libibmad-5.0.0.MLNX20180328.afe7c88.tar.gz

libibprof:
mlnx_ofed_libibprof/libibprof-1.1.44-1.src.rpm

libibumad:
mlnx_ofed_libibumad/libibumad-43.1.1.MLNX20180612.87b4d9b.tar.gz

libibverbs:
mlnx_ofed/libibverbs.git mlnx_ofed_4_4
commit aea8cff074892ebdf9f7edceed4d4d37d6b76c90
libmlx4:
mlnx_ofed/libmlx4.git mlnx_ofed_4_4
commit ffed5ce24ad36abc42588742535b42fbfa7b2ca3
libmlx5:
mlnx_ofed/libmlx5.git mlnx_ofed_4_4
commit fcba03024505b3e7bb500ee1b4860a6be88df8cb
libopensmssa:
mlnx_ofed_ssa/plugin/libopensmssa-0.0.9.3.MLNX20151203.50eb579.tar.gz

librdmacm:
mlnx_ofed/librdmacm.git mlnx_ofed_4_4
commit 6b3a118ecbfb4731d51fb3ca37e2642ec86612e8
librxe:
mlnx_ofed/librxe.git master
commit 607460456c717c3b65428367676cacb5495ac005
libvma:
vma/source_rpms//libvma-8.7.0-0.src.rpm

mlnx-en:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_4_4_2
commit ee7aa0ef19b42b607a460dc7cd92fccc514b9041

mlnx-ethtool:
upstream/ethtool.git for-upstream
commit ac0cf295abe0c0832f0711fed66ab9601c8b2513
mlnx-iproute2:
mlnx_ofed/iproute2.git mlnx_ofed_4_4
commit cd3ef5b3877e73c52cca5e62d9172845bccd53bb
mlnx-nfsrdma:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_4_4_2
commit ee7aa0ef19b42b607a460dc7cd92fccc514b9041
mlnx-nvme:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_4_4_2
commit ee7aa0ef19b42b607a460dc7cd92fccc514b9041
mlnx-ofa_kernel:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_4_4_2
commit ee7aa0ef19b42b607a460dc7cd92fccc514b9041

mlnx-rdma-rxe:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_4_4_2
commit ee7aa0ef19b42b607a460dc7cd92fccc514b9041
mpi-selector:
ofed-1.5.3-rpms/mpi-selector/mpi-selector-1.0.3-1.src.rpm

mpitests:
mlnx_ofed_mpitest/mpitests-3.2.19-84f02b3.src.rpm

mstflint:
mlnx_ofed_mstflint/mstflint-4.10.0.tar.gz

multiperf:
mlnx_ofed_multiperf/multiperf-3.0-0.12.gbb02555.tar.gz

mxm:
mlnx_ofed_mxm/mxm-3.7.3111-1.src.rpm

ofed-docs:
docs.git mlnx_ofed-4.0
commit 3d1b0afb7bc190ae5f362223043f76b2b45971cc

openmpi:
mlnx_ofed_ompi_1.8/openmpi-3.1.1rc1-1.src.rpm

opensm:
mlnx_ofed_opensm/opensm-5.2.0.MLNX20180620.a0b90c5.tar.gz

perftest:
mlnx_ofed_perftest/perftest-4.4-0.2.g4942ab6.tar.gz

qperf:
mlnx_ofed_qperf/qperf-0.4.9.tar.gz

rdma-core:
mlnx_ofed/rdma-core.git mlnx_ofed_4_4
commit b6ff541f362bda16662f9be9bd68a3a0e1889471
sharp:
mlnx_ofed_sharp/sharp-1.7.1.MLNX20180618.7c14dc0.tar.gz

sockperf:
sockperf/sockperf-3.5-0.git31a0b54b26e4.src.rpm

srp:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_4_4_2
commit ee7aa0ef19b42b607a460dc7cd92fccc514b9041
srptools:
srptools/srptools-41mlnx1-5.src.rpm

ucx:
mlnx_ofed_ucx/ucx-1.4.0-1.src.rpm

EOF

echo
echo Installed Packages:
echo -------------------

pkglist1=
pkglist2=

if [ -x /usr/bin/dpkg ]; then
    pkglist1=$(dpkg --list | grep -E "#DEB_PACKAGES_LIST#")
fi

if (which rpm >/dev/null 2>&1); then
    pkglist2=$(rpm -qa --queryformat "[%{NAME}]
" | grep -E "kernel-ib|ar_mgr|cc_mgr|dapl|dump_pr|fabric-collector|hcoll|ibacm|ibacm_ssa|ibdump|ibsim|ibssa|ibutils|ibutils2|infiniband-diags|^iser|kmod-iser|iser.*kmp|^isert|kmod-isert|isert.*kmp|kernel-mft|knem|libdisni|libibcm|libibmad|libibprof|libibumad|libibverbs|libmlx4|libmlx5|libopensmssa|librdmacm|librxe|libvma|mlnx-en|mlnx-ethtool|mlnx-iproute2|mlnx-nfsrdma|mlnx-nvme|mlnx-ofa_kernel|mlnx-rdma-rxe|mpi-selector|mpitests|mstflint|multiperf|mxm|ofed-docs|openmpi|opensm|perftest|qperf|rdma-core|ibacm|libibcm|libibumad|libibverbs|librdmacm|srp_daemon|sharp|sockperf|^srp$|kmod-srp|srp.*kmp|srptools|ucx")
fi

echo -e "$pkglist1"
echo -e "$pkglist2"
