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>

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to devuan-bugs@lists.dyne.org, devuan-dev@lists.dyne.org:
bug#468; Package libpython2.7-minimal. (Thu, 21 May 2020 15:48:01 GMT) (full text, mbox, link).


Acknowledgement sent to peter@pwduffy.org.uk:
New bug report received and forwarded. Copy sent to devuan-dev@lists.dyne.org. (Thu, 21 May 2020 15:48:06 GMT) (full text, mbox, link).


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

From: Peter Duffy <peter@pwduffy.org.uk>
To: submit@bugs.devuan.org
Subject: python platform.linux_distribution() returns debian
Date: Thu, 21 May 2020 16:33:35 +0100
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



Information forwarded to devuan-bugs@lists.dyne.org, devuan-dev@lists.dyne.org:
bug#468; Package libpython2.7-minimal. (Fri, 22 May 2020 10:03:01 GMT) (full text, mbox, link).


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

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
Date: Fri, 22 May 2020 10:45:05 +0100
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. (Fri, 22 May 2020 12:03:02 GMT) (full text, mbox, link).


Acknowledgement sent to Mark Hindley <mark@hindley.org.uk>:
Extra info received and forwarded to list. Copy sent to devuan-dev@lists.dyne.org. (Fri, 22 May 2020 12:03:04 GMT) (full text, mbox, link).


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

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
Date: Fri, 22 May 2020 12:49:17 +0100
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

Reply sent to Mark Hindley <mark@hindley.org.uk>:
You have taken responsibility. (Tue, 24 Jan 2023 17:20:02 GMT) (full text, mbox, link).


Notification sent to peter@pwduffy.org.uk:
bug acknowledged by developer. (Tue, 24 Jan 2023 17:20:04 GMT) (full text, mbox, link).


Message #18 received at 468-done@bugs.devuan.org (full text, mbox, reply):

From: Mark Hindley <mark@hindley.org.uk>
To: peter@pwduffy.org.uk, 468-done@bugs.devuan.org
Subject: Re: bug#468: python platform.linux_distribution() returns debian
Date: Tue, 24 Jan 2023 17:17:49 +0000
Peter,

I am going to close this as libpython2.7-minimal was removed from Debian[1] and
the python3 platform library doesn't have linux_distribution().

Mark

[1]  https://bugs.debian.org/1027108


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: Sun Nov 24 08:32:27 2024;