environment_information 1.4.124 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +91 -15
- data/doc/README.gen +42 -14
- data/doc/todo/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +16 -12
- data/lib/environment_information/base/base.rb +483 -99
- data/lib/environment_information/colours/colours.rb +92 -66
- data/lib/environment_information/commandline/commandline.rb +137 -0
- data/lib/environment_information/constants/constants.rb +372 -11
- data/lib/environment_information/project/project.rb +1 -1
- data/lib/environment_information/query/constants.rb +46 -0
- data/lib/environment_information/query/help.rb +88 -0
- data/lib/environment_information/query/menu.rb +487 -0
- data/lib/environment_information/query/misc.rb +2006 -0
- data/lib/environment_information/query/query.rb +245 -0
- data/lib/environment_information/query/reset.rb +202 -0
- data/lib/environment_information/query/run.rb +70 -0
- data/lib/environment_information/requires/require_the_environment_information_project.rb +2 -7
- data/lib/environment_information/requires/require_the_toplevel_methods.rb +1 -3
- data/lib/environment_information/toplevel_methods/toplevel_methods.rb +2258 -0
- data/lib/environment_information/version/version.rb +2 -2
- data/lib/environment_information/www/sinatra_interface.rb +20 -17
- data/lib/environment_information/www/webobject_interface.cgi +6 -7
- data/lib/environment_information/yaml/colours.yml +3 -3
- data/lib/environment_information/yaml/query_to_use_for_all_components.yml +284 -0
- data/lib/environment_information/yaml/{array_tracked_programs.yml → track_these_components.yml} +77 -11
- metadata +18 -60
- data/lib/environment_information/class/class.rb +0 -2580
- data/lib/environment_information/class/colours.rb +0 -282
- data/lib/environment_information/colours/sfancy.rb +0 -19
- data/lib/environment_information/colours/simp.rb +0 -19
- data/lib/environment_information/constants/array_tracked_components.rb +0 -210
- data/lib/environment_information/constants/encoding.rb +0 -21
- data/lib/environment_information/constants/error_line.rb +0 -17
- data/lib/environment_information/constants/file_constants.rb +0 -102
- data/lib/environment_information/constants/misc.rb +0 -86
- data/lib/environment_information/constants/namespace.rb +0 -14
- data/lib/environment_information/constants/newline.rb +0 -16
- data/lib/environment_information/constants/regex.rb +0 -30
- data/lib/environment_information/constants/temp_directory.rb +0 -52
- data/lib/environment_information/misc_components/README.md +0 -3
- data/lib/environment_information/misc_components/cflags.rb +0 -36
- data/lib/environment_information/misc_components/cpuinfo.rb +0 -64
- data/lib/environment_information/misc_components/operating_system.rb +0 -54
- data/lib/environment_information/misc_components/operating_system_bit_type.rb +0 -42
- data/lib/environment_information/misc_components/ram.rb +0 -30
- data/lib/environment_information/misc_components/rubygems_installation_directory.rb +0 -54
- data/lib/environment_information/misc_components/screen_resolution.rb +0 -50
- data/lib/environment_information/queries/README.md +0 -2
- data/lib/environment_information/queries/complex_version.rb +0 -273
- data/lib/environment_information/queries/pkg_config.rb +0 -125
- data/lib/environment_information/queries/simple_version.rb +0 -272
- data/lib/environment_information/requires/require_the_individual_misc_components.rb +0 -30
- data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +0 -153
- data/lib/environment_information/toplevel_methods/cd.rb +0 -16
- data/lib/environment_information/toplevel_methods/e.rb +0 -43
- data/lib/environment_information/toplevel_methods/hash.rb +0 -65
- data/lib/environment_information/toplevel_methods/internet_is_available.rb +0 -30
- data/lib/environment_information/toplevel_methods/is_on_roebe.rb +0 -16
- data/lib/environment_information/toplevel_methods/menu.rb +0 -90
- data/lib/environment_information/toplevel_methods/misc.rb +0 -324
- data/lib/environment_information/toplevel_methods/n_subcommands.rb +0 -31
- data/lib/environment_information/toplevel_methods/prefix_to_use.rb +0 -39
- data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +0 -61
- data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +0 -45
- data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +0 -84
- data/lib/environment_information/toplevel_methods/return_alias_to.rb +0 -30
- data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +0 -28
- data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +0 -54
- data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +0 -28
- data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +0 -182
- data/lib/environment_information/toplevel_methods/show_all_available_components.rb +0 -192
- data/lib/environment_information/toplevel_methods/write_what_into.rb +0 -24
- data/lib/environment_information/yaml/array_default_programs_on_linux.yml +0 -15
- data/lib/environment_information/yaml/array_lfs_core_programs.yml +0 -37
- data/lib/environment_information/yaml/array_science_cluster.yml +0 -12
- data/lib/environment_information/yaml/array_tracked_non_programs.yml +0 -13
- data/lib/environment_information/yaml/array_tracked_xorg_components.yml +0 -37
- data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +0 -284
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/ruby -w
|
|
2
|
-
# Encoding: UTF-8
|
|
3
|
-
# frozen_string_literal: true
|
|
4
|
-
# =========================================================================== #
|
|
5
|
-
# === EnvironmentInformation::Queries::ComplexVersion
|
|
6
|
-
#
|
|
7
|
-
# This class will try to do a query based on more complex means.
|
|
8
|
-
# =========================================================================== #
|
|
9
|
-
# require 'environment_information/queries/simple_version.rb'
|
|
10
|
-
# EnvironmentInformation::Queries::ComplexVersion.new
|
|
11
|
-
# =========================================================================== #
|
|
12
|
-
require 'environment_information/base/base.rb'
|
|
13
|
-
|
|
14
|
-
module EnvironmentInformation
|
|
15
|
-
|
|
16
|
-
module Queries
|
|
17
|
-
|
|
18
|
-
class ComplexVersion < ::EnvironmentInformation::Base # === EnvironmentInformation::Queries::ComplexVersion
|
|
19
|
-
|
|
20
|
-
# ========================================================================= #
|
|
21
|
-
# === initialize
|
|
22
|
-
#
|
|
23
|
-
# The first argument is mandatory.
|
|
24
|
-
# ========================================================================= #
|
|
25
|
-
def initialize(
|
|
26
|
-
for_this_program = nil,
|
|
27
|
-
run_already = true
|
|
28
|
-
)
|
|
29
|
-
reset
|
|
30
|
-
set_program_name(
|
|
31
|
-
for_this_program
|
|
32
|
-
)
|
|
33
|
-
# ======================================================================= #
|
|
34
|
-
# === Handle blocks given next
|
|
35
|
-
# ======================================================================= #
|
|
36
|
-
if block_given?
|
|
37
|
-
yielded = yield
|
|
38
|
-
if yielded.is_a? Hash
|
|
39
|
-
if yielded.has_key? :prefix_to_use
|
|
40
|
-
@prefix_to_use << yielded.delete(:prefix_to_use)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
run if run_already
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# ========================================================================= #
|
|
48
|
-
# === reset
|
|
49
|
-
# ========================================================================= #
|
|
50
|
-
def reset
|
|
51
|
-
# ======================================================================= #
|
|
52
|
-
# === @program_name
|
|
53
|
-
# ======================================================================= #
|
|
54
|
-
@program_name = ''.dup
|
|
55
|
-
# ======================================================================= #
|
|
56
|
-
# === @program_version
|
|
57
|
-
# ======================================================================= #
|
|
58
|
-
@program_version = nil
|
|
59
|
-
# ======================================================================= #
|
|
60
|
-
# === @prefix_to_use
|
|
61
|
-
# ======================================================================= #
|
|
62
|
-
@prefix_to_use = ''.dup
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# ========================================================================= #
|
|
66
|
-
# === set_program_name
|
|
67
|
-
# ========================================================================= #
|
|
68
|
-
def set_program_name(i)
|
|
69
|
-
@program_name = i.to_sym if i
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# ========================================================================= #
|
|
73
|
-
# === program_name?
|
|
74
|
-
# ========================================================================= #
|
|
75
|
-
def program_name?
|
|
76
|
-
@program_name
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# ========================================================================= #
|
|
80
|
-
# === program_version?
|
|
81
|
-
# ========================================================================= #
|
|
82
|
-
def program_version?
|
|
83
|
-
@program_version
|
|
84
|
-
end; alias version? program_version? # === version?
|
|
85
|
-
|
|
86
|
-
# ========================================================================= #
|
|
87
|
-
# === return_version_of
|
|
88
|
-
# ========================================================================= #
|
|
89
|
-
def return_version_of(
|
|
90
|
-
this_program = @program_name
|
|
91
|
-
)
|
|
92
|
-
_ = ::EnvironmentInformation.query_to_use_for_the_individual_components?
|
|
93
|
-
if _.nil?
|
|
94
|
-
_ = ::EnvironmentInformation.load_file_query_to_use_for_the_individual_components
|
|
95
|
-
end
|
|
96
|
-
if _.has_key?(this_program)
|
|
97
|
-
cmd_to_run = _[this_program]
|
|
98
|
-
case cmd_to_run
|
|
99
|
-
# ===================================================================== #
|
|
100
|
-
# === :custom_busybox
|
|
101
|
-
# ===================================================================== #
|
|
102
|
-
when :custom_busybox
|
|
103
|
-
@program_version = ::EnvironmentInformation.return_version_of_busybox
|
|
104
|
-
# ===================================================================== #
|
|
105
|
-
# === :custom_xrandr
|
|
106
|
-
# ===================================================================== #
|
|
107
|
-
when :custom_xrandr
|
|
108
|
-
@program_version = ::EnvironmentInformation.return_version_of_xrandr
|
|
109
|
-
# ===================================================================== #
|
|
110
|
-
# === :custom_xvid
|
|
111
|
-
# ===================================================================== #
|
|
112
|
-
when :custom_xvid
|
|
113
|
-
@program_version = ::EnvironmentInformation.return_version_of_xvid
|
|
114
|
-
# ===================================================================== #
|
|
115
|
-
# === :custom_boost
|
|
116
|
-
# ===================================================================== #
|
|
117
|
-
when :custom_boost
|
|
118
|
-
@program_version = ::EnvironmentInformation.return_version_of_boost
|
|
119
|
-
# ===================================================================== #
|
|
120
|
-
# === :custom_mpc
|
|
121
|
-
# ===================================================================== #
|
|
122
|
-
when :custom_mpc
|
|
123
|
-
@program_version = ::EnvironmentInformation.return_version_of_mpc
|
|
124
|
-
else
|
|
125
|
-
result = `#{@prefix_to_use}#{cmd_to_run} #{ERROR_LINE}`.to_s.strip.dup
|
|
126
|
-
if result.include? ' #' # Handle "uname -a" aka Linux darkstar.example.net 5.4.50 #1 SMP
|
|
127
|
-
result = result.split(' #').first.strip
|
|
128
|
-
end
|
|
129
|
-
@program_version = result
|
|
130
|
-
end
|
|
131
|
-
return nil if @program_version.nil?
|
|
132
|
-
if @program_version.include? '# HMMER ' # <- Specifically for "hammer".
|
|
133
|
-
@program_version = @program_version.scan(
|
|
134
|
-
/# HMMER (\d{0,2}\.\d{0,2}\.\d{0,2})/
|
|
135
|
-
).flatten.first.to_s
|
|
136
|
-
end
|
|
137
|
-
if @program_version.include? 'extracts blocks from damag' # bzip2recover
|
|
138
|
-
@program_version = @program_version.scan(
|
|
139
|
-
/bzip2recover (\d{0,2}\.\d{0,2}\.\d{0,2}): extracts blocks from damaged .bz2 files/
|
|
140
|
-
).flatten.first.to_s.dup
|
|
141
|
-
end
|
|
142
|
-
# ===================================================================== #
|
|
143
|
-
# === Handle Imagemagick: 'Version: ImageMagick 7.0.10-28'
|
|
144
|
-
# ===================================================================== #
|
|
145
|
-
if @program_version.include? 'Version: ImageMagick '
|
|
146
|
-
@program_version = @program_version.scan(
|
|
147
|
-
/Version: ImageMagick (\d{0,2}\.\d{0,2}\.\d{0,2}-\d{0,2})/
|
|
148
|
-
).flatten.first.to_s.tr('-','.')
|
|
149
|
-
end
|
|
150
|
-
# ===================================================================== #
|
|
151
|
-
# === Handle 'KDE Frameworks: 5.73.0'
|
|
152
|
-
# ===================================================================== #
|
|
153
|
-
if @program_version.include? 'KDE Frameworks: '
|
|
154
|
-
@program_version = @program_version.scan(
|
|
155
|
-
/KDE Frameworks: (\d{0,2}\.\d{0,2}\.\d{0,2})/
|
|
156
|
-
).flatten.first.to_s
|
|
157
|
-
end
|
|
158
|
-
# ===================================================================== #
|
|
159
|
-
# === Handle 'ncurses 6.2.20200212' aka ncurses
|
|
160
|
-
# ===================================================================== #
|
|
161
|
-
if @program_version.include? 'ncurses '
|
|
162
|
-
@program_version = @program_version.scan(
|
|
163
|
-
/ncurses (\d{1,1}\.\d{1,1})/
|
|
164
|
-
).flatten.first.to_s
|
|
165
|
-
end
|
|
166
|
-
# ===================================================================== #
|
|
167
|
-
# === Handle ruby 'ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]'
|
|
168
|
-
# ===================================================================== #
|
|
169
|
-
if @program_version.include? 'ruby '
|
|
170
|
-
@program_version = @program_version.scan(
|
|
171
|
-
/^ruby (\d{1,1}\.\d{1,1}\.\d{1,1})/
|
|
172
|
-
).flatten.first.to_s
|
|
173
|
-
end
|
|
174
|
-
# ===================================================================== #
|
|
175
|
-
# === Handle patchelf '0.12.20200827.8d3a16e'
|
|
176
|
-
#
|
|
177
|
-
# This can also include output such as "patchelf 0.14.3".
|
|
178
|
-
# ===================================================================== #
|
|
179
|
-
if @program_version.include? 'patchelf '
|
|
180
|
-
@program_version = @program_version.scan(
|
|
181
|
-
/^patchelf (\d{1,1}\.\d{1,2}\.?\d{0,2})/
|
|
182
|
-
).flatten.first.to_s
|
|
183
|
-
end
|
|
184
|
-
# ===================================================================== #
|
|
185
|
-
# We have to be careful with the next, as a few programs report the
|
|
186
|
-
# version on the second line, not on the first.
|
|
187
|
-
# ===================================================================== #
|
|
188
|
-
if @program_version.include? N
|
|
189
|
-
@program_version = @program_version.split(N).first.strip
|
|
190
|
-
end
|
|
191
|
-
# ===================================================================== #
|
|
192
|
-
# Next handle cases such as the following two examples:
|
|
193
|
-
#
|
|
194
|
-
# "ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers"
|
|
195
|
-
# "openjdk version \"14.0.2\" 2020-07-14"
|
|
196
|
-
# "ffmpeg version n5.1.2 Copyright (c) 2000-2022 the FFmpeg developers"
|
|
197
|
-
#
|
|
198
|
-
# ===================================================================== #
|
|
199
|
-
if @program_version.include? ' version '
|
|
200
|
-
@program_version = @program_version.scan(
|
|
201
|
-
/ version n?"?(\d{0,2}\.\d{1,2}\.?\d{0,2})"?/ # See: See: https://rubular.com/r/39cIQqXin2oco0
|
|
202
|
-
).flatten.first.to_s.strip
|
|
203
|
-
end
|
|
204
|
-
# ===================================================================== #
|
|
205
|
-
# Handle cases such as: "nginx/1.18.0"
|
|
206
|
-
# ===================================================================== #
|
|
207
|
-
if @program_version.include? '/'
|
|
208
|
-
@program_version = @program_version.split('/').last.strip
|
|
209
|
-
end
|
|
210
|
-
if @program_version.include?('(') and # Specifically for XTERM.
|
|
211
|
-
@program_version.include?(')')
|
|
212
|
-
@program_version = @program_version.split('(').last.to_s.delete(')') # 7.7.0(359)
|
|
213
|
-
end
|
|
214
|
-
if @program_version.include? '-'
|
|
215
|
-
# Specifically to fix relion: "3.1.0-commit-GITDIR"
|
|
216
|
-
@program_version = @program_version.split('-').first.to_s.strip
|
|
217
|
-
end
|
|
218
|
-
if @program_version.include? COMMAND_NOT_FOUND
|
|
219
|
-
@program_version = nil
|
|
220
|
-
elsif @program_version.include? ' '
|
|
221
|
-
# =================================================================== #
|
|
222
|
-
# Assume input such as: "GNU ld (GNU Binutils) 2.35"
|
|
223
|
-
# =================================================================== #
|
|
224
|
-
@program_version = @program_version.split(' ').last
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
return @program_version
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
# ========================================================================= #
|
|
231
|
-
# === run
|
|
232
|
-
# ========================================================================= #
|
|
233
|
-
def run
|
|
234
|
-
return_version_of
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
end; end; end
|
|
238
|
-
|
|
239
|
-
if __FILE__ == $PROGRAM_NAME
|
|
240
|
-
array = %i(
|
|
241
|
-
mpc
|
|
242
|
-
gtk2
|
|
243
|
-
linux
|
|
244
|
-
binutils
|
|
245
|
-
boost
|
|
246
|
-
coreutils
|
|
247
|
-
diffutils
|
|
248
|
-
ffmpeg
|
|
249
|
-
findutils
|
|
250
|
-
java
|
|
251
|
-
imagemagick
|
|
252
|
-
kde_frameworks
|
|
253
|
-
llvm
|
|
254
|
-
ncurses
|
|
255
|
-
nginx
|
|
256
|
-
qt
|
|
257
|
-
rubygems
|
|
258
|
-
sharutils
|
|
259
|
-
sysstat
|
|
260
|
-
swig
|
|
261
|
-
texinfo
|
|
262
|
-
tmux
|
|
263
|
-
xfsprogs
|
|
264
|
-
xterm
|
|
265
|
-
hmmer
|
|
266
|
-
viennarna
|
|
267
|
-
xstdcmap
|
|
268
|
-
)
|
|
269
|
-
array.each {|entry|
|
|
270
|
-
_ = EnvironmentInformation::Queries::ComplexVersion.new(entry)
|
|
271
|
-
_.report_left_right
|
|
272
|
-
}
|
|
273
|
-
end # complexversion
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/ruby -w
|
|
2
|
-
# Encoding: UTF-8
|
|
3
|
-
# frozen_string_literal: true
|
|
4
|
-
# =========================================================================== #
|
|
5
|
-
# === EnvironmentInformation::Queries::PkgConfig
|
|
6
|
-
#
|
|
7
|
-
# This class will try to do a pkg-config query, based on a .yml file.
|
|
8
|
-
#
|
|
9
|
-
# As input it needs the name of the program at hand; and that program
|
|
10
|
-
# has to be registered in the .yml file. The query will then use
|
|
11
|
-
# "pkg-config", which in turn queries the local .pc file for the
|
|
12
|
-
# version.
|
|
13
|
-
# =========================================================================== #
|
|
14
|
-
# require 'environment_information/queries/pkg_config.rb'
|
|
15
|
-
# EnvironmentInformation::Queries::PkgConfig.new
|
|
16
|
-
# =========================================================================== #
|
|
17
|
-
require 'environment_information/base/base.rb'
|
|
18
|
-
|
|
19
|
-
module EnvironmentInformation
|
|
20
|
-
|
|
21
|
-
module Queries
|
|
22
|
-
|
|
23
|
-
class PkgConfig < ::EnvironmentInformation::Base # === EnvironmentInformation::Queries::PkgConfig
|
|
24
|
-
|
|
25
|
-
# ========================================================================= #
|
|
26
|
-
# === initialize
|
|
27
|
-
#
|
|
28
|
-
# The first argument is mandatory.
|
|
29
|
-
# ========================================================================= #
|
|
30
|
-
def initialize(
|
|
31
|
-
for_this_program = nil,
|
|
32
|
-
run_already = true
|
|
33
|
-
)
|
|
34
|
-
reset
|
|
35
|
-
set_program_name(for_this_program)
|
|
36
|
-
run if run_already
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# ========================================================================= #
|
|
40
|
-
# === reset
|
|
41
|
-
# ========================================================================= #
|
|
42
|
-
def reset
|
|
43
|
-
# ======================================================================= #
|
|
44
|
-
# === @program_name
|
|
45
|
-
# ======================================================================= #
|
|
46
|
-
@program_name = ''.dup
|
|
47
|
-
# ======================================================================= #
|
|
48
|
-
# === @program_version
|
|
49
|
-
# ======================================================================= #
|
|
50
|
-
@program_version = nil
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# ========================================================================= #
|
|
54
|
-
# === set_program_name
|
|
55
|
-
# ========================================================================= #
|
|
56
|
-
def set_program_name(i)
|
|
57
|
-
@program_name = i.to_sym if i
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# ========================================================================= #
|
|
61
|
-
# === program_name?
|
|
62
|
-
# ========================================================================= #
|
|
63
|
-
def program_name?
|
|
64
|
-
@program_name
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# ========================================================================= #
|
|
68
|
-
# === program_version?
|
|
69
|
-
# ========================================================================= #
|
|
70
|
-
def program_version?
|
|
71
|
-
@program_version
|
|
72
|
-
end; alias version? program_version? # === version?
|
|
73
|
-
|
|
74
|
-
# ========================================================================= #
|
|
75
|
-
# === run
|
|
76
|
-
# ========================================================================= #
|
|
77
|
-
def run
|
|
78
|
-
return_version_of
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# ========================================================================= #
|
|
82
|
-
# === return_version_of
|
|
83
|
-
# ========================================================================= #
|
|
84
|
-
def return_version_of(this_program = @program_name)
|
|
85
|
-
_ = ::EnvironmentInformation.query_to_use_for_the_individual_components?
|
|
86
|
-
if _.nil?
|
|
87
|
-
_ = ::EnvironmentInformation.load_file_query_to_use_for_the_individual_components
|
|
88
|
-
end
|
|
89
|
-
if _.has_key?(this_program)
|
|
90
|
-
result = _[this_program]
|
|
91
|
-
case result
|
|
92
|
-
when :pkgconfig
|
|
93
|
-
@program_version = `pkg-config --modversion #{this_program} #{ERROR_LINE}`.dup
|
|
94
|
-
else
|
|
95
|
-
@program_version = `#{result} #{ERROR_LINE}`.dup
|
|
96
|
-
end
|
|
97
|
-
if @program_version.include? NOT_FOUND_IN_PKG_CONFIG_SEARCH_PATH
|
|
98
|
-
@program_version = nil
|
|
99
|
-
end
|
|
100
|
-
else # We will try to run it anyway.
|
|
101
|
-
@program_version = `pkg-config --modversion #{this_program} #{ERROR_LINE}`.dup
|
|
102
|
-
end
|
|
103
|
-
@program_version.strip! if @program_version
|
|
104
|
-
return @program_version
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
end; end
|
|
108
|
-
|
|
109
|
-
# =========================================================================== #
|
|
110
|
-
# === EnvironmentInformation.query_pkgconfig_version_for
|
|
111
|
-
#
|
|
112
|
-
# This is a simpler toplevel-query, for .pc files in general.
|
|
113
|
-
# =========================================================================== #
|
|
114
|
-
def self.query_pkgconfig_version_for(i = :gtk2)
|
|
115
|
-
::EnvironmentInformation::Queries::PkgConfig.new(i).version?
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
if __FILE__ == $PROGRAM_NAME
|
|
121
|
-
_ = EnvironmentInformation::Queries::PkgConfig.new(:webkit2gtk)
|
|
122
|
-
puts _.program_name?.to_s+': '+_.program_version?.to_s
|
|
123
|
-
_ = EnvironmentInformation::Queries::PkgConfig.new(:gjs)
|
|
124
|
-
puts _.program_name?.to_s+': '+_.program_version?.to_s
|
|
125
|
-
end
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/ruby -w
|
|
2
|
-
# Encoding: UTF-8
|
|
3
|
-
# frozen_string_literal: true
|
|
4
|
-
# =========================================================================== #
|
|
5
|
-
# === EnvironmentInformation::Queries::SimpleVersion
|
|
6
|
-
#
|
|
7
|
-
# This class will try to do a query based on the main binary at hand.
|
|
8
|
-
#
|
|
9
|
-
# It is only a wrapper over "--version" and nothing else.
|
|
10
|
-
# =========================================================================== #
|
|
11
|
-
# require 'environment_information/queries/simple_version.rb'
|
|
12
|
-
# EnvironmentInformation::Queries::SimpleVersion.new
|
|
13
|
-
# =========================================================================== #
|
|
14
|
-
require 'environment_information/base/base.rb'
|
|
15
|
-
|
|
16
|
-
module EnvironmentInformation
|
|
17
|
-
|
|
18
|
-
module Queries
|
|
19
|
-
|
|
20
|
-
class SimpleVersion < ::EnvironmentInformation::Base # === EnvironmentInformation::Queries::SimpleVersion
|
|
21
|
-
|
|
22
|
-
# ========================================================================= #
|
|
23
|
-
# === initialize
|
|
24
|
-
#
|
|
25
|
-
# The first argument is mandatory.
|
|
26
|
-
# ========================================================================= #
|
|
27
|
-
def initialize(
|
|
28
|
-
for_this_program = nil,
|
|
29
|
-
run_already = true
|
|
30
|
-
)
|
|
31
|
-
reset
|
|
32
|
-
set_program_name(
|
|
33
|
-
for_this_program
|
|
34
|
-
)
|
|
35
|
-
# ======================================================================= #
|
|
36
|
-
# === Handle blocks given next
|
|
37
|
-
# ======================================================================= #
|
|
38
|
-
if block_given?
|
|
39
|
-
yielded = yield
|
|
40
|
-
if yielded.is_a? Hash
|
|
41
|
-
if yielded.has_key? :prefix_to_use
|
|
42
|
-
@prefix_to_use << yielded.delete(:prefix_to_use)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
run if run_already
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# ========================================================================= #
|
|
50
|
-
# === reset
|
|
51
|
-
# ========================================================================= #
|
|
52
|
-
def reset
|
|
53
|
-
# ======================================================================= #
|
|
54
|
-
# === @program_name
|
|
55
|
-
# ======================================================================= #
|
|
56
|
-
@program_name = ''.dup
|
|
57
|
-
# ======================================================================= #
|
|
58
|
-
# === @program_version
|
|
59
|
-
# ======================================================================= #
|
|
60
|
-
@program_version = nil
|
|
61
|
-
# ======================================================================= #
|
|
62
|
-
# === @prefix_to_use
|
|
63
|
-
# ======================================================================= #
|
|
64
|
-
@prefix_to_use = ''.dup
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# ========================================================================= #
|
|
68
|
-
# === set_program_name
|
|
69
|
-
# ========================================================================= #
|
|
70
|
-
def set_program_name(i)
|
|
71
|
-
@program_name = i.to_sym if i
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
# ========================================================================= #
|
|
75
|
-
# === program_name?
|
|
76
|
-
# ========================================================================= #
|
|
77
|
-
def program_name?
|
|
78
|
-
@program_name
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# ========================================================================= #
|
|
82
|
-
# === program_version?
|
|
83
|
-
# ========================================================================= #
|
|
84
|
-
def program_version?
|
|
85
|
-
@program_version
|
|
86
|
-
end; alias version? program_version? # === version?
|
|
87
|
-
|
|
88
|
-
# ========================================================================= #
|
|
89
|
-
# === return_version_of
|
|
90
|
-
# ========================================================================= #
|
|
91
|
-
def return_version_of(
|
|
92
|
-
this_program = program_name?
|
|
93
|
-
)
|
|
94
|
-
# ======================================================================= #
|
|
95
|
-
# The next variable will store the Hash containing all individual
|
|
96
|
-
# queries for the registered programs. For instance:
|
|
97
|
-
#
|
|
98
|
-
# :busybox=>:custom_busybox, :bzip2=>:"bzip2recover --version",
|
|
99
|
-
# :cairo=>:pkgconfig, :ccache=>:version, :check=>:pkgconfig,
|
|
100
|
-
# :clang=>:version, :clutter=>:"pkg-config --modversion clutter-1.0",
|
|
101
|
-
# :lighttpd=>:version # and so forth
|
|
102
|
-
#
|
|
103
|
-
# ======================================================================= #
|
|
104
|
-
_ = ::EnvironmentInformation.query_to_use_for_the_individual_components?
|
|
105
|
-
if _.nil?
|
|
106
|
-
_ = ::EnvironmentInformation.load_file_query_to_use_for_the_individual_components
|
|
107
|
-
end
|
|
108
|
-
if _.has_key?(this_program) # Check whether the program is registered.
|
|
109
|
-
result = _[this_program]
|
|
110
|
-
case result
|
|
111
|
-
# ===================================================================== #
|
|
112
|
-
# === :version
|
|
113
|
-
#
|
|
114
|
-
# This is the simplest entry point; we will try the commandline flag
|
|
115
|
-
# "--version" here. If you have to use "-v" then use :short_version
|
|
116
|
-
# instead.
|
|
117
|
-
# ===================================================================== #
|
|
118
|
-
when :version
|
|
119
|
-
@program_version = `#{@prefix_to_use}#{this_program} --version #{ERROR_LINE}`.strip
|
|
120
|
-
# ===================================================================== #
|
|
121
|
-
# === :short_version
|
|
122
|
-
# ===================================================================== #
|
|
123
|
-
when :short_version,
|
|
124
|
-
:simple_version
|
|
125
|
-
@program_version = `#{@prefix_to_use}#{this_program} -v #{ERROR_LINE}`.strip
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
if @program_version
|
|
129
|
-
if @program_version.include? N
|
|
130
|
-
@program_version = @program_version.split(N).first
|
|
131
|
-
end
|
|
132
|
-
if @program_version.include? '--'
|
|
133
|
-
@program_version.gsub!(/--/,'') # For strace specifically.
|
|
134
|
-
end
|
|
135
|
-
# ===================================================================== #
|
|
136
|
-
# Next format entries such as:
|
|
137
|
-
#
|
|
138
|
-
# "lighttpd/1.4.71 - a light and fast webserver"
|
|
139
|
-
#
|
|
140
|
-
# This may fail, though - see vim:
|
|
141
|
-
#
|
|
142
|
-
# "VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Mar 15 2024 11:08:54)"
|
|
143
|
-
#
|
|
144
|
-
# ===================================================================== #
|
|
145
|
-
if @program_version.include? ' - '
|
|
146
|
-
unless this_program.to_s.include?('vim')
|
|
147
|
-
@program_version = @program_version.split(' - ').first.to_s
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
# if @program_version.include? 'GNOME Document Viewer'
|
|
151
|
-
# @program_version.sub!(/GNOME Document Viewer/,'') # For evince specifically.
|
|
152
|
-
# end
|
|
153
|
-
if @program_version.include? 'GNU'
|
|
154
|
-
@program_version.gsub!(/GNU/,'')
|
|
155
|
-
end
|
|
156
|
-
# ===================================================================== #
|
|
157
|
-
# Next we will specifically handle vim:
|
|
158
|
-
# ===================================================================== #
|
|
159
|
-
if @program_version =~ / (\d{1,2}\.\d{1,2}) \(/
|
|
160
|
-
@program_version = $1.to_s.dup
|
|
161
|
-
end
|
|
162
|
-
if @program_version.include? ' built on linux-gnu.'
|
|
163
|
-
@program_version.gsub!(/ built on linux-gnu\./, '') # Fixing wget specifically.
|
|
164
|
-
end
|
|
165
|
-
if @program_version.include?('Midnight Commander')
|
|
166
|
-
@program_version.gsub!(/Midnight Commander/, '')
|
|
167
|
-
end
|
|
168
|
-
if @program_version.include?('[') and @program_version.include?(']')
|
|
169
|
-
@program_version.gsub!(/\[.+\]/, '')
|
|
170
|
-
end
|
|
171
|
-
@program_version.strip!
|
|
172
|
-
if @program_version.start_with? "#{this_program} "
|
|
173
|
-
# For example: "ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]"
|
|
174
|
-
@program_version.sub!(/#{this_program} /, '')
|
|
175
|
-
elsif @program_version.start_with? "#{this_program.capitalize} "
|
|
176
|
-
# For example: "Wget 1.20.3 built on linux-gnu."
|
|
177
|
-
@program_version.sub!(/#{this_program.capitalize} /, '')
|
|
178
|
-
elsif @program_version.start_with? "#{this_program.upcase} "
|
|
179
|
-
# For example: "NASM version 2.15.04 compiled on Aug 27 2020"
|
|
180
|
-
@program_version.sub!(/#{this_program.upcase} /, '')
|
|
181
|
-
elsif @program_version.downcase.start_with? "#{this_program.downcase} "
|
|
182
|
-
# For example: "IceWM", has a unusual start.
|
|
183
|
-
@program_version.sub!(/#{this_program} /i, '')
|
|
184
|
-
elsif @program_version.start_with? 'Awk'
|
|
185
|
-
@program_version.sub!(/Awk /i, '') # Ad-hox fix here.
|
|
186
|
-
end
|
|
187
|
-
if @program_version.include? '- Vi IMproved '
|
|
188
|
-
@program_version.sub!(/- Vi IMproved /, '') # Fixing vim specifically.
|
|
189
|
-
end
|
|
190
|
-
if @program_version.include? '(v'
|
|
191
|
-
# This is specifically for perl:
|
|
192
|
-
# "This is perl 5, version 32, subversion 0 (v5.32.0) built for x86_64-linux-thread-multi"
|
|
193
|
-
@program_version = @program_version.scan(
|
|
194
|
-
/\(v(\d{0,2}\.?\d{0,2}\.\d{0,2})\)/
|
|
195
|
-
).flatten.first.to_s.dup
|
|
196
|
-
end
|
|
197
|
-
# ===================================================================== #
|
|
198
|
-
# The next check for "Version" should come after we eliminated
|
|
199
|
-
# the leading program name.
|
|
200
|
-
# ===================================================================== #
|
|
201
|
-
if @program_version.include? 'Version '
|
|
202
|
-
@program_version = @program_version.scan(
|
|
203
|
-
/Version (\d{0,2}\.?\d{0,2}\.\d{0,2})/
|
|
204
|
-
).flatten.first.to_s.dup
|
|
205
|
-
elsif @program_version.include? 'version '
|
|
206
|
-
# This here should work for most programs, save for perl.
|
|
207
|
-
@program_version = @program_version.scan(
|
|
208
|
-
/version (\d{0,2}\.?\d{0,2}\.\d{0,2})/
|
|
209
|
-
).flatten.first.to_s.dup
|
|
210
|
-
end
|
|
211
|
-
if @program_version.include? ' patchlevel '
|
|
212
|
-
# =================================================================== #
|
|
213
|
-
# Gnuplot has this specifically: "5.4 patchlevel 0"
|
|
214
|
-
# =================================================================== #
|
|
215
|
-
@program_version = @program_version.sub(/ patchlevel /,'.').strip
|
|
216
|
-
end
|
|
217
|
-
# ===================================================================== #
|
|
218
|
-
# Next we kill everything inside (). This may sometimes be
|
|
219
|
-
# problematic, which is why this check comes quite late.
|
|
220
|
-
# ===================================================================== #
|
|
221
|
-
if @program_version.include?('(') and @program_version.include?(')')
|
|
222
|
-
@program_version.gsub!(/\(.+\)/, '')
|
|
223
|
-
end
|
|
224
|
-
# ===================================================================== #
|
|
225
|
-
# Handle: "IceWM 1.8.0, Copyright 1997-2003 Marko Macek, 2001 Mathias Hasselmann."
|
|
226
|
-
# ===================================================================== #
|
|
227
|
-
if @program_version.include?(',')
|
|
228
|
-
@program_version = @program_version.split(',').first
|
|
229
|
-
end
|
|
230
|
-
if @program_version.include?('/')
|
|
231
|
-
# =================================================================== #
|
|
232
|
-
# Assume something like "lighttpd/1.4.71".
|
|
233
|
-
# =================================================================== #
|
|
234
|
-
@program_version = @program_version.split('/').last
|
|
235
|
-
end
|
|
236
|
-
# ===================================================================== #
|
|
237
|
-
# Next, if a '-' is included, we split it and use the last part.
|
|
238
|
-
# This handles cases such as "valgrind-3.16.0".
|
|
239
|
-
# ===================================================================== #
|
|
240
|
-
if @program_version.include?('-')
|
|
241
|
-
@program_version = @program_version.split('-').last
|
|
242
|
-
end
|
|
243
|
-
# ===================================================================== #
|
|
244
|
-
# Last but not least, for "node" specifically.
|
|
245
|
-
# ===================================================================== #
|
|
246
|
-
if @program_version.start_with? 'v'
|
|
247
|
-
@program_version[0,1] = ''
|
|
248
|
-
end
|
|
249
|
-
if @program_version.include? ':' # e. g. for glslang.
|
|
250
|
-
@program_version = @program_version.split(':').last.to_s.strip
|
|
251
|
-
end
|
|
252
|
-
if @program_version.include? COMMAND_NOT_FOUND
|
|
253
|
-
@program_version = nil
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
return @program_version
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
# ========================================================================= #
|
|
260
|
-
# === run (run tag)
|
|
261
|
-
# ========================================================================= #
|
|
262
|
-
def run
|
|
263
|
-
return_version_of
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
end; end; end
|
|
267
|
-
|
|
268
|
-
if __FILE__ == $PROGRAM_NAME
|
|
269
|
-
seek_this_program = :gnuplot # :lftp
|
|
270
|
-
_ = EnvironmentInformation::Queries::SimpleVersion.new(seek_this_program)
|
|
271
|
-
_.report_left_right
|
|
272
|
-
end # rb simple_version
|