Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1245004 > unrolled thread

[PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find version number

Started byAlexander Kapshuk <alexander.kapshuk@gmail.com>
First post2015-10-12 20:50 +0200
Last post2015-10-14 23:50 +0200
Articles 20 on this page of 21 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find version number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 22/22] ver_linux: proc/modules, limit text processing to 'sed' Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
      Re: [PATCH 22/22] ver_linux: proc/modules, limit text processing to 'sed' Jim Davis <jim.epost@gmail.com> - 2015-10-12 22:30 +0200
        Re: [PATCH 22/22] ver_linux: proc/modules, limit text processing to 'sed' Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-13 19:40 +0200
    [PATCH 21/22] ver_linux: wireless-tools, look for numerical input, not field number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 02/22] ver_linux: make --version, use regex to find version number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 14/22] ver_linux: ldd, look for numerical input, not field number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 17/22] ver_linux: net-tools, look for numerical input, not field number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 19/22] ver_linux: sh-utils, look for numerical input, not field number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 03/22] ver_linux: binutils, fix inaccurate output Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 18/22] ver_linux: loadkeys, look for numerical input, not field number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 05/22] ver_linux: module-init-tools, look for numerical input, not field number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 07/22] ver_linux: jfsutils, look for numerical input, not field number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 08/22] ver_linux: reiserfsprogs, look for numerical input, not field number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 16/22] ver_linux: procps, look for numerical input, not field number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 15/22] ver_linux: libcpp, fix missing output Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 13/22] ver_linux: libc, input redirection to sed fails in some distros Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    [PATCH 09/22] ver_linux: xfsprogs, look for numerical input, not field number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-12 20:50 +0200
    Re: [PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find  version number Jim Davis <jim.epost@gmail.com> - 2015-10-14 01:30 +0200
      Re: [PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find  version number Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2015-10-14 11:30 +0200
        Re: [PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find  version number Jim Davis <jim.epost@gmail.com> - 2015-10-14 23:50 +0200

Page 1 of 2  [1] 2  Next page →


#1245004 — [PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find version number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find version number
Message-ID<qiQkx-7rT-3@gated-at.bofh.it>
Rely on regex to find the version number, rather than a field number.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 7de36df..af6467e 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -11,8 +11,12 @@ echo ' '
 uname -a
 echo ' '
 
-gcc -dumpversion 2>&1| awk \
-'NR==1{print "Gnu C                 ", $1}'
+gcc -dumpversion 2>&1 |
+awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("GNU C\t\t\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 make --version 2>&1 | awk -F, '{print $1}' | awk \
       '/GNU Make/{print "Gnu make              ",$NF}'
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1245005 — [PATCH 22/22] ver_linux: proc/modules, limit text processing to 'sed'

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 22/22] ver_linux: proc/modules, limit text processing to 'sed'
Message-ID<qiQkz-7rT-45@gated-at.bofh.it>
In reply to#1245004
This patch is more of a personal preference, rather than a fix for a problem.

The current implementation used a combination of both 'cat' and 'sed'
to generate an unsorted list of kernel modules separated by while space.

The proposed implementation uses 'sort' and 'sed' to generate a sort
list of kernel modules separated by while space.

Tested on:
Gentoo Linux
Debian 6.0.10
Oracle Linux Server release 7.1
Arch Linux
openSuSE 13.2

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index ae426c2..024a11a 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -178,7 +178,16 @@ awk '/version/{
 	substr($0,RSTART,RLENGTH))
 }'
 
-if [ -e /proc/modules ]; then
-    X=`cat /proc/modules | sed -e "s/ .*$//"`
-    echo "Modules Loaded         "$X
-fi
+test -e /proc/modules &&
+sort /proc/modules |
+sed '
+	s/ .*//
+	H
+${
+	g
+	s/^\n/Modules Loaded\t\t/
+	y/\n/ /
+	q
+}
+	d
+'
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245109 — Re: [PATCH 22/22] ver_linux: proc/modules, limit text processing to 'sed'

FromJim Davis <jim.epost@gmail.com>
Date2015-10-12 22:30 +0200
SubjectRe: [PATCH 22/22] ver_linux: proc/modules, limit text processing to 'sed'
Message-ID<qiRTk-1ps-21@gated-at.bofh.it>
In reply to#1245005
On Mon, Oct 12, 2015 at 11:40 AM, Alexander Kapshuk
<alexander.kapshuk@gmail.com> wrote:
> This patch is more of a personal preference, rather than a fix for a problem.

Using the sed hold space isn't exactly easy to follow...  if, unlike
the other patches, there isn't some potential improvement over the
status quo I'd suggest sticking with the original version.

-- 
Jim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245972 — Re: [PATCH 22/22] ver_linux: proc/modules, limit text processing to 'sed'

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-13 19:40 +0200
SubjectRe: [PATCH 22/22] ver_linux: proc/modules, limit text processing to 'sed'
Message-ID<qjbIm-53L-31@gated-at.bofh.it>
In reply to#1245109
On Mon, Oct 12, 2015 at 11:22 PM, Jim Davis <jim.epost@gmail.com> wrote:
> On Mon, Oct 12, 2015 at 11:40 AM, Alexander Kapshuk
> <alexander.kapshuk@gmail.com> wrote:
>> This patch is more of a personal preference, rather than a fix for a problem.
>
> Using the sed hold space isn't exactly easy to follow...  if, unlike
> the other patches, there isn't some potential improvement over the
> status quo I'd suggest sticking with the original version.
>
> --
> Jim

Thanks for your feedback.

If the use of a shell variable to store the generated list of modules
be deemed more favourable than the use of the 'sed' hold space, may I
at least suggest either of the two approaches below:

Sorted list:
Y=`sort /proc/modules | sed 's/ .*$//'`

Unsorted list:
Z=`sed 's/ .*$//' /proc/modules`

The use of 'cat' in the context of the original implementation is redundant.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245006 — [PATCH 21/22] ver_linux: wireless-tools, look for numerical input, not field number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 21/22] ver_linux: wireless-tools, look for numerical input, not field number
Message-ID<qiQkz-7rT-49@gated-at.bofh.it>
In reply to#1245004
Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field.

Tested on:
Gentoo Linux

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index f839be3..ae426c2 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -171,8 +171,12 @@ awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
 	substr($0,RSTART,RLENGTH))
 }'
 
-iwconfig --version 2>&1 | awk \
-'(NR==1 && ($3 == "version")) {print "wireless-tools        ",$4}'
+iwconfig --version 2>&1 |
+awk '/version/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("Wireless-tools\t\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 if [ -e /proc/modules ]; then
     X=`cat /proc/modules | sed -e "s/ .*$//"`
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245007 — [PATCH 02/22] ver_linux: make --version, use regex to find version number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 02/22] ver_linux: make --version, use regex to find version number
Message-ID<qiQkz-7rT-47@gated-at.bofh.it>
In reply to#1245004
Rely on regex to find the version number, rather than a field number.
Reduce the number of 'awk' invocations from two to one.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index af6467e..31c0e4d 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -18,8 +18,12 @@ awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
 	substr($0,RSTART,RLENGTH))
 }'
 
-make --version 2>&1 | awk -F, '{print $1}' | awk \
-      '/GNU Make/{print "Gnu make              ",$NF}'
+make --version 2>&1 |
+awk '/GNU Make/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("GNU Make\t\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 echo "binutils               $(ld -v | egrep -o '[0-9]+\.[0-9\.]+')"
 
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245008 — [PATCH 14/22] ver_linux: ldd, look for numerical input, not field number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 14/22] ver_linux: ldd, look for numerical input, not field number
Message-ID<qiQkz-7rT-57@gated-at.bofh.it>
In reply to#1245004
Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field.
Proposed implementation also eliminates the necessity to invoke 'head' + 'awk'.

The '-v' flag either seems to have been deprecated in some distros, e.g. Gentoo, or is an alias for '--version' in others. The proposed implementation uses the latter flag only.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 909d039..a7d0eca 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -114,8 +114,12 @@ sed '
 	q
 ' /proc/self/maps
 
-ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \
-'NR==1{print "Dynamic linker (ldd)  ", $NF}'
+ldd --version 2>&1 |
+awk '/^ldd/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("Dynamic linker (ldd)\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 ls -l /usr/lib/libg++.so /usr/lib/libstdc++.so  2>/dev/null | awk -F. \
        '{print "Linux C++ Library      " $4"."$5"."$6}'
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245010 — [PATCH 17/22] ver_linux: net-tools, look for numerical input, not field number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 17/22] ver_linux: net-tools, look for numerical input, not field number
Message-ID<qiQkz-7rT-61@gated-at.bofh.it>
In reply to#1245004
Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field.
Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 2269803..4ef1b7d 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -140,8 +140,12 @@ awk '/version/{
 	substr($0,RSTART,RLENGTH))
 }'
 
-ifconfig --version 2>&1 | grep tools | awk \
-'NR==1{print "Net-tools             ", $NF}'
+ifconfig --version 2>&1 |
+awk '/tools/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("Net-tools\t\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 # Kbd needs 'loadkeys -h',
 loadkeys -h 2>&1 | awk \
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245011 — [PATCH 19/22] ver_linux: sh-utils, look for numerical input, not field number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 19/22] ver_linux: sh-utils, look for numerical input, not field number
Message-ID<qiQkz-7rT-55@gated-at.bofh.it>
In reply to#1245004
Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field.

Tested on:
Gentoo Linux
Debian 6.0.10
Oracle Linux Server release 7.1

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index e6b57d5..1c6ec22 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -157,7 +157,12 @@ awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
 oprofiled --version 2>&1 | awk \
 '(NR==1 && ($2 == "oprofile")) {print "oprofile              ", $3}'
 
-expr --v 2>&1 | awk 'NR==1{print "Sh-utils              ", $NF}'
+expr --v 2>&1 |
+awk '/^expr/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("Sh-utils\t\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 udevinfo -V 2>&1 | grep version | awk '{print "udev                  ", $3}'
 
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245013 — [PATCH 03/22] ver_linux: binutils, fix inaccurate output

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 03/22] ver_linux: binutils, fix inaccurate output
Message-ID<qiQkz-7rT-65@gated-at.bofh.it>
In reply to#1245004
Current implementation output on Gentoo Linux:
binutils               2.25.1
1.1
2.25.1

Proposed implementation:
Binutils		2.25.1

Tested on:
Gentoo Linux
Debian 6.0.10
Oracle Linux Server release 7.1

Rely on regex to find the version number.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 31c0e4d..1fea749 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -25,7 +25,12 @@ awk '/GNU Make/{
 	substr($0,RSTART,RLENGTH))
 }'
 
-echo "binutils               $(ld -v | egrep -o '[0-9]+\.[0-9\.]+')"
+ld -v 2>&1 |
+awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("Binutils\t\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 echo -n "util-linux             "
 fdformat --version | awk '{print $NF}' | sed -e s/^util-linux-// -e s/\)$//
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245014 — [PATCH 18/22] ver_linux: loadkeys, look for numerical input, not field number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 18/22] ver_linux: loadkeys, look for numerical input, not field number
Message-ID<qiQkz-7rT-63@gated-at.bofh.it>
In reply to#1245004
'loadkeys -h' no longer prints the version number across all distros,
despite the claim to do so in the manpage, which I found to be the case
on a Debian Linux system.

The proposed implementation utilises the output of 'loadkeys -V' to
acquire the version of both 'Kbd' and 'Console-tools'.

Tested on:
Gentoo Linux
Debian 6.0.10
Oracle Linux Server release 7.1

Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 4ef1b7d..e6b57d5 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -147,13 +147,12 @@ awk '/tools/{
 	substr($0,RSTART,RLENGTH))
 }'
 
-# Kbd needs 'loadkeys -h',
-loadkeys -h 2>&1 | awk \
-'(NR==1 && ($3 !~ /option/)) {print "Kbd                   ", $3}'
-
-# while console-tools needs 'loadkeys -V'.
-loadkeys -V 2>&1 | awk \
-'(NR==1 && ($2 ~ /console-tools/)) {print "Console-tools         ", $3}'
+loadkeys -V 2>&1 |
+awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	$0 = substr($0,RSTART,RLENGTH)
+	printf("Kbd\t\t\t%s\nConsole-tools\t\t%s\n",$0,$0)
+}'
 
 oprofiled --version 2>&1 | awk \
 '(NR==1 && ($2 == "oprofile")) {print "oprofile              ", $3}'
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245015 — [PATCH 05/22] ver_linux: module-init-tools, look for numerical input, not field number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 05/22] ver_linux: module-init-tools, look for numerical input, not field number
Message-ID<qiQkz-7rT-67@gated-at.bofh.it>
In reply to#1245004
Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field.

Tested on:
Gentoo Linux
Debian 6.0.10
Oracle Linux Server release 7.1

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 28e7640..7cc74d1 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -39,7 +39,12 @@ awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
 	printf("Util-linux\t\t%s\nMount\t\t\t%s\n",$0,$0)
 }'
 
-depmod -V  2>&1 | awk 'NR==1 {print "module-init-tools     ",$NF}'
+depmod -V  2>&1 |
+awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("Module-init-tools\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 tune2fs 2>&1 | grep "^tune2fs" | sed 's/,//' |  awk \
 'NR==1 {print "e2fsprogs             ", $2}'
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245017 — [PATCH 07/22] ver_linux: jfsutils, look for numerical input, not field number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 07/22] ver_linux: jfsutils, look for numerical input, not field number
Message-ID<qiQkz-7rT-69@gated-at.bofh.it>
In reply to#1245004
Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field.
Proposed implementation also eliminates the necessity to invoke 'grep' + 'sed' + 'awk'.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 2e1929f..7d85447 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -53,8 +53,12 @@ awk '/^tune2fs/{
 	substr($0,RSTART,RLENGTH))
 }'
 
-fsck.jfs -V 2>&1 | grep version | sed 's/,//' |  awk \
-'NR==1 {print "jfsutils              ", $3}'
+fsck.jfs -V 2>&1 |
+awk '/version/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("Jfsutils\t\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 reiserfsck -V 2>&1 | grep ^reiserfsck | awk \
 'NR==1{print "reiserfsprogs         ", $2}'
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245018 — [PATCH 08/22] ver_linux: reiserfsprogs, look for numerical input, not field number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 08/22] ver_linux: reiserfsprogs, look for numerical input, not field number
Message-ID<qiQkA-7rT-75@gated-at.bofh.it>
In reply to#1245004
Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field.

Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 7d85447..65d4c02 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -60,8 +60,12 @@ awk '/version/{
 	substr($0,RSTART,RLENGTH))
 }'
 
-reiserfsck -V 2>&1 | grep ^reiserfsck | awk \
-'NR==1{print "reiserfsprogs         ", $2}'
+reiserfsck -V 2>&1 |
+awk '/^reiserfsck/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("Reiserfsprogs\t\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 fsck.reiser4 -V 2>&1 | grep ^fsck.reiser4 | awk \
 'NR==1{print "reiser4progs          ", $2}'
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245019 — [PATCH 16/22] ver_linux: procps, look for numerical input, not field number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 16/22] ver_linux: procps, look for numerical input, not field number
Message-ID<qiQkA-7rT-71@gated-at.bofh.it>
In reply to#1245004
Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field.
Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 882ddb9..2269803 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -133,8 +133,12 @@ sed '
 	s!.*so\.!!
 	s!^!Linux C++ Library\t!
 '
-ps --version 2>&1 | grep version | awk \
-'NR==1{print "Procps                ", $NF}'
+ps --version 2>&1 |
+awk '/version/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("Procps\t\t\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 ifconfig --version 2>&1 | grep tools | awk \
 'NR==1{print "Net-tools             ", $NF}'
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245020 — [PATCH 15/22] ver_linux: libcpp, fix missing output

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 15/22] ver_linux: libcpp, fix missing output
Message-ID<qiQkA-7rT-81@gated-at.bofh.it>
In reply to#1245004
Neither 'libg++.so', nor 'libstdc++.so' were found where the current
implementation expects them to be found in the distros below.

Gentoo Linux
Debian 6.0.10
Oracle Linux Server release 7.1

Which results in zero ouput generated.

The proposed implementation relies on 'ldconfig' to locate the libraries
in question.  'Sed' is used to do the text processing.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index a7d0eca..882ddb9 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -121,9 +121,18 @@ awk '/^ldd/{
 	substr($0,RSTART,RLENGTH))
 }'
 
-ls -l /usr/lib/libg++.so /usr/lib/libstdc++.so  2>/dev/null | awk -F. \
-       '{print "Linux C++ Library      " $4"."$5"."$6}'
-
+libcpp=`ldconfig -p 2>/dev/null |
+	awk '/(libg|stdc)[+]+\.so/ {
+	print $NF
+	exit
+	}
+'`
+test -r "$libcpp" &&
+ls -l $libcpp |
+sed '
+	s!.*so\.!!
+	s!^!Linux C++ Library\t!
+'
 ps --version 2>&1 | grep version | awk \
 'NR==1{print "Procps                ", $NF}'
 
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245022 — [PATCH 13/22] ver_linux: libc, input redirection to sed fails in some distros

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 13/22] ver_linux: libc, input redirection to sed fails in some distros
Message-ID<qiQkA-7rT-89@gated-at.bofh.it>
In reply to#1245004
The current implementation has been found not to work across all distros.

The proposed implementation relies on 'sed' to both output the string
'Linux C Library' as well as to open '/proc/self/maps' without having
to use output redirection.

Tested on:
Gentoo Linux
Debian 6.0.10
Oracle Linux Server release 7.1
Arch Linux
openSuSE 13.2

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index af5ac82..909d039 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -107,8 +107,12 @@ isdnctrl 2>&1 | grep version | awk \
 showmount --version 2>&1 | grep nfs-utils | awk \
 'NR==1{print "nfs-utils             ", $NF}'
 
-echo -n "Linux C Library        "
-sed -n -e '/^.*\/libc-\([^/]*\)\.so$/{s//\1/;p;q}' < /proc/self/maps
+test -r /proc/self/maps &&
+sed '
+	/.*libc-\(.*\)\.so$/!d
+	s//Linux C Library\t\t\1/
+	q
+' /proc/self/maps
 
 ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \
 'NR==1{print "Dynamic linker (ldd)  ", $NF}'
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245024 — [PATCH 09/22] ver_linux: xfsprogs, look for numerical input, not field number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-12 20:50 +0200
Subject[PATCH 09/22] ver_linux: xfsprogs, look for numerical input, not field number
Message-ID<qiQkA-7rT-87@gated-at.bofh.it>
In reply to#1245004
Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field.
Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---
 scripts/ver_linux | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 65d4c02..a926225 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -70,8 +70,12 @@ awk '/^reiserfsck/{
 fsck.reiser4 -V 2>&1 | grep ^fsck.reiser4 | awk \
 'NR==1{print "reiser4progs          ", $2}'
 
-xfs_db -V 2>&1 | grep version | awk \
-'NR==1{print "xfsprogs              ", $3}'
+xfs_db -V 2>&1 |
+awk '/version/{
+	match($0, /[0-9]+([.]?[0-9]+)+/)
+	printf("Xfsprogs\t\t%s\n",
+	substr($0,RSTART,RLENGTH))
+}'
 
 pccardctl -V 2>&1| grep pcmciautils | awk '{print "pcmciautils           ", $2}'
 
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1246217 — Re: [PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find version number

FromJim Davis <jim.epost@gmail.com>
Date2015-10-14 01:30 +0200
SubjectRe: [PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find version number
Message-ID<qjhb4-4JU-1@gated-at.bofh.it>
In reply to#1245004
I tried out patches 1-22 on a Fedora 22 system with the v4.3-rc5
source tree; everything looks pretty good.  The old ver_linux script
didn't get the mount version right, but the new one does

< mount                  debug
> Mount            2.26.2

One minor thing with Net-tools, the old version printed

< Net-tools              2.10-alpha

while the regex the in the new version skips the '-alpha'

> Net-tools        2.10

Though I'm not a big fan of patch 22 (the sed hold space thing) there
are several nice improvements all in all.

-- 
Jim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1246450 — Re: [PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find version number

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2015-10-14 11:30 +0200
SubjectRe: [PATCH 01/22] ver_linux: gcc -dumpversion, use regex to find version number
Message-ID<qjqxJ-2DR-23@gated-at.bofh.it>
In reply to#1246217
On Wed, Oct 14, 2015 at 2:21 AM, Jim Davis <jim.epost@gmail.com> wrote:
> I tried out patches 1-22 on a Fedora 22 system with the v4.3-rc5
> source tree; everything looks pretty good.  The old ver_linux script
> didn't get the mount version right, but the new one does
>
> < mount                  debug
>> Mount            2.26.2
>
> One minor thing with Net-tools, the old version printed
>
> < Net-tools              2.10-alpha
>
> while the regex the in the new version skips the '-alpha'
>
>> Net-tools        2.10
>
> Though I'm not a big fan of patch 22 (the sed hold space thing) there
> are several nice improvements all in all.
>
> --
> Jim

Thanks very much for reviewing the patches and for your commentary.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | linux.kernel


csiph-web