Devuan bug report logs - #468
python platform.linux_distribution() returns debian

version graph

Package: libpython2.7-minimal; Maintainer for libpython2.7-minimal is (unknown); Source for libpython2.7-minimal is src:python2.7.

Reported by: peter@pwduffy.org.uk

Date: Thu, 21 May 2020 15:48:01 UTC

Severity: normal

Found in version 2.7.13

Done: Mark Hindley <mark@hindley.org.uk>

Full log


Message #5 received at submit@bugs.devuan.org (full text, mbox, reply):

Received: (at submit) by bugs.devuan.org; 21 May 2020 15:40:03 +0000
Return-Path: <peter@pwduffy.org.uk>
Delivered-To: devuanbugs@dyne.org
Received: from tupac3.dyne.org [195.169.149.119]
	by doc.devuan.org with IMAP (fetchmail-6.4.0.beta4)
	for <debbugs@localhost> (single-drop); Thu, 21 May 2020 15:40:03 +0000 (UTC)
Received: from omega.myqiq.info (omega.myqiq.info [72.52.170.129])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by vm6.ganeti.dyne.org (Postfix) with ESMTPS id 5A205F60CBE
	for <submit@bugs.devuan.org>; Thu, 21 May 2020 17:33:39 +0200 (CEST)
Authentication-Results: vm6.ganeti.dyne.org;
	dkim=pass (2048-bit key; unprotected) header.d=pwduffy.org.uk header.i=@pwduffy.org.uk header.b="NJRbiZ3l";
	dkim-atps=neutral
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
	d=pwduffy.org.uk; s=default; h=Content-Transfer-Encoding:Mime-Version:
	Message-ID:Date:Content-Type:To:Reply-To:From:Subject:Sender:Cc:Content-ID:
	Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
	:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
	List-Subscribe:List-Post:List-Owner:List-Archive;
	bh=E4N8Ir03HzmIbDIXVOGvyRmziSQ+8mVaWBLV3bPI77Q=; b=NJRbiZ3lxCdcnpr+0dyCkzMvQT
	gJW9KCSoInGPd6WNbLj0AewbjH54NThQMw9ZYBYF99rApGkYt13iAjed1y2hYwx30HS4sAV0AnfR3
	4cOQNdnCyFrm0UZKxSAJZYvVzmqjz5+v15qXj/bMKSQl5+2Fl9cHkEarVnBftHC1+4E9yD2Lofpq2
	FuuxDBUnvyp5Q2uSt3oSiqd423kkMXlDUr1TuGd4vDQDWkpfXjKBq9rd1EH4ReLiQRutU6KORwepW
	SuT3vrPk/gF7XrCnND2L0gUQ7/wVFMDDOBzJV4knZRJlpzy2i/225Qy9TS3C1FwAerPBBZfCvULaK
	SvKC4FpQ==;
Received: from cpc118362-brad23-2-0-cust385.17-1.cable.virginm.net ([86.14.225.130]:58938 helo=[192.168.1.86])
	by omega.myqiq.info with esmtpa (Exim 4.93)
	(envelope-from <peter@pwduffy.org.uk>)
	id 1jbnCS-00BIUU-LZ
	for submit@bugs.devuan.org; Thu, 21 May 2020 15:33:36 +0000
Subject: python platform.linux_distribution() returns debian
From: Peter Duffy <peter@pwduffy.org.uk>
Reply-To: peter@pwduffy.org.uk
To: submit@bugs.devuan.org
Content-Type: text/plain; charset="UTF-8"
Date: Thu, 21 May 2020 16:33:35 +0100
Message-ID: <1590075215.2942.97.camel@baldur.shiftshaper.org.uk>
Mime-Version: 1.0
X-Mailer: Evolution 2.32.3 (2.32.3-34.el6) 
Content-Transfer-Encoding: 7bit
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - omega.myqiq.info
X-AntiAbuse: Original Domain - bugs.devuan.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - pwduffy.org.uk
X-Get-Message-Sender-Via: omega.myqiq.info: authenticated_id: smtp@pwduffy.org.uk
X-Authenticated-Sender: omega.myqiq.info: smtp@pwduffy.org.uk
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID,
	DKIM_VALID_AU,DKIM_VALID_EF,SPF_PASS autolearn=disabled version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tupac3.dyne.org
Package: libpython2.7-minimal
Version: 2.7.13

Environment in which bug seen: Devuan 2.1 (ascii)

Problem behaviour: python function platform.linux_distribution() returns
"debian" instead of "devuan"

To reproduce: 

(from command-line):
python

(from python prompt):
import platform
platform.linux_distribution()

(should return: "('debian','9','')"

quit()

Test fix:

platform.linux_distribution() tries to use the file /etc/lsb-release.
This doesn't appear to exist either in Debian stretch or Devuan ascii -
unless it's present in a package which isn't included in the default
install. Creating it with appropriate values fixes the problem:

Check whether /etc/lsb-release exists: it shouldn't, - but if so,
rename it (and rename it back after the test).

lsb_release -a > /etc/lsb-release

Edit /etc/lsb-release and change as follows:

"Distributor ID: " => "DISTRIB_ID="
"Description: " => "DISTRIB_DESCRIPTION="
"Release: "     => "DISTRIB_RELEASE="
"Codename: "    => "DISTRIB_CODENAME="

Above test should now return: "('Devuan','2.1','ascii')"

Additional information:

The problem is apparently caused by the combination of the absence
of /etc/lsb-release, and the presence of /etc/debian_release. The
algorithm in platform.linux_distribution() is apparently to try
reading /etc/lsb-release, and if it doesn't exist, look for any file
matching /etc/*_(version|release)

The bug also exists in python3 (package libpython3.5-minimal, version
3.5.3) - to reproduce, repeat the above test using "python3" instead of
"python"

The bug also exists in beowulf

Not sure whether above "fix" is feasible in practice - maybe other
python-based packages rely on getting back "debian" from
platform.linux_distribution()?

This problem came to light because it breaks the waagent package -
because it believes that it's running on debian, waagent tries to use
systemd-based commands and functions. I'm currently working this
problem, but I'm approaching it by putting in place internal tests to
ascertain whether debian or devuan, rather than relying on a
system-level fix. 

platform.linux_distribution() is deprecated and slated for removal

If it's decided that this can be safely fixed by
creating /etc/lsb-release, one question needs answering: whether to
lowercase the DISTRIB_ID field, or to leave it as returned by
lsb_release



Send a report that this bug log contains spam.


Devuan BTS -- Powered by Debian bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.

Devuan Bugs Owner <owner@bugs.devuan.org>.
Last modified: Thu Apr 18 13:05:42 2024;