Reliable way to determine native packaging system

Theodore Papadopoulo Theodore.Papadopoulo at
Thu Mar 14 18:25:52 UTC 2013

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.

Version: GnuPG v1.4.13 (GNU/Linux)
Comment: Using GnuPG with Thunderbird -


More information about the users mailing list