24

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.

1
  • 1
    The test results pastebins are dead.
    – enzotib
    Aug 23, 2013 at 8:30

6 Answers 6

29

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.

  1. Make sure you removed the entries of -proposed or -backports in your /etc/apt/sources.list and /etc/apt/sources.list.d/* files.
  2. Add an apt-preferences file, e.g. /etc/apt/preferences.d/99-back-to-stable-updates containing (for precise 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.

  3. 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.

  4. 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.

4
  • I suppose it should work with debian as well. Unfortunately, it doesn't do anything for me :/
    – Michael
    Mar 18, 2016 at 17:27
  • @Michael 1) Debian does not have the concept of -proposed official repositories. 2) This site is about Ubuntu, not Debian. I'd suggest you to ask a new question on Unix.SE.
    – gertvdijk
    Mar 19, 2016 at 15:38
  • This solution also worked with 'xenial' version! (after replacing precise with xenial in the file, of course) Thanks a lot!
    – morhook
    Jul 5, 2016 at 16:47
  • thank you. have same my life. this solution work well on rpi4 ubuntu 20.04 desktop 64 bit Dec 14, 2020 at 14:57
4

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.

1
  • 1
    Interesting solution, probably best and more general than mine. By the way, the number of downgraded packages is the same, confirming the correctness of both approaches.
    – enzotib
    Sep 2, 2011 at 18:18
2

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.

2

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.

1

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...

1
  • The last paragraph is speculation only and should therefore be a comment on the question or researched properly. Jan 4, 2019 at 9:48
0

I proposed to provide a function to downgrade all proposed packages with a simple maintained command equiavalent to ppa-purge at https://bugs.launchpad.net/ubuntu/+source/software-properties/+bug/1810499 since the posts here still seem to represent the state of the system.

"proposed" - get it?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .