After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 589549 - Could use the lsb informations to guess the distribution
Could use the lsb informations to guess the distribution
Status: RESOLVED FIXED
Product: gdm
Classification: Core
Component: general
2.27.x
Other Linux
: Normal normal
: ---
Assigned To: GDM maintainers
GDM maintainers
Depends on:
Blocks:
 
 
Reported: 2009-07-23 21:24 UTC by Sebastien Bacher
Modified: 2010-06-17 03:45 UTC
See Also:
GNOME target: ---
GNOME version: 2.27/2.28


Attachments
use the lsb informations to get the distribution (982 bytes, patch)
2009-07-23 21:27 UTC, Sebastien Bacher
none Details | Review

Description Sebastien Bacher 2009-07-23 21:24:17 UTC
Currently the code displays ubuntu as being debian because there is a debian_version is etc, the code could use lsb to get the version
Comment 1 Sebastien Bacher 2009-07-23 21:27:42 UTC
Created attachment 139109 [details] [review]
use the lsb informations to get the distribution
Comment 2 Halton Huo 2009-08-19 09:09:27 UTC
Solaris also meet similar problem, refer to http://defect.opensolaris.org/bz/show_bug.cgi?id=10760

Checking the code, it is because it only checks some kinds os release files.

1253 static const char *known_etc_info_files [] = {
1254         "redhat-release",
1255         "SuSE-release",
1256         "gentoo-release",
1257         "arch-release",
1258         "debian_version",
1259         "mandriva-release",
1260         "slackware-version",
1261         NULL
1262 };      

These need to be extended for Ubuntu(/etc/lsb-release) and OpenSolaris(/etc/release).

halton@hp-dv2000:$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu karmic (development branch)"

-bash-3.2$ cat /etc/release 
                       OpenSolaris Development snv_116 X86
           Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                             Assembled 15 June 2009

For Ubuntu, file_read_one_line() does not work to satisfy the /etc/lsb-release style. My idea is extend redefine this function to

file_read_line(const char *filename, int line_no, const char *cmd)

if line_no > 1
  read content of line_no
else
  execute cmd
fi

Comments?
Comment 3 Pascal Terjan 2009-08-27 08:03:42 UTC
Well you should not read a given line number, you need to parse the file as the order of info is not guaranted.
Especially if you want it to handle other distros too.

$ cat /etc/lsb-release 
LSB_VERSION=lsb-3.1-ia32:lsb-3.1-noarch
DISTRIB_ID=MandrivaLinux
DISTRIB_RELEASE=2009.0
DISTRIB_CODENAME=zarapha
DISTRIB_DESCRIPTION="Mandriva Linux 2009.0"

I think that, when available, lsb-release should be used first
Comment 4 Pascal Terjan 2009-08-27 08:14:16 UTC
Sorry I had not seen the proposed patch.

My comments on it:

- You should strip the "" in the result (I don't have Ubuntu to test but I think you will get "Ubuntu karmic (development branch)" with the quotes included in the string)

[pterjan@n4 SOURCES]$ lsb_release -d
Description:	Mandriva Linux 2010.0
[pterjan@n4 SOURCES]$ lsb_release -sd
"Mandriva Linux 2010.0"

- I would not add the return but maybe move if (version != NULL) break; to the beginning of the for
Comment 5 William Jon McCann 2010-06-17 03:45:55 UTC
Fixed in master.  Thanks!