What's the best way to re-enable PPAs/repos after an upgrade?

You need to add them all back/re-enabled them individually by uncommenting the lines in the files in the /etc/apt/sources.list.d/ directory.

Though upgrade time is a good time to reevaluate if you need the PPA in the first place if you were just using one to get a newer version of a package.


I wrote a bash script that removes the leading hash character from all files in sources.list.d that were disabled during the upgrade.

The following code is for upgrading raring sources to saucy.

If you want to keep the suffix # disabled on upgrade to ..., use

for f in /etc/apt/sources.list.d/*.list; do sudo sed -i 's/raring/saucy/g' $f; sudo sed -i 's/^# \(.*disabled on upgrade to.*\)/\1/g' $f;done

if you want to delete the suffix # disabled on upgrade to ..., use

for f in /etc/apt/sources.list.d/*.list; do sudo sed -i 's/raring/saucy/g' $f; sudo sed -i 's/^# \(.*\) # disabled on upgrade to.*/\1/g' $f;done

Here's a python script that uses the Python APT API to find and enable such sources, while setting the release to the current release:

#! /usr/bin/python3

import aptsources.sourceslist as sl
import lsb_release

codename = lsb_release.get_distro_information()['CODENAME']
sources = sl.SourcesList()

for source in sources.list:
    if source.comment.lower().find("disabled on upgrade") >= 0:
        source.dist = codename
        source.set_enabled(True)
        print(source)
sources.save()

If you run it without sudo, it won't be able to save changes, but it will show which sources would be enabled. Run with sudo to save the changes.