environment_information 1.4.29
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of environment_information might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +1061 -0
- data/bin/envi +7 -0
- data/bin/fast_envi +7 -0
- data/doc/README.gen +893 -0
- data/doc/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +54 -0
- data/environment_information.gemspec +130 -0
- data/lib/environment_information/base/base.rb +113 -0
- data/lib/environment_information/class/add.rb +186 -0
- data/lib/environment_information/class/colours.rb +283 -0
- data/lib/environment_information/class/constants.rb +35 -0
- data/lib/environment_information/class/environment_information.rb +51 -0
- data/lib/environment_information/class/help.rb +86 -0
- data/lib/environment_information/class/html.rb +78 -0
- data/lib/environment_information/class/initialize.rb +178 -0
- data/lib/environment_information/class/menu.rb +436 -0
- data/lib/environment_information/class/misc.rb +821 -0
- data/lib/environment_information/class/opn.rb +33 -0
- data/lib/environment_information/class/register_sigint.rb +20 -0
- data/lib/environment_information/class/reset.rb +213 -0
- data/lib/environment_information/class/ruby.rb +79 -0
- data/lib/environment_information/class/run.rb +61 -0
- data/lib/environment_information/class/show_display_and_report.rb +310 -0
- data/lib/environment_information/colours/colours.rb +150 -0
- data/lib/environment_information/colours/sfancy.rb +19 -0
- data/lib/environment_information/colours/simp.rb +19 -0
- data/lib/environment_information/constants/array_tracked_components.rb +207 -0
- data/lib/environment_information/constants/constants.rb +17 -0
- data/lib/environment_information/constants/encoding.rb +21 -0
- data/lib/environment_information/constants/error_line.rb +17 -0
- data/lib/environment_information/constants/file_constants.rb +102 -0
- data/lib/environment_information/constants/misc.rb +86 -0
- data/lib/environment_information/constants/namespace.rb +14 -0
- data/lib/environment_information/constants/newline.rb +16 -0
- data/lib/environment_information/constants/regex.rb +30 -0
- data/lib/environment_information/constants/temp_directory.rb +52 -0
- data/lib/environment_information/gui/gtk/bindings.rb +300 -0
- data/lib/environment_information/misc_components/README.md +3 -0
- data/lib/environment_information/misc_components/cflags.rb +36 -0
- data/lib/environment_information/misc_components/cpuinfo.rb +64 -0
- data/lib/environment_information/misc_components/operating_system.rb +54 -0
- data/lib/environment_information/misc_components/operating_system_bit_type.rb +42 -0
- data/lib/environment_information/misc_components/ram.rb +30 -0
- data/lib/environment_information/misc_components/rubygems_installation_directory.rb +54 -0
- data/lib/environment_information/misc_components/screen_resolution.rb +50 -0
- data/lib/environment_information/project/project.rb +27 -0
- data/lib/environment_information/queries/README.md +2 -0
- data/lib/environment_information/queries/complex_version.rb +263 -0
- data/lib/environment_information/queries/pkg_config.rb +125 -0
- data/lib/environment_information/queries/simple_version.rb +211 -0
- data/lib/environment_information/requires/require_asciitable.rb +15 -0
- data/lib/environment_information/requires/require_the_constants.rb +7 -0
- data/lib/environment_information/requires/require_the_environment_information_project.rb +23 -0
- data/lib/environment_information/requires/require_the_individual_misc_components.rb +30 -0
- data/lib/environment_information/requires/require_the_toplevel_methods.rb +22 -0
- data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +152 -0
- data/lib/environment_information/toplevel_methods/cd.rb +16 -0
- data/lib/environment_information/toplevel_methods/e.rb +30 -0
- data/lib/environment_information/toplevel_methods/hash.rb +60 -0
- data/lib/environment_information/toplevel_methods/internet_is_available.rb +30 -0
- data/lib/environment_information/toplevel_methods/is_on_roebe.rb +16 -0
- data/lib/environment_information/toplevel_methods/menu.rb +90 -0
- data/lib/environment_information/toplevel_methods/misc.rb +264 -0
- data/lib/environment_information/toplevel_methods/n_subcommands.rb +31 -0
- data/lib/environment_information/toplevel_methods/prefix_to_use.rb +39 -0
- data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +61 -0
- data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +45 -0
- data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +84 -0
- data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +28 -0
- data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +54 -0
- data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +28 -0
- data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +186 -0
- data/lib/environment_information/toplevel_methods/show_all_available_components.rb +192 -0
- data/lib/environment_information/toplevel_methods/write_what_into.rb +24 -0
- data/lib/environment_information/version/version.rb +25 -0
- data/lib/environment_information/www/sinatra_interface.rb +213 -0
- data/lib/environment_information/www/webobject_interface.cgi +29 -0
- data/lib/environment_information/yaml/array_default_programs_on_linux.yml +14 -0
- data/lib/environment_information/yaml/array_lfs_core_programs.yml +35 -0
- data/lib/environment_information/yaml/array_science_cluster.yml +12 -0
- data/lib/environment_information/yaml/array_tracked_non_programs.yml +13 -0
- data/lib/environment_information/yaml/array_tracked_programs.yml +165 -0
- data/lib/environment_information/yaml/array_tracked_xorg_components.yml +34 -0
- data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +215 -0
- data/lib/environment_information.rb +5 -0
- data/test/testing_environment_information.rb +26 -0
- data/test/testing_missing_components.rb +9 -0
- data/test/testing_prefix_for_the_environment_information_project.rb +20 -0
- metadata +195 -0
data/doc/README.gen
ADDED
@@ -0,0 +1,893 @@
|
|
1
|
+
ADD_RUBY_BADGE
|
2
|
+
|
3
|
+
## About the environment_information gem
|
4
|
+
|
5
|
+
This project is called **EnvironmentInformation** (**environment information**).
|
6
|
+
|
7
|
+
Its primary goal is **to gather information about the environment that ruby is
|
8
|
+
presently running on** - in other words, **the host system** and its
|
9
|
+
capabilities.
|
10
|
+
|
11
|
+
This gathered information can then be shown to the user on the commandline,
|
12
|
+
or via a ruby-gtk widget, or via a sinatra-interface on the www. The main focus
|
13
|
+
for this project is on the **commandline-usage**, though. For example, the
|
14
|
+
file at **bin/fenvi**, which is part of this project, can be used to
|
15
|
+
quickly show all versions of different programs on the target computer
|
16
|
+
system.
|
17
|
+
|
18
|
+
To provide a short overview how this may look, taken on the **KDE konsole**
|
19
|
+
and **bash**, have a look at the following image:
|
20
|
+
|
21
|
+
![alt text][screenshot1]
|
22
|
+
[screenshot1]: https://i.imgur.com/KiXIIVV.png
|
23
|
+
|
24
|
+
Invocation example:
|
25
|
+
|
26
|
+
fenvi
|
27
|
+
|
28
|
+
Generated output (only showing the first five entries):
|
29
|
+
|
30
|
+
atk 2.32.0
|
31
|
+
bash 5.0.0
|
32
|
+
binutils 2.32
|
33
|
+
bison 3.4.1
|
34
|
+
bzip2 1.0.8
|
35
|
+
|
36
|
+
Do note that by default **colours** will be used, so atk may appear
|
37
|
+
in green, and the associated version will be shown in a blue
|
38
|
+
colour (actually steelblue, by default). If you do not want to use
|
39
|
+
colours, you can disable them for the current invocation run, like
|
40
|
+
in this way:
|
41
|
+
|
42
|
+
envi --no-colours
|
43
|
+
envi --no-colors
|
44
|
+
envi --disable-colours
|
45
|
+
envi --disable-colors
|
46
|
+
|
47
|
+
Take note that you can tweak most of the behaviour of **EnvironmentInformation**
|
48
|
+
via specific **commandline flags**.
|
49
|
+
|
50
|
+
To obtain **a listing of the available options**, you can invoke the
|
51
|
+
main executable called **envi** (**bin/envi**) via:
|
52
|
+
|
53
|
+
envi --help
|
54
|
+
|
55
|
+
What is meant with the term **environment**?
|
56
|
+
|
57
|
+
**Definition**:
|
58
|
+
|
59
|
+
The term **environment**, within the context of the **environment_information gem**,
|
60
|
+
is **the (software) environment** that can be discovered by the ruby version
|
61
|
+
found within the **$PATH** variable, on the given computer system at hand.
|
62
|
+
|
63
|
+
Recall that there may be situations where there is more than one
|
64
|
+
version of ruby installed, on a given computer system, in different
|
65
|
+
locations - e. g. **/usr/bin/** versus **/usr/local/bin/**
|
66
|
+
versus **/home/** or **/opt/** setups. Thus, $PATH should be kept in mind in
|
67
|
+
the event that you have multiple ruby versions on the given computer system
|
68
|
+
at hand, as the incorrect ruby version may be discovered, in certain
|
69
|
+
situations. Furthermore keep also in mind that multiple binaries may exist
|
70
|
+
at the target system, e. g. bzip at /bin but also at /usr/bin or elsewhere.
|
71
|
+
|
72
|
+
Thus, I recommend to always ensure that **$PATH** is correctly set on the
|
73
|
+
target machine. First come, first serve, so it is a good advice to keep
|
74
|
+
PATH clean, and 'logical'.
|
75
|
+
|
76
|
+
At any rate, the **information** that will be gathered by the
|
77
|
+
**EnvironmentInformation** project may also be stored more persistently
|
78
|
+
in a **standalone .html file**, if you so desire to. This .html file
|
79
|
+
could then be used for static display of the information (but may
|
80
|
+
become quickly outdated, so keep this in mind as well).
|
81
|
+
|
82
|
+
The **Environment information** project may include any of the
|
83
|
+
following as its output:
|
84
|
+
|
85
|
+
- The **GCC Version** in use on the given computer host system.
|
86
|
+
- The (Linux) Kernel in use.
|
87
|
+
- Which Ruby Version is used.
|
88
|
+
- Which Rubygem version is used.
|
89
|
+
- The path to the rubygem directory.
|
90
|
+
- What the Host CPU Model is (on Linux at the least).
|
91
|
+
- What is the the **GTK*+, **GLIB*+ and **gdk-pixbuf** version, respectively.
|
92
|
+
- Which **dhcpcd version** is available.
|
93
|
+
- What Xorg components are available, such as libX11, libxcm, libxp,
|
94
|
+
libxau.
|
95
|
+
|
96
|
+
And so on and so forth - and a lot more.
|
97
|
+
|
98
|
+
Why are there many **different ways** to query the version of a locally
|
99
|
+
installed programs?
|
100
|
+
|
101
|
+
The main reason as to why **different ways** have to be supported is because
|
102
|
+
different software is installed in different ways, making use of
|
103
|
+
information in, well - different ways.
|
104
|
+
|
105
|
+
For example: not every software comes with a **.pc** file, so we can not
|
106
|
+
rely on .pc files uniformly for every installed program. Sometines no
|
107
|
+
commandline-binary is provided, so the **--version** flag can not be
|
108
|
+
used either; and if no .pc file exists for a given program, we may
|
109
|
+
have to query the name of the **.so files** (on a linux system),
|
110
|
+
and infer the version from that.
|
111
|
+
|
112
|
+
The main class in this project is **class EnvironmentInformation**,
|
113
|
+
which resides under **module EnvironmentInformation**.
|
114
|
+
|
115
|
+
The actual query of the version is done on the toplevel, so for example:
|
116
|
+
|
117
|
+
EnvironmentInformation.gcc?
|
118
|
+
|
119
|
+
would display the version of GCC at hand.
|
120
|
+
|
121
|
+
The code there will typically try to query .pc files via **pkg**-config,
|
122
|
+
but may sometimes try to infer the version from the .so file at hand,
|
123
|
+
and sometimes it will try to run the system binary (or an associated
|
124
|
+
binary) with a -V or -v or --version flag, and parse that output.
|
125
|
+
|
126
|
+
Typically the components that will be displayed, are handled by code
|
127
|
+
that resides in the file **display.rb**. The instance variable
|
128
|
+
**@display_these_components** keeps track of which components will
|
129
|
+
be displayed, so that information about these disparate programs
|
130
|
+
and components can be tracked.
|
131
|
+
|
132
|
+
There are in general only two entries that are of interest to
|
133
|
+
class EnvironmentInformation here:
|
134
|
+
|
135
|
+
(a) The name of the program.
|
136
|
+
(b) The associated specific program version, as String, of that program.
|
137
|
+
|
138
|
+
So, for example, we may see a key→value association like:
|
139
|
+
|
140
|
+
ruby => 2.5.1
|
141
|
+
|
142
|
+
If you need a **String** representation of the dataset then you can
|
143
|
+
use the method <b>.string?</b> or <b>.stringified</b>, which will give
|
144
|
+
you a **String** instead. The **.stringified** method exists
|
145
|
+
primarily due to **convenience** alone, for people who don't
|
146
|
+
want to do much conversion on their own and just be done with it).
|
147
|
+
|
148
|
+
There are various additional helper methods, such as a reader-method
|
149
|
+
called <b>.main_string?</b> or <b>.string</b> (they are equivalent to
|
150
|
+
one another, aka one is an alias).
|
151
|
+
|
152
|
+
This should allow you to re-use the information from this gem in
|
153
|
+
other projects, such as if you wish to get the String of all
|
154
|
+
available programs, and display this on a webpage. Or, alternatively,
|
155
|
+
just use a toplevel method call, such as:
|
156
|
+
|
157
|
+
EnvironmentInformation.glibc_version?
|
158
|
+
|
159
|
+
## How to make use of the project
|
160
|
+
|
161
|
+
There are, essentially, three recommended ways how to use the main
|
162
|
+
class of this project:
|
163
|
+
|
164
|
+
(1)
|
165
|
+
|
166
|
+
From the commandline, just call **envi** directly and pass in
|
167
|
+
specific commands to this executable (optionally).
|
168
|
+
|
169
|
+
For instance: invoke the envi-executable with the argument "ALL"
|
170
|
+
or "--all" and the class will show all information that could
|
171
|
+
be found. This is personally my favourite way how to invoke
|
172
|
+
this class. I even combine it with "FALL" or "RALL" (**--really-all**
|
173
|
+
or **--really-everything**), which will also compare the programs
|
174
|
+
versions that are available, if the RBT project is available
|
175
|
+
(**gem install rbt**), and then inform me as to which programs
|
176
|
+
are **not** up-to-date on the local computer system at hand. This
|
177
|
+
then allows me to compile/install these programs. This idea came
|
178
|
+
to be because I liked the Linux from Scratch project a lot, and
|
179
|
+
there you may often have to upgrade programs.
|
180
|
+
|
181
|
+
Note that **--really-everything** may be hard to type. I suggest to
|
182
|
+
use an alias in that case, or just the upcased variant **FALL** or
|
183
|
+
**RALL**. See the file <b>menu.rb</b> for more aliases to that.
|
184
|
+
|
185
|
+
(2)
|
186
|
+
|
187
|
+
The other use case is the "embedded use", i.e. for use in a
|
188
|
+
<b>.cgi page</b> or perhaps for a ruby-on-rails webpage.
|
189
|
+
|
190
|
+
An example for the former follows:
|
191
|
+
|
192
|
+
_ = EnvironmentInformation.new(:do_not_run_yet) # The symbol allows us to prepare the class first.
|
193
|
+
_.set_n_tokens 58
|
194
|
+
_.disable_colours # <- Recommended, since the colours are thought for the commandline only.
|
195
|
+
_.be_silent
|
196
|
+
_.dont_show_ruby_stuff # <- If you do not need information about ruby.
|
197
|
+
_.run
|
198
|
+
|
199
|
+
But you do not have to instantiate a new object; you can
|
200
|
+
simply use another toplevel API, since as of September 2019.
|
201
|
+
|
202
|
+
(3)
|
203
|
+
|
204
|
+
For example, to query the glibc version, you could use this:
|
205
|
+
|
206
|
+
EnvironmentInformation.glibc? # => "2.29"
|
207
|
+
|
208
|
+
Which variant to prefer? This depends on your use case. If you
|
209
|
+
need more flexibility then you should use the class; if you
|
210
|
+
only need the version-string, number 3 may be best as it is
|
211
|
+
the simplest.
|
212
|
+
|
213
|
+
You can also display some additional information, such as the version
|
214
|
+
of GTK, Glib, Atk and Pango, by passing in "f" or "full" or "--full"
|
215
|
+
on the commandline, without the quotation marks.
|
216
|
+
|
217
|
+
See the help section to this this script, which can be invoked by
|
218
|
+
passing "help" or "--help" as argument to envi.
|
219
|
+
|
220
|
+
You can also pass this information through a block, if you would like to:
|
221
|
+
|
222
|
+
_ = EnvironmentInformation.new(:do_not_run_yet) {
|
223
|
+
n_tokens: 58,
|
224
|
+
use_colours: no,
|
225
|
+
be_silent: true
|
226
|
+
show_ruby_stuff: no
|
227
|
+
}
|
228
|
+
_.run
|
229
|
+
|
230
|
+
Do note that the following **API** also works, primarily due to
|
231
|
+
convenience - you can try it in **irb**, of course:
|
232
|
+
|
233
|
+
require 'environment_information'
|
234
|
+
|
235
|
+
EnvironmentInformation[]
|
236
|
+
|
237
|
+
The executable version for class EnvironmentInformation is called <b>envi</b>.
|
238
|
+
It will reside under **bin/envi** of this gem.
|
239
|
+
|
240
|
+
So you can invoke the script by typing "envi" from the commandline,
|
241
|
+
without the quotes; if you installed it as a gem into a prefix
|
242
|
+
other than /usr, it may be that the bin/ directory resides only
|
243
|
+
in that gem, though. Setting an alias may help in this case.
|
244
|
+
|
245
|
+
## Colours used by the EnvironmentInformation project
|
246
|
+
|
247
|
+
Support for colours is available through the **colours** gem. In theory
|
248
|
+
any other colour-related gem could be used as well, but this may require
|
249
|
+
someone to write support-code for this, in regards to other gems.
|
250
|
+
|
251
|
+
Presently (August 2020) this project only uses the **colours** gem
|
252
|
+
(**gem install colours**) though.
|
253
|
+
|
254
|
+
You can specifically **disable** the use of colours for the current
|
255
|
+
invocation run, from the commandline, via either:
|
256
|
+
|
257
|
+
envi --disable-colours
|
258
|
+
envi --disable-colors
|
259
|
+
envi --nocolours
|
260
|
+
envi --nocolors
|
261
|
+
envi --no-colours
|
262
|
+
|
263
|
+
envi --really-all --disable-colours
|
264
|
+
envi --really-all --disable-colors
|
265
|
+
|
266
|
+
envi --all --disable-colours
|
267
|
+
envi --all --disable-colors
|
268
|
+
|
269
|
+
Both UK and US spelling should work fine; use whatever you prefer.
|
270
|
+
|
271
|
+
Internally, the **@use_colours** variable is used to determine
|
272
|
+
whether colours are to be used. You can query the current
|
273
|
+
setting via the following toplevel method:
|
274
|
+
|
275
|
+
EnvironmentInformation.use_colours?
|
276
|
+
|
277
|
+
You can also query whether colours are used via **envi* as
|
278
|
+
well (the **bin/envi** file):
|
279
|
+
|
280
|
+
envi --use-colours?
|
281
|
+
envi --use-colors?
|
282
|
+
|
283
|
+
## fenvi
|
284
|
+
|
285
|
+
There is an executable at **bin/fast_envi**, as part of this gem, which
|
286
|
+
complements the executable at **bin/envi**. envi is simply an abbreviation
|
287
|
+
to "environment information"; and fenvi stands for "fast environment
|
288
|
+
information". That is exactly the primary use case for fenvi - it shall
|
289
|
+
allow for maximum speed, without "maximal usability". The latter means
|
290
|
+
that fenvi will not offer as much customization/flexibility as envi
|
291
|
+
does. In fact - the EnvironmentInformation project was rewritten in
|
292
|
+
**September 2019** precisely to make the whole project much more
|
293
|
+
performant and faster; the old code was too slow, for various reasons.
|
294
|
+
(Note: I am using an alias called fenvi that refers to fenvi; the
|
295
|
+
official name of the executable **fast_envi** though.)
|
296
|
+
|
297
|
+
Nonetheless, **fenvi** also supports some commandline flags.
|
298
|
+
|
299
|
+
For example, if you wish to only show the registered xorg components
|
300
|
+
and their corresponding versions, then you can issue the following
|
301
|
+
flag:
|
302
|
+
|
303
|
+
fenvi --xorg
|
304
|
+
|
305
|
+
This would **show all xorg components**.
|
306
|
+
|
307
|
+
fenvi --help
|
308
|
+
|
309
|
+
Would show the help options. Right now this is limited to just two
|
310
|
+
options (or perhaps a bit more than that in the long run).
|
311
|
+
|
312
|
+
Another option is:
|
313
|
+
|
314
|
+
fenvi --compare-to-program-versions
|
315
|
+
|
316
|
+
This can be used to quickly compare the program versions of the
|
317
|
+
local computer system. Note that this functionality depends on
|
318
|
+
the RBT gem:
|
319
|
+
|
320
|
+
gem install rbt
|
321
|
+
|
322
|
+
## Determining which programs should be shown on your own
|
323
|
+
|
324
|
+
You can decide to only show the version of some programs, via the
|
325
|
+
**commandline** specifically.
|
326
|
+
|
327
|
+
For example, say that you wish to see only the versions of **ruby**,
|
328
|
+
**python** and **perl**, then you could try the following:
|
329
|
+
|
330
|
+
envi --use-these-programs=ruby,python,perl
|
331
|
+
|
332
|
+
If you wish to display the local versions of **bash**, **binutils**
|
333
|
+
and **bison**, then you can try this:
|
334
|
+
|
335
|
+
envi --use-these-programs=bash,binutils,bison
|
336
|
+
|
337
|
+
If you wish to show all components that may be important for
|
338
|
+
the LFS (linux from scratch) project then you can use this:
|
339
|
+
|
340
|
+
envi --use-these-programs=bash,binutils,bison,flex,bzip2,coreutils,diffutils,find,awk,gcc,grep,gzip,linux,make,m4,patch,perl,python,sed,tar,texinfo,xz
|
341
|
+
|
342
|
+
Since that is a bit annoying to type (it's quite long), you can also
|
343
|
+
use the **fake-symbol** :lfs for this instead:
|
344
|
+
|
345
|
+
envi --use-these-programs=:lfs
|
346
|
+
|
347
|
+
Or, even simpler than that:
|
348
|
+
|
349
|
+
envi --lfs
|
350
|
+
|
351
|
+
In fact, this functionality has been added precisely to
|
352
|
+
avoid using a shell script, such as this one:
|
353
|
+
|
354
|
+
http://www.linuxfromscratch.org/lfs/view/development/chapter02/hostreqs.html
|
355
|
+
|
356
|
+
The name **fake-symbol** is given because via the commandline
|
357
|
+
you can only pass e. g. a String, not a Symbol, as bash does
|
358
|
+
not know what a Symbol is. So if a string has a leading :
|
359
|
+
then the EnvironmentInformation project will assume that the
|
360
|
+
user wanted to convey a **special meaning**.
|
361
|
+
|
362
|
+
If you do not wish to save any local file then invoke EnvironmentInformation
|
363
|
+
in this way:
|
364
|
+
|
365
|
+
envi --lfs --no-save
|
366
|
+
|
367
|
+
If you wish to show the local version of openssl as well, try
|
368
|
+
adding this commandline flag:
|
369
|
+
|
370
|
+
envi --openssl
|
371
|
+
|
372
|
+
## xorg components
|
373
|
+
|
374
|
+
To display the registered **xorg components**, you could use any of
|
375
|
+
the following commandline flags:
|
376
|
+
|
377
|
+
envi --xorg-components
|
378
|
+
envi --xorg
|
379
|
+
|
380
|
+
Do note that not necessarily every xorg component is registered,
|
381
|
+
but most of the xorg-components should be covered by now.
|
382
|
+
|
383
|
+
## Reading from a local file
|
384
|
+
|
385
|
+
The **EnvironmentInformation project** can read from a **local file**
|
386
|
+
containing the programs whose version you would like to show, on the
|
387
|
+
commandline.
|
388
|
+
|
389
|
+
The commandline invocation goes like this:
|
390
|
+
|
391
|
+
envi --read-from-this-file=/Depot/j/display_these_programs.md
|
392
|
+
envi --file=/Depot/j/display_these_programs.md
|
393
|
+
envi --input-from=/Depot/j/display_these_programs.md
|
394
|
+
|
395
|
+
The reason as to why this functionality has been made available
|
396
|
+
is so that people can use their own custom input to the main
|
397
|
+
class of this gem, if they would like to.
|
398
|
+
|
399
|
+
A requirement for this to work is that there is a corresponding
|
400
|
+
component that can query the version of a program. I am open for
|
401
|
+
suggestions what to add, if anything is missing, as well as
|
402
|
+
including a more generic way to make a query. Either way this
|
403
|
+
depends on others to make suggestions.
|
404
|
+
|
405
|
+
## Sorting the components alphabetically
|
406
|
+
|
407
|
+
You can display the components in an alphabetical manner, if you
|
408
|
+
would like to, through this:
|
409
|
+
|
410
|
+
envi --sort-alphabetically
|
411
|
+
|
412
|
+
## Sinatra interface
|
413
|
+
|
414
|
+
Since as of **May 2019** there is now a small sinatra "interface"
|
415
|
+
available.
|
416
|
+
|
417
|
+
To start it, try:
|
418
|
+
|
419
|
+
envi --sinatra
|
420
|
+
|
421
|
+
In order for this to work, you need to have sinatra installed, such as
|
422
|
+
via this way:
|
423
|
+
|
424
|
+
gem install sinatra
|
425
|
+
|
426
|
+
or
|
427
|
+
|
428
|
+
gem install sinatra --user-install # into the home directory
|
429
|
+
|
430
|
+
It is not a mandatory dependency for this gem, so it is not registered
|
431
|
+
to be a hard dependency in the **.gemspec** file.
|
432
|
+
|
433
|
+
## The science cluster
|
434
|
+
|
435
|
+
There are also a few science-related applications, such as for hmmer
|
436
|
+
or relion. To query their versions specifically you can issue:
|
437
|
+
|
438
|
+
envi --science
|
439
|
+
|
440
|
+
## Show the URL of every registered program
|
441
|
+
|
442
|
+
You can, if you like to, show the remote URLs to the different
|
443
|
+
programs, if you have the **RBT project** installed (**gem install rbt**).
|
444
|
+
|
445
|
+
Then, you should be able to do the following:
|
446
|
+
|
447
|
+
envi --everything --show-remote-url
|
448
|
+
|
449
|
+
This variant will not only display the local programs found,
|
450
|
+
but will additionally also show the **remote URLs** on the
|
451
|
+
commandline, on the right hand side, to the corresponding
|
452
|
+
program at hand.
|
453
|
+
|
454
|
+
## Only display the operating system in use
|
455
|
+
|
456
|
+
If you are only interested in seeing the operating system, try
|
457
|
+
this **commandline flag**:
|
458
|
+
|
459
|
+
envi --os?
|
460
|
+
|
461
|
+
## Showing additional programs on an ad-hoc basis
|
462
|
+
|
463
|
+
You can also show additional individual components via the **--additional**
|
464
|
+
flag, like this:
|
465
|
+
|
466
|
+
envi --additional=php,python,perl
|
467
|
+
|
468
|
+
This would display the local versions of the installed programs
|
469
|
+
**php**, **python** and **perl**.
|
470
|
+
|
471
|
+
Note that since as of **September 2019** you can also add the
|
472
|
+
name of the component directly. For example, to show the
|
473
|
+
version of bash, you can invoke envi like this:
|
474
|
+
|
475
|
+
envi --bash
|
476
|
+
|
477
|
+
To also show php and python, you can do this:
|
478
|
+
|
479
|
+
envi --bash --php --python
|
480
|
+
|
481
|
+
Use whichever variant you prefer - the choices are up to the user.
|
482
|
+
|
483
|
+
## Ruby-gtk bindings
|
484
|
+
|
485
|
+
A small **gtk-widget** exists, which can be started via either of:
|
486
|
+
|
487
|
+
envi --gui
|
488
|
+
envi --gtk
|
489
|
+
|
490
|
+
Note that this requires the **ruby-gtk package**, in particular
|
491
|
+
**gtk2**, and possibly also the gem called **gtk_paradise**.
|
492
|
+
|
493
|
+
Installing these could be done through the following commandline
|
494
|
+
invocations:
|
495
|
+
|
496
|
+
gem install gtk2
|
497
|
+
gem install gtk3
|
498
|
+
gem install gtk_paradise
|
499
|
+
|
500
|
+
You may need the "devel" packages (.h files) for this to work.
|
501
|
+
|
502
|
+
The **gtk** widget is really just extremely simple, and thus not too
|
503
|
+
terribly useful, since it lacks functionality; I only wanted to be
|
504
|
+
able to **embed this information** into other ruby-gtk applications.
|
505
|
+
At some point in the future, the functionality may be extended - but
|
506
|
+
for the time being, it will remain simple. **Simple is beautiful**,
|
507
|
+
too.
|
508
|
+
|
509
|
+
Presently (September 2019) the gtk-bindings in the
|
510
|
+
**environment_information** project only support **ruby-gtk2**,
|
511
|
+
but in the future I may switch to **ruby-gtk3** - or at the
|
512
|
+
least offer means for the user to decide which variant is
|
513
|
+
to be used.
|
514
|
+
|
515
|
+
## No changelog entries any longer
|
516
|
+
|
517
|
+
In the past, changes to this project were listed specifically, together
|
518
|
+
with the date - a short changelog.
|
519
|
+
|
520
|
+
However had, most users are probably more interested in the options
|
521
|
+
and features that are supported as-is; the features that are available
|
522
|
+
right **now**. Seeing every unimportant change made in the long
|
523
|
+
forgotten past, is not that useful for most users. Additionally, for
|
524
|
+
**small projects**, a changelog is not really that worthwhile to be
|
525
|
+
had to begin with.
|
526
|
+
|
527
|
+
So, I have abandoned the concept of a changelog for this project. Do
|
528
|
+
note that if there is something noteworthy that has been changed, it
|
529
|
+
will be mentioned and documented here in this file (**README.md**)
|
530
|
+
anyway.
|
531
|
+
|
532
|
+
## How to add new components/entries to this project
|
533
|
+
|
534
|
+
The file <b>environment_information/constants/array_tracked_components.rb</b>
|
535
|
+
keeps track over all available entries.
|
536
|
+
|
537
|
+
The method called **return_default_programs_on_a_linux_computer**,
|
538
|
+
defined in the file <b>environment_information/base/misc.rb</b>,
|
539
|
+
will add all the entries that are, assumingly, useful on a linux
|
540
|
+
computer by default.
|
541
|
+
|
542
|
+
If you want to change the entries, or add new ones, look there first.
|
543
|
+
If you wish to register a new program, you have to add it onto the
|
544
|
+
main Array (in the constants.rb file) first.
|
545
|
+
|
546
|
+
You will also have to add a method that does the actual **query**
|
547
|
+
part for the program version at hand, within the
|
548
|
+
<b>environment_information/individual_components/</b> subdirectory.
|
549
|
+
|
550
|
+
It may be simplest to just copy one of those .rb files, by giving it
|
551
|
+
the same name as the program you wish to see displayed. You will
|
552
|
+
then have to **change the content** of that method too, in that
|
553
|
+
new file, but this is quite trivial and takes at maximum five
|
554
|
+
minutes (for those who have not seen it before; it takes
|
555
|
+
significantly less time for those who already know what to change
|
556
|
+
there). Entries that come with **pkg-config .pc files** are even
|
557
|
+
simpler to add - this is much easier than manually parsing
|
558
|
+
**--version** flags.
|
559
|
+
|
560
|
+
In the future I may switch to a yaml file rather than hardcode
|
561
|
+
the entries in .rb directly, but for the time being, I will stick
|
562
|
+
to the method described above.
|
563
|
+
|
564
|
+
## Short display variant
|
565
|
+
|
566
|
+
If you only wish to quickly view the most important information
|
567
|
+
about the local computer system, then you can use the following
|
568
|
+
variant:
|
569
|
+
|
570
|
+
envi --short
|
571
|
+
|
572
|
+
## Caveats
|
573
|
+
|
574
|
+
Note that the **EnvironmentInformation** project has to sometimes guess
|
575
|
+
how to obtain the necessary information, in order to determine which
|
576
|
+
program is installed. For example, for programs such as **readline**
|
577
|
+
there is no trivial way to determine which version is used, to
|
578
|
+
**EnvironmentInformation** will attempt to read the .so files, and
|
579
|
+
determine the version from the .so files. This may fail, depending
|
580
|
+
on the setup of the host computer.
|
581
|
+
|
582
|
+
In general, the two best ways to determine the version of programs
|
583
|
+
are via a **--version** flag or simply by using **pkg-config** to
|
584
|
+
query the .pc file of the package. But this is not available for
|
585
|
+
all programs, so ultimately **EnvironmentInformation** may not
|
586
|
+
display completely accurate information on all given computer
|
587
|
+
systems.
|
588
|
+
|
589
|
+
## Clearing the old dataset
|
590
|
+
|
591
|
+
Via **--clear** on the commandline you can remove all old entries.
|
592
|
+
This commandline flag thus resets **class EnvironmentInformation**
|
593
|
+
to a totally clean, fresh state. Internally the method .reset() will
|
594
|
+
be called on **class EnvironmentInformation**.
|
595
|
+
|
596
|
+
This allows you to show only one component, or a few components,
|
597
|
+
for example. The following example demonstrates this.
|
598
|
+
|
599
|
+
Say that you wish to show **only** **python** and **php**, thus
|
600
|
+
two programs only. Then you can use the following flag to achieve
|
601
|
+
this, in this order:
|
602
|
+
|
603
|
+
envi --clear --python --php
|
604
|
+
|
605
|
+
The order is important because --clear will clear at the moment
|
606
|
+
it occurs in **ARGV**, which holds the commandline-arguments
|
607
|
+
issued on the commandline by the user.
|
608
|
+
|
609
|
+
## Which packages will be checked by default?
|
610
|
+
|
611
|
+
The following provides a list of packages that are presently,
|
612
|
+
in **October of 2019**, tracked.
|
613
|
+
|
614
|
+
In the past I did manually copy/paste the following listing, but
|
615
|
+
since as of 15th of October 2019, the list is **autogenerated** via
|
616
|
+
a macro.
|
617
|
+
|
618
|
+
This listing can be seen in the **file**:
|
619
|
+
|
620
|
+
environment_information/constants/array_tracked_components.rb
|
621
|
+
|
622
|
+
These are the following programs:
|
623
|
+
|
624
|
+
ADD_ENVIRONMENT_INFORMATION_PROPERLY_FORMATTED_ARRAY
|
625
|
+
|
626
|
+
You can also display these programs dynamically, such as through the
|
627
|
+
following **API**:
|
628
|
+
|
629
|
+
require 'environment_information'
|
630
|
+
|
631
|
+
pp EnvironmentInformation.tracked_programs?
|
632
|
+
|
633
|
+
Note that since as of **March 2019**, environment_information will also attempt
|
634
|
+
to find out the installed version for **gmp**, **mpfr** and **mpc**. This
|
635
|
+
may fail, though, and will be silently ignored in these cases (at least
|
636
|
+
for the time being).
|
637
|
+
|
638
|
+
You can use the following method to display a list of all programs
|
639
|
+
that are registered, from the commandline:
|
640
|
+
|
641
|
+
envi --registered-components?
|
642
|
+
|
643
|
+
This will show every registered (and thus, available) component of this
|
644
|
+
project.
|
645
|
+
|
646
|
+
As of **February 2020**, this project tracks at the least 105 different
|
647
|
+
programs. More entries will be added in the future, but the primary
|
648
|
+
focus will be on a **Linux from Scratch** / **Beyond Linux from Scratch**
|
649
|
+
setup, so expect those programs that are installed first, to be added
|
650
|
+
next, too.
|
651
|
+
|
652
|
+
## Querying the components that will be shown
|
653
|
+
|
654
|
+
You can query the components that will be shown, by issuing one of
|
655
|
+
the following commands:
|
656
|
+
|
657
|
+
envi --show-components?
|
658
|
+
envi --show-components
|
659
|
+
|
660
|
+
Note that this works exclusively, meaning that if you use this
|
661
|
+
commandline switch, then you will ONLY get a query of the
|
662
|
+
components that are available.
|
663
|
+
|
664
|
+
## Replaying the information
|
665
|
+
|
666
|
+
Normally showing all information when issuing **envi --RALL** can take
|
667
|
+
quite some time; on my computer system 18 seconds, before the rewrite
|
668
|
+
in February 2020.
|
669
|
+
|
670
|
+
The reason as to why it takes that long is mostly because many different
|
671
|
+
files have to be queried; their --version flag has to be called or
|
672
|
+
their .pc file has to be checked, but most importantly querying data
|
673
|
+
from the **RBT project** currently takes way too long. This is not an
|
674
|
+
ideal situation, as nobody wants to wait.
|
675
|
+
|
676
|
+
Waiting 18 seconds is simply too long, though, but until that part in
|
677
|
+
RBT is improved, I have added a **--replay** functionality for **class
|
678
|
+
EnvironmentInformation** (via the commandline).
|
679
|
+
|
680
|
+
What this functionality does is to take an available (existing) .yml
|
681
|
+
file that holds the information from the last invocation run, and then
|
682
|
+
proceeds to display this information on the commandline to the user.
|
683
|
+
This will evidently be much faster, since the information has already
|
684
|
+
been stored before in a prior run.
|
685
|
+
|
686
|
+
This change required that the environment information project will
|
687
|
+
also generate a **.yml file** by default.
|
688
|
+
|
689
|
+
Note that this functionality is not yet complete; I will extend this
|
690
|
+
at a later time (written this part here as of **December 2019**).
|
691
|
+
|
692
|
+
You can disable saving into this .yml file via:
|
693
|
+
|
694
|
+
envi --no-yaml-file
|
695
|
+
|
696
|
+
To invoke the replay functionality, do:
|
697
|
+
|
698
|
+
envi --replay
|
699
|
+
|
700
|
+
## Avoid the creation of local files
|
701
|
+
|
702
|
+
By default, the main class in this project may generate a few local
|
703
|
+
files. This may not always be wanted, or possible (e. g. in a
|
704
|
+
read-only filesystem), so an option has to exist that disables
|
705
|
+
this functionality.
|
706
|
+
|
707
|
+
That option is called **--no-save** and can be used like this:
|
708
|
+
|
709
|
+
envi --lfs --no-save
|
710
|
+
|
711
|
+
## Using another prefix
|
712
|
+
|
713
|
+
By default, the environment_information project will assume that
|
714
|
+
the main prefix is / or /usr, respectively. In other words, it
|
715
|
+
will assume that, for example, the binary called "bison" will
|
716
|
+
reside at /usr/bin/bison. To be more correct, it will make use
|
717
|
+
of the PATH environment variable, but for most users this will
|
718
|
+
list /usr/bin/ first.
|
719
|
+
|
720
|
+
That way "bison --version" should work and be the same as
|
721
|
+
"/usr/bin/bison --version".
|
722
|
+
|
723
|
+
For pkg-config .pc files, the main target will usually then
|
724
|
+
be at /usr/lib/pkgconfig/.
|
725
|
+
|
726
|
+
Note that the above is not always a correct assumption. For
|
727
|
+
example, the **GoboLinux approach** uses the **/Programs/**
|
728
|
+
hierarchy instead (but it also keeps legacy symlinks, so in
|
729
|
+
fact GoboLinux works just like any other linux distribution too).
|
730
|
+
|
731
|
+
On my home setup, I tend to use /home/Programs/ since some
|
732
|
+
time - mostly because I tend to relocate /home/ in general
|
733
|
+
or may keep it on a separate partition.
|
734
|
+
|
735
|
+
For these latter use cases we require another way to quickly
|
736
|
+
list all versions of different programs. On 14.01.2020
|
737
|
+
support for this has been (partially) added.
|
738
|
+
|
739
|
+
Invoke this like so:
|
740
|
+
|
741
|
+
envi --work-on-programs-directory-only
|
742
|
+
|
743
|
+
Note that this would use /home/Programs/ right now, which
|
744
|
+
is hardcoded - and thus not flexible.
|
745
|
+
|
746
|
+
I am aware of this limitation, so expect more code changes
|
747
|
+
in the future to extend this functionality.
|
748
|
+
|
749
|
+
One key idea for this is to set up /home/Programs/Toolchain/
|
750
|
+
and have that one work reliably to cross-compile different
|
751
|
+
architectures, libc libraries and so forth. But for now,
|
752
|
+
this subsection is a stub.
|
753
|
+
|
754
|
+
## Rationale as to why some programs may work and some may not
|
755
|
+
|
756
|
+
Querying the specific version installed on a given computer
|
757
|
+
system can be tricky. If a **.pc file** is available (**pkg-config**)
|
758
|
+
then querying the version is quite trivial. If a **binary** is
|
759
|
+
available then often **--version** or **-V** will work. But
|
760
|
+
sometimes there is no binary, and no .pc file either. So what
|
761
|
+
to do in such a case?
|
762
|
+
|
763
|
+
This is not simple to answer, since it may depend on the
|
764
|
+
program at hand.
|
765
|
+
|
766
|
+
It may be possible to infer the proper version from the
|
767
|
+
library at hand e. g. **/usr/lib/foobar.so.4.8.2**. Here
|
768
|
+
we could assume that the version will be 4.8.2, but this
|
769
|
+
is not necessarily guaranteed to work, either.
|
770
|
+
|
771
|
+
In the past, before the rewrite of this project in **February 2020**,
|
772
|
+
the environment_information project had used code that would
|
773
|
+
check for such conditions - for example, for **readline**,
|
774
|
+
and look for specific .so files under **/usr/lib/** or
|
775
|
+
elsewhere.
|
776
|
+
|
777
|
+
But the resulting code that had to be written for this, was not
|
778
|
+
very elegant, and takes about 10-20 lines of code for checking
|
779
|
+
this, including fall-backs, for each program that does not
|
780
|
+
conform to --version or a .pc file. I am no longer sure whether
|
781
|
+
it is worth to add that code, since it also may have to be
|
782
|
+
maintained, and is not always perfect nor does it always work,
|
783
|
+
depending on the computer system at hand. So, past this point,
|
784
|
+
**environment_information** is not doing its best to query the
|
785
|
+
version for all programs - it will try pkg-config and
|
786
|
+
--version or -V in most cases, and if that fails then
|
787
|
+
the environment_information project will assume that the
|
788
|
+
program at hand is not installed.
|
789
|
+
|
790
|
+
This may be a **false negative**, but to me it appears
|
791
|
+
to be better in the long run, in regards to maintainability
|
792
|
+
of the whole project. After all one reason for the rewrite
|
793
|
+
in 2020 was to simplify the whole project, and this objective
|
794
|
+
has been achieved - all the commands are now stored in yaml
|
795
|
+
files, and that is so much simpler to handle than the
|
796
|
+
corresponding ruby methods that were used before that.
|
797
|
+
|
798
|
+
## Adding new entries to EnvironmentInformation
|
799
|
+
|
800
|
+
New entries can be added into the following yaml file:
|
801
|
+
|
802
|
+
**query_to_use_for_the_individual_components.yml**
|
803
|
+
|
804
|
+
The two most commonly used variants there are version,
|
805
|
+
for **bin/foo --version* invocations, and pkgconfig,
|
806
|
+
for querying pkg-config .pc files. However had, many
|
807
|
+
programs make use of different invocation variants,
|
808
|
+
don't come with a .pc file, and have no binaries.
|
809
|
+
Querying the correct version of such files is difficult
|
810
|
+
since there is no standard. This is a reason why the
|
811
|
+
code has to handle these cases.
|
812
|
+
|
813
|
+
But in principle, adding a new entry is as simple as
|
814
|
+
adding a new line into that .yml file (and registering
|
815
|
+
that component in a second .yml file).
|
816
|
+
|
817
|
+
## The toplevel main hash
|
818
|
+
|
819
|
+
EnvironmentInformation tries to store the information that
|
820
|
+
it has collected into a **hash**, which can be accessed like
|
821
|
+
this quickly:
|
822
|
+
|
823
|
+
EnvironmentInformation.hash?
|
824
|
+
|
825
|
+
By default this hash is empty, so you have to fill it up
|
826
|
+
first, if you want to do so, via the following method:
|
827
|
+
|
828
|
+
EnvironmentInformation.initialize
|
829
|
+
|
830
|
+
hash = EnvironmentInformation.hash? # ← and here you can query it
|
831
|
+
|
832
|
+
The hash can then be used as basis for reporting at a later time,
|
833
|
+
or replaying that information via the **--replay** commandline
|
834
|
+
switch to the executable.
|
835
|
+
|
836
|
+
## Dependencies of the EnvironmentInformation project
|
837
|
+
|
838
|
+
The sole dependency for the **environment_information gem**
|
839
|
+
is on the **colours** gem.
|
840
|
+
|
841
|
+
Up until the beginning of March 2020, the EnvironmentInformation
|
842
|
+
project also depended on the **opn gem**. However had, I
|
843
|
+
noticed that in a restricted environment installation of
|
844
|
+
gems can be difficult, so I made opn **optional**. If you have
|
845
|
+
it installed then EnvironmentInformation will still try to
|
846
|
+
make use of the **Opn namespace**; and if it is not installed
|
847
|
+
then EnvironmentInformation will simply **skip** Opn completely.
|
848
|
+
|
849
|
+
## Rationale behind the different queries
|
850
|
+
|
851
|
+
As was already explained, different programs require different
|
852
|
+
ways to determine which version is installed. Some projects
|
853
|
+
would allow more than one way, such as the --version flag,
|
854
|
+
but also querying .pc files. Ruby, for example, supports both
|
855
|
+
--version, and comes with a .pc file (if you compiled it from
|
856
|
+
source, at the least).
|
857
|
+
|
858
|
+
So, which way to choose?
|
859
|
+
|
860
|
+
In my opinion, .pc files are better than --version, for
|
861
|
+
at the least two reasons:
|
862
|
+
|
863
|
+
- The resulting code to handle this is much simpler. .pc
|
864
|
+
files are quite uniform, whereas the output of --version
|
865
|
+
is very dissimilar between different programs.
|
866
|
+
|
867
|
+
- Another reason is that invoking the binary, just to
|
868
|
+
do a --version, is actually more expensive (CPU-wise)
|
869
|
+
than it is to query a simple text file, which is
|
870
|
+
essentially what .pc files are. So this is another reason
|
871
|
+
in favour of .pc files.
|
872
|
+
|
873
|
+
For these reasons, and a few smaller ones, the EnvironmentInformation
|
874
|
+
project will try to prefer .pc files whenever that is possible.
|
875
|
+
We may retain code that can handle --version calls, though,
|
876
|
+
if they need a special way to query.
|
877
|
+
|
878
|
+
## Querying all registered pkg-config entries
|
879
|
+
|
880
|
+
To show all registered pkg-config entries (with .pc files)
|
881
|
+
do this:
|
882
|
+
|
883
|
+
envi --pkgconfig
|
884
|
+
|
885
|
+
If you want to obtain an Array of all outdated programs
|
886
|
+
on the target computer system, try this method:
|
887
|
+
|
888
|
+
EnvironmentInformation.return_array_of_outdated_programs
|
889
|
+
|
890
|
+
You need to have initialized the main hash once, before
|
891
|
+
being able to make use of that method.
|
892
|
+
|
893
|
+
ADD_CONTACT_INFORMATION
|