I'm working on a script to install a package from a URL. The script needs to install the package if it isn't installed and forcibly replace the existing version with the specified RPM if it is already installed. Unfortunately both yum install and yum update return 1 if the package is already at the right version. How do I just tell yum to absolutely, positively install an RPM and only return an exit code if there's an actual error?

  • do you mean allowing downgrades, or actually reinstalling even when EVR is the same? – guido Nov 5 '14 at 18:10
  • Delete the package first? ;-) – Hauke Laging Nov 5 '14 at 18:28
  • @guido Reinstalling is not necessary, but it must definitely allow downgrades. – l0b0 Nov 5 '14 at 18:51
  • did you already try yum --allow-downgrade install <package-version>? – guido Nov 5 '14 at 21:30

Instead of your script calling yum to do the download and install, I would just make the script download the file (with e.g. curl or wget) and then force the installation of the downloaded .rpm file:

rpm --install --force file_name.rpm

As the OP indicated, rpm can donwload the URL directly without a problem. From the man page:

   rpm {-i|--install} [install-options] PACKAGE_FILE ...

   rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...

   rpm {-F|--freshen} [install-options] PACKAGE_FILE ...


   In  these  options, PACKAGE_FILE can be either rpm binary file or ASCII
   package manifest (see PACKAGE SELECTION OPTIONS), and may be  specified
   as  an  ftp  or  http URL, in which case the package will be downloaded
   before being installed. See FTP/HTTP OPTIONS for information  on  rpm's
   internal ftp and http client support.
  • I agree here, unless the OP is doing no dependency checking... – eyoung100 Nov 5 '14 at 17:26
  • @eyoung100 If that could be a problem, first installing with yum from the local download should get any missing dependencies, and then if that fails, because of already being up-to-date, do the forced RPM install. That's still only one download. – Anthon Nov 5 '14 at 17:54
  • rpm seems to be fine installing from URLs. Why would I need to download first? Anyway, your command works. Thanks! – l0b0 Nov 6 '14 at 9:36
  • @l0b0 I currently don't have an RPM based system running and I have been using Debian packaging for too long. I thought I remembered that rpm could only install locally. (I used to have a SuSE system, where YaST would download and install from the net, I used rpm only for locally created .rpm files). – Anthon Nov 6 '14 at 9:48
  • what if the downgraded package needs a to-be-downgraded dependency? – guido Nov 6 '14 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.