From: Keith Wiles <keith.wiles@intel.com>
To: dev@dpdk.org
Subject: [PATCH v2] usertools: script to output version string
Date: Thu, 6 Jul 2017 09:56:49 -0500 [thread overview]
Message-ID: <20170706145649.65075-1-keith.wiles@intel.com> (raw)
Signed-off-by: Keith Wiles <keith.wiles@intel.com>
---
usertools/dpdk-version.sh | 124 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 124 insertions(+)
create mode 100755 usertools/dpdk-version.sh
diff --git a/usertools/dpdk-version.sh b/usertools/dpdk-version.sh
new file mode 100755
index 000000000..7b794bcd6
--- /dev/null
+++ b/usertools/dpdk-version.sh
@@ -0,0 +1,124 @@
+#!/bin/bash
+#
+# BSD LICENSE
+#
+# Copyright(c) 2017 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Locate the rte_version.h file and parse out the version strings.
+#
+# If RTE_SDK is set, then it is used to locate the file. If the
+# RTE_SDK variable is not set then the current working directory
+# is used.
+#
+# See usage below for more details.
+#
+
+fname=rte_version.h
+
+function usage() {
+ cat <<EOM
+ Usage: dpdk-version.sh
+
+ Locate the rte_version.h file and parse out the version information.
+
+ If RTE_SDK is set, then it is used to locate the file. If the
+ RTE_SDK variable is not set then the current working directory
+ is used.
+
+ The default output of the version is 'DPDK Version: YY.MM.MINOR'
+ e.g. 'dpdk-version.sh' gives 'DPDK Version: 17.08.0'
+
+ Options: Only one option can be used at a time.
+
+ '-h' prints usage messages
+
+ '-l' prints out the full version string
+ e.g. 'dpdk-version.sh -l' gives 'DPDK-17.08.0-rc0'
+
+ '-s' prints a shorter version string
+ e.g. 'dpdk-version.sh -s' gives '17.08.0'
+
+ '-m' prints out information is comma delimited format.
+ e.g. 'dpdk-version.sh -m' give 'DPDK,17,08,0,-rc0'
+
+ '-p' prints out a Python readable format of the version.
+ e.g. 'dpdk-version.sh -m' gives
+
+ version = {
+ 'prefix': 'DPDK',
+ 'year': '17',
+ 'month': '08',
+ 'minor': '0',
+ 'suffix': '-rc'
+ }
+EOM
+ exit 1
+}
+
+if [ -z ${RTE_SDK} ] ; then
+ echo "*** RTE_SDK is not set, using "${PWD}
+ sdk=${PWD}
+else
+ sdk=${RTE_SDK}
+fi
+
+fpath=${sdk}/lib/librte_eal/common/include/${fname}
+
+if [ ! -e ${fpath} ]; then
+ echo "File not found @ "${fpath}
+ usage
+fi
+
+PREFIX=`grep "define RTE_VER_PREFIX" ${fpath} | cut -d ' ' -f 3 | sed -e 's/\"//g'`
+SUFFIX=`grep "define RTE_VER_SUFFIX" ${fpath} | cut -d ' ' -f 3 | sed -e 's/\"//g'`
+
+YY=`grep "define RTE_VER_YEAR" ${fpath} | cut -d ' ' -f 3`
+MM=`grep "define RTE_VER_MONTH" ${fpath} | cut -d ' ' -f 3`
+MINOR=`grep "define RTE_VER_MINOR" ${fpath} | cut -d ' ' -f 3`
+
+if [ "$1" = "-h" ]; then
+ usage
+elif [ "$1" = "-l" ]; then
+ echo ${PREFIX}-${YY}.${MM}.${MINOR}${SUFFIX}
+elif [ "$1" = '-s' ]; then
+ echo ${YY}.${MM}.${MINOR}
+elif [ "$1" = "-p" ]; then
+ echo "dpdk_version = {"
+ echo " 'prefix': '"${PREFIX}"',"
+ echo " 'year': '"${YY}"',"
+ echo " 'month': '"${MM}"',"
+ echo " 'minor': '"${MINOR}"',"
+ echo " 'suffix': '"${SUFFIX}"'"
+ echo "}"
+elif [ "$1" = "-m" ]; then
+ echo ""${PREFIX}","${YY}","${MM}","${MINOR}","${SUFFIX}""
+else
+ echo "DPDK Version: "${YY}.${MM}.${MINOR}
+fi
--
2.11.0
next reply other threads:[~2017-07-06 14:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 14:56 Keith Wiles [this message]
2017-08-07 11:35 ` [PATCH v2] usertools: script to output version string Thomas Monjalon
2017-08-07 13:17 ` Wiles, Keith
2017-08-07 16:49 ` Thomas Monjalon
2017-08-07 17:31 ` Wiles, Keith
2019-01-23 19:16 ` Ferruh Yigit
2019-03-01 16:46 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170706145649.65075-1-keith.wiles@intel.com \
--to=keith.wiles@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.