How can I revert back from an upgrade to the Proposed repository?
I mistakenly enabled the Pre-release updates (natty-proposed) repository and then upgraded all packages.
How can I undo this?
Here are the test results from @enzotib's instructions and the test results from my instructions.
Solution 1:
Here's a more general way to revert from locally installed packages, proposed and backports packages to the stable+updates channel. While the other answers are correct and work in a similar way, I think this is a more elegant approach.
- Make sure you removed the entries of
-proposed
or-backports
in your/etc/apt/sources.list
and/etc/apt/sources.list.d/*
files. -
Add an apt-preferences file, e.g.
/etc/apt/preferences.d/99-back-to-stable-updates
containing (forprecise
here - replace with your version):Package: * Pin: release a=precise Pin-Priority: 1001 Package: * Pin: release a=precise-updates Pin-Priority: 1001 Package: * Pin: release a=precise-security Pin-Priority: 1001 Package: * Pin: release a=precise-proposed Pin-Priority: -10 Package: * Pin: release a=precise-backports Pin-Priority: -10
This pinning of > 1000 will make apt force a downgrade on packages from that channel and a priority of < 0 on the
-proposed
and-backports
channels will make remove any additional packages too. -
Now run
sudo apt-get update sudo apt-get dist-upgrade
Inspect the proposed solution apt will give you, and if you think it's okay, then accept it. If you need to check on why and what version it will be downgraded to, check this with
apt-cache policy packagename
to see what versions are available and what apt decides is the candidate for installation. Remove the
/etc/apt/preferences.d/99-back-to-stable-updates
file again, as it's not needed anymore.
Thanks to mlind
on the Ubuntu forums for this inspriation on pinning in his post from more than 5 years ago - yet it helped me out pretty well today.
Solution 2:
This page suggests that Apt pinning can be used to downgrade from an entire repository by leveraging the fact that pin priorities higher than 1000 can cause package downgrades.
One solution, then, might be to temporarily increment by 1000 the default priorities of all package files except for those from the natty-proposed
repository:
apt-cache policy | awk '
/^ [0-9]+ / {
p = $1;
getline;
r = $0;
if (r !~ /a=natty-proposed/) p += 1000;
print "Package: *\nPin: " r "\nPin-priority: " p "\n"
}
' | sudo tee /etc/apt/preferences.d/downgrade-from-natty-proposed
(Note: This method fails to increase the priority of package files whose release fields contain commas. See this question.)
After doing this, apt-get --simulate upgrade
can be used to test for successful downgrade detection. After confirming that the correct downgrades are detected, sudo apt-get upgrade
should be all that is needed to perform the downgrade.
When the downgrade is complete, use Software Sources to disable the Pre-release updates (natty-proposed) repository, then remove the temporary priority increase:
sudo rm /etc/apt/preferences.d/downgrade-from-natty-proposed
Finally, reboot so that all running programs are their downgraded versions.
Solution 3:
I cannot find a simpler solution than the following. Yet hoping someone get in with a better answer.
The following script that can execute the downgrade
#!/bin/bash
# get a list of installed packages
dpkg --get-selections | awk '{ print $1 }' > all-packages
# run apt-cache policy on each of them, then elaborate with the awk script
apt-cache policy $(<all-packages) |
./get-prev-pkg-vers >old-versions
# install previous version of packages
sudo apt-get --simulate install $(< old-versions)
The awk
script, named get-prev-pkg-vers
is as follow
#!/usr/bin/awk -f
/^[^ ]/ {
package = $1
gsub(":", "", package)
search_next = 0
}
/^ [^ ]/ {
installed = 0
version = $1
if (search_next == 1) {
print package "=" version
search_next = 0
}
}
/^ \*\*\* [^ ]/ {
installed = 1
}
/^ [^ ]/ {
branch = $3
if (installed == 1 && branch ~ /proposed/) {
search_next = 1
}
installed = 0
}
When running the script, the proposed repo should NOT have been disable yet.
Remember to set the executable bit on both scripts.
A problem with this approach is that all downgraded packages will result as manually installed (also those that were automacally installed).
To be safe, add the --simulate
option to apt-get
at end of the bash script.
Solution 4:
Reverting all packages from natty-proposed is probably not needed: most packages will be updated to the same versions soon through natty-updates anyway.
In case you have a problem with one package, you could revert that one package using the method darent presents (after disabling -proposed), or you can use sudo aptitude install packagename/natty
. But more importantly, you should file a bug against the package. Few people actually test natty-proposed, and if regressions (=new problems) occur they should certainly be reported. Otherwise they might end-up in the updates for all ubuntu users. So if you have any issues, please report.
Solution 5:
In synaptic you can disable the repository for proposed and update your sources. Then you'll see than all the packages than have been updated appears as locally installed (since they're not in the repos anymore).
Now you'll have to "downgrade" those packages. Select one by one, and in the upper menu chose:
package > force version
(or Control+E)
A menu will appear with the avalliable options. I'd choose the lower version number for each package. If you make a mistake and there's a newer version in the normal repos, it will be solved in a later update.
A quick solution would be to use the purge-ppa command pointing to the porposed repository, but don't know if it would work with them, i've only used it to purge external ppa's and downgrade packages to the official ubuntu versions. I won't recomend you to do this in this case, maybe somebody know if it's a safe method...