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

cat << EOF
OFED-internal-5.0-1.0.0.0:

ar_mgr:
osm_plugins/ar_mgr/ar_mgr-1.0-0.49.MLNX20200216.g4ea049f.tar.gz

cc_mgr:
osm_plugins/cc_mgr/cc_mgr-1.0-0.48.MLNX20200216.g4ea049f.tar.gz

dapl:
dapl.git mlnx_ofed_4_0
commit bdb055900059d1b8d5ee8cdfb457ca653eb9dd2d
dump_pr:
osm_plugins/dump_pr//dump_pr-1.0-0.44.MLNX20200216.g4ea049f.tar.gz

fabric-collector:
fabric_collector//fabric-collector-1.1.0.MLNX20170103.89bb2aa.tar.gz

gpio-mlxbf:
mlnx_ofed_soc/gpio-mlxbf-1.0-0.g6d44a8a.src.rpm

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

i2c-mlx:
mlnx_ofed_soc/i2c-mlx-1.0-0.g422740c.src.rpm

ibacm:
mlnx_ofed/ibacm.git mlnx_ofed_4_1
commit 4ae5d193f628c71bac481218bc88d0f77f7eff9a
ibdump:
https://github.com/Mellanox/ibdump f1c55e301d8f53053c61432b33eefa00616ab6f6
commit f1c55e301d8f53053c61432b33eefa00616ab6f6
ibsim:
mlnx_ofed_ibsim/ibsim-0.7mlnx1-0.11.g85c342b.tar.gz

ibutils:
ofed-1.5.3-rpms/ibutils/ibutils-1.5.7.1-0.12.gdcaeae2.tar.gz

ibutils2:
ibutils2/ibutils2-2.1.1-0.119.MLNX20200223.g16f321b.tar.gz

infiniband-diags:
mlnx_ofed_infiniband_diags/infiniband-diags-5.6.0.MLNX20200211.354e4b7.tar.gz

iser:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_0
commit 34c46d3a19701504270f289748236634ca171d57

isert:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_0
commit 34c46d3a19701504270f289748236634ca171d57

kernel-mft:
mlnx_ofed_mft/kernel-mft-4.14.0-105.src.rpm

knem:
knem.git mellanox-master
commit 12569ca124fd672699702ab0e2144846a54060e2
libibcm:
mlnx_ofed/libibcm.git mlnx_ofed_4_1
commit e3e9fffe4d2d2f730110a7bdeb7da7b8ea97e51e
libibmad:
mlnx_ofed_libibmad/libibmad-5.4.0.MLNX20190423.1d917ae.tar.gz

libibumad:
mlnx_ofed_libibumad/libibumad-43.1.1.MLNX20200211.078947f.tar.gz

libibverbs:
mlnx_ofed/libibverbs.git mlnx_ofed_5_0
commit aff0c3063a9e31334b9dfe169b72d72fc1a63dc5
libmlx4:
mlnx_ofed/libmlx4.git mlnx_ofed_5_0
commit 44e82a1c2c3cc67960f4646125b5c93de6676b95
libmlx5:
mlnx_ofed/libmlx5.git mlnx_ofed_5_0
commit bd5e2650991c0e15d7db68d62ae4c399b1182eba
libpka:
mlnx_ofed_soc/libpka-1.0-1.g6cc68a2.src.rpm

librdmacm:
mlnx_ofed/librdmacm.git mlnx_ofed_5_0
commit c009f0c743215011f8e582b7788a811a590006fc
librxe:
mlnx_ofed/librxe.git master
commit afd75c6164324ac68a3e39f3c988ce85978669d4
libvma:
vma/source_rpms//libvma-9.0.2-0.src.rpm

mlnx-dpdk:
mlnx_ofed/dpdk.git mlnx_ofed_5_0
commit 99be8854fa506362217728095e42795061204506
mlnx-en:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_0
commit 34c46d3a19701504270f289748236634ca171d57

mlnx-ethtool:
mlnx_ofed/ethtool.git mlnx_ofed_5_0
commit ec244c419cbe50634982070257c4019027755832
mlnx-iproute2:
mlnx_ofed/iproute2.git mlnx_ofed_5_0
commit dbcecf3a980e410ace3360cc2d62955b519ce15d
mlnx-nfsrdma:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_0
commit 34c46d3a19701504270f289748236634ca171d57

mlnx-nvme:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_0
commit 34c46d3a19701504270f289748236634ca171d57

mlnx-ofa_kernel:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_0
commit 34c46d3a19701504270f289748236634ca171d57

mlnx-rdma-rxe:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_0
commit 34c46d3a19701504270f289748236634ca171d57

mlx-bootctl:
mlnx_ofed_soc/mlx-bootctl-1.3-0.g2aa74b7.src.rpm

mlx-l3cache:
mlnx_ofed_soc/mlx-l3cache-0.1-1.gebb0728.src.rpm

mlx-pmc:
mlnx_ofed_soc/mlx-pmc-1.1-0.g1141c2e.src.rpm

mlx-trio:
mlnx_ofed_soc/mlx-trio-0.1-1.g9d13513.src.rpm

mlxbf-livefish:
mlnx_ofed_soc/mlxbf-livefish-1.0-0.gec08328.src.rpm

mpi-selector:
ofed-1.5.3-rpms/mpi-selector/mpi-selector-1.0.3-1.src.rpm

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

mstflint:
mlnx_ofed_mstflint/mstflint-4.13.0-1.41.g4e8819c.tar.gz

multiperf:
mlnx_ofed_multiperf/multiperf-3.0-0.14.g5f0fd0e.tar.gz

multiperf:
mlnx_ofed_multiperf/mlnx_libs/multiperf-3.0.0.mlnxlibs-0.13.gcdaa426.tar.gz

mxm:
mlnx_ofed_mxm/mxm-3.7.3112-1.src.rpm

nvme-snap:
nvme/nvme-snap-2.0.2-79.mlnx.src.rpm

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

openmpi:
mlnx_ofed_ompi_1.8/openmpi-4.0.3rc4-1.src.rpm

opensm:
mlnx_ofed_opensm/opensm-5.6.0.MLNX20200217.cedc1e4.tar.gz

openvswitch:
openvswitch.git mlnx_ofed_5_0
commit b4f3b7368032372403d4796d4d392c1aad063d50

perftest:
mlnx_ofed_perftest/perftest-4.4-0.19.ga8821ec.tar.gz

perftest:
mlnx_ofed_perftest/mlnx_libs/perftest-4.4.0.mlnxlibs-0.11.gd240b65.tar.gz

pka-mlxbf:
mlnx_ofed_soc/pka-mlxbf-1.0-0.g963f663.src.rpm

qperf:
mlnx_ofed_qperf/qperf-0.4.11.tar.gz

rdma-core:
mlnx_ofed/rdma-core.git mlnx_ofed_5_0
commit 83592a9e34ad7ade9348ca7431caab42ecbbe4a9
rshim:
mlnx_ofed_soc/rshim-1.18-0.gb99e894.src.rpm

sharp:
mlnx_ofed_sharp/sharp-2.1.0.MLNX20200223.f63394a9c8.tar.gz

sockperf:
sockperf/sockperf-3.7-0.gita1e8e835a689.src.rpm

srp:
mlnx_ofed/mlnx-ofa_kernel-4.0.git mlnx_ofed_5_0
commit 34c46d3a19701504270f289748236634ca171d57

srptools:
srptools/srptools-41mlnx1-5.src.rpm

tmfifo:
mlnx_ofed_soc/tmfifo-1.5-0.g31e8a6e.src.rpm

ucx:
mlnx_ofed_ucx/ucx-1.8.0-1.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|cc_mgr|dapl|dump_pr|fabric-collector|gpio-mlxbf|hcoll|i2c-mlx|ibacm|ibdump|ibsim|ibutils|ibutils2|infiniband-diags|^iser|kmod-iser|iser.*kmp|^isert|kmod-isert|isert.*kmp|kernel-mft|knem|libibcm|libibmad|libibumad|libibverbs|libmlx4|libmlx5|libpka|librdmacm|librxe|libvma|mlnx-dpdk|mlnx-en|mlnx-ethtool|mlnx-iproute2|mlnx-nfsrdma|mlnx-nvme|mlnx-ofa_kernel|mlnx-rdma-rxe|mlx-bootctl|mlx-l3cache|mlx-pmc|mlx-trio|mlxbf-livefish|mpi-selector|mpitests|mstflint|multiperf|multiperf|mxm|nvme-snap|ofed-docs|openmpi|opensm|openvswitch|perftest|perftest|pka-mlxbf|qperf|rdma-core|ibacm|libibcm|libibumad|libibverbs|librdmacm|srp_daemon|rshim|sharp|sockperf|^srp$|kmod-srp|srp.*kmp|srptools|tmfifo|ucx")
fi

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