environment_information 1.4.124

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.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1322 -0
  3. data/bin/envi +7 -0
  4. data/bin/fast_envi +7 -0
  5. data/doc/README.gen +1058 -0
  6. data/doc/todo/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +55 -0
  7. data/environment_information.gemspec +135 -0
  8. data/lib/environment_information/base/base.rb +166 -0
  9. data/lib/environment_information/class/class.rb +2580 -0
  10. data/lib/environment_information/class/colours.rb +282 -0
  11. data/lib/environment_information/colours/colours.rb +224 -0
  12. data/lib/environment_information/colours/sfancy.rb +19 -0
  13. data/lib/environment_information/colours/simp.rb +19 -0
  14. data/lib/environment_information/constants/array_tracked_components.rb +210 -0
  15. data/lib/environment_information/constants/constants.rb +17 -0
  16. data/lib/environment_information/constants/encoding.rb +21 -0
  17. data/lib/environment_information/constants/error_line.rb +17 -0
  18. data/lib/environment_information/constants/file_constants.rb +102 -0
  19. data/lib/environment_information/constants/misc.rb +86 -0
  20. data/lib/environment_information/constants/namespace.rb +14 -0
  21. data/lib/environment_information/constants/newline.rb +16 -0
  22. data/lib/environment_information/constants/regex.rb +30 -0
  23. data/lib/environment_information/constants/temp_directory.rb +52 -0
  24. data/lib/environment_information/gui/jruby/environment_information.rb +77 -0
  25. data/lib/environment_information/gui/shared_code/environment_information/environment_information_module.rb +99 -0
  26. data/lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb +419 -0
  27. data/lib/environment_information/misc_components/README.md +3 -0
  28. data/lib/environment_information/misc_components/cflags.rb +36 -0
  29. data/lib/environment_information/misc_components/cpuinfo.rb +64 -0
  30. data/lib/environment_information/misc_components/operating_system.rb +54 -0
  31. data/lib/environment_information/misc_components/operating_system_bit_type.rb +42 -0
  32. data/lib/environment_information/misc_components/ram.rb +30 -0
  33. data/lib/environment_information/misc_components/rubygems_installation_directory.rb +54 -0
  34. data/lib/environment_information/misc_components/screen_resolution.rb +50 -0
  35. data/lib/environment_information/project/project.rb +27 -0
  36. data/lib/environment_information/queries/README.md +2 -0
  37. data/lib/environment_information/queries/complex_version.rb +273 -0
  38. data/lib/environment_information/queries/pkg_config.rb +125 -0
  39. data/lib/environment_information/queries/simple_version.rb +272 -0
  40. data/lib/environment_information/requires/require_asciitable.rb +15 -0
  41. data/lib/environment_information/requires/require_the_constants.rb +7 -0
  42. data/lib/environment_information/requires/require_the_environment_information_project.rb +23 -0
  43. data/lib/environment_information/requires/require_the_individual_misc_components.rb +30 -0
  44. data/lib/environment_information/requires/require_the_toplevel_methods.rb +22 -0
  45. data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +153 -0
  46. data/lib/environment_information/toplevel_methods/cd.rb +16 -0
  47. data/lib/environment_information/toplevel_methods/e.rb +43 -0
  48. data/lib/environment_information/toplevel_methods/hash.rb +65 -0
  49. data/lib/environment_information/toplevel_methods/internet_is_available.rb +30 -0
  50. data/lib/environment_information/toplevel_methods/is_on_roebe.rb +16 -0
  51. data/lib/environment_information/toplevel_methods/menu.rb +90 -0
  52. data/lib/environment_information/toplevel_methods/misc.rb +324 -0
  53. data/lib/environment_information/toplevel_methods/n_subcommands.rb +31 -0
  54. data/lib/environment_information/toplevel_methods/prefix_to_use.rb +39 -0
  55. data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +61 -0
  56. data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +45 -0
  57. data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +84 -0
  58. data/lib/environment_information/toplevel_methods/return_alias_to.rb +30 -0
  59. data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +28 -0
  60. data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +54 -0
  61. data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +28 -0
  62. data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +182 -0
  63. data/lib/environment_information/toplevel_methods/show_all_available_components.rb +192 -0
  64. data/lib/environment_information/toplevel_methods/write_what_into.rb +24 -0
  65. data/lib/environment_information/version/version.rb +25 -0
  66. data/lib/environment_information/www/sinatra_interface.rb +213 -0
  67. data/lib/environment_information/www/webobject_interface.cgi +29 -0
  68. data/lib/environment_information/yaml/array_default_programs_on_linux.yml +15 -0
  69. data/lib/environment_information/yaml/array_lfs_core_programs.yml +37 -0
  70. data/lib/environment_information/yaml/array_science_cluster.yml +12 -0
  71. data/lib/environment_information/yaml/array_tracked_non_programs.yml +13 -0
  72. data/lib/environment_information/yaml/array_tracked_programs.yml +235 -0
  73. data/lib/environment_information/yaml/array_tracked_xorg_components.yml +37 -0
  74. data/lib/environment_information/yaml/colours.yml +3 -0
  75. data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +284 -0
  76. data/lib/environment_information.rb +5 -0
  77. data/test/testing_environment_information.rb +26 -0
  78. data/test/testing_missing_components.rb +9 -0
  79. data/test/testing_prefix_for_the_environment_information_project.rb +20 -0
  80. metadata +177 -0
data/doc/README.gen ADDED
@@ -0,0 +1,1058 @@
1
+ DEFAULT_HEADER
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 on a black background:
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 (as a Hash inside
221
+ of that block), if you would like to:
222
+
223
+ _ = EnvironmentInformation.new(:do_not_run_yet) {{
224
+ n_tokens: 58,
225
+ use_colours: no,
226
+ be_silent: true
227
+ show_ruby_stuff: no
228
+ }}
229
+ _.run
230
+
231
+ Do note that the following **API** also works, primarily due to
232
+ convenience - you can try it in **irb**, of course:
233
+
234
+ require 'environment_information'
235
+
236
+ EnvironmentInformation[]
237
+
238
+ The executable version for class EnvironmentInformation is called <b>envi</b>.
239
+ It will reside under **bin/envi** of this gem.
240
+
241
+ So you can invoke the script by typing "envi" from the commandline,
242
+ without the quotes; if you installed it as a gem into a prefix
243
+ other than /usr, it may be that the bin/ directory resides only
244
+ in that gem, though. Setting an alias may help in this case.
245
+
246
+ ## Colours used by the EnvironmentInformation project
247
+
248
+ Support for colours in the <b>environment_information</b> gem
249
+ is available through the following file:
250
+
251
+ environment_information/colours/colours.rb
252
+
253
+ Which, in turn, taps into the **colours** gem.
254
+
255
+ In theory other colour-related gems could be used as well, but this may
256
+ require someone to write support-code for this, in regards to other
257
+ gems.
258
+
259
+ Presently (August 2020; September 2022) this project <b>only</b> uses
260
+ the **colours** gem (**gem install colours**), though.
261
+
262
+ You can specifically **disable** the use of colours for the current
263
+ invocation run, for whatever the reasons, from the commandline,
264
+ via either:
265
+
266
+ envi --disable-colours
267
+ envi --disable-colors
268
+ envi --nocolours
269
+ envi --nocolors
270
+ envi --no-colours
271
+
272
+ envi --really-all --disable-colours
273
+ envi --really-all --disable-colors
274
+
275
+ envi --all --disable-colours
276
+ envi --all --disable-colors
277
+
278
+ Note that <b>envi</b> refers to <b>bin/envi</b>, which is distributed
279
+ as part of this gem.
280
+
281
+ Both UK and US spelling should work fine in regards to colours/colors;
282
+ use whichever variant you prefer. As I was taught the UK spelling in
283
+ school, I prefer the UK spelling in general.
284
+
285
+ Internally, the <b>@use_colours</b> variable is used to determine
286
+ whether colours are to be used for the main class of this gem.
287
+
288
+ You can <b>query</b> the current setting via the following toplevel
289
+ method (in ruby):
290
+
291
+ EnvironmentInformation.use_colours?
292
+
293
+ You can also query whether colours are used via <b>envi</b>
294
+ as well (the **bin/envi** file) from the commandline, via:
295
+
296
+ envi --use-colours?
297
+ envi --use-colors?
298
+
299
+ The default assumption for commandline use of this gem is that
300
+ the user uses a black/dark background in the terminal; and white
301
+ colour for the text, or at the least some light/bright colour.
302
+
303
+ Not every uses uses a black background, though. In these cases
304
+ the default colours used by the environment_gem are not optimal.
305
+
306
+ Because this may be a concern for some users, support was added
307
+ to the environment_information gem to allow them to use different
308
+ colours if they want to. So, not only can you disable colours
309
+ altogether, but you can also fine-tune them to your liking, if
310
+ you want to.
311
+
312
+ The file that will handle this is a .yml file and it normally
313
+ resides at:
314
+
315
+ environment_information/yaml/colours.yml
316
+
317
+ Currently (September 2022) it only covers two values - the
318
+ colour for the left-hand display, and the colour for the
319
+ right-hand display. This refers to the table-layout that
320
+ you can see when you use the environment_gem (bin/envi)
321
+ on the commandline. To the left side one will typically
322
+ see the name of the program; to the right side the version
323
+ of that program is shown. The two colour names used in
324
+ the .yml file will determine this. You can change the names
325
+ there; I use HTML colour names.
326
+
327
+ If the .yml file can not be found or is missing then the
328
+ two default colours in use will be <b>forestgreen</b>
329
+ (for the left side) and <b>steelblue</b> (for the
330
+ right side).
331
+
332
+ A third entry exists called <b>program_not_found</b>,
333
+ defaulting to <b>lightslategrey</b>. Most users probably may
334
+ not need to change this, but in the event that you would
335
+ like to, you can change it of course. In principle commandline
336
+ support could be added to change the colours on an ad-hoc
337
+ basis during a run of bin/envi, but for now I'll leave it
338
+ how it is. If someone wants to be able to fine-tune the colours
339
+ on the commandline, without wanting to modify the .yml file,
340
+ let me know; I'll add support in this case then.
341
+
342
+ Note that you can combine this in various means.
343
+
344
+ For instance, to show information about EVERY program,
345
+ and use a compact display without any newlines, while
346
+ also disabling colours, use the following:
347
+
348
+ envi --rall --oneliner --disable-colours
349
+
350
+ The following image shows how this looks:
351
+
352
+ <img src="https://i.imgur.com/dt3PhRY.png" style="margin: 2em">
353
+
354
+ Yes, this is not very elegant and hard(er) to read,
355
+ but imagine if you work on Linux runlevel 3, without
356
+ a GUI. In this case this can be convenient to have
357
+ in one terminal as you work.
358
+
359
+
360
+ ## fenvi
361
+
362
+ There is an executable at **bin/fast_envi**, as part of this gem, which
363
+ complements the executable at **bin/envi**. envi is simply an abbreviation
364
+ to "environment information"; and fenvi stands for "fast environment
365
+ information". That is exactly the primary use case for fenvi - it shall
366
+ allow for maximum speed, without "maximal usability". The latter means
367
+ that fenvi will not offer as much customization/flexibility as envi
368
+ does. In fact - the EnvironmentInformation project was rewritten in
369
+ **September 2019** precisely to make the whole project much more
370
+ performant and faster; the old code was too slow, for various reasons.
371
+ (Note: I am using an alias called fenvi that refers to fenvi; the
372
+ official name of the executable is **fast_envi** though.)
373
+
374
+ Nonetheless, **fenvi** also supports some commandline flags.
375
+
376
+ For example, if you wish to only show the registered xorg components
377
+ and their corresponding versions, then you can issue the following
378
+ flag:
379
+
380
+ fenvi --xorg
381
+
382
+ This would **show all xorg components**.
383
+
384
+ fenvi --help
385
+
386
+ Would show the help options. Right now this is limited to just two
387
+ options (or perhaps a bit more than that in the long run).
388
+
389
+ Another option is:
390
+
391
+ fenvi --compare-to-program-versions
392
+
393
+ This can be used to quickly compare the program versions of the
394
+ local computer system. Note that this functionality depends on
395
+ the RBT gem:
396
+
397
+ gem install rbt
398
+
399
+ ## Determining which programs should be shown on your own
400
+
401
+ You can decide to only show the version of some programs, via the
402
+ **commandline** specifically.
403
+
404
+ For example, say that you wish to see only the versions of **ruby**,
405
+ **python** and **perl**, then you could try the following:
406
+
407
+ envi --use-these-programs=ruby,python,perl
408
+
409
+ If you wish to display the local versions of **bash**, **binutils**
410
+ and **bison**, then you can try this:
411
+
412
+ envi --use-these-programs=bash,binutils,bison
413
+
414
+ If you wish to show all components that may be important for
415
+ the LFS (linux from scratch) project then you can use this:
416
+
417
+ 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
418
+
419
+ Since that is a bit annoying to type (it's quite long), you can also
420
+ use the **fake-symbol** :lfs for this instead:
421
+
422
+ envi --use-these-programs=:lfs
423
+
424
+ Or, even simpler than that:
425
+
426
+ envi --lfs
427
+
428
+ In fact, this functionality has been added precisely to
429
+ avoid using a shell script, such as this one:
430
+
431
+ http://www.linuxfromscratch.org/lfs/view/development/chapter02/hostreqs.html
432
+
433
+ The name **fake-symbol** is given because via the commandline
434
+ you can only pass e. g. a String, not a Symbol, as bash does
435
+ not know what a Symbol is. So if a string has a leading :
436
+ then the EnvironmentInformation project will assume that the
437
+ user wanted to convey a **special meaning**.
438
+
439
+ If you do not wish to save any local file then invoke EnvironmentInformation
440
+ in this way:
441
+
442
+ envi --lfs --no-save
443
+
444
+ If you wish to show the local version of openssl as well, try
445
+ adding this commandline flag:
446
+
447
+ envi --openssl
448
+
449
+ ## xorg components
450
+
451
+ To display the registered **xorg components**, you could use any of
452
+ the following commandline flags:
453
+
454
+ envi --xorg-components
455
+ envi --xorg
456
+
457
+ Do note that not necessarily every xorg component is registered,
458
+ but most of the xorg-components should be covered by now.
459
+
460
+ ## Reading from a local file
461
+
462
+ The **EnvironmentInformation project** can read from a **local file**
463
+ containing the programs whose version you would like to show, on the
464
+ commandline.
465
+
466
+ The commandline invocation goes like this:
467
+
468
+ envi --read-from-this-file=/Depot/j/display_these_programs.md
469
+ envi --file=/Depot/j/display_these_programs.md
470
+ envi --input-from=/Depot/j/display_these_programs.md
471
+
472
+ The reason as to why this functionality has been made available
473
+ is so that people can use their own custom input to the main
474
+ class of this gem, if they would like to.
475
+
476
+ A requirement for this to work is that there is a corresponding
477
+ component that can query the version of a program. I am open for
478
+ suggestions what to add, if anything is missing, as well as
479
+ including a more generic way to make a query. Either way this
480
+ depends on others to make suggestions.
481
+
482
+ ## Sorting the components alphabetically
483
+
484
+ You can display the components in an alphabetical manner, if you
485
+ would like to, through this:
486
+
487
+ envi --sort-alphabetically
488
+
489
+ ## Sinatra interface
490
+
491
+ Since as of **May 2019** there is now a small sinatra "interface"
492
+ available.
493
+
494
+ To start it, try:
495
+
496
+ envi --sinatra
497
+
498
+ In order for this to work, you need to have sinatra installed, such as
499
+ via this way:
500
+
501
+ gem install sinatra
502
+
503
+ or
504
+
505
+ gem install sinatra --user-install # into the home directory
506
+
507
+ It is not a mandatory dependency for this gem, so it is not registered
508
+ to be a hard dependency in the **.gemspec** file.
509
+
510
+ ## The science cluster
511
+
512
+ There are also a few science-related applications, such as for hmmer
513
+ or relion. To query their versions specifically you can issue:
514
+
515
+ envi --science
516
+
517
+ ## Show the URL of every registered program
518
+
519
+ You can, if you like to, show the remote URLs to the different
520
+ programs, if you have the **RBT project** installed (**gem install rbt**).
521
+
522
+ Then, you should be able to do the following:
523
+
524
+ envi --everything --show-remote-url
525
+
526
+ This variant will not only display the local programs found,
527
+ but will additionally also show the **remote URLs** on the
528
+ commandline, on the right hand side, to the corresponding
529
+ program at hand.
530
+
531
+ ## Only display the operating system in use
532
+
533
+ If you are only interested in seeing the operating system, try
534
+ this **commandline flag**:
535
+
536
+ envi --os?
537
+
538
+ ## Showing additional programs on an ad-hoc basis
539
+
540
+ You can also show additional individual components via the **--additional**
541
+ flag, like this:
542
+
543
+ envi --additional=php,python,perl
544
+
545
+ This would display the local versions of the installed programs
546
+ **php**, **python** and **perl**. You can add any additional
547
+ program as you see fit there, separated via ',' character -
548
+ this will, however had, only work if that program has been
549
+ registered in the <b>environment_information</b> gem.
550
+
551
+ Note that since as of **September 2019** you can also add the name
552
+ of the component directly. For example, to show the version of
553
+ bash, you can invoke envi like this:
554
+
555
+ envi --bash
556
+
557
+ To also show php and python, you can do this:
558
+
559
+ envi --bash --php --python
560
+
561
+ Use whichever variant you prefer - the choices are up to the user.
562
+
563
+ ## Ruby-gtk bindings
564
+
565
+ A small **gtk-widget** exists, which can be started via either of:
566
+
567
+ envi --gui
568
+ envi --gtk
569
+
570
+ Note that this requires the **ruby-gtk package**, in particular
571
+ **gtk2**, and possibly also the gem called **gtk_paradise**.
572
+
573
+ Installing these could be done through the following commandline
574
+ invocations:
575
+
576
+ gem install gtk2
577
+ gem install gtk3
578
+ gem install gtk_paradise
579
+
580
+ You may need the "devel" packages (.h files) for this to work.
581
+
582
+ The **gtk** widget is really just extremely simple, and thus not too
583
+ terribly useful, since it lacks functionality; I only wanted to be
584
+ able to **embed this information** into other ruby-gtk applications.
585
+ At some point in the future, the functionality may be extended - but
586
+ for the time being, it will remain simple. **Simple is beautiful**,
587
+ too.
588
+
589
+ Presently (September 2019) the gtk-bindings in the
590
+ **environment_information** project only support **ruby-gtk2**,
591
+ but in the future I may switch to **ruby-gtk3** - or at the
592
+ least offer means for the user to decide which variant is
593
+ to be used.
594
+
595
+ ## No changelog entries any longer
596
+
597
+ In the past, changes to this project were listed specifically, together
598
+ with the date - a short changelog.
599
+
600
+ However had, most users are probably more interested in the options
601
+ and features that are supported as-is; the features that are available
602
+ right **now**. Seeing every unimportant change made in the long
603
+ forgotten past, is not that useful for most users. Additionally, for
604
+ **small projects**, a changelog is not really that worthwhile to be
605
+ had to begin with.
606
+
607
+ So, I have abandoned the concept of a changelog for this project. Do
608
+ note that if there is something noteworthy that has been changed, it
609
+ will be mentioned and documented here in this file (**README.md**)
610
+ anyway.
611
+
612
+ ## How to add new components/entries to this project
613
+
614
+ The file <b>environment_information/constants/array_tracked_components.rb</b>
615
+ keeps track over all available entries.
616
+
617
+ The method called **return_default_programs_on_a_linux_computer**,
618
+ defined in the file <b>environment_information/base/misc.rb</b>,
619
+ will add all the entries that are, assumingly, useful on a linux
620
+ computer by default.
621
+
622
+ If you want to change the entries, or add new ones, look there first.
623
+ If you wish to register a new program, you have to add it onto the
624
+ main Array (in the constants.rb file) first.
625
+
626
+ You will also have to add a method that does the actual **query**
627
+ part for the program version at hand, within the
628
+ <b>environment_information/individual_components/</b> subdirectory.
629
+
630
+ It may be simplest to just copy one of those .rb files, by giving it
631
+ the same name as the program you wish to see displayed. You will
632
+ then have to **change the content** of that method too, in that
633
+ new file, but this is quite trivial and takes at maximum five
634
+ minutes (for those who have not seen it before; it takes
635
+ significantly less time for those who already know what to change
636
+ there). Entries that come with **pkg-config .pc files** are even
637
+ simpler to add - this is much easier than manually parsing
638
+ **--version** flags.
639
+
640
+ In the future I may switch to a yaml file rather than hardcode
641
+ the entries in .rb directly, but for the time being, I will stick
642
+ to the method described above.
643
+
644
+ ## Short display variant
645
+
646
+ If you only wish to quickly view the most important information
647
+ about the local computer system, then you can use the following
648
+ variant:
649
+
650
+ envi --short
651
+
652
+ ## Caveats
653
+
654
+ Note that the **EnvironmentInformation** project has to sometimes guess
655
+ how to obtain the necessary information, in order to determine which
656
+ program is installed. For example, for programs such as **readline**
657
+ there is no trivial way to determine which version is used, to
658
+ **EnvironmentInformation** will attempt to read the .so files, and
659
+ determine the version from the .so files. This may fail, depending
660
+ on the setup of the host computer.
661
+
662
+ In general, the two best ways to determine the version of programs
663
+ are via a **--version** flag or simply by using **pkg-config** to
664
+ query the .pc file of the package. But this is not available for
665
+ all programs, so ultimately **EnvironmentInformation** may not
666
+ display completely accurate information on all given computer
667
+ systems.
668
+
669
+ ## Clearing the old dataset
670
+
671
+ Via **--clear** on the commandline you can remove all old entries.
672
+ This commandline flag thus resets **class EnvironmentInformation**
673
+ to a totally clean, fresh state. Internally the method .reset() will
674
+ be called on **class EnvironmentInformation**.
675
+
676
+ This allows you to show only one component, or a few components,
677
+ for example. The following example demonstrates this.
678
+
679
+ Say that you wish to show **only** **python** and **php**, thus
680
+ two programs only. Then you can use the following flag to achieve
681
+ this, in this order:
682
+
683
+ envi --clear --python --php
684
+
685
+ The order is important because --clear will clear at the moment
686
+ it occurs in **ARGV**, which holds the commandline-arguments
687
+ issued on the commandline by the user.
688
+
689
+ ## Which packages will be checked by default?
690
+
691
+ The following provides a list of packages that are presently,
692
+ in **October of 2019**, tracked.
693
+
694
+ In the past I did manually copy/paste the following listing, but
695
+ since as of 15th of October 2019, the list is **autogenerated** via
696
+ a macro.
697
+
698
+ This listing can be seen in the **file**:
699
+
700
+ environment_information/constants/array_tracked_components.rb
701
+
702
+ These are the following programs:
703
+
704
+ ADD_ENVIRONMENT_INFORMATION_PROPERLY_FORMATTED_ARRAY
705
+
706
+ You can also display these programs dynamically, such as through the
707
+ following **API**:
708
+
709
+ require 'environment_information'
710
+
711
+ pp EnvironmentInformation.tracked_programs?
712
+
713
+ Note that since as of **March 2019**, environment_information will also attempt
714
+ to find out the installed version for **gmp**, **mpfr** and **mpc**. This
715
+ may fail, though, and will be silently ignored in these cases (at least
716
+ for the time being).
717
+
718
+ You can use the following method to display a list of all programs
719
+ that are registered, from the commandline:
720
+
721
+ envi --registered-components?
722
+
723
+ This will show every registered (and thus, available) component of this
724
+ project.
725
+
726
+ As of **February 2020**, this project tracks at the least 105 different
727
+ programs. More entries will be added in the future, but the primary
728
+ focus will be on a **Linux from Scratch** / **Beyond Linux from Scratch**
729
+ setup, so expect those programs that are installed first, to be added
730
+ next, too.
731
+
732
+ ## Querying the components that will be shown
733
+
734
+ You can query the components that will be shown, by issuing one of
735
+ the following commands:
736
+
737
+ envi --show-components?
738
+ envi --show-components
739
+
740
+ Note that this works exclusively, meaning that if you use this
741
+ commandline switch, then you will ONLY get a query of the
742
+ components that are available.
743
+
744
+ ## Replaying the information
745
+
746
+ Normally showing all information when issuing **envi --RALL** can take
747
+ quite some time; on my computer system 18 seconds, before the rewrite
748
+ in February 2020.
749
+
750
+ The reason as to why it takes that long is mostly because many different
751
+ files have to be queried; their --version flag has to be called or
752
+ their .pc file has to be checked, but most importantly querying data
753
+ from the **RBT project** currently takes way too long. This is not an
754
+ ideal situation, as nobody wants to wait.
755
+
756
+ Waiting 18 seconds is simply too long, though, but until that part in
757
+ RBT is improved, I have added a **--replay** functionality for **class
758
+ EnvironmentInformation** (via the commandline).
759
+
760
+ What this functionality does is to take an available (existing) .yml
761
+ file that holds the information from the last invocation run, and then
762
+ proceeds to display this information on the commandline to the user.
763
+ This will evidently be much faster, since the information has already
764
+ been stored before in a prior run.
765
+
766
+ This change required that the environment information project will
767
+ also generate a **.yml file** by default.
768
+
769
+ Note that this functionality is not yet complete; I will extend this
770
+ at a later time (written this part here as of **December 2019**).
771
+
772
+ You can disable saving into this .yml file via:
773
+
774
+ envi --no-yaml-file
775
+
776
+ To invoke the replay functionality, do:
777
+
778
+ envi --replay
779
+
780
+ ## Avoid the creation of local files
781
+
782
+ By default, the main class in this project may generate a few local
783
+ files. This may not always be wanted, or possible (e. g. in a
784
+ read-only filesystem), so an option has to exist that disables
785
+ this functionality.
786
+
787
+ That option is called **--no-save** and can be used like this:
788
+
789
+ envi --lfs --no-save
790
+
791
+ ## Using another prefix
792
+
793
+ By default, the environment_information project will assume that
794
+ the main prefix is / or /usr, respectively. In other words, it
795
+ will assume that, for example, the binary called "bison" will
796
+ reside at /usr/bin/bison. To be more correct, it will make use
797
+ of the PATH environment variable, but for most users this will
798
+ list /usr/bin/ first.
799
+
800
+ That way "bison --version" should work and be the same as
801
+ "/usr/bin/bison --version".
802
+
803
+ For pkg-config .pc files, the main target will usually then
804
+ be at /usr/lib/pkgconfig/.
805
+
806
+ Note that the above is not always a correct assumption. For
807
+ example, the **GoboLinux approach** uses the **/Programs/**
808
+ hierarchy instead (but it also keeps legacy symlinks, so in
809
+ fact GoboLinux works just like any other linux distribution too).
810
+
811
+ On my home setup, I tend to use /home/Programs/ since some
812
+ time - mostly because I tend to relocate /home/ in general
813
+ or may keep it on a separate partition.
814
+
815
+ For these latter use cases we require another way to quickly
816
+ list all versions of different programs. On 14.01.2020
817
+ support for this has been (partially) added.
818
+
819
+ Invoke this like so:
820
+
821
+ envi --work-on-programs-directory-only
822
+
823
+ Note that this would use /home/Programs/ right now, which
824
+ is hardcoded - and thus not flexible.
825
+
826
+ I am aware of this limitation, so expect more code changes
827
+ in the future to extend this functionality.
828
+
829
+ One key idea for this is to set up /home/Programs/Toolchain/
830
+ and have that one work reliably to cross-compile different
831
+ architectures, libc libraries and so forth. But for now,
832
+ this subsection is a stub.
833
+
834
+ ## Rationale as to why some programs may work and some may not
835
+
836
+ Querying the specific version installed on a given computer
837
+ system can be tricky. If a **.pc file** is available (**pkg-config**)
838
+ then querying the version is quite trivial. If a **binary** is
839
+ available then often **--version** or **-V** will work. But
840
+ sometimes there is no binary, and no .pc file either. So what
841
+ to do in such a case?
842
+
843
+ This is not simple to answer, since it may depend on the
844
+ program at hand.
845
+
846
+ It may be possible to infer the proper version from the
847
+ library at hand e. g. **/usr/lib/foobar.so.4.8.2**. Here
848
+ we could assume that the version will be 4.8.2, but this
849
+ is not necessarily guaranteed to work, either.
850
+
851
+ In the past, before the rewrite of this project in **February 2020**,
852
+ the environment_information project had used code that would
853
+ check for such conditions - for example, for **readline**,
854
+ and look for specific .so files under **/usr/lib/** or
855
+ elsewhere.
856
+
857
+ But the resulting code that had to be written for this, was not
858
+ very elegant, and takes about 10-20 lines of code for checking
859
+ this, including fall-backs, for each program that does not
860
+ conform to --version or a .pc file. I am no longer sure whether
861
+ it is worth to add that code, since it also may have to be
862
+ maintained, and is not always perfect nor does it always work,
863
+ depending on the computer system at hand. So, past this point,
864
+ **environment_information** is not doing its best to query the
865
+ version for all programs - it will try pkg-config and
866
+ --version or -V in most cases, and if that fails then
867
+ the environment_information project will assume that the
868
+ program at hand is not installed.
869
+
870
+ This may be a **false negative**, but to me it appears
871
+ to be better in the long run, in regards to maintainability
872
+ of the whole project. After all one reason for the rewrite
873
+ in 2020 was to simplify the whole project, and this objective
874
+ has been achieved - all the commands are now stored in yaml
875
+ files, and that is so much simpler to handle than the
876
+ corresponding ruby methods that were used before that.
877
+
878
+ ## Adding new entries to EnvironmentInformation
879
+
880
+ New entries can be added into the following yaml file:
881
+
882
+ **query_to_use_for_the_individual_components.yml**
883
+
884
+ The two most commonly used variants there are version,
885
+ for **bin/foo --version* invocations, and pkgconfig,
886
+ for querying pkg-config .pc files. However had, many
887
+ programs make use of different invocation variants,
888
+ don't come with a .pc file, and have no binaries.
889
+ Querying the correct version of such files is difficult
890
+ since there is no standard. This is a reason why the
891
+ code has to handle these cases.
892
+
893
+ But in principle, adding a new entry is as simple as
894
+ adding a new line into that .yml file (and registering
895
+ that component in a second .yml file).
896
+
897
+ ## The toplevel main hash
898
+
899
+ EnvironmentInformation tries to store the information that
900
+ it has collected into a **hash**, which can be accessed like
901
+ this quickly:
902
+
903
+ EnvironmentInformation.hash?
904
+
905
+ By default this hash is empty, so you have to fill it up
906
+ first, if you want to do so, via the following method:
907
+
908
+ EnvironmentInformation.initialize
909
+
910
+ hash = EnvironmentInformation.hash? # ← and here you can query it
911
+
912
+ The hash can then be used as basis for reporting at a later time,
913
+ or replaying that information via the **--replay** commandline
914
+ switch to the executable.
915
+
916
+ ## Dependencies of the EnvironmentInformation project
917
+
918
+ The sole dependency for the **environment_information gem**
919
+ is on the **colours** gem.
920
+
921
+ Up until the beginning of March 2020, the EnvironmentInformation
922
+ project also depended on the **opn gem**. However had, I
923
+ noticed that in a restricted environment installation of
924
+ gems can be difficult, so I made opn **optional**. If you have
925
+ it installed then EnvironmentInformation will still try to
926
+ make use of the **Opn namespace**; and if it is not installed
927
+ then EnvironmentInformation will simply **skip** Opn completely.
928
+
929
+ ## Rationale behind the different queries
930
+
931
+ As was already explained, different programs require different
932
+ ways to determine which version is installed. Some projects
933
+ would allow more than one way, such as the --version flag,
934
+ but also querying .pc files. Ruby, for example, supports both
935
+ --version, and comes with a .pc file (if you compiled it from
936
+ source, at the least).
937
+
938
+ So, which way to choose?
939
+
940
+ In my opinion, .pc files are better than --version, for
941
+ at the least two reasons:
942
+
943
+ - The resulting code to handle this is much simpler. .pc
944
+ files are quite uniform, whereas the output of --version
945
+ is very dissimilar between different programs.
946
+
947
+ - Another reason is that invoking the binary, just to
948
+ do a --version, is actually more expensive (CPU-wise)
949
+ than it is to query a simple text file, which is
950
+ essentially what .pc files are. So this is another reason
951
+ in favour of .pc files.
952
+
953
+ For these reasons, and a few smaller ones, the EnvironmentInformation
954
+ project will try to prefer .pc files whenever that is possible.
955
+ We may retain code that can handle --version calls, though,
956
+ if they need a special way to query.
957
+
958
+ ## Querying all registered pkg-config entries
959
+
960
+ To show all registered pkg-config entries (with .pc files)
961
+ do this:
962
+
963
+ envi --pkgconfig
964
+
965
+ If you want to obtain an Array of all outdated programs
966
+ on the target computer system, try this method:
967
+
968
+ EnvironmentInformation.return_array_of_outdated_programs
969
+
970
+ You need to have initialized the main hash once, before
971
+ being able to make use of that method.
972
+
973
+ ## Quickly showing the version of individual programs
974
+
975
+ You can show the version of individual programs
976
+ like this:
977
+
978
+ envi --bash
979
+ envi --brotli
980
+
981
+ This will only work if the program has been registered,
982
+ though - so the second variant will not work.
983
+
984
+ Also take note that this will be ultra-short output,
985
+ so nothing will be saved into a local file. The idea
986
+ here is that the user only wants to see the version
987
+ of the program at hand, such as the <b>bash shell</b>.
988
+
989
+ ## Aliases to program names
990
+
991
+ For several reasons it may be useful to define some aliases
992
+ or shortcuts to registered names. For example, the input
993
+ name **yacc** should point to the program called **bison**,
994
+ and the input name **diff** should really be an abbreviation
995
+ for **diffutils**. This allows the user to use the
996
+ environment_information project in a more convenient manner.
997
+
998
+ Currently these aliases are hardcoded, defined in the
999
+ method called **EnvironmentInformation.return_alias_to()**.
1000
+
1001
+ If no alias is found then the method will simply return
1002
+ the original input argument. This allows us to use this
1003
+ method as a 'sanitizer' or filter.
1004
+
1005
+ ## Support for KDE
1006
+
1007
+ If you have the RBT gem installed (gem install rbt) then you
1008
+ can invoke envi via:
1009
+
1010
+ envi --kde?
1011
+
1012
+ Since as of August 2022 this will try to show the versions
1013
+ of installed KDE applications.
1014
+
1015
+ This currently does not work very well; at a later point
1016
+ this will be polished and improved.
1017
+
1018
+ ## Bugs and other misbehaviours
1019
+
1020
+ I noticed a few bugs here and there over the years. For instance,
1021
+ sometimes there may not be any output and the program stops
1022
+ working suddenly. This sometimes happens because there is some
1023
+ error in the underlying way how EnvironmentInformation obtains
1024
+ the version-information. In the long run I intend to improve
1025
+ the situation, by no longer falling into such issues - but
1026
+ they are not easily reproducible on my system. Either way I
1027
+ added this subsection in November 2021, to lessen the confusion
1028
+ for users at the least a little bit. And, again, as said, in
1029
+ the long run the code will change so as to not run into such
1030
+ situations anymore.
1031
+
1032
+ To provide a specific example: there may be instances of
1033
+ emacs about, such as on antiX, which simply did not
1034
+ provide any output. When I compiled emacs from source, it
1035
+ worked fine - so always check that the program works as
1036
+ assumed it **should** work.
1037
+
1038
+ ## GUIs - Graphical User Interfaces
1039
+
1040
+ A few bindings to graphical user interfaces exist, to ruby-gtk3 and
1041
+ ruby-libui. These are mostly just demos, proof-of-concept. They are
1042
+ not really very elegant or sophisticated - I really only wanted to
1043
+ show how to embed the information gained from the commandline via
1044
+ a GUI as well.
1045
+
1046
+ Since as of 2024, a GUI via jruby-Swing is now part of this
1047
+ gem. The current GUI is very minimalistic:
1048
+
1049
+ <img src="https://i.imgur.com/kGHXiCd.png" style="margin: 1em">
1050
+
1051
+ Still not very elegant. But the advantage here is that this
1052
+ also works on windows, and I may add more code over time to
1053
+ make this more useful on windows as well. One day I would like
1054
+ to have a collection of different widget sets that all work
1055
+ on as many different operating systems as possible. Stay
1056
+ tuned for more updates in this regard in the future.
1057
+
1058
+ ADD_CONTACT_INFORMATION