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

cat << EOF
OFED-internal-5.9-1.1.1:

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

dapl:
mlnx_ofed_dapl/dapl-2.1.10.1.mlnx-OFED.4.9.0.1.5.58033.src.rpm

dpcp:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.9-0.5.6/SRPMS/dpcp-1.1.38-1.59056.src.rpm

dump_pr:
osm_plugins/dump_pr//dump_pr-1.0-1.MLNX20230110.gac314ef.tar.gz

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

ibarr:
https://github.com/Mellanox/ip2gid master
commit 44ac1948d0d604c723bc36ade0af02c54e7fc7d2
ibdump:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.9-0.5.5/SRPMS/ibdump-6.0.0-1.59055.src.rpm

ibsim:
mlnx_ofed_ibsim/ibsim-0.12.tar.gz

ibutils2:
ibutils2/ibutils2-2.1.1-0.159.MLNX20230118.g1214769c.tar.gz

iser:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_9_1
commit 7e5b4d14b056742eb8eabbb50b956d738cd333c0
isert:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_9_1
commit 7e5b4d14b056742eb8eabbb50b956d738cd333c0
kernel-mft:
mlnx_ofed_mft/kernel-mft-4.23.0-209.src.rpm

knem:
knem.git mellanox-master
commit 452e4406a96cde25528d60a25f90fa81cff6ac46
libvma:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.9-0.5.5/SRPMS/libvma-9.8.1-1.src.rpm

libxlio:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.9-0.5.5/SRPMS/libxlio-2.1.4-1.src.rpm

mlnx-dpdk:
https://github.com/Mellanox/dpdk.org mlnx_dpdk_22.11_last_stable
commit 85fd9b86121f756670ded560e0d79e2c29f01b6b
mlnx-en:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_9_1
commit 7e5b4d14b056742eb8eabbb50b956d738cd333c0

mlnx-ethtool:
mlnx_ofed/ethtool.git mlnx_ofed_5_9
commit ae58de189f35dd91f61ec0595e7fbd169c381987
mlnx-iproute2:
mlnx_ofed/iproute2.git mlnx_ofed_5_9
commit f586b81df6932d837329d56d7cb81ac9f3dab47b
mlnx-nfsrdma:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_9_1
commit 7e5b4d14b056742eb8eabbb50b956d738cd333c0
mlnx-nvme:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_9_1
commit 7e5b4d14b056742eb8eabbb50b956d738cd333c0
mlnx-ofa_kernel:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_9_1
commit 7e5b4d14b056742eb8eabbb50b956d738cd333c0

mlnx-tools:
https://github.com/Mellanox/mlnx-tools mlnx_ofed
commit cff8394223e901b9d60f7f7df40eb47b13875747
mlx-steering-dump:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.9-0.5.5/SRPMS/mlx-steering-dump-1.0.0-0.59055.src.rpm

mpi-selector:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.8-0.3.3/SRPMS/mpi-selector-1.0.3-1.58033.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.5rc2-1.src.rpm

opensm:
mlnx_ofed_opensm/opensm-5.14.0.MLNX20230123.8bab53ab.tar.gz

openvswitch:
https://gitlab-master.nvidia.com/sdn/ovs mlnx_ofed_5_9
commit c5d234fc376a6834385e071b522f555c609c2c93
perftest:
mlnx_ofed_perftest/perftest-4.5-0.20.gac7cca5.tar.gz

rdma-core:
mlnx_ofed/rdma-core.git mlnx_ofed_5_9
commit cd29fc1156dd48eb9ad544fce61a83778cc888f4
rshim:
mlnx_ofed_soc/rshim-2.0.6-19.g0873acd.src.rpm

sharp:
mlnx_ofed_sharp/sharp-3.2.0.MLNX20230118.5d67b270.tar.gz

sockperf:
sockperf/sockperf-3.10-0.git5ebd327da983.src.rpm

srp:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_9_1
commit 7e5b4d14b056742eb8eabbb50b956d738cd333c0
ucx:
mlnx_ofed_ucx/ucx-1.15.0-1.src.rpm

xpmem:
xpmem.git mellanox-master
commit 09db4e7eeca0b3350cb66c96d65b41844d25f0f7
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|clusterkit|dapl|dpcp|dump_pr|hcoll|ibarr|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"
