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


Groups > linux.kernel > #1432716 > unrolled thread

[PATCH 01/32] ver_linux: complete awk implementation

Started byAlexander Kapshuk <alexander.kapshuk@gmail.com>
First post2016-06-28 12:30 +0200
Last post2016-06-28 12:30 +0200
Articles 11 on this page of 31 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 01/32] ver_linux: complete awk implementation Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 09/32] ver_linux: wrap up call to 'tune2fs' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 17/32] ver_linux: wrap up call to 'pppd --version' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 32/32] ver_linux: 'printversion()' function definition Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
      Re: [PATCH 32/32] ver_linux: 'printversion()' function definition Valdis.Kletnieks@vt.edu - 2016-06-28 14:50 +0200
        Re: [PATCH 32/32] ver_linux: 'printversion()' function definition Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 16:50 +0200
          Re: [PATCH 32/32] ver_linux: 'printversion()' function definition Valdis.Kletnieks@vt.edu - 2016-06-28 16:50 +0200
            Re: [PATCH 32/32] ver_linux: 'printversion()' function definition Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-07-02 09:40 +0200
    [PATCH 27/32] ver_linux: wrap up call to 'expr --v' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 02/32] ver_linux: assign the usage message to a variable and print it Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 11/32] ver_linux: wrap up call to 'reiserfsck -V' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 08/32] ver_linux: wrap up call to 'depmod -V' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 25/32] ver_linux: wrap up call to 'loadkeys -V' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 14/32] ver_linux: wrap up call to 'pccardctl -V' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 18/32] ver_linux: wrap up call to 'isdnctrl' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 12/32] ver_linux: wrap up call to 'fsck.reiser4 -V' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 10/32] ver_linux: wrap up call to 'fsck.jfs -V' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 06/32] ver_linux: wrap up call to 'ld -v' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 21/32] ver_linux: wrap up call to 'ldd --version' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 07/32] ver_linux: wrap up call to 'mount --version' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 30/32] ver_linux: build a list of kernel modules as a string and print it Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 28/32] ver_linux: wrap up call to 'udevadm --version' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 15/32] ver_linux: wrap up call to 'cardmgr -V' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 23/32] ver_linux: wrap up call to 'ps --version' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 31/32] ver_linux: 'version()' function definition Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 26/32] ver_linux: wrap up call to 'oprofiled --version' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 19/32] ver_linux: wrap up call to 'showmount --version' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 13/32] ver_linux: wrap up call to 'xfs_db -V' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 05/32] ver_linux: wrap up call to 'make --version' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 03/32] ver_linux: execute 'uname -a' from awk Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200
    [PATCH 20/32] ver_linux: wrap up querying for version of 'Linux C Library' in awk function Alexander Kapshuk <alexander.kapshuk@gmail.com> - 2016-06-28 12:30 +0200

Page 2 of 2 — ← Prev page 1 [2]


#1432734 — [PATCH 30/32] ver_linux: build a list of kernel modules as a string and print it

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 30/32] ver_linux: build a list of kernel modules as a string and print it
Message-ID<rOYrh-5Ep-73@gated-at.bofh.it>
In reply to#1432716
Reimplement the code that generates an alphabetically sorted list of
kernel modules in awk and print the name of this entry and the list of
modules via a function call.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 6bba20c..3bf72ad 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -61,16 +61,11 @@ BEGIN {
 	printversion("Udev", version("udevadm --version 2>&1"))
 	printversion("Wireless-tools", version("iwconfig --version 2>&1"))
 
-test -e /proc/modules &&
-sort /proc/modules |
-sed '
-	s/ .*//
-	H
-${
-	g
-	s/^\n/Modules Loaded\t\t/
-	y/\n/ /
-	q
+	if (system("test -r /proc/modules") == 0) {
+		while ("sort /proc/modules" | getline > 0) {
+			mods = mods sep $1
+			sep = " "
+		}
+		printversion("Modules Loaded", mods)
+	}
 }
-	d
-'
-- 
2.7.3

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


#1432735 — [PATCH 28/32] ver_linux: wrap up call to 'udevadm --version' in awk function

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 28/32] ver_linux: wrap up call to 'udevadm --version' in awk function
Message-ID<rOYrh-5Ep-87@gated-at.bofh.it>
In reply to#1432716
Wrap up the call to 'udevadm --version', the code to process its output,
and the resulting formatted output in awk functions.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 1bfe340..a432d65 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -58,13 +58,7 @@ BEGIN {
 	printversion("Console-tools", version("loadkeys -V 2>&1"))
 	printversion("Oprofile", version("oprofiled --version 2>&1"))
 	printversion("Sh-utils", version("expr --v 2>&1"))
-
-udevadm --version 2>&1 |
-awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
-	match($0, /[0-9]+([.]?[0-9]+)+/)
-	printf("Udev\t\t\t%s\n",
-	substr($0,RSTART,RLENGTH))
-}'
+	printversion("Udev", version("udevadm --version 2>&1"))
 
 iwconfig --version 2>&1 |
 awk '/version/{
-- 
2.7.3

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


#1432736 — [PATCH 15/32] ver_linux: wrap up call to 'cardmgr -V' in awk function

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 15/32] ver_linux: wrap up call to 'cardmgr -V' in awk function
Message-ID<rOYrh-5Ep-81@gated-at.bofh.it>
In reply to#1432716
Wrap up the call to 'cardmgr -V', the code to process its output,
and the resulting formatted output in awk functions.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index b2145a9..cdcd284 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -24,9 +24,7 @@ BEGIN {
 	printversion("Reiser4fsprogs", version("fsck.reiser4 -V 2>&1"))
 	printversion("Xfsprogs", version("xfs_db -V 2>&1"))
 	printversion("Pcmciautils", version("pccardctl -V 2>&1"))
-
-cardmgr -V 2>&1| grep version | awk \
-'NR==1{print "pcmcia-cs             ", $3}'
+	printversion("Pcmcia-cs", version("cardmgr -V 2>&1"))
 
 quota -V 2>&1 |
 awk '/version/{
-- 
2.7.3

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


#1432737 — [PATCH 23/32] ver_linux: wrap up call to 'ps --version' in awk function

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 23/32] ver_linux: wrap up call to 'ps --version' in awk function
Message-ID<rOYrh-5Ep-85@gated-at.bofh.it>
In reply to#1432716
Wrap up the call to 'ps --version', the code to process its output,
and the resulting formatted output in awk functions.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 6111489..5754af1 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -52,12 +52,7 @@ BEGIN {
 	if (system("test -r " libcpp) == 0)
 		printversion("Linux C++ Library", version("readlink " libcpp))
 
-ps --version 2>&1 |
-awk '/version/{
-	match($0, /[0-9]+([.]?[0-9]+)+/)
-	printf("Procps\t\t\t%s\n",
-	substr($0,RSTART,RLENGTH))
-}'
+	printversion("Procps", version("ps --version 2>&1"))
 
 ifconfig --version 2>&1 |
 awk '/tools/{
-- 
2.7.3

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


#1432738 — [PATCH 31/32] ver_linux: 'version()' function definition

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 31/32] ver_linux: 'version()' function definition
Message-ID<rOYri-5Ep-97@gated-at.bofh.it>
In reply to#1432716
Definition of the 'version()' function. The function encapsulates the
algorithm that extracts the version number of the utility being queried,
and returns it as a value.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 3bf72ad..27b43ae 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -69,3 +69,14 @@ BEGIN {
 		printversion("Modules Loaded", mods)
 	}
 }
+
+function version(cmd,    ver) {
+	while (cmd | getline > 0) {
+		if (!/ver_linux/ && match($0, /[0-9]+([.]?[0-9]+)+/)) {
+			ver = substr($0, RSTART, RLENGTH)
+			break
+		}
+	}
+	close(cmd)
+	return ver
+}
-- 
2.7.3

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


#1432739 — [PATCH 26/32] ver_linux: wrap up call to 'oprofiled --version' in awk function

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 26/32] ver_linux: wrap up call to 'oprofiled --version' in awk function
Message-ID<rOYrh-5Ep-91@gated-at.bofh.it>
In reply to#1432716
Wrap up the call to 'oprofiled --version', the code to process its output,
and the resulting formatted output in awk functions.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 5eff838..b8030d6 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -56,9 +56,7 @@ BEGIN {
 	printversion("Net-tools", version("ifconfig --version 2>&1"))
 	printversion("Kbd", version("loadkeys -V 2>&1"))
 	printversion("Console-tools", version("loadkeys -V 2>&1"))
-
-oprofiled --version 2>&1 | awk \
-'(NR==1 && ($2 == "oprofile")) {print "oprofile              ", $3}'
+	printversion("Oprofile", version("oprofiled --version 2>&1"))
 
 expr --v 2>&1 |
 awk '/^expr/{
-- 
2.7.3

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


#1432741 — [PATCH 19/32] ver_linux: wrap up call to 'showmount --version' in awk function

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 19/32] ver_linux: wrap up call to 'showmount --version' in awk function
Message-ID<rOYri-5Ep-101@gated-at.bofh.it>
In reply to#1432716
Wrap up the call to 'showmount --version', the code to process its output,
and the resulting formatted output in awk functions.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 1359fd8..bb51c5d 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -28,9 +28,7 @@ BEGIN {
 	printversion("Quota-tools", version("quota -V 2>&1"))
 	printversion("PPP", version("pppd --version 2>&1"))
 	printversion("Isdn4k-utils", version("isdnctrl 2>&1"))
-
-showmount --version 2>&1 | grep nfs-utils | awk \
-'NR==1{print "nfs-utils             ", $NF}'
+	printversion("Nfs-utils", version("showmount --version 2>&1"))
 
 test -r /proc/self/maps &&
 sed '
-- 
2.7.3

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


#1432742 — [PATCH 13/32] ver_linux: wrap up call to 'xfs_db -V' in awk function

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 13/32] ver_linux: wrap up call to 'xfs_db -V' in awk function
Message-ID<rOYri-5Ep-103@gated-at.bofh.it>
In reply to#1432716
Wrap up the call to 'xfs_db -V', the code to process its output,
and the resulting formatted output in awk functions.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 2637f2b..a54db0d 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -22,13 +22,7 @@ BEGIN {
 	printversion("Jfsutils", version("fsck.jfs -V 2>&1"))
 	printversion("Reiserfsprogs", version("reiserfsck -V 2>&1"))
 	printversion("Reiser4fsprogs", version("fsck.reiser4 -V 2>&1"))
-
-xfs_db -V 2>&1 |
-awk '/version/{
-	match($0, /[0-9]+([.]?[0-9]+)+/)
-	printf("Xfsprogs\t\t%s\n",
-	substr($0,RSTART,RLENGTH))
-}'
+	printversion("Xfsprogs", version("xfs_db -V 2>&1"))
 
 pccardctl -V 2>&1 |
 awk '/pcmciautils/{
-- 
2.7.3

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


#1432743 — [PATCH 05/32] ver_linux: wrap up call to 'make --version' in awk function

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 05/32] ver_linux: wrap up call to 'make --version' in awk function
Message-ID<rOYri-5Ep-95@gated-at.bofh.it>
In reply to#1432716
Wrap up the call to 'make --version', the code to process its output,
and the resulting formatted output in awk functions.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 9362782..3042291 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -13,13 +13,7 @@ BEGIN {
 	printf("\n")
 
 	printversion("GNU C", version("gcc -dumpversion 2>&1"))
-
-make --version 2>&1 |
-awk '/GNU Make/{
-	match($0, /[0-9]+([.]?[0-9]+)+/)
-	printf("GNU Make\t\t%s\n",
-	substr($0,RSTART,RLENGTH))
-}'
+	printversion("GNU Make", version("make --version 2>&1"))
 
 ld -v 2>&1 |
 awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
-- 
2.7.3

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


#1432744 — [PATCH 03/32] ver_linux: execute 'uname -a' from awk

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 03/32] ver_linux: execute 'uname -a' from awk
Message-ID<rOYri-5Ep-105@gated-at.bofh.it>
In reply to#1432716
Execute 'uname -a' using the awk system() function.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 2f1d494..c509f09 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -9,8 +9,8 @@ BEGIN {
 	usage = usage "Compare to the current minimal requirements in Documentation/Changes.\n"
 	print usage
 
-uname -a
-echo ' '
+	system("uname -a")
+	printf("\n")
 
 gcc -dumpversion 2>&1 |
 awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
-- 
2.7.3

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


#1432745 — [PATCH 20/32] ver_linux: wrap up querying for version of 'Linux C Library' in awk function

FromAlexander Kapshuk <alexander.kapshuk@gmail.com>
Date2016-06-28 12:30 +0200
Subject[PATCH 20/32] ver_linux: wrap up querying for version of 'Linux C Library' in awk function
Message-ID<rOYri-5Ep-109@gated-at.bofh.it>
In reply to#1432716
Wrap up querying for version of 'Linux C Library', and the resulting
formatted output in an awk function.

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

diff --git a/scripts/ver_linux b/scripts/ver_linux
index bb51c5d..d3faf4a 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -30,12 +30,16 @@ BEGIN {
 	printversion("Isdn4k-utils", version("isdnctrl 2>&1"))
 	printversion("Nfs-utils", version("showmount --version 2>&1"))
 
-test -r /proc/self/maps &&
-sed '
-	/.*libc-\(.*\)\.so$/!d
-	s//Linux C Library\t\t\1/
-	q
-' /proc/self/maps
+	if (system("test -r /proc/self/maps") == 0) {
+		while (getline <"/proc/self/maps" > 0) {
+			n = split($0, procmaps, "/")
+			if (/libc.*so$/ && match(procmaps[n], /[0-9]+([.]?[0-9]+)+/)) {
+				ver = substr(procmaps[n], RSTART, RLENGTH)
+				printversion("Linux C Library", ver)
+				break
+			}
+		}
+	}
 
 ldd --version 2>&1 |
 awk '/^ldd/{
-- 
2.7.3

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | linux.kernel


csiph-web