How to automatically update /etc/apt/sources.list with source URIs on Ubuntu 16.04?
I had this same issue on a server install of Ubuntu 16.04, so no GUI. All that I needed was a couple of sed
commands.
sudo sed -i -- 's/#deb-src/deb-src/g' /etc/apt/sources.list && sudo sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list
Then sudo apt-get update
and continue on.
Open Software & Updates and enable "Source code".
Here is a (currently untested) Bash script that could be used to uncomment deb-src
lines in sources.list
:
tempdir=$(mktemp -d)
cd "$tempdir"
source_file=/etc/apt/sources.list
new_file=sources.list.new
perl -pE 's/^#\s+(deb-src)/$1/' "$source_file" > "$new_file"
sudo cp "$new_file" "$source_file"
sudo apt-get update