Is it possible to only allow specific packages updates from a PPA
You would use what is called "pinning"
Assuming you are installing package foo from the PPA, you would almost certainly need to install any dependencies from the ppa as well.
But if there are other programs, you can specify which repository to use with pinning.
See Ubuntu wiki pinning
There is an example of pinning a ppa on that page
https://help.ubuntu.com/community/PinningHowto#Pinning_the_ubuntu-mozilla-daily_PPA
From the wiki page:
To make apt-get upgrading as painless as possible set a lower Pin-Priority on the PPA, this will stop unwanted package versions from installing. Once set, packages from the ubuntu-mozilla-daily PPA will always lose in any contest with packages from other repositories, even if they have a higher version.
Create the file /etc/apt/preferences.d/ubuntu-mozilla-daily-pin-400
Add the following to the file:
Package: *
Pin: release o=LP-PPA-ubuntu-mozilla-daily
Pin-Priority: 400
Use the following commands, before and after, to check that the Pin-Priority has been updated.
apt-cache policy
apt-cache policy firefox-3.5
First of all, if you have already upgraded packages from a PPA by mistake, see this answer: https://askubuntu.com/a/142808/103117 in particular the section on using ppa-purge. Because I had already upgraded packages and apt-get will not downgrade regardless of priorities, it is easiest to purge all the upgraded packages first, then fix the priorities, then re-add the PPA and only upgrade the packages you want.
For a full explanation of the priority / pinning system, see man apt_preferences
.
If a package is available from multiple sources, each one will be assigned a priority and you can see that with apt-cache policy <package name>
. For example, I use a PPA called nathan-renniewaldock/ppa/ubuntu and I do not want to install mysql-server-5.5 (my "package Y") from there. So I can check my current situation with:
rob@frodo:~$ apt-cache policy mysql-server-5.5
mysql-server-5.5:
Installed: 5.5.27-1~ppa1~precise
Candidate: 5.5.27-1~ppa1~precise
Version table:
*** 5.5.27-1~ppa1~precise 0
500 http://ppa.launchpad.net/nathan-renniewaldock/ppa/ubuntu/ precise/main amd64 Packages
100 /var/lib/dpkg/status
5.5.24-0ubuntu0.12.04.1 0
500 http://gb.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu/ precise-security/main amd64 Packages
5.5.22-0ubuntu1 0
500 http://gb.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
So because everything is priority 500, according to the man page the one with the highest version number is chosen.
If, for example, you want to install only ddclient ("package X"), but not any other package, you want to reduce the priority for all packages in the PPA except for ddclient. Create a file called /etc/apt/preferences.d/nathan-preferences
. Note that all files in that directory are read and there are some rules about the filename (it must contain only alphanumeric characters, hypens, dashes and have no extension or end in .pref).
First we need to know how to identify our PPA. The apt-cache policy
command on its own dispays information about all sources. I know my PPA has "nathan" in the name so I do:
$ apt-cache policy | grep nathan
400 http://ppa.launchpad.net/nathan-renniewaldock/ppa/ubuntu/ precise/main i386 Packages
release v=12.04,o=LP-PPA-nathan-renniewaldock,a=precise,n=precise,l=PPA,c=main
The interesting part is "o=LP-PPA-nathan-renniewaldock", which we use in the /etc/apt/preferences.d/nathan-prefs file like this:
Package: *
Pin: release o=LP-PPA-nathan-renniewaldock
Pin-Priority: 400
Package: ddclient
Pin: release o=LP-PPA-nathan-renniewaldock
Pin-Priority: 500
This sets everything in the PPA to priority 400, then turns ddclient back up to the default 500. Now, I can check that it has worked:
$ apt-cache policy ddclient
ddclient:
Installed: 3.8.0-11.4ubuntu1
Candidate: 3.8.1-0~ppa1~precise
Package pin: 3.8.1-0~ppa1~precise
Version table:
3.8.1-0~ppa1~precise 500
400 http://ppa.launchpad.net/nathan-renniewaldock/ppa/ubuntu/ precise/main amd64 Packages
*** 3.8.0-11.4ubuntu1 500
500 http://gb.archive.ubuntu.com/ubuntu/ precise/universe amd64 Packages
100 /var/lib/dpkg/status
So ddclient has a priority of 500, which is the same as the original Ubuntu package, but it will be installed from the nathan PPA because that one is a higher version. Now let's make sure the other packages won't be installed:
$ apt-cache policy mysql-server
mysql-server:
Installed: 5.5.24-0ubuntu0.12.04.1
Candidate: 5.5.24-0ubuntu0.12.04.1
Version table:
5.5.27-1~ppa1~precise 0
400 http://ppa.launchpad.net/nathan-renniewaldock/ppa/ubuntu/ precise/main amd64 Packages
*** 5.5.24-0ubuntu0.12.04.1 0
500 http://gb.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu/ precise-security/main amd64 Packages
100 /var/lib/dpkg/status
5.5.22-0ubuntu1 0
500 http://gb.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
In this case the package from the nathan PPA has priority 400 which is lower than the Ubuntu one, so even though it is of a higher version it will not be upgraded. We can check with:
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
ddclient
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 77.7 kB of archives.
After this operation, 11.3 kB of additional disk space will be used.
Do you want to continue [Y/n]?
Since only the package I want is to be upgraded, I am happy to say yes.