The following command worked fine on Ubuntu 15.10:
sudo apt-get build-dep emacs24
However, on Ubuntu 16.04 I get the following error when running it:
Reading package lists... Done
E: You must put some 'source' URIs in your sources.list
In 15.10 all lines (around 10 in number) with deb-src
in /etc/apt/sources.list
where uncommented, whereas in 16.04 the corresponding lines where commented out. For example, here are 4 lines from my current sources.list
:
## Major bug fix updates produced after the final release of the
## distribution.
deb http://no.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://no.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
What is the reason for this change?
Next, I would like to avoid manually edit /etc/apt/sources.list
each time I do a reinstallation of Ubuntu. How can this (uncommenting the deb-src
lines) be done automatically?
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.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 insources.list
:simpler solution that does what the others have posted more succinctly:
Key distinctions: Perl has the -i inplace option which modifies files in place; I did not add a suffix for backup files because I didn't want the backup files to accidentally be treated as data files. And " *" deals with optional whitespace. "perl -p -n -e" is mostly the same as "sed -e", though watch out for greedy regex matching.
It has the same limitations the others do: it enables sources even if the original wasn't enabled (i.e. partners), and it doesn't work on /etc/apt/sources.list.d. The following will also process /etc/apt/sources.list.d* but makes a backup first.
Here is a simplification of @Tobi's result that does it on a single call to sed:
This adds
\s\?
which is an optional white space (note the ? needs to be escaped).