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

cat << EOF
OFED-internal-5.3-1.0.0:

ar_mgr:
osm_plugins/ar_mgr/ar_mgr-1.0-5.8.2.MLNX20210321.g58d33bf.tar.gz

clusterkit:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/clusterkit-1.0.36-1.52104.src.rpm

dapl:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/dapl-2.1.10.1.mlnx-OFED.4.9.0.1.4.52104.src.rpm

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

dump_pr:
osm_plugins/dump_pr//dump_pr-1.0-5.8.2.MLNX20210321.g58d33bf.tar.gz

fabric-collector:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/fabric-collector-1.1.0.MLNX20170103.89bb2aa-0.1.52104.src.rpm

hcoll:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/hcoll-4.7.3189-1.52104.src.rpm

ibdump:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/ibdump-6.0.0-1.52104.src.rpm

ibsim:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/ibsim-0.10-1.52104.src.rpm

ibutils2:
ibutils2/ibutils2-2.1.1-0.132.MLNX20210321.g84ba964.tar.gz

iser:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_3
commit 19d48787e91c989a7a0a856d04d0c80bca648423
isert:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_3
commit 19d48787e91c989a7a0a856d04d0c80bca648423
kernel-mft:
mlnx_ofed_mft/kernel-mft-4.16.3-12.src.rpm

knem:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/knem-1.1.4.90mlnx1-OFED.5.1.2.5.0.1.src.rpm

libvma:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/libvma-9.2.2-0.src.rpm

mlnx-dpdk:
https://github.com/Mellanox/dpdk.org mlnx_dpdk_20.11_last_stable
commit f05f7352848c8906a9d8dfd607687d52b5f7fcaf
mlnx-en:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_3
commit 19d48787e91c989a7a0a856d04d0c80bca648423

mlnx-ethtool:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/mlnx-ethtool-5.8-1.52104.src.rpm

mlnx-iproute2:
mlnx_ofed/iproute2.git mlnx_ofed_5_3
commit 130d9fd2320a4ece4a6fc330624be2bc341f569a
mlnx-nfsrdma:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_3
commit 19d48787e91c989a7a0a856d04d0c80bca648423
mlnx-nvme:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_3
commit 19d48787e91c989a7a0a856d04d0c80bca648423
mlnx-ofa_kernel:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_3
commit 19d48787e91c989a7a0a856d04d0c80bca648423

mpi-selector:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/mpi-selector-1.0.3-1.52104.src.rpm

mpitests:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/mpitests-3.2.20-5d20b49.52104.src.rpm

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

multiperf:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/multiperf-3.0-0.14.g5f0fd0e.52104.src.rpm

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

openmpi:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/openmpi-4.1.0rc5-1.52104.src.rpm

opensm:
mlnx_ofed_opensm/opensm-5.8.2.MLNX20210321.2958ab8.tar.gz

openvswitch:
openvswitch.git mlnx_ofed_5_3
commit b5c772fad3a4b3345805fb4dc19b9e181931b23d
perftest:
mlnx_ofed_perftest/perftest-4.5-0.1.g23b8f9c.tar.gz

rdma-core:
mlnx_ofed/rdma-core.git mlnx_ofed_5_3
commit 696ecf5f1be2fbc7a3b72787c6a4d455d8f47904
rshim:
mlnx_ofed_soc/rshim-2.0.5-10.g0ae03b4.src.rpm

sharp:
mlnx_ofed_sharp/sharp-2.4.5.MLNX20210302.7c3c223.tar.gz

sockperf:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.2-1.0.4.0/SRPMS/sockperf-3.7-0.gita1e8e835a689.52104.src.rpm

srp:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_3
commit 19d48787e91c989a7a0a856d04d0c80bca648423
ucx:
mlnx_ofed_ucx/ucx-1.10.0-1.src.rpm

xpmem:
xpmem.git mellanox-master
commit 740afed1b7647b241a5a3a57b13ce11ec882d9d5
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|mlnx-dpdk|mlnx-en|mlnx-ethtool|mlnx-iproute2|mlnx-nfsrdma|mlnx-nvme|mlnx-ofa_kernel|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"
