-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I'm trying to find a standard way of finding the native packaging system of a linux distribution. I'm not sure at all that testing the presence of {rpm/yum}|{apt-get} is reliable as for example I can install apt-get of my fedora computer.
So the question is, is there a simple test that can reliably determine whether a linux machine is rpm or debian based for its native package scheme ?
Thank's in advance,
Theo.
Am 14.03.2013 16:07, schrieb Theodore Papadopoulo:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I'm trying to find a standard way of finding the native packaging system of a linux distribution. I'm not sure at all that testing the presence of {rpm/yum}|{apt-get} is reliable as for example I can install apt-get of my fedora computer.
So the question is, is there a simple test that can reliably determine whether a linux machine is rpm or debian based for its native package scheme?
presence of /var/lib/rpm /etc/os-release /etc/redhat-release
On Thu, 14 Mar 2013 16:09:24 +0100, Reindl Harald wrote:
I'm trying to find a standard way of finding the native packaging system of a linux distribution. I'm not sure at all that testing the presence of {rpm/yum}|{apt-get} is reliable as for example I can install apt-get of my fedora computer.
So the question is, is there a simple test that can reliably determine whether a linux machine is rpm or debian based for its native package scheme?
presence of /var/lib/rpm /etc/os-release /etc/redhat-release
And perhaps a run-time check, such as an RPM based query, which would only work if the RPM database is filled with details about installed files.
$ rpm -qa|wc -l 1601 $ rpm -qf /sbin/init systemd-198-3.fc19.x86_64 $ rpm -qf $(which bash) bash-4.2.45-1.fc19.x86_64
On 03/14/2013 04:43 PM, Michael Schwendt wrote:
On Thu, 14 Mar 2013 16:09:24 +0100, Reindl Harald wrote:
presence of /var/lib/rpm /etc/os-release /etc/redhat-release
And perhaps a run-time check, such as an RPM based query, which would only work if the RPM database is filled with details about installed files.
$ rpm -qa|wc -l 1601 $ rpm -qf /sbin/init systemd-198-3.fc19.x86_64 $ rpm -qf $(which bash) bash-4.2.45-1.fc19.x86_64
There's no standard way I know of that's guaranteed to work (I think LSB has some bits that could help but since you can't depend on them being installed or even available everywhere it's pretty much useless).
You could take a look at how sos does this:
https://github.com/sosreport/sosreport
Sos is a support data collection tool written in python. The upstream version now runs on Fedora, RHEL, RHEV, RHS, Debian, Ubuntu, Mac OSX, and Windows. It abstracts package management in a policy class - each target defines a policy which probes the environment to determine whether it should be the active policy. So for e.g. if /etc/fedora-release or /etc/redhat-release exists the redhat policy is activated.
This is fairly robust and lets you define hierarchies (e.g. the Ubuntu policy extends Debian policy, and both Debian and Red Hat policies inherit from a common LinuxPolicy) so that policies can share common bits of implementation.
The downside is that you have to create and maintain the policies and either add support for each new flavour or provide generic fall backs that do a reasonable job on unknown hosts.
Regards, Bryn.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 03/14/2013 06:39 PM, Bryn M. Reeves wrote:
On 03/14/2013 04:43 PM, Michael Schwendt wrote:
On Thu, 14 Mar 2013 16:09:24 +0100, Reindl Harald wrote:
presence of /var/lib/rpm /etc/os-release /etc/redhat-release
And perhaps a run-time check, such as an RPM based query, which would only work if the RPM database is filled with details about installed files.
$ rpm -qa|wc -l 1601 $ rpm -qf /sbin/init systemd-198-3.fc19.x86_64 $ rpm -qf $(which bash) bash-4.2.45-1.fc19.x86_64
There's no standard way I know of that's guaranteed to work (I think LSB has some bits that could help but since you can't depend on them being installed or even available everywhere it's pretty much useless).
You could take a look at how sos does this:
https://github.com/sosreport/sosreport
Sos is a support data collection tool written in python. The upstream version now runs on Fedora, RHEL, RHEV, RHS, Debian, Ubuntu, Mac OSX, and Windows. It abstracts package management in a policy class - each target defines a policy which probes the environment to determine whether it should be the active policy. So for e.g. if /etc/fedora-release or /etc/redhat-release exists the redhat policy is activated.
This is fairly robust and lets you define hierarchies (e.g. the Ubuntu policy extends Debian policy, and both Debian and Red Hat policies inherit from a common LinuxPolicy) so that policies can share common bits of implementation.
The downside is that you have to create and maintain the policies and either add support for each new flavour or provide generic fall backs that do a reasonable job on unknown hosts.
Regards, Bryn.
Interesting, I'll have a look. But the downside you mention is exactly the one I want to avoid. Having to handle a mapping between distributions and packaging systems. See the other message I just posted...
Anyway thnk for this pointer.
Theo.
On 03/14/2013 06:27 PM, Theodore Papadopoulo wrote:
Interesting, I'll have a look. But the downside you mention is exactly the one I want to avoid. Having to handle a mapping between distributions and packaging systems. See the other message I just posted...
I think that's the crux of this problem: you can either approach it via heuristics (check for presence of known package manager bits, e.g. /var/lib/rpm etc., even make some guess about 'rpm has X packages installed, deb has Y, X>Y: it's an RPM distro, for the unusual cases where more than one is present), or, you have to define and maintain the mapping by hand.
Either one could work out for a given use; it all depends on the consequences of getting it wrong or of not having a policy available for some environment where the tool runs.
Regards, Bryn.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 03/14/2013 05:43 PM, Michael Schwendt wrote:
On Thu, 14 Mar 2013 16:09:24 +0100, Reindl Harald wrote:
I'm trying to find a standard way of finding the native packaging system of a linux distribution. I'm not sure at all that testing the presence of {rpm/yum}|{apt-get} is reliable as for example I can install apt-get of my fedora computer.
So the question is, is there a simple test that can reliably determine whether a linux machine is rpm or debian based for its native package scheme?
presence of /var/lib/rpm /etc/os-release /etc/redhat-release
And perhaps a run-time check, such as an RPM based query, which would only work if the RPM database is filled with details about installed files.
$ rpm -qa|wc -l 1601 $ rpm -qf /sbin/init systemd-198-3.fc19.x86_64 $ rpm -qf $(which bash) bash-4.2.45-1.fc19.x86_64
Yes I imagined that detecting /var/lib/rpm was one way to deal with the problem (but not /etc/*-release as this is exactly what I want to avoid: having to map distributions to packaging system).
I was hoping that there was some magic command a la lsb_release which could have helped for this). Well I guess I'll have to rely on some heuristic like those for now.
Would there be a possibility (for the long term) to add such a facility. I understand that this is quite difficult as it requires some synchronisation between distributions.
For the record, I'm just trying to have my cmake based build system to decide which packaging scheme it should use on a given linux machine...
Thank's for the answers.
Theo.
Am 14.03.2013 19:25, schrieb Theodore Papadopoulo:
Yes I imagined that detecting /var/lib/rpm was one way to deal with the problem (but not /etc/*-release as this is exactly what I want to avoid: having to map distributions to packaging system).
I was hoping that there was some magic command a la lsb_release which could have helped for this). Well I guess I'll have to rely on some heuristic like those for now.
Would there be a possibility (for the long term) to add such a facility. I understand that this is quite difficult as it requires some synchronisation between distributions
i fear this is unlikely, there are way too much distributions
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 03/14/2013 07:48 PM, Reindl Harald wrote:
Am 14.03.2013 19:25, schrieb Theodore Papadopoulo:
Yes I imagined that detecting /var/lib/rpm was one way to deal with the problem (but not /etc/*-release as this is exactly what I want to avoid: having to map distributions to packaging system).
I was hoping that there was some magic command a la lsb_release which could have helped for this). Well I guess I'll have to rely on some heuristic like those for now.
Would there be a possibility (for the long term) to add such a facility. I understand that this is quite difficult as it requires some synchronisation between distributions
i fear this is unlikely, there are way too much distributions
I understand that... On the other way fedora often opens the route... ;-)
Is there a place where this can be escalated and discussed ?
Theo.
Hi
On Thu, Mar 14, 2013 at 3:05 PM, Theodore Papadopoulo wrote:
Is there a place where this can be escalated and discussed ?
http://lists.freedesktop.org/mailman/listinfo/distributions
Rahul
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 03/14/2013 09:03 PM, Rahul Sundaram wrote:
Hi
On Thu, Mar 14, 2013 at 3:05 PM, Theodore Papadopoulo wrote:
Is there a place where this can be escalated and discussed ?
http://lists.freedesktop.org/mailman/listinfo/distributions
Rahul
Thank you. I will try that in a minute.
Theo.
On 14.03.2013 19:25, Theodore Papadopoulo wrote:
Yes I imagined that detecting /var/lib/rpm was one way to deal with the problem (but not /etc/*-release as this is exactly what I want to avoid: having to map distributions to packaging system).
Maybe you have your reasons that I don't understand but package management is distribution related. Generally Linux distributions are built around package managers. There are rpm based ones like Fedora, RH, SuSE and deb based like Debian, Ubuntu. There is opkg in OpenWRT and something that I can't remember right now in Arch. So package management is tightly related to Linux distro. Detecting Linux distribution is easier than searching for rpm or dpkg commands and checking if they are dominant package managers on the system.
Mateusz Marzantowicz
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 03/14/2013 11:33 PM, Mateusz Marzantowicz wrote:
On 14.03.2013 19:25, Theodore Papadopoulo wrote:
Yes I imagined that detecting /var/lib/rpm was one way to deal with the problem (but not /etc/*-release as this is exactly what I want to avoid: having to map distributions to packaging system).
Maybe you have your reasons that I don't understand but package management is distribution related. Generally Linux distributions are built around package managers. There are rpm based ones like Fedora, RH, SuSE and deb based like Debian, Ubuntu. There is opkg in OpenWRT and something that I can't remember right now in Arch. So package management is tightly related to Linux distro. Detecting Linux distribution is easier than searching for rpm or dpkg commands and checking if they are dominant package managers on the system.
Mateusz Marzantowicz
Simply go to:
http://en.wikipedia.org/wiki/List_of_Linux_distributions
and see the number of distributions. There are far fewer packaging systems than distributions, and I clearly do not want to maintain a map distribution -> packaging system.
I know that these packaging systems are differing in details (for rpm, Suse and Fedora/Redhat macros are not the same), but if I can provide a spec that relies on the common denominator, it would build a package for any rpm based distrib without me even knowing that this distribution exists.
So there is an advantage in having a reliable way to get this information, otherwise I will do something heuristicL that works sometimes.... and I like when I write the code once and then can forget it forever because it just works ;-)
OK I know this will never be the case, but if I can convince distribs/people to provide such a facility, the gnu/linux world will be infinitesimally better I think...
And it seems that the cost of adding some script (with a common name) or adding an option (eg in lsb_release) is not very high. The more difficult step is to convince everyone and to get some consensus... Bit again, this seems so trixial, so that I cannot see people arguing the pros and cons forever. They will find it's a good or a bad idea. The time spent to discuss this is probably already much higher than the time needed to implement sthg simple.
Theo.
On Thu, 2013-03-14 at 19:25 +0100, Theodore Papadopoulo wrote:
Yes I imagined that detecting /var/lib/rpm was one way to deal with the problem (but not /etc/*-release as this is exactly what I want to avoid: having to map distributions to packaging system).
I was hoping that there was some magic command a la lsb_release which could have helped for this). Well I guess I'll have to rely on some heuristic like those for now.
I would have thought that looking for the various /etc/release types of file that you know about would have been the simplest solutions. Surely, you'd know what to expect for all the releases that you're supporting?
In the last few days, I had read a page discussing a more universal single /etc/release file, that would use the one filename for all distros, and have parameters inside it that were specific to the particular release.
I don't remember where I read that, but it was most likely a reference found on this list.
On 3/14/13, Tim ignored_mailbox@yahoo.com.au wrote:
In the last few days, I had read a page discussing a more universal single /etc/release file, that would use the one filename for all distros, and have parameters inside it that were specific to the particular release.
That would be /etc/os-release: http://www.freedesktop.org/software/systemd/man/os-release.html
-T.C.
Tim:
In the last few days, I had read a page discussing a more universal single /etc/release file, that would use the one filename for all distros, and have parameters inside it that were specific to the particular release.
T.C. Hollingsworth:
That would be /etc/os-release: http://www.freedesktop.org/software/systemd/man/os-release.html
Yes, that was it. Sounds just like what they original poster wants, but probably hasn't been implemented enough for them to use.
But, to my mind, if I was having to support numerous OSs, rather than trying to poll package managers databases, and make guesses about which distro it was (and release version, etc), it'd be far easier to find out what release file they each use, and search for them (in the absence of a universal release file). It'd only be one file per release, and surely each release file would be unique enough to identify it clearly.
On Thu, 14 Mar 2013 16:07:21 +0100 Theodore Papadopoulo Theodore.Papadopoulo@inria.fr wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I'm trying to find a standard way of finding the native packaging system of a linux distribution. I'm not sure at all that testing the presence of {rpm/yum}|{apt-get} is reliable as for example I can install apt-get of my fedora computer.
So the question is, is there a simple test that can reliably determine whether a linux machine is rpm or debian based for its native package scheme ?
Thank's in advance,
Theo.
Have you looked at the Distrowatch site? They do list the package management system for each distribution that they track, but I'm not certain if the D/W database recognizes package management as a searchable property.
-- cmg