Ubuntu 14.04 包含两个发布文件:
# cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.3 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.3 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
root@yeni2:/# cat /etc/debian_version
jessie/sid
两者都被函数使用platform.linux_distribution()
但是,这个函数被 Ubuntu 修补以返回 Ubuntu 操作系统名称,另见代码中的注释(右边是 Ubuntu 安装的文件,左边是 Python 2.7.10 中找到的源文件):
Python-2.7.10 # diff Lib/platform.py /mnt/ubu/\@/usr/lib/python2.7/platform.py
1c1
< #!/usr/bin/env python
---
> #! /usr/bin/python2.7
262c262
< 'UnitedLinux', 'turbolinux')
---
> 'UnitedLinux', 'turbolinux', 'Ubuntu')
290a291,294
> _distributor_id_file_re = re.compile("(?:DISTRIB_ID\s*=)\s*(.*)", re.I)
> _release_file_re = re.compile("(?:DISTRIB_RELEASE\s*=)\s*(.*)", re.I)
> _codename_file_re = re.compile("(?:DISTRIB_CODENAME\s*=)\s*(.*)", re.I)
>
314a319,337
> # check for the LSB /etc/lsb-release file first, needed so
> # that the distribution doesn't get identified as Debian.
> try:
> with open("/etc/lsb-release", "rU") as etclsbrel:
> for line in etclsbrel:
> m = _distributor_id_file_re.search(line)
> if m:
> _u_distname = m.group(1).strip()
> m = _release_file_re.search(line)
> if m:
> _u_version = m.group(1).strip()
> m = _codename_file_re.search(line)
> if m:
> _u_id = m.group(1).strip()
> if _u_distname and _u_version:
> return (_u_distname, _u_version, _u_id)
> except (EnvironmentError, UnboundLocalError):
> pass
>
您的 python 2.7.9 编译了源代码,不包含来自 Ubuntu 的补丁,这就是它返回内容的原因/etc/debian_version