jjb: fix memory printing on FreeBSD
[lttng-ci.git] / scripts / common / print.sh
1 #!/bin/bash
2 #
3 # SPDX-FileCopyrightText: 2020 Michael Jeanson <mjeanson@efficios.com>
4 # SPDX-License-Identifier: GPL-2.0-or-later
5
6 set -exu
7
8 COLOR_BLUE='\033[0;34m'
9 COLOR_NONE='\033[0m' # No Color
10
11 print_blue() {
12 echo -e "${COLOR_BLUE}$1${COLOR_NONE}"
13 }
14
15 print_hardware() {
16 if command -v lscpu >/dev/null 2>&1; then
17 print_blue "CPU Details"
18 lscpu
19 fi
20
21 if command -v free >/dev/null 2>&1; then
22 print_blue "Memory Details"
23 free -m
24 else
25 print_blue "Memory Details"
26 vmstat free
27 fi
28
29 print_blue "Storage Details"
30 df -H -T
31 }
32
33 print_os() {
34 set +ex
35
36 print_blue "Operating System Details"
37
38 if [ -f "/etc/os-release" ]; then
39 (. "/etc/os-release"; echo "Version: $NAME $VERSION")
40 elif [ -f "/etc/release" ]; then
41 echo "Version: $(head -n1 /etc/release)"
42 elif command -v sw_vers >/dev/null 2>&1; then
43 # For MacOS
44 echo "Version: $(sw_vers -productName) $(sw_vers -productVersion)"
45 fi
46
47 echo -n "Kernel: "
48 uname -a
49
50 set -ex
51 }
52
53 print_pkgconfig_mod() {
54 local mod=$1
55 if pkg-config --exists "${mod}"; then
56 print_blue "$mod version"
57 pkg-config --modversion "${mod}"
58 fi
59 }
60
61 print_tooling() {
62 set +ex
63
64 print_blue "Selected CC version"
65 ${CC:-cc} --version | head -n1
66
67 print_blue "Selected CXX version"
68 ${CXX:-c++} --version | head -n1
69
70 print_blue "Default gcc version"
71 gcc --version | head -n1
72 gcc -dumpmachine
73
74 print_blue "Default g++ version"
75 g++ --version | head -n1
76 g++ -dumpmachine
77
78 if command -v clang >/dev/null 2>&1; then
79 print_blue "Default clang version"
80 clang --version
81 fi
82
83 if command -v clang++ >/dev/null 2>&1; then
84 print_blue "Default clang++ version"
85 clang++ --version
86 fi
87
88 print_blue "git version"
89 git --version
90
91 print_blue "bash version"
92 bash --version | head -n1
93
94 print_blue "make version"
95 ${MAKE:-make} --version | head -n1
96
97 if command -v cmake >/dev/null 2>&1; then
98 print_blue "cmake version"
99 cmake --version
100 fi
101
102 print_blue "automake version"
103 automake --version | head -n1
104
105 print_blue "autoconf version"
106 autoconf --version | head -n1
107
108 print_blue "libtool version"
109 if libtool --version >/dev/null 2>&1; then
110 libtool --version | head -n1
111 else
112 # Thanks Apple!
113 libtool -V
114 fi
115
116 print_blue "bison version"
117 ${BISON:-bison} --version | head -n1
118
119 print_blue "flex version"
120 ${FLEX:-flex} --version
121
122 print_blue "swig version"
123 swig -version | ${GREP:-grep} SWIG
124
125 print_blue "tar version"
126 ${TAR:-tar} --version | head -n1
127
128 print_blue "Selected python version"
129 ${PYTHON:-python} --version
130
131 if command -v "${PYTHON2:-python2}" >/dev/null 2>&1; then
132 print_blue "python2 version"
133 ${PYTHON2:-python2} --version
134 fi
135
136 if command -v "${PYTHON3:-python3}" >/dev/null 2>&1; then
137 print_blue "python3 version"
138 ${PYTHON3:-python3} --version
139 fi
140
141 print_blue "java version"
142 java -version
143
144 print_blue "javac version"
145 javac -version
146
147 if command -v asciidoc >/dev/null 2>&1; then
148 print_blue "asciidoc version"
149 asciidoc --version
150 fi
151
152 if command -v xmlto >/dev/null 2>&1; then
153 print_blue "xmlto version"
154 xmlto --version
155 fi
156
157 if command -v openssl >/dev/null 2>&1; then
158 print_blue "openssl version"
159 openssl version
160 fi
161
162 if command -v pkg-config >/dev/null 2>&1; then
163 print_blue "pkg-config version"
164 pkg-config --version
165
166 #print_blue "pkg-config modules installed"
167 #pkg-config --list-all
168
169 print_pkgconfig_mod glib-2.0
170 print_pkgconfig_mod libdw
171 print_pkgconfig_mod libelf
172 print_pkgconfig_mod libxml-2.0
173 print_pkgconfig_mod msgpack
174 print_pkgconfig_mod popt
175 print_pkgconfig_mod uuid
176 print_pkgconfig_mod zlib
177 fi
178
179 set -ex
180 }
This page took 0.033633 seconds and 4 git commands to generate.