Unsolved Qt apt-get installation script for multiple Linux Distributions
-
I'm trying to build a Qt install script for multiple Linux distributions. I know that Ubuntu uses "apt-get" repository and RHEL and CentOS use "yum" repository. What's the best way to detect the distribution in my script.
I was thinking something like the following just wanted to know the best way to detect the distro.
if (Ubuntu) sudo apt-get install -y [qt package] else-if (RHEL or CentOS) sudo yum -y install [qt package] endif
I found lsb_release on Ubuntu but not on CentOS. So is there a way to detect whether "yum" or "apt-get" is used?
-
-
@anshah
As you found,lsb_release
is not always there. In any case, that approach will require you to pre-enumerate which distros you know about use which, too much work to maintain.Stick to testing whether
apt_get
oryum
is present, it's much easier, and your script requires it to run anyway. So like:if [ -f /usr/bin/apt-get ] then sudo apt-get install -y [qt package] elif [ -f /usr/bin/yum ] then sudo yum -y install [qt package] fi
[edit: fixed executable check SGaist]