GNOME Bugzilla – Bug 589549
Could use the lsb informations to guess the distribution
Last modified: 2010-06-17 03:45:55 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
Created attachment 139109 [details] [review] use the lsb informations to get the distribution
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?
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
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
Fixed in master. Thanks!