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

Package: libpython2.7-minimal; Reported by: peter@pwduffy.org.uk; dated Thu, 21 May 2020 15:48:01 UTC; Maintainer for libpython2.7-minimal is (unknown).

Message received at 468@bugs.devuan.org:


Received: (at 468) by bugs.devuan.org; 22 May 2020 11:50:05 +0000
Return-Path: <mark@hindley.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); Fri, 22 May 2020 11:50:04 +0000 (UTC)
Received: from mx.hindley.org.uk (mohindley.plus.com [81.174.245.179])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by vm6.ganeti.dyne.org (Postfix) with ESMTPS id 9B5F1F60CBD
	for <468@bugs.devuan.org>; Fri, 22 May 2020 13:49:20 +0200 (CEST)
Received: from apollo.hindleynet ([192.168.1.3] helo=hindley.org.uk)
	by mx.hindley.org.uk with smtp (Exim 4.84_2)
	(envelope-from <mark@hindley.org.uk>)
	id 1jc6Aw-0007fU-HM; Fri, 22 May 2020 12:49:18 +0100
Received: (nullmailer pid 5439 invoked by uid 1000);
	Fri, 22 May 2020 11:49:17 -0000
Date: Fri, 22 May 2020 12:49:17 +0100
From: Mark Hindley <mark@hindley.org.uk>
To: Peter Duffy <peter@pwduffy.org.uk>
Cc: 468@bugs.devuan.org
Subject: Re: bug#468: python platform.linux_distribution() returns debian
Message-ID: <20200522114917.GG32762@hindley.org.uk>
References: <1590075215.2942.97.camel@baldur.shiftshaper.org.uk>
 <20200522094505.GE32762@hindley.org.uk>
 <1590146461.2950.104.camel@baldur.shiftshaper.org.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1590146461.2950.104.camel@baldur.shiftshaper.org.uk>
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_PASS autolearn=disabled
	version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tupac3.dyne.org

Peter,

On Fri, May 22, 2020 at 12:21:01PM +0100, Peter Duffy wrote:
> Hi Mark,
> 
> Thanks for getting back to me. I agree that this is problematic, and I
> concur with your points and decision not to fix.

I will leave this open, in case any better suggestions come along.

> As I mentioned, I came up against this whilst trying to fix waagent (aka
> walinuxagent and azurelinuxagent) - the glue layer which the Microsoft
> Azure front-end uses to communicate with linux running on VMs. I'm
> trying to set up a virtualbox VM based on devuan ascii, for use as a
> base OS image in Azure. At the moment, waagent detects the system as
> debian instead of devuan, and so tries to use systemd-based utilities
> and functions: of course, these aren't present, so waagent doesn't work
> under devuan. (I'm not sure that it's worth flagging it up as a bug in
> the waagent package? OK, the problem is specific to devuan, but it needs
> to be fixed in waagent.)

Yes, please do.  Let me know if there is anything I can do to help.

It is also worth noting that this approach will sometimes be broken in Debian
too: non-systemd init is still possible in all Debian suites. I suggest it would
be better if they detected init system and acted on that rather than inferred
the init from the distribution. 

> BTW - one point of order. The utility is /usr/bin/lsb_release - the file
> that platform.linux_distribution() tries to use is /etc/lsb-release.
> Don't ask me why :(

Absolutely -- thanks for correcting my lazy typing!

Mark

Acknowledgement sent to Mark Hindley <mark@hindley.org.uk>:
Extra info received and forwarded to list. Copy sent to devuan-dev@lists.dyne.org. Full text available.
Information forwarded to devuan-bugs@lists.dyne.org, devuan-dev@lists.dyne.org:
bug#468; Package libpython2.7-minimal. Full text available.

Message received at 468@bugs.devuan.org:


Received: (at 468) by bugs.devuan.org; 22 May 2020 09:50:05 +0000
Return-Path: <mark@hindley.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); Fri, 22 May 2020 09:50:05 +0000 (UTC)
Received: from mx.hindley.org.uk (mohindley.plus.com [81.174.245.179])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by vm6.ganeti.dyne.org (Postfix) with ESMTPS id 357A7F609D9
	for <468@bugs.devuan.org>; Fri, 22 May 2020 11:45:07 +0200 (CEST)
Received: from apollo.hindleynet ([192.168.1.3] helo=hindley.org.uk)
	by mx.hindley.org.uk with smtp (Exim 4.84_2)
	(envelope-from <mark@hindley.org.uk>)
	id 1jc4Ej-00070Z-O4; Fri, 22 May 2020 10:45:05 +0100
Received: (nullmailer pid 3138 invoked by uid 1000);
	Fri, 22 May 2020 09:45:05 -0000
Date: Fri, 22 May 2020 10:45:05 +0100
From: Mark Hindley <mark@hindley.org.uk>
To: peter@pwduffy.org.uk, 468@bugs.devuan.org
Subject: Re: bug#468: python platform.linux_distribution() returns debian
Message-ID: <20200522094505.GE32762@hindley.org.uk>
References: <1590075215.2942.97.camel@baldur.shiftshaper.org.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1590075215.2942.97.camel@baldur.shiftshaper.org.uk>
X-Debbugs-No-Ack: No Thanks
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_PASS autolearn=disabled
	version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tupac3.dyne.org

Peter,

Thanks for this. It is somewhat problematic for a number of reasons:

 - python2 is EOL.
 
 - as you point out, platform.linux_distribution() is deprecated and slated for
   removal in python3 (presumably for the very reason you have discovered -- it
   isn't reliable).
   
 - In my opinion, applications and functions should use output of lsb_release
   -a directly (as many already do).
   
 - Devuan beowulf deliberately has ID=Debian in lsb_release -a (see the Release
   Notes[1] for an explanation why). This has been changed to ID=Devuan for
   ceres/chimaera.
   
 - neither python2 nor python3 are forked packages and Devuan uses Debian's
   packages directly.
 
Considering all that, I find it difficult to see a feasible route to fixing
this. Having /etc/lsb_release as another source of information only consulted by
some applications seems a retrograde step.

Best wishes,

Mark

[1]  https://files.devuan.org/devuan_beowulf/Release_notes.txt


Information forwarded to devuan-bugs@lists.dyne.org, devuan-dev@lists.dyne.org:
bug#468; Package libpython2.7-minimal. Full text available.

Message received at submit@bugs.devuan.org:


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



Acknowledgement sent to peter@pwduffy.org.uk:
New bug report received and forwarded. Copy sent to devuan-dev@lists.dyne.org. Full text available.
Report forwarded to devuan-bugs@lists.dyne.org, devuan-dev@lists.dyne.org:
bug#468; Package libpython2.7-minimal. Full text available.

Devuan BTS -- Powered by Debian bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.

Devuan Bugs Owner <owner@bugs.devuan.org>.
Last modified: Sat, 4 Jul 2020 00:39:02 UTC