#!/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-5.7-1.0.2:; exit 0; fi
if [ "X$1" == "X-n" ]; then echo 5.7-1.0.2; exit 0; fi
if [ "X$1" != "X-l" ] && [ "X$1" != "X" ]; then usage; exit 1; fi

cat << EOF
OFED-internal-5.7-1.0.2:

clusterkit:
mlnx_ofed_clusterkit/clusterkit-1.7.421-1.src.rpm

dapl:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.6-1.0.3/SRPMS/dapl-2.1.10.1.mlnx-OFED.4.9.0.1.4.56103.src.rpm

dpcp:
/sw/release/sw_acceleration/dpcp/dpcp-1.1.29-1.src.rpm

dump_pr:
osm_plugins/dump_pr//dump_pr-1.0-5.11.0.MLNX20220713.g58a37c9.tar.gz

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

ibdump:
https://github.com/Mellanox/ibdump master
commit e153b19b9a8bfc7840b11109cd571db8f090a0d5
ibsim:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.6-1.0.3/SRPMS/ibsim-0.10-1.56103.src.rpm

ibutils2:
ibutils2/ibutils2-2.1.1-0.151.MLNX20220720.gcd746c3.tar.gz

iser:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_7
commit e78f334bd2f27d9ccacf0cec50d5df7905f9c37c

isert:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_7
commit e78f334bd2f27d9ccacf0cec50d5df7905f9c37c

kernel-mft:
mlnx_ofed_mft/kernel-mft-4.21.0-99.src.rpm

knem:
knem.git mellanox-master
commit 7110490b77d9c1b745ce999e8b1bca287061d433
libvma:
vma/source_rpms//libvma-9.6.4-1.src.rpm

libxlio:
/sw/release/sw_acceleration/xlio/libxlio-1.3.5-1.src.rpm

mlnx-dpdk:
https://github.com/Mellanox/dpdk.org mlnx_dpdk_20.11_last_stable
commit 5e17b7d6924075d96f8a9e05144cec9bf687823c
mlnx-en:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_7
commit e78f334bd2f27d9ccacf0cec50d5df7905f9c37c

mlnx-ethtool:
mlnx_ofed/ethtool.git mlnx_ofed_5_7
commit eaf899a774adda682b5f39edc5d9485c37d07ef9
mlnx-iproute2:
mlnx_ofed/iproute2.git mlnx_ofed_5_7
commit 83f4577fcad825124ff957b6bba9cdbd187cf7d5
mlnx-nfsrdma:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_7
commit e78f334bd2f27d9ccacf0cec50d5df7905f9c37c

mlnx-nvme:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_7
commit e78f334bd2f27d9ccacf0cec50d5df7905f9c37c

mlnx-ofa_kernel:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_7
commit e78f334bd2f27d9ccacf0cec50d5df7905f9c37c

mlnx-tools:
https://github.com/Mellanox/mlnx-tools mlnx_ofed
commit cff2a53ad336171ecf033211c78a50c9cd4a3700
mlx-steering-dump:
https://github.com/Mellanox/mlx_steering_dump master
commit de2d679be345d4a620234fdd08f55f5813137393
mpi-selector:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.6-1.0.3/SRPMS/mpi-selector-1.0.3-1.56103.src.rpm

mpitests:
mlnx_ofed_mpitest/mpitests-3.2.20-de56b6b.src.rpm

mstflint:
mlnx_ofed_mstflint/mstflint-4.16.1-2.tar.gz

multiperf:
http://l-gerrit.mtl.labs.mlnx:8080/Performance/multiperf rdma-core-support
commit e2ca961a51a07fedcc58c656d36a144808bd093b
ofed-docs:
docs.git mlnx_ofed-4.0
commit 3d1b0afb7bc190ae5f362223043f76b2b45971cc

openmpi:
mlnx_ofed_ompi_1.8/openmpi-4.1.5a1-1.src.rpm

opensm:
mlnx_ofed_opensm/opensm-5.12.0.MLNX20220721.3a88a9b.tar.gz

openvswitch:
openvswitch.git mlnx_ofed_5_7
commit 13bea7c68f2f9102e20567b988a44d776322e7d2

perftest:
mlnx_ofed_perftest/perftest-4.5-0.17.g6f25f23.tar.gz

rdma-core:
mlnx_ofed/rdma-core.git mlnx_ofed_5_7
commit 8afde0242d3365ff3be5e11b9674629076f2c67e
rshim:
mlnx_ofed_soc/rshim-2.0.6-13.gd253708.src.rpm

sharp:
mlnx_ofed_sharp/sharp-3.0.0.MLNX20220713.ea604271.tar.gz

sockperf:
sockperf/sockperf-3.8-0.git31ee322aa82a.src.rpm

srp:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_7
commit e78f334bd2f27d9ccacf0cec50d5df7905f9c37c

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

xpmem:
xpmem.git mellanox-master
commit 80ec83a8880c0d5831cb1144ad204c4190452107
EOF

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

pkglist1=
pkglist2=

if [ -x /usr/bin/dpkg ]; then
    pkglist1=$(dpkg --list | grep -E "clusterkit|libdapl-dev|libdapl2|dapl2-utils|dpcp|dump-pr|hcoll|ibdump|ibsim|ibsim-doc|ibutils2|iser-dkms|isert-dkms|kernel-mft-dkms|knem|knem-dkms|libvma|libvma-dev|libvma-dbg|libvma-utils|libxlio|libxlio-dev|libxlio-dbg|libxlio-utils|mlnx-dpdk|mlnx-dpdk-doc|mlnx-dpdk-dev|mlnx-en-utils|mlnx-en-dkms|mlnx-ethtool|mlnx-iproute2|mlnx-nfsrdma-dkms|mlnx-nvme-dkms|mlnx-ofed-kernel-utils|mlnx-ofed-kernel-dkms|mlnx-tools|mlx-steering-dump|mpitests|mstflint|openmpi|opensm|opensm-doc|libopensm|libopensm-devel|openvswitch-datapath-source|openvswitch-datapath-dkms|openvswitch-common|libopenvswitch|openvswitch-switch|openvswitch-pki|openvswitch-testcontroller|openvswitch-dbg|python3-openvswitch|openvswitch-test|openvswitch-vtep|libopenvswitch-dev|openvswitch-ipsec|perftest|rdma-core|ibacm|ibverbs-providers|ibverbs-utils|libibverbs-dev|libibverbs1|libibverbs1-dbg|libibumad-dev|libibumad3|libibumad3-dbg|librdmacm-dev|librdmacm1|librdmacm1-dbg|rdmacm-utils|srptools|python3-pyverbs|infiniband-diags|libibmad5|libibmad5-dbg|libibmad-dev|libibnetdisc5|libibnetdisc5-dbg|libibnetdisc-dev|rshim|sharp|sockperf|srp-dkms|ucx-dev|ucx")
fi

if (which rpm >/dev/null 2>&1); then
    pkglist2=$(rpm -qa --queryformat "[%{NAME}]
" | grep -E "kernel-ib|clusterkit|dapl|dpcp|dump_pr|hcoll|ibdump|ibsim|ibutils2|^iser|kmod-iser|iser.*kmp|^isert|kmod-isert|isert.*kmp|kernel-mft|knem|libvma|libxlio|mlnx-dpdk|mlnx-en|mlnx-ethtool|mlnx-iproute2|mlnx-nfsrdma|mlnx-nvme|mlnx-ofa_kernel|mlnx-tools|mlx-steering-dump|mpi-selector|mpitests|mstflint|multiperf|ofed-docs|openmpi|opensm|openvswitch|perftest|rdma-core|ibacm|libibcm|libibumad|libibverbs|librdmacm|srp_daemon|infiniband-diags|python3-pyverbs|rshim|sharp|sockperf|^srp$|kmod-srp|srp.*kmp|ucx|xpmem|neohost-backend|neohost-sdk")
fi

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