From: Bruce Richardson Date: Fri, 8 Jul 2016 20:37:05 +0000 (+0100) Subject: tools: fix pmdinfo for FreeBSD X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=139bdc1db6618985a9468a937d78e6c5982712dd;p=dpdk.git tools: fix pmdinfo for FreeBSD There were a couple of issues which prevented pmdinfo.py from running on FreeBSD, both of which are fixed by this patch. * The path to python is not /usr/bin/python as on Linux, so use /usr/bin/env to find it on both OS's. * The path to the pci ids DB is in a different location on FreeBSD, so use the platform python library to look in different default locations depending on the underlying OS. [There are two possible locations to look on FreeBSD, as defined by pciconf manpage, so check in both in order of better to worse] Fixes: c67c9a5c646a ("tools: query binaries for HW and other support information") Signed-off-by: Bruce Richardson --- diff --git a/tools/pmdinfo.py b/tools/pmdinfo.py index e53115420a..662034af6f 100755 --- a/tools/pmdinfo.py +++ b/tools/pmdinfo.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # ------------------------------------------------------------------------- # scripts/pmdinfo.py # @@ -10,6 +10,7 @@ import sys from optparse import OptionParser import string import json +import platform # For running from development directory. It should take precedence over the # installed pyelftools. @@ -557,6 +558,14 @@ def main(stream=None): global raw_output global pcidb + pcifile_default = "./pci.ids" # for unknown OS's assume local file + if platform.system() == 'Linux': + pcifile_default = "/usr/share/hwdata/pci.ids" + elif platform.system() == 'FreeBSD': + pcifile_default = "/usr/local/share/pciids/pci.ids" + if not os.path.exists(pcifile_default): + pcifile_default = "/usr/share/misc/pci_vendors" + optparser = OptionParser( usage='usage: %prog [-hrtp] [-d ', description="Dump pmd hardware support info", @@ -568,7 +577,7 @@ def main(stream=None): optparser.add_option("-d", "--pcidb", dest="pcifile", help="specify a pci database " "to get vendor names from", - default="/usr/share/hwdata/pci.ids", metavar="FILE") + default=pcifile_default, metavar="FILE") optparser.add_option("-t", "--table", dest="tblout", help="output information on hw support as a hex table", action='store_true')