-
Notifications
You must be signed in to change notification settings - Fork 12
/
check
executable file
·136 lines (107 loc) · 3.35 KB
/
check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/sh -e
# Copyright (c) 2018-2024, Firas Khalil Khana
# Distributed under the terms of the ISC License
# Contributors:
# * Luiz Antônio Rangel at Pindorama (takusuman) <[email protected]>
# Boilerplate that checks if it's GNU, Heirloom
# or just desist and print the current POSIX
# standard of the system.
GNUorNonGNU() {
cmd=$1
heirloom_ver="$(getconf HEIRLOOM_TOOLCHEST_VERSION || printf 'err')"
posix_ver=$(getconf _POSIX_VERSION)
case "$($cmd --version 2>/dev/null || printf 'err')" in
err) case "$heirloom_ver" in
'err')
if (command -v "$cmd" 2>&1 >/dev/null); then
printf 'POSIX version: %d\n' \
$posix_ver
else
printf 'Not found.\n'
return 1
fi
;;
*)
if [ $heirloom_ver -gt 070715 ]; then
NG="(New Generation)"
fi
printf 'Heirloom Toolchest%srel. %d\n' \
" $NG " $heirloom_ver
;;
esac ;;
*) $cmd --version 2>&1 | sed 1q | cut -d' ' -f4 ;;
esac
}
if command -v b3sum 2>&1 >/dev/null; then
printf 'b3sum :: '
b3sum --version | cut -d' ' -f2
elif command -v sha256sum 2>&1 >/dev/null; then
printf 'sha256sum :: '
sha256sum --version | sed 1q | cut -d' ' -f2-
elif command -v openssl 2>&1 >/dev/null; then
printf 'sha256sum (Open/LibreSSL) :: '
openssl version
fi
printf 'bash :: '
bash --version | sed 1q | cut -d' ' -f4
printf 'bc :: '
{ (command -v bc 2>&1 >/dev/null) && ( (bc --version ||
getconf HEIRLOOM_TOOLCHEST_VERSION ||
getconf _POSIX_VERSION) | sed 1q | cut -d' ' -f2) 2>/dev/null; } ||
printf 'Not found.\n'
printf 'binutils :: '
ld --version | sed 1q | cut -d' ' -f5
printf 'bison :: '
bison --version | sed 1q | cut -d' ' -f4
printf 'bzip2 :: '
bzip2 --version 2>&1 </dev/null | sed 1q | cut -d' ' -f8-
printf 'coreutils :: '
GNUorNonGNU 'ls'
printf 'diffutils :: '
GNUorNonGNU 'diff'
printf 'findutils :: '
GNUorNonGNU 'find'
printf 'g++ :: '
g++ --version | sed 1q | cut -d' ' -f3-
printf 'gawk :: '
gawk --version | sed 1q | cut -d' ' -f3
printf 'gcc :: '
gcc --version | sed 1q | cut -d' ' -f3-
printf 'git :: '
git --version | cut -d' ' -f3
if $(ldd --version 2>&1 | grep 'musl' 2>&1 >/dev/null); then
printf 'musl libc :: '
ldd --version 2>&1 | sed -n 2p | cut -d' ' -f2
elif $(ldd --version 2>&1 | grep 'GNU' 2>&1 >/dev/null); then
printf 'glibc :: '
ldd --version 2>&1 | sed 1q | cut -d' ' -f4
fi
printf 'grep :: '
GNUorNonGNU 'grep'
printf 'gzip :: '
gzip --version | sed 1q | cut -d' ' -f2
printf 'libzstd :: '
(printf '#include <zstd.h>\nZSTD_VERSION_STRING' |
(gcc -E -P - 2>/dev/null || echo 'libzstd not found.') | tail -n1)
printf 'linux :: '
uname -r
printf 'm4 :: '
m4 --version | sed 1q | cut -d' ' -f4
printf 'make :: '
make --version | sed 1q | cut -d' ' -f3
printf 'patch :: '
patch --version | sed 1q | cut -d' ' -f3
printf 'perl :: '
perl -V:version | cut -d"'" -f2
printf 'sed :: '
GNUorNonGNU 'sed'
printf 'tar :: '
( (tar --version ||
# Important: Heirloom tar(1) is broken for
# the modern world since its conception.
getconf HEIRLOOM_TOOLCHEST_VERSION ||
getconf _POSIX_VERSION) | sed 1q | cut -d' ' -f4) 2>/dev/null
printf 'texinfo :: '
makeinfo --version | sed 1q | cut -d' ' -f4
printf 'xz :: '
xz --version | sed 1q | cut -d' ' -f4