From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 54A57B458 for ; Fri, 8 Jul 2016 22:37:28 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP; 08 Jul 2016 13:37:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,331,1464678000"; d="scan'208";a="136126260" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga004.fm.intel.com with ESMTP; 08 Jul 2016 13:37:26 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u68KbPMc012700; Fri, 8 Jul 2016 21:37:25 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id u68KbPKl007321; Fri, 8 Jul 2016 21:37:25 +0100 Received: (from bricha3@localhost) by sivswdev01.ir.intel.com with id u68KbP16007317; Fri, 8 Jul 2016 21:37:25 +0100 From: Bruce Richardson To: dev@dpdk.org Cc: thomas.monjalon@6wind.com, Bruce Richardson Date: Fri, 8 Jul 2016 21:37:05 +0100 Message-Id: <1468010225-7260-3-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1468010225-7260-1-git-send-email-bruce.richardson@intel.com> References: <1468010225-7260-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 2/2] scripts: fix pmdinfo for FreeBSD X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2016 20:37:28 -0000 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 --- tools/pmdinfo.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/pmdinfo.py b/tools/pmdinfo.py index e531154..662034a 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') -- 2.7.4