You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for detecting a distro from a rootfs even on another OS #161
I would be interested to run a distro detection based on some rootfs-like archive for aLinux distro and that on any OS. It could be a a plain pre-imaged rootfs, a container image, a VM image or similar and I would like to detect what it is regardless of which OS distro runs on.
So essentially I would modify distro to accept an optional path to the root of a distro FS defaulting to / so the behavior would be the same as today by default and would not attempt to run lsb_release unless the path is the default '/' and the current OS is Linux.
Well, you're the first one asking for such behavior, so I can't say that I've had any appetite for it just yet. It went through my mind that it would be nice to support remote distro identification in the sense that you could just provide a machine to identify a distribution on. It would be better if you could provide the exact API you'd expect from a feature like that, and, of course, a PR if you're interested.
OR implement the strategies of every lsb_release for distros supported here (which is essentially what this module does already so it would just be to further this)
Assuming that we (we being the world) want to standardize retrieving the linux distrubtion information, I guess that not using lsb_release at all but rather implementing the major distribution's implementation of lsb_release (whatever is not already explicitly implemented in distro) would be great. This would not only force standardization but also remove a known yet arbitrarily implemented dependency on lsb_release.
Activity
pombredanne commentedon Jan 15, 2017
So essentially I would modify distro to accept an optional path to the root of a distro FS defaulting to
/so the behavior would be the same as today by default and would not attempt to runlsb_releaseunless the path is the default '/' and the current OS is Linux.pombredanne commentedon Jan 15, 2017
... and make a few paths relative to that provide root path rather than absolute.
Do you have any appetite for including this type of behavior?
nir0s commentedon Jan 17, 2017
Well, you're the first one asking for such behavior, so I can't say that I've had any appetite for it just yet. It went through my mind that it would be nice to support remote distro identification in the sense that you could just provide a machine to identify a distribution on. It would be better if you could provide the exact API you'd expect from a feature like that, and, of course, a PR if you're interested.
pombredanne commentedon Jan 25, 2017
perfect. I will consider a PR .
hartwork commentedon Feb 18, 2017
lsb_releasedoes not seem to support a custom root directory. So for the calltolsb_release -a(https://github.com/nir0s/distro/blob/1a7d01b095f757754b511591ebe428bd57e19d34/distro.py#L917) it seems to me that root permissions and usingchrootwould be needed. Unless the call tolsb_releasecan be avoided. I'm curious what you come up with.pombredanne commentedon Feb 19, 2017
@hartwork What is
lsb_release? it depends!This is a spec AFAIK. Tool-wise we have many implementations.
At https://sourceforge.net/projects/lsb and now at http://bzr.linuxfoundation.org/loggerhead/lsb/3.1/si/annotate/head:/lsb_release/src/lsb_release this is a shell script.
In Debian and Ubuntu this is a Python script:
https://anonscm.debian.org/cgit/collab-maint/lsb.git/tree/lsb_release.py
http://packages.ubuntu.com/yakkety/lsb-release
In Fedora and Red Hat, the lsb shell script is used as a base:
http://pkgs.fedoraproject.org/repo/extras/redhat-lsb/redhat-lsb-4.1-1.tar.bz2/9c1e474cb81c0ee1941c3129e0e50ea1/
AFAIK, other distros each use their own minor variations or do not have it at all.
So the strategy could be:
lsb_releaseentirely.lsb_releasefor distros supported here (which is essentially what this module does already so it would just be to further this)nir0s commentedon Mar 13, 2017
Assuming that we (we being the world) want to standardize retrieving the linux distrubtion information, I guess that not using
lsb_releaseat all but rather implementing the major distribution's implementation oflsb_release(whatever is not already explicitly implemented in distro) would be great. This would not only force standardization but also remove a known yet arbitrarily implemented dependency onlsb_release.Detect distro from arbitrary rootfs root_dir python-distro#161
pombredanne commentedon Nov 12, 2019
I pushed a PR with a fix for this #247
Add --root-dir option to cli python-distro#161
Add --root-dir option to cli python-distro#161
Merge pull request #247 from pombredanne/161-root-dir-arg
hartwork commentedon Jul 10, 2021
Is this ready to be closed as fixed by #247?
HorlogeSkynet commentedon Sep 25, 2021
Indeed, closing here then 👍