When I upgrade from 11.10 to 12.04, what's the best way to re-enable my PPAs and added repositories?

share|improve this question
up vote 18 down vote accepted

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.

share|improve this answer
    
+1 for the "time to reevaluate" – Édouard Lopez Aug 17 '16 at 9:19

I have created a couple of scripts to both enable (re-enable) and disable PPAs, specially after an upgrade. Here they are:

PPA re-enable script

#! /bin/bash
# PPA re-enable script
# Use: ppa-reenable source.list
# to reenable a PPA without its source line
# Use: ppa-reenable src source.list
# to reenable a PPA with its source line

mod=1
file="$1"
if [ $1 == "src" ]; then mod=""; file="$2"; fi;
sudo sed -i "${mod}s/^# \(.*\) \(disabled on upgrade.*\)\?/\1/" "$file"

PPA disable script

#! /bin/bash
# PPA disable script
# Use: ppa-disable source.list
# to disable the PPA completely
# Use: ppa-disable src source.list
# to disable the source of the PPA only

file="${1}"
mod=""
# If its only needed to disable the source
if [ $1 = "src" ]; then mod="2"; file="${2}"; fi;

# If source line is disabled, don't comment it out
second="`sed -n 2p \"$file\"`"
second="${second:0:1}"
if ( [ $second == "#" ] && [ $mod != "2" ] ); then
    mod="1"
fi

sudo sed -i "${mod}s/^/# /" "$file"

The sudo is included so you can store this script in your home bin directory

share|improve this answer

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.

share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.