Is there a command to do just that: if a package is already installed, update it, otherwise install the latest version
For now I'm doing two commands:
yum install mypackage
yum update mypackage
Maybe there's a more efficient way?
At least for me, yum
is bright enough that if I tell it to install something which is already installed, and for which an update is available, it will just apply the update instead. E.g.:
[root@risby ~]# rpm -qa|grep openvpn
openvpn-2.2.2-7.fc17.x86_64
openvpn is installed.
[root@risby ~]# yum update
[...]
--> Running transaction check
---> Package openvpn.x86_64 0:2.2.2-7.fc17 will be updated
---> Package openvpn.x86_64 0:2.3.1-2.fc17 will be an update
An update is available.
[root@risby ~]# yum install openvpn
[...]
--> Running transaction check
---> Package openvpn.x86_64 0:2.2.2-7.fc17 will be updated
---> Package openvpn.x86_64 0:2.3.1-2.fc17 will be an update
yum install
does the right thing anyway. yum version is 3.4.3, by the way.