It must be rocket science…

So I’m sitting here writing some generic “unhandled exception” code to display a dialog box in case Banshee throws up, as it’s better to have some kind of indication that it’s sick, than nothing at all. Along with the exception message and stack trace, I have it print the version information for all assemblies, and print the output of `uname -sirom` However one of the simplest, most useful pieces of platform information is the name and version of the distribution. Not the kernel version… the distribution release version. Like SuSE 10 Beta 3, or Ubuntu Breezy Preview Release 1, or Fedora Core 4. Something incredibly simple, yet meaningful. But how to find this out without doing some kind of insane file system fingerprinting or something else that is much more complicated than it should be?

Why isn’t there some simple static file, like /etc/distro, that contains a one line string of the distro name and version? Can it be too much to ask? Is there something simple that I’m missing? Am I the only developer that finds this information useful?

Actually, maybe some kind of Key=Value file, /etc/distro, could have more detailed, standard keys. Like Name=SuSE, Version=10.0, Release=Beta 3, Vendor=Novell, Kernel=Such and Such, etc., etc. Just so long as there’s some kind of standard distribution version file, with standard keys. I don’t care if it’s Key/Value, XML, Binary… just something with lots of useful information, that is standard across all distributions.

Oh well… the exception dialog rocks anyway.

This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

13 Responses to It must be rocket science…

  1. William Lachance says:

    Most Linux distributions do put some kind of versioning information into ‘/etc’ (Debian is ‘/etc/debian_version’, RedHat is ‘/etc/redhat-release’). The autoconf scripts for NetworkManager and Sabayon use them: look there for the correct filenames for some common distributions.

  2. Sam Morris says:

    $ cat /etc/lsb-release
    DISTRIB_ID=Debian
    DISTRIB_RELEASE=3.1
    DISTRIB_CODENAME=sarge
    DISTRIB_DESCRIPTION=”Debian GNU/Linux”

    ;)

  3. AdamW says:

    In Mandriva we have /etc/mandriva-release, /etc/mandrake-release and /etc/mandrakelinux-release for backwards compatibility, and /etc/redhat-release for wider compatibility (it was in initial versions of MDK, people started using it in scripts, so we’ve kept it ever since in case people still are :>)

  4. Jonah says:

    I just checked, and on my Ubuntu Hoary system the /etc/lsb-release file has the info you want:

    $ cat /etc/lsb-release
    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=5.04
    DISTRIB_CODENAME=hoary
    DISTRIB_DESCRIPTION=”Ubuntu (The Hoary Hedgehog Release)”

    The file /etc/debian_release also exists, but is significantly less informative:

    $ cat /etc/debian_version
    3.1

  5. SuSE has /etc/lsb-release, but that just contains the kernel version. But it also has /etc/SuSE-release, which contains:

    SUSE LINUX 10.0 (i586) beta2
    VERSION = 10.0

    So these /etc/*-release files seem decently standard with regard to their location and general content, but the formats seem to vary, and some are more useful than others.

    It’d still be great to have some kind of unified standard for the contents and layout of say /etc/lsb-release.

    In the mean time, thanks for the tips… maybe I’ll end up throwing together some kind of parser – it’s better than nothing!

  6. And by “kernel version,” what I really meant the LSB_VERSION field, which is allegedly supposed to identify against which LSB release the distro is compatible with. At first I had only glanced at the filed and it resembled my kernel version :)

  7. Andy Preston says:

    Slackware

    /etc/slackware-version

  8. David Smith says:

    /etc/issue is printed by getty before the login prompt. It should be a
    good indicator of the distribution and version of any UNIX-like
    system.

  9. You really want to use the lsb_release command, not base it off a file in /etc or something similar. Something along the lines of:

    : tfheen@thosu ~ > lsb_release -a
    LSB Version: n/a
    Distributor ID: Ubuntu
    Description: Ubuntu (The Breezy Badger Release) Development Branch
    Release: 5.10
    Codename: breezy

    should be enough, by far.

  10. David Smith says:

    I agree with using the lsb_release command is the best way for LSB 1.1
    compliant systems but /etc/issue is the best fall-back if that command
    is unavailable or parsing fails.

  11. Ah! lsb_release -a is exactly what I’m looking for. Thanks everyone.

  12. bob says:

    /etc/issue

  13. Russ says:

    Ah, very useful discussion to have stumbled upon. Thanks loads, guys.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>