Announcement

Collapse
No announcement yet.

HOW TO: Revert installed packages to official release versions

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    HOW TO: Revert installed packages to official release versions

    Many of us like to keep the extra Kubuntu PPAs (updates, backports) enabled to receive the freshest that the Kubuntu team and KDE have to offer. Occasionally, though, this can create situations in which a package goes "orphan." Once this happens, then depending on how version numbers are tracked, dist-upgrade may not be able to replace them.

    Most recently, this happened to me shortly after the 13.10 release. The Kubuntu updates PPA was pulling in and publishing nightly builds from KDE's Git repository. Because I had that PPA enabled, apt-get dist-upgrade dutifully installed each package. At some point the PPA stopped publishing builds, and much of my KDE went "orphan." In other words, the currently installed packages were neither from the official 13.10 release nor from a PPA. You can tell this happens with the help of apt-cache:
    Code:
    steve@t520:~$ [B]apt-cache policy kde-workspace[/B]
    kde-workspace:
      Installed: 4.11.2+git20131021+bzr48600+pkg833~ubuntu13.10.1
      Candidate: 4.11.2+git20131021+bzr48600+pkg833~ubuntu13.10.1
      Version table:
     *** 4.11.2+git20131021+bzr48600+pkg833~ubuntu13.10.1
            [COLOR="#FF0000"]100 /var/lib/dpkg/status[/COLOR]
         4:4.11.2-0ubuntu1 0
            500 http://mirror.anl.gov/ubuntu/ saucy/universe amd64 Packages
            100 /var/lib/dpkg/status
    The clue here is that the installed version, indicated with ***, is no longer linked to any of the official pockets (saucy, saucy-updates, saucy-security, saucy-backports) or to any current PPA, but instead only to the list of locally-installed packages (as shown in red). Understanding how to fix this requires some knowledge of Debian packaging, so keep reading.

    Normally, without any updates or PPA replacements installed, the output of the above would be:
    Code:
    steve@t520:~$ [B]apt-cache policy kde-workspace[/B]
    kde-workspace:
      Installed: 4:4.11.2-0ubuntu1
      Candidate: 4:4.11.2-0ubuntu1
      Version table:
     *** 4:4.11.2-0ubuntu1 0
            500 [url]http://mirror.anl.gov/ubuntu/[/url] saucy/universe amd64 Packages
            100 /var/lib/dpkg/status
    The three-digit number in front of the two possible installation choices indicates the priority of a package. By default, packages in all pockets and PPAs (but not backports) are set to priority 500. This means that APT relies only on the version number to decide whether to upgrade a package. Once a package is installed (or upgraded), APT also adds an entry to the file /var/lib/dpkg/status to keep track of what's installed. The priority is set to 100, which is the convention for installed packages.

    When a package is upgraded from a pocket or PPA, the cache policy display appears like so:
    Code:
    steve@t520:~$ [B]apt-cache policy distro-info-data[/B]
    distro-info-data:
      Installed: 0.16ubuntu0.1
      Candidate: 0.16ubuntu0.1
      Version table:
     *** 0.16ubuntu0.1 0
            [COLOR="#FF0000"]500 http://mirror.anl.gov/ubuntu/ saucy-updates/main amd64 Packages
            100 /var/lib/dpkg/status[/COLOR]
         0.16 0
            500 http://mirror.anl.gov/ubuntu/ saucy/main amd64 Packages
    Here, the installed version is from saucy-updates and the list of locally-installed packages indicates the same. Compare the pair of red lines in this output to the single red line in the first cache output above.

    Now, imagine that eventually a new version of kde-workspace appears in saucy-updates. Its priority will be 500, which is defined as "causes a version to be installed unless there is a version available belonging to the target release or the installed version is more recent" (from man apt_preferences). The installed version, remember, is 4.11.2+git20131021+bzr48600+pkg833~ubuntu13.10.1. It's certainly possible to envision a state where the APT somehow interprets the version number in saucy-updates to be "less" than the installed version -- and, indeed, if this were to happen, the new version of kde-workspace will not be installed.

    The way to fix this is to downgrade the affected packages to the official versions. To do this, we need to elevate their priority to something greater than 1000, according to the previously-mentioned man page: "causes a version to be installed even if this constitutes a downgrade of the package." Through the magic of APT pinning, we can make this happen.



    Step 1. In a command window, run:
    Code:
    sudo nano /etc/apt/preferences.d/return-to-release
    Enter the following:
    Code:
    Package: *
    Pin: release o=Ubuntu, a=[i]RELEASE[/i]
    Pin-Priority: 1001
    
    Package: *
    Pin: release o=Ubuntu, a=[i]RELEASE[/i]-updates
    Pin-Priority: 1001
    
    Package: *
    Pin: release o=Ubuntu, a=[i]RELEASE[/i]-security
    Pin-Priority: 1001
    Remember to substitute the name of the release for RELEASE in each of the lines above. That's the first word of the two-word release name: precise, quantal, raring, saucy, etc. Press Ctrl+X to save the file and exit the editor.


    Step 2. Now, run:
    Code:
    sudo apt-get update && sudo apt-get dist-upgrade
    APT will update its package cache, solve dependencies, and perform a downgrade of the "orphaned" packages to the most recent versions in the official pockets.

    After the downgrade completes, delete the file:
    Code:
    sudo rm /etc/apt/preferences.d/return-to-release

    Step 3. Disable the Kubuntu PPAs, at least for now, so that you don't find yourself back in this state again. You might have one or two such files: kubuntu-ppa-ppa-release.list and kubuntu-ppa-backports-release.list (where release is, of course, some release name). Type the following:
    Code:
    sudo nano /etc/apt/sources.list.d/kubuntu-ppa*.list
    Place a # in front of each line to comment it out. Press Ctrl+X to save. If you have only one .list file, nano will exit. If you have two .list files, nano will open the next one. Comment the lines in this file. Press Ctrl+X once more to save and exit.


    Step 4. Clean up the downloads and update the cache once more (to reset priorities to the default of 500):
    Code:
    sudo apt-get clean
    
    sudo apt-get update
    Finally, for good measure, reboot.
    Last edited by SteveRiley; Oct 26, 2013, 04:06 PM.

    #2
    Hi Steve. I've got this by running the command:
    Code:
    $ apt-cache policy kde-workspace
    kde-workspace:
      Instalado: 4:4.11.2+git20131022+bzr48601+pkg833~ubuntu13.10.1
      Candidato: 4:4.11.2+git20131022+bzr48601+pkg833~ubuntu13.10.1
      Tabela de versão:
     *** 4:4.11.2+git20131022+bzr48601+pkg833~ubuntu13.10.1 0
            100 /var/lib/dpkg/status
         4:4.11.2-0ubuntu1 0
            500 http://br.archive.ubuntu.com/ubuntu/ saucy/universe amd64 Packages
            500 http://archive.ubuntu.com/ubuntu/ saucy/universe amd64 Packages
         4:4.11.1+git20130910+bzr48547+pkg822~ubuntu13.10.1 0
            500 http://ppa.launchpad.net/kubuntu-ppa/ppa/ubuntu/ saucy/main amd64 Packages
         4:4.11.0+git20130819+bzr48502+pkg815~saucy1 0
            500 http://ppa.launchpad.net/kubuntu-ppa/ppa/ubuntu/ saucy/main amd64 Packages
         4:4.10.97+git20130805+bzr48465+pkg810~saucy1 0
            500 http://ppa.launchpad.net/kubuntu-ppa/ppa/ubuntu/ saucy/main amd64 Packages
    But I didn't undestand what I should write in
    Code:
    sudo nano /etc/apt/preferences.d/return-to-release
    Could you help me?
    Last edited by geoaraujo; Oct 26, 2013, 07:43 AM.

    Comment


      #3
      Originally posted by SteveRiley View Post
      Many of us like to keep the extra Kubuntu PPAs (updates, backports) enabled to receive the freshest that the Kubuntu team and KDE have to offer. Occasionally, though, this can create situations in which a package goes "orphan." Once this happens, then depending on how version numbers are tracked, dist-upgrade may not be able to replace them.

      Most recently, this happened to me shortly after the 13.10 release. The Kubuntu updates PPA was pulling in and publishing nightly builds from KDE's Git repository. Because I had that PPA enabled, apt-get dist-upgrade dutifully installed each package. At some point the PPA stopped publishing builds, and much of my KDE went "orphan." In other words, the currently installed packages were neither from the official 13.10 release nor from a PPA.
      Thank you for this Steve. Just 'fixed' both laptops (saucy) using this procedure. How did you become aware of this?
      Using Kubuntu Linux since March 23, 2007
      "It is a capital mistake to theorize before one has data." - Sherlock Holmes

      Comment


        #4
        Excellent. Thanks for posting this. I've been wondering about the updates PPA publishing the 'git' packages.

        194 packages downgraded.

        Interesting that 'aptitude full-upgrade' would not perform the downgrade. It noted the same 194 packages, but didn't offer to do anything with them.

        Success:

        Code:
        $ apt-cache policy kde-workspace
        kde-workspace:                                                                                                       
          Installed: 4:4.11.2-0ubuntu1                                                                                       
          Candidate: 4:4.11.2-0ubuntu1
          Version table:
         *** 4:4.11.2-0ubuntu1 0
               500 http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ saucy/universe amd64 Packages
                100 /var/lib/dpkg/status
        Last edited by ronw; Oct 26, 2013, 10:05 AM. Reason: Corrected priority from 1001 to 500 after deleting the pref file and updating

        Comment


          #5
          Oh, I've figured out.
          Boy, 300 packages reverted!

          Comment


            #6
            Make sure that after you have dist-upgraded (after the update) you remove the return-to-release file in /etc/apt/preferences.d/ and rerun update and dist-upgrade.
            Using Kubuntu Linux since March 23, 2007
            "It is a capital mistake to theorize before one has data." - Sherlock Holmes

            Comment


              #7
              So in this unique case, using ppa-purge will not work properly, I take it?

              Sent from my dlx using Tapatalk

              Comment


                #8
                Originally posted by claydoh View Post
                So in this unique case, using ppa-purge will not work properly, I take it?
                Because APT no longer has any knowledge that these packages came from a PPA, I can't see how it would work.

                Comment


                  #9
                  Originally posted by Snowhog View Post
                  How did you become aware of this?
                  I figured there had to be a better way than manually downgrading each package individually -- which probably would be fraught with troubles. I had already known about APT pinning in general the special case of package priorities greater than 1000. These two bits of information seemed to be the ideal method for accomplishing the task. So I created the preferences file and ran a dry run with apt-get -s dist-upgrade. The output showed that my idea would indeed work. Then I ran it "for real," rebooted, and all was back to normal.

                  Comment


                    #10
                    No, I meant, how did you figure out/discover that packages no longer were associated with a release?
                    Using Kubuntu Linux since March 23, 2007
                    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                    Comment


                      #11
                      But should I also disable some kubuntu ppa?

                      After the downgrade and the removal of the file I've got:
                      Code:
                      $ apt-cache policy kde-workspace
                      kde-workspace:
                        Instalado: 4:4.11.2-0ubuntu1
                        Candidato: 4:4.11.2-0ubuntu1
                        Tabela de versão:
                       *** 4:4.11.2-0ubuntu1 0
                              500 http://br.archive.ubuntu.com/ubuntu/ saucy/universe amd64 Packages
                              500 http://archive.ubuntu.com/ubuntu/ saucy/universe amd64 Packages
                              100 /var/lib/dpkg/status
                           4:4.11.1+git20130910+bzr48547+pkg822~ubuntu13.10.1 0
                              500 http://ppa.launchpad.net/kubuntu-ppa/ppa/ubuntu/ saucy/main amd64 Packages
                           4:4.11.0+git20130819+bzr48502+pkg815~saucy1 0
                              500 http://ppa.launchpad.net/kubuntu-ppa/ppa/ubuntu/ saucy/main amd64 Packages
                           4:4.10.97+git20130805+bzr48465+pkg810~saucy1 0
                              500 http://ppa.launchpad.net/kubuntu-ppa/ppa/ubuntu/ saucy/main amd64 Packages

                      Comment


                        #12
                        Originally posted by Snowhog View Post
                        No, I meant, how did you figure out/discover that packages no longer were associated with a release?
                        A few days ago I noticed that APT was offering several upgraded packages, but I was on slow airport Wi-Fi and didn't let it run. Then yesterday APT no longer showed these available upgrades. "Hm, where did they go?" I mused. I ran the first apt-cache policy command above and immediately realized the problem when I saw that the installed package was no longer linked to anything.

                        At first, I simply disabled the Kubuntu updates PPA and tried a dist-upgrade. But a previous run last week had pulled in newer versions, and APT wouldn't downgrade because the official pockets are at priority 500. Forcing their priorities to 1001 did the trick.

                        Comment


                          #13
                          Ah. So your excessive time spent at Milliways isn't without it's benefits after all!
                          Using Kubuntu Linux since March 23, 2007
                          "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                          Comment


                            #14
                            Originally posted by geoaraujo View Post
                            But should I also disable some kubuntu ppa?
                            Yes, disable the Kubuntu PPAs for now. I'll add that to my instructions when I'm back at my PC.

                            Comment


                              #15
                              Nice. It worked. Thank you, Steve.

                              Comment

                              Working...
                              X