[Solved] Differentiate between various Linux distros lazarus / 32-Linux ---------------------------------------------------------------------- petevick · 2022-05-29 14:56 At the moment in my project I differentiate between Linux and Windows by this code.... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i { TForm1 }function OSVersion: String;begin  {$IFDEF Linux}  OSVersion := 'Linux';  {$ELSE}  {$IFDEF WINDOWS}  OSVersion := 'Windows';  {$ENDIF}  {$ENDIF}end; ...but is there a way to differentiate between other Linux/Ubuntu distros, say Linux Mint and Kubuntu. ---------------------------------------------------------------------- petevick · 2022-05-29 15:44 Hmmm, maybe I just expand on what I have, something like..... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i { TForm1 }function OSVersion: String;begin  {$IFDEF Linux}  OSVersion := 'Linux';  {$ELSE}  {$IFDEF Ubuntu}  OSVersion := 'Ubuntu';  {$ELSE}  {$IFDEF WINDOWS}  OSVersion := 'Windows';  {$ENDIF}  {$ENDIF}  {$ENDIF}end; ---------------------------------------------------------------------- petevick · 2022-05-29 15:56 Nope, that doesn't work ---------------------------------------------------------------------- Lutz Mändle · 2022-05-29 16:29 Have a look at /etc/os-release, there is also a man page (man os- release). ---------------------------------------------------------------------- howardpc · 2022-05-29 16:39 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  FileUtil; function GetLinuxDistro: String;const  Issue = '/etc/issue';begin  case FileExists(Issue) of    True:  Result := ReadFileToString(Issue);    False: Result := 'unknown distro';  end;end; ---------------------------------------------------------------------- petevick · 2022-05-29 16:49 Quote from: Lutz Mändle on May 29, 2022, 06:29:37 pmHave a look at /etc/os-release, there is also a man page (man os-release). Thanks for this Lutz, but I think the solution from howardpc will be a tad more straight forward as 'issue' is just a one line text file. ---------------------------------------------------------------------- petevick · 2022-05-29 16:50 Quote from: howardpc on May 29, 2022, 06:39:24 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  FileUtil; function GetLinuxDistro: String;const  Issue = '/etc/issue';begin  case FileExists(Issue) of    True:  Result := ReadFileToString(Issue);    False: Result := 'unknown distro';  end;end;    Thanks for this, It should work for me. ---------------------------------------------------------------------- Kays · 2022-05-29 17:05 Quote from: Lutz Mändle on May 29, 2022, 06:29:37 pmHave a look at /etc/os-release, there is also a man page (man os-release).Right. Everything’s runnin’ on systemd nowadays. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   OSVersion := 'systemd'; ---------------------------------------------------------------------- MarkMLl · 2022-05-29 17:15 Quote from: petevick on May 29, 2022, 06:49:22 pmQuote from: Lutz Mändle on May 29, 2022, 06:29:37 pmHave a look at /etc/os-release, there is also a man page (man os-release). Thanks for this Lutz, but I think the solution from howardpc will be a tad more straight forward as 'issue' is just a one line text file. I believe /etc/os-release is the nearest thing you'll get to a correct answer since this is officially sanctioned by both linux.org and freedesktop.org: hence you will also find it supported by Solaris etc., with standardised content. Anything using conditional compilation is doomed to failure, since all you're doing is asking the build environment what it thinks it's compiling for. So as a specific example, you might be building a 32-bit Linux program with no GUI which is going to be run on a 64-bit distro with KDE. Conditionals do have their uses, but what you're trying to do isn't one of them :-) MarkMLl ---------------------------------------------------------------------- winni · 2022-05-29 19:39 Quote from: Kays on May 29, 2022, 07:05:45 pmQuote from: Lutz Mändle on May 29, 2022, 06:29:37 pmHave a look at /etc/os-release, there is also a man page (man os-release).Right. Everything’s runnin’ on systemd nowadays. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   OSVersion := 'systemd'; Hi! This is not correct. There is a hardcore crew that is angry about systemd. Have a look at https://nosystemd.org/ Winni ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2022-05-29 21:55 Hey Y'all, This actually made me curious of how many ways we can assess this and I've added another app to my Test* collection of apps: Test Linux Distribution Information Of course I went all overboard and it even has i18n with one language: Portuguese. Hope it's useful for anyone. TODO: Get the information via the lsb_release CLI commandFind if these 4/5 methods are really the whole shibang or if there are others. Cheers, Gus ---------------------------------------------------------------------- Thaddy · 2022-05-30 06:25 Quote from: winni on May 29, 2022, 09:39:13 pm This is not correct. There is a hardcore crew that is angry about systemd. Fake news? For sure. There is a very valid reason everybody is using systemd: it works better than the old alternatives. ---------------------------------------------------------------------- friend · 2022-05-30 07:55 Quote from: Thaddy on May 30, 2022, 08:25:18 amFake news? For sure. There is a very valid reason everybody is using systemd: it works better than the old alternatives. You don't know what you're talking about. This cannot even be called "news" -- now the association is unsurprising for someone whose profile picture is a flag of Ukraine and recently called the President of the Russian Federation a criminal in his signature. You seem to like talking about what you don't know. I bet you haven't even read about the reasons why systemd is criticized. ---------------------------------------------------------------------- winni · 2022-05-30 08:51 Quote from: Thaddy on May 30, 2022, 08:25:18 amQuote from: winni on May 29, 2022, 09:39:13 pm This is not correct. There is a hardcore crew that is angry about systemd. Fake news? For sure. There is a very valid reason everybody is using systemd: it works better than the old alternatives. Don't call everything you're not informed about "fake news". Some former Debian Developers issued an non-systemd Debian called Devuan: https://www.devuan.org/ A (not complete) list of Linux distros without systemd: https://en.wikipedia.org/wiki/Category:Linux_distributions_without_sys temd Winni ---------------------------------------------------------------------- marcov · 2022-05-30 08:52 Some people are also still maintaining Minix. That doesn't mean Linux is irrelevant, but also not that all Linux code should still work with Minix. ---------------------------------------------------------------------- MarkMLl · 2022-05-30 09:01 Quote from: friend on May 30, 2022, 09:55:37 amYou don't know what you're talking about. This cannot even be called "news" -- now the association is unsurprising for someone whose profile picture is a flag of Ukraine and recently called the President of the Russian Federation a criminal in his signature. You seem to like talking about what you don't know. I bet you haven't even read about the reasons why systemd is criticized. I suggest that it is inappropriate for somebody with so little experience of this forum to express himself so strongly, and in particular to drag international events into the discussion: events which contravene international law and custom. Apart from that: systemd is not part of Linux per se., in the same way that the GNU utilities and the X11 windowing system are not part of Linux. As such any discussion of it is off-topic and irrelevant to the OP's question. MarkMLl ---------------------------------------------------------------------- petevick · 2022-05-30 09:04 Quote from: MarkMLl on May 30, 2022, 11:01:42 am[I suggest that it is inappropriate for somebody with so little experience of this forum to express himself so strongly, and in particular to drag international events into the discussion: events which contravene international law and custom. Apart from that: systemd is not part of Linux per se., in the same way that the GNU utilities and the X11 windowing system are not part of Linux. As such any discussion of it is off-topic and irrelevant to the OP's question. MarkMLl Gotta love the voice of reason ---------------------------------------------------------------------- friend · 2022-05-30 09:41 Quote from: MarkMLl on May 30, 2022, 11:01:42 am I suggest that it is inappropriate for somebody with so little experience of this forum to express himself so strongly, and in particular to drag international events into the discussion: events which contravene international law and custom. Apart from that: systemd is not part of Linux per se., in the same way that the GNU utilities and the X11 windowing system are not part of Linux. As such any discussion of it is off-topic and irrelevant to the OP's question. MarkMLl Can't wait till I have a couple of thousand posts here to be able to express myself more boldly.  I just mentioned his avatar and signature -- not dragging the thing itself into the discussion, I simple made an observation about his manifest opinion on a subject and his comment on another; both spring forth from the same mental state. You are right about it being off-topic and not related to the OP's question; so are half a dozen posts above mine including yours. I believe Kays was being ironic in his post (since /etc/os-release is part of systemd's specification and is possibly not present in better distributions that do not use that dung). ---------------------------------------------------------------------- 440bx · 2022-05-30 09:51 Quote from: friend on May 30, 2022, 09:55:37 am...called the President of the Russian Federation a criminal in his signature. You seem to like talking about what you don't know. I like precision and accuracy, therefore it is necessary to point out that calling a criminal, a criminal, is nothing other than an accurate description. Just like a square is called a square, an array is called an array and, unsurprisingly, a criminal is called a criminal.  What's not surprising is that criminals and, apparently their sympathizers, don't care for accurate descriptions. Programmers should be accurate. ---------------------------------------------------------------------- Zvoni · 2022-05-30 10:02 I remember using "Conky" on my Linux-Laptop, and there i'm able to pull out Distro, Kernel-Version, Desktop etc. Would have to look at the source-code again, but i think Gus with "lsb_release" is close ---------------------------------------------------------------------- MarkMLl · 2022-05-30 11:16 Quote from: Zvoni on May 30, 2022, 12:02:14 pmI remember using "Conky" on my Linux-Laptop, and there i'm able to pull out Distro, Kernel- Version, Desktop etc. Would have to look at the source-code again, but i think Gus with "lsb_release" is close Mozilla Firefox can still get that, but you have to look Help -> More Troubleshooting Information... which gets a vast amount of info about libraries being used etc. The worrying thing is that much of that stuff is also available to Google et al., because of the amount of unnecessary JavaScript that gets pulled into almost every webpage. MarkMLl ---------------------------------------------------------------------- PascalDragon · 2022-05-30 11:28 Quote from: Thaddy on May 30, 2022, 08:25:18 amQuote from: winni on May 29, 2022, 09:39:13 pm This is not correct. There is a hardcore crew that is angry about systemd. Fake news? For sure. There is a very valid reason everybody is using systemd: it works better than the old alternatives. Better... Not really. I had quite a lot more boot problems since ArchLinux changed to systemd than I had in the time with its original SysV init system.  Quote from: friend on May 30, 2022, 11:41:33 amI believe Kays was being ironic in his post (since /etc/os-release is part of systemd's specification and is possibly not present in better distributions that do not use that dung). While it was systemd that introduced the /etc/os-release and enforces its presence this does not mean that a distribution that provides /etc/os-release must indeed use systemd. See also here. ---------------------------------------------------------------------- friend · 2022-05-30 11:33 Quote from: 440bx on May 30, 2022, 11:51:40 amI like precision and accuracy, therefore it is necessary to point out that calling a criminal, a criminal, is nothing other than an accurate description. Just like a square is called a square, an array is called an array and, unsurprisingly, a criminal is called a criminal.  What's not surprising is that criminals and, apparently their sympathizers, don't care for accurate descriptions. Programmers should be accurate. I agree with you about precision and accuracy friend, but, the real world is not zeroes and ones. Being accurate within a given limited set? Saying that dividing 1 by 2 is impossible because you've been only taught about integers. Having an opinion based on what the media says is stupidity. He might be right about some things. Quote from: Zvoni on May 30, 2022, 12:02:14 pmI remember using "Conky" on my Linux-Laptop, and there i'm able to pull out Distro, Kernel- Version, Desktop etc. Would have to look at the source-code again, but i think Gus with "lsb_release" is close Found this comment in Conky's source code, in a file called linux.cc under the project's src directory: Code: C  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i /* I am assuming the distribution name is the first string in /proc/version  that:    - is preceded by a '('    - starts with a capital    - is followed by a space and a number    but i am not sure if this is always true... */ Not a certain way, but this seems to be better, for better distributions free from systemdung. ---------------------------------------------------------------------- MarkMLl · 2022-05-30 11:42 Quote from: friend on May 30, 2022, 01:33:00 pmFound this comment in Conky's source code, in a file called linux.cc under the project's src directory: Code: C  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i /* I am assuming the distribution name is the first string in /proc/version  that:    - is preceded by a '('    - starts with a capital    - is followed by a space and a number    but i am not sure if this is always true... */ Not a certain way, but this seems to be better, for better distributions free from systemdung. I don't think you can rely on that. That will come from something like CONFIG_LOCALVERSION in the kernel configuration, and if the local user rebuilds the kernel the distro name is likely to be lost even though everything on disc- plus udev configuration etc.- is still very much distro-defined. MarkMLl ---------------------------------------------------------------------- Zvoni · 2022-05-30 12:03 Quote from: friend on May 30, 2022, 01:33:00 pm Found this comment in Conky's source code, in a file called linux.cc under the project's src directory: Code: C  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i /* I am assuming the distribution name is the first string in /proc/version  that:    - is preceded by a '('    - starts with a capital    - is followed by a space and a number    but i am not sure if this is always true... */ Not a certain way, but this seems to be better, for better distributions free from systemdung. Sorry, with "Source-code" i meant the Conky-configfile, not Conky itself. In the config-files i use some CLI-commands grep/awk-ing for specific information. That's why i said, Gus is close with his "lsb_release"