Fixing Foreign Package Downgrading In Linux Mint
Tags: linux, bash
Published: 2020-08-10 19:16:17

After one installs mintupgrade and runs `mintupgrade upgrade`, they might encounter a plethora of packages that need to be downgraded. After trying to go into software sources and downgrading foreign packages, one discovers package after package that needs to be fixed before the actual downgrade can commence before Linux Mint can be upgraded. This article presents a simple solution that worked for me and might work for you.

1. Run `mintupgrade upgrade`. The output should end in a really long list like:

    ```
    [prior output not shown]
        - xxd: 2:8.1.2269-1ubuntu5, should be 2:8.0.1453-1ubuntu1.3 (from bionic-updates)
        - xz-utils: 5.2.4-1, should be 5.2.2-1.3 (from bionic)
        - yelp-xsl: 3.36.0-1, should be 3.20.1-4 (from bionic)
        - zenity: 3.32.0-5, should be 3.28.1-1 (from bionic)
        - zenity-common: 3.32.0-5, should be 3.28.1-1 (from bionic)
        - zlib1g: 1:1.2.11.dfsg-2ubuntu1, should be 1:1.2.11.dfsg-0ubuntu2 (from bionic)
        - zlib1g:i386: 1:1.2.11.dfsg-2ubuntu1, should be 1:1.2.11.dfsg-0ubuntu2 (from bionic)
     
    ------------------------------------------------
    !!  ERROR: The packages above have incorrect versions. They can be downgraded using 'Software Sources -> Maintenance -> Downgrade Foreign Packages'.
    !!  Exiting.
    ------------------------------------------------
     
      + Restoring your backed up APT sources..
    ```

2. On this webpage, press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> to open DevTools.
3. Click on the Console tab in DevTools.
4. If you are using FireFox, you need to type `'allow pasting';` in order to get it allow pasting. Then press <kbd>Enter</kbd> to remove all the text you entered.
5. Copy and paste and (but do not execute) the following JS code.

    ```
    "aptitude install -f " + String.raw`
        - xxd: 2:8.1.2269-1ubuntu5, should be 2:8.0.1453-1ubuntu1.3 (from bionic-updates)
        - xz-utils: 5.2.4-1, should be 5.2.2-1.3 (from bionic)
        - yelp-xsl: 3.36.0-1, should be 3.20.1-4 (from bionic)
        - zenity: 3.32.0-5, should be 3.28.1-1 (from bionic)
        - zenity-common: 3.32.0-5, should be 3.28.1-1 (from bionic)
        - zlib1g: 1:1.2.11.dfsg-2ubuntu1, should be 1:1.2.11.dfsg-0ubuntu2 (from bionic)
        - zlib1g:i386: 1:1.2.11.dfsg-2ubuntu1, should be 1:1.2.11.dfsg-0ubuntu2 (from bionic)
    `.split(/\s+- ([^:]+(?:[:]i386|[:]amd64|[:]arm64)?)[:] .*?([^ ]+) \(from[^\n]*\n?/gi).map(function(x) {
        return x ? x + "=" : " ";
    }).join("").replace(/= /g, " ").trim()
    ```

6. Replace the example list of library versions in the above code with the list generated by your mintupgrade on your machine. **Replace any engraves and backslashes with \\` and \\\\ respectively.**
7. In the DevTools console, press <kbd>Enter</kbd> to run the JS code.
8. The JS code will output a command line starting with `aptitude install`. Copy, paste and run this command in the console.
9. Aptitude **might** terminate early and output a short list of packages that are in conflict with the downgrade. Otherwise, if the downgrade was successful, skip to the last step.

        gir1.2-gdkpixbuf-2.0
        libgdk-pixbuf2.0-0
        libgdk-pixbuf2.0-0
        libgtk-3-0
        libgtk-3-bin

10. **Read step #11 before executing this command.** You need to tell aptitude to downgrade the packages that were in conflict (replace the example package list with the packages in your circumstance):

        aptitude remove -f gir1.2-gdkpixbuf-2.0 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgtk-3-bin

11. **VERY IMPORTANT:** After executing `aptitude remove`, keep typing <kbd>n</kbd> followed by <kbd>Enter</kbd> until aptitude gives you the option to downgrade the packages. Then, you type <kbd>y</kbd> followed by <kbd>Enter</kbd>.

12. Go back to step #8 and try again to run the aptitude version change.

13. `mint upgrade` and it should work now.

I hope this article helps you.