Adding repositories to sources.list.d manually

Talles L - Jul 13 '20 - - Dev Community

It's pretty common to find instructions for adding an deb repository source as a shell script. They normally append stuff to /etc/apt/sources.list, while I prefer creating a separate file for each repo on /etc/apt/sources.list.d.

Here's how I do:

1. Create a /etc/apt/sources.list.d/{repo name}.list file with its content being the repository source (some at the end of this post):

sudo vim /etc/apt/sources.list.d/{repo name}.list
Enter fullscreen mode Exit fullscreen mode

2. Download the repo GPG key (as text):

curl {gpg key url} > {repo name}
Enter fullscreen mode Exit fullscreen mode

3. Convert it to a .gpg (binary):

gpg --dearmor {repo name}
Enter fullscreen mode Exit fullscreen mode

4. Delete the original file and move the .gpg one to /etc/apt/trusted.gpg.d/:

rm {repo name} && sudo mv {repo name}.gpg /etc/apt/trusted.gpg.d/
Enter fullscreen mode Exit fullscreen mode

Now you can sudo apt update and sudo apt install {your package}.

Here's some of my repos (Ubuntu 20.04):

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .