It's not a format suitable for blindly copying to another machine, but users who wish to work out whether they've added a repository yet or not (like I did), you can just do:
sudo apt update
When apt
is updating, it outputs a list of repositories it fetches. It seems obvious, but I've just realised what the GET
URLs are that it spits out.
The following awk
-based expression could be used to generate a sources.list file:
cat /tmp/apt-update.txt | awk '/http/ { gsub("/", " ", $3); gsub("^\s\*$", "main", $3); printf("deb "); if($4 ~ "^[a-z0-9]$") printf("[arch=" $4 "] "); print($2 " " $3) }' | sort | uniq
Alternatively, as other answers suggest, you could just cat
all the pre-existing sources like this:
cat /etc/apt/sources.list /etc/apt/sources.list.d/*
Since the disabled repositories are commented out with hash, this should work as intended.