2

Is there a way to use apt to apply a pending upgrade to a package, but do nothing if it's not installed?

I have many Debian systems, all with different sets of packages, and I want to apply specific patches as they become available. I'd like to run the same command across all my systems but without installing missing packages. Ordinarily I would use apt-get install package to do the upgrade, but this will install it where it's not already there.

I could work around this with something along the lines of

(dpkg -l package | grep '^ii') && apt-get install package

but is there a better way?

  • Just apt-get upgrade will not install missing packages. You want a version of apt-get upgrade that is package-specific? Like apt-get upgrade pkgname? if so, why? – Faheem Mitha Mar 19 '15 at 9:01
  • I take a very conservative view to patching: I only apply patches where the fix is important to my servers. Also, some patches can be applied without affecting production, where others require downtime (e.g. a postgresql patch will restart the database after it's applied). I need a fine-graned approach so that I can apply important patches with minimal disruption. – Flup Mar 19 '15 at 9:04
2

I think you are looking for:

apt-get install --only-upgrade pkgname

man apt-get says:

 --only-upgrade
     Do not install new packages; when used in conjunction with 
     install, only-upgrade will install upgrades for already
     installed packages only and ignore requests to install new
     packages. Configuration Item: APT::Get::Only-Upgrade.
| improve this answer | |
  • I am! Thanks so much -- for some reason I never saw that in the manpage. – Flup Mar 19 '15 at 9:38
  • 1
    @Flup Till just now, I didn't know it existed either. :-) – Faheem Mitha Mar 19 '15 at 10:42

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.