Because of bug #693758 I'd like to prevent apt-get upgrade
and Update Manager from updating the "libgtk2.0-0" package.
How can this be achieved?
Because of bug #693758 I'd like to prevent apt-get upgrade
and Update Manager from updating the "libgtk2.0-0" package.
How can this be achieved?
There are different ways of holding back packages: with dpkg
, apt
, dselect
, aptitude
or Synaptic.
Put a package on hold:
echo "<package-name> hold" | sudo dpkg --set-selections
Remove the hold:
echo "<package-name> install" | sudo dpkg --set-selections
Display the status of all your packages:
dpkg --get-selections
Display the status of a single package:
dpkg --get-selections <package-name>
Show all packages on hold:
dpkg --get-selections | grep "\<hold$"
Hold a package:
sudo apt-mark hold <package-name>
Remove the hold:
sudo apt-mark unhold <package-name>
Show all packages on hold:
sudo apt-mark showhold
With dselect, enter the [S]elect screen, find the package you wish to hold in its present state and press = or H. The changes will take effect immediately after exiting the [S]elect screen.
The following approaches are limited in that locking/holding a package within aptitude or synaptic doesn't affect apt-get/apt.
Hold a package:
sudo aptitude hold <package-name>
Remove the hold:
sudo aptitude unhold <package-name>
Go to Synaptic Package Manager (System > Administration > Synaptic Package Manager).
Click the search button and type the package name.
When you find the package, select it and go to the Package menu and select Lock Version.
That package will now not show in the update manager and will not be updated.
devscripts
, a lot packaged are pulled as Recommended packages. As I don't need a mailserver (postfix), I could disable the installation of it by running echo postfix hold | sudo dpkg --set-selections
before running sudo apt-get install devscripts
. This hold action persists only for this installation, after the installation the selections are reset.
Commented
Aug 20, 2011 at 10:47
apt-mark
doesn't support hold
in version 0.7.25 (Ubuntu Lucid)
sudo apt-mark hold/unhold
currently works in Ubuntu 16.04 (Xenial Xerus). I held some obsolete packages and then executed sudo apt-get dist-upgrade
in order to see if they would be upgraded, but the held packages were not upgraded. By the way, you can hold/unhold several packages at once. Example: sudo apt-mark hold thunar thunar-dbg thunar-data libthunarx-2-0 libthunarx-2-dev
. Nice!
Commented
Sep 3, 2016 at 4:20
I was looking for the same thing and after a lot of research I found that using the following syntax you can forbid one specific version but allow the next update:
Package: compiz-plugins-main
Pin: version 1:0.9.7.0~bzr19-0ubuntu10.1
Pin-Priority: -1
This goes into the /etc/apt/preferences
file.
To put a package "foo" on hold:
echo "foo hold" | dpkg --set-selections
In your case we are going to put wine on hold:
sudo -i
echo "wine hold" | dpkg --set-selections
To remove the hold:
sudo -i
echo "wine install" | dpkg --set-selections
apt-get install wine=1.2.3
. Being on hold prevents apt-get (dist-)upgrade
from changing it.
/var/cache/apt/archives
) is independent of holds & upgrades & stuff, so all the versions you've downloaded will be there until you run apt-get [auto]clean
Install synaptic
using sudo apt-get install synaptic
.
Run using gksudo synaptic
and on the search box locate the package you want to lock, ie: gedit
From the package menu select Lock version:
And that is all, the version currently installed at the time of the lock will stay installed even during upgrades.
Preventing a package from being installed is called "package holding" and it is very simple to do:
echo package_name hold | dpkg --set-selections
...where *package_name* is the name of the package you want to prevent from installation.
Note: the above command assumes root privileges. In other words, you will probably need to type sudo su
before running it.
s/sudo su/sudo -s/g
(or sudo -i
). (-i
will give a login shell, -s
will not).
Since some time apt-get
is replaced by apt
, so for example I want to prevent Firefox from updating to version above 56, because a lot of add-ons, like "Tab Groups" don't work any more with the new Firefox 57 (see "WebExtensions Update").
It is possible to hold more than one packages with one command and use wildcards.
sudo apt-mark hold firefox firefox-locale-*
If you should deside to unhold them later, that would be the command:
sudo apt-mark unhold firefox firefox-locale-*
Everything you ever wanted to know about "holding" and "pinning" packages to specific versions: https://help.ubuntu.com/community/PinningHowto
I synaptic you can freeze the version of a specific package I'm not a 100% sure as to whether this will amend apt-get but it will definately stop update manager.
To freeze a package select it in synaptic then open the package menu and select freeze version.
Hope this helps
edit: This question 16668 deals with a similar situation
Adding details to @soger's comments relative to Ubuntu 16.04.
Ubuntu 16.04 does not have an existing /etc/apt/preferences file by default. If you don't have one currently, just create a new file and populate it with a stanza as @soger describes above to exclude the given package and its dependencies from updates.
Afterwards, run apt update
and you're GTG. :0)
For example, I have an Ubuntu 16.04.5 LTS server with embedded Intel video card and an NVidia card. The NVidia card is the only one used. The server also uses CUDA drivers. I had a problem where apt
kept insisting
va-driver-all
(Intel drivers) required an update, but it could not determine which version to install. This was driving me nuts, and I didn't need the Intel drivers anyway. I entered this text into the preferences file and flushed apt, problem solved.
Package: va-driver-all
Pin: release *
Pin-Priority: -1
You can use on aptitude the "specific override", like this:
aptitude reinstall ~i oracle-java8-jre:
This is a one time only use of (not stored for future reinstalls), keep specific override, to reinstall all packages in your system but not oracle-java8-jre.
If you use a keep specific override, the package will momentarily be in a state of keep and aptitude will not try to install it.
A very good thing if you think your system was compromised some how as you can reinstall everything in just one punch card.
If you have Synaptic installed you can select the package and use the menu Package -> Lock Version to prevent it being updated.
You can install Synaptic with sudo apt-get install synaptic. I personally find it more useful than the Software Center... then again, I'm fairly old school. :)
To keep a package at the currently-installed version and prevent it from being automatically upgraded, you can add an APT preference fragment to /etc/apt/preferences.d
like this:
Package: vim
Pin: release a=now
Pin-Priority: 1001
Occasionally one might want to hold back all the packages currently installed. Here's how.
First save the current state, so you can undo:
dpkg --get-selections > current_selections.txt
Then, to hold back all the packages:
dpkg --get-selections | sed -r "s/\tinstall/hold/" |dpkg --set-selections
Finally, when you want to revert back to the previous state:
dpkg --set-selections < current_selections.txt
One use case for this might be when creating a VM or Amazon AMI snapshot to migrate from a QA to production environment.
disable packages from the auto-update
apt-get
toapt
, it's worth noting thatapt-mark hold packagename
is still the standard solution for this. Tryingapt hold
will just complain withE: Invalid operation hold