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

cat << EOF
OFED-internal-5.1-2.3.7:

ar_mgr:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/ar_mgr-1.0-0.2.MLNX20200630.g8577618.51066.src.rpm

dapl:
MLNX_OFED/MLNX_OFED_LINUX-5.1-0.6.6.0/MLNX_OFED_EXTRA/SRPMS/dapl-2.1.10.1.mlnx-OFED.51066.src.rpm

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

dump_pr:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/dump_pr-1.0-0.2.MLNX20200630.g8577618.51066.src.rpm

fabric-collector:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/fabric-collector-1.1.0.MLNX20170103.89bb2aa-0.1.51066.src.rpm

hcoll:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/hcoll-4.6.3125-1.51066.src.rpm

ibdump:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/ibdump-6.0.0-1.51066.src.rpm

ibsim:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/ibsim-0.9-1.51066.src.rpm

ibutils2:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/ibutils2-2.1.1-0.126.MLNX20200721.gf95236b.51066.src.rpm

iser:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_1_2
commit cfc0603e066f33654709d853502f65901208e4f9

isert:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_1_2
commit cfc0603e066f33654709d853502f65901208e4f9

kernel-mft:
mlnx_ofed_mft/kernel-mft-4.15.1-9.src.rpm

knem:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/knem-1.1.4.90mlnx1-OFED.5.1.0.6.1.1.src.rpm

libpka:
mlnx_ofed_soc/libpka-1.0-1.gcc98895.src.rpm

libvma:
vma/source_rpms/libvma-9.1.2-0.src.rpm

mlnx-dpdk:
https://github.com/Mellanox/dpdk.org mlnx_dpdk_19.11_last_stable
commit cff0304b3dc2d4b7ea0a77cee504018fb1abc34a
mlnx-en:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_1_2
commit cfc0603e066f33654709d853502f65901208e4f9

mlnx-ethtool:
mlnx_ofed/ethtool.git mlnx_ofed_5_1
commit 0d980e7b688d1112dc0c209b48d20ea3c6f9aa0f
mlnx-iproute2:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/mlnx-iproute2-5.6.0-1.51066.src.rpm

mlnx-nfsrdma:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_1_2
commit cfc0603e066f33654709d853502f65901208e4f9

mlnx-nvme:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_1_2
commit cfc0603e066f33654709d853502f65901208e4f9

mlnx-ofa_kernel:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_1_2
commit cfc0603e066f33654709d853502f65901208e4f9

mlxbf-bootctl:
https://github.com/Mellanox/mlxbf-bootctl bluefield-rel/3.0
commit 2f662d5a8d6e9ae573efeff4087d2e38ab835024
mpi-selector:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/mpi-selector-1.0.3-1.51066.src.rpm

mpitests:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/mpitests-3.2.20-5d20b49.51066.src.rpm

mstflint:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/mstflint-4.14.0-3.51066.src.rpm

multiperf:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/multiperf-3.0-0.14.g5f0fd0e.51066.src.rpm

mxm:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/mxm-3.7.3112-1.51066.src.rpm

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

openmpi:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/openmpi-4.0.4rc3-1.51066.src.rpm

opensm:
mlnx_ofed_opensm/opensm-5.7.1.MLNX20200824.a32af0f.tar.gz

openvswitch:
openvswitch.git mlnx_ofed_5_1_2
commit b9686d4c7e476f03f6d9a6e60b5d7286326d2052
perftest:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/perftest-4.4-0.30.g9c50960.51066.src.rpm

rdma-core:
mlnx_ofed/rdma-core.git mlnx_ofed_5_1_2
commit 16d3e82c3216cd8b9b856918448ad309edd97009
rshim:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/rshim-2.0.5-OFED.5.1.0.6.6.src.rpm

sharp:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/sharp-2.2.0.MLNX20200721.2fd570a-1.51066.src.rpm

sockperf:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/sockperf-3.7-0.gita1e8e835a689.51066.src.rpm

srp:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_1_2
commit cfc0603e066f33654709d853502f65901208e4f9

ucx:
/sw/release/mlnx_ofed/IBHPC/OFED-internal-5.1-0.6.6.0/SRPMS/ucx-1.9.0-1.51066.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|dapl|dpcp|dump_pr|fabric-collector|hcoll|ibdump|ibsim|ibutils2|^iser|kmod-iser|iser.*kmp|^isert|kmod-isert|isert.*kmp|kernel-mft|knem|libpka|libvma|mlnx-dpdk|mlnx-en|mlnx-ethtool|mlnx-iproute2|mlnx-nfsrdma|mlnx-nvme|mlnx-ofa_kernel|mlxbf-bootctl|mpi-selector|mpitests|mstflint|multiperf|mxm|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|neohost-backend|neohost-sdk")
fi

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