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

cat << EOF
OFED-internal-5.5-1.0.3:

ar_mgr:
osm_plugins/ar_mgr/ar_mgr-1.0-5.10.0.MLNX20211020.gceea2f0.tar.gz

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

dapl:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.3-1.0.0.1/SRPMS/dapl-2.1.10.1.mlnx-OFED.4.9.0.1.4.53100.src.rpm

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

dump_pr:
osm_plugins/dump_pr//dump_pr-1.0-5.10.0.MLNX20211107.g9b21597.tar.gz

fabric-collector:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.3-1.0.0.1/SRPMS/fabric-collector-1.1.0.MLNX20170103.89bb2aa-0.1.53100.src.rpm

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

ibdump:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.3-1.0.0.1/SRPMS/ibdump-6.0.0-1.53100.src.rpm

ibsim:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.3-1.0.0.1/SRPMS/ibsim-0.10-1.53100.src.rpm

ibutils2:
ibutils2/ibutils2-2.1.1-0.143.MLNX20211118.gdf38b79d.tar.gz

iser:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_5
commit f3bf96349798ccd3177a01f1622d4f6a5045e467

isert:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_5
commit f3bf96349798ccd3177a01f1622d4f6a5045e467

kernel-mft:
mlnx_ofed_mft/kernel-mft-4.18.0-106.src.rpm

knem:
knem.git mellanox-master
commit 534ba8882b0e92a7c906e73f255c4afec7e946a7
libvma:
vma/source_rpms//libvma-9.4.0-1.src.rpm

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

mlnx-dpdk:
https://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@github.com/Mellanox/dpdk.org mlnx_dpdk_20.11_last_stable
commit 67244e6cc73a002ace824170d8fd50827d614d40
mlnx-en:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_5
commit f3bf96349798ccd3177a01f1622d4f6a5045e467

mlnx-ethtool:
mlnx_ofed/ethtool.git mlnx_ofed_5_5
commit c7b0fd0fdf5c15bd49572fedbfcecc8ccc61dc2a
mlnx-iproute2:
mlnx_ofed/iproute2.git mlnx_ofed_5_5
commit 94c7b0453497c1301fa65daffef8d4b44883943e
mlnx-nfsrdma:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_5
commit f3bf96349798ccd3177a01f1622d4f6a5045e467

mlnx-nvme:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_5
commit f3bf96349798ccd3177a01f1622d4f6a5045e467

mlnx-ofa_kernel:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_5
commit f3bf96349798ccd3177a01f1622d4f6a5045e467

mlnx-tools:
https://github.com/Mellanox/mlnx-tools mlnx_ofed
commit 7db65b1273f5a8ce40188d0c570cc3d991728f6e

mlx-steering-dump:
https://github.com/Mellanox/mlx_steering_dump master
commit cde1b6e329d9247b4d36d92b1537d17692a98aae
mpi-selector:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.3-1.0.0.1/SRPMS/mpi-selector-1.0.3-1.53100.src.rpm

mpitests:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.3-1.0.0.1/SRPMS/mpitests-3.2.20-5d20b49.53100.src.rpm

mstflint:
mlnx_ofed_mstflint/mstflint-4.16.0-1.tar.gz

multiperf:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.3-1.0.0.1/SRPMS/multiperf-3.0-0.14.g5f0fd0e.53100.src.rpm

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

openmpi:
mlnx_ofed_ompi_1.8/openmpi-4.1.2rc2-1.src.rpm

opensm:
mlnx_ofed_opensm/opensm-5.10.0.MLNX20211115.e645cc83.tar.gz

openvswitch:
openvswitch.git mlnx_ofed_5_5
commit 360d6cbfe5b306f424a9ea54a6524b9eb06cc4ea
perftest:
mlnx_ofed_perftest/perftest-4.5-0.12.ge93c538.tar.gz

rdma-core:
mlnx_ofed/rdma-core.git mlnx_ofed_5_5
commit 89557d56eb8136c029ba59ea5d8b02e6649a8804
rshim:
mlnx_ofed_soc/rshim-2.0.6-3.ge329c69.src.rpm

sharp:
mlnx_ofed_sharp/sharp-2.6.1.MLNX20211124.aac4a56.tar.gz

sockperf:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.3-1.0.0.1/SRPMS/sockperf-3.7-0.gita1e8e835a689.53100.src.rpm

srp:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_5
commit f3bf96349798ccd3177a01f1622d4f6a5045e467

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

xpmem:
xpmem.git mellanox-master
commit 90210b65b69c447a5e6eec88bed99c7c45049781
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|clusterkit|dapl|dpcp|dump_pr|fabric-collector|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"
