5

apt-key is deprecated, as indicated by it's man page.

add-apt-repository uses apt-key in the background. As of Ubuntu 22.04, this will issue a warning message when used, and then on every apt update.

When instructed to use add-apt-repository (like installing lutris), what should I do instead in order to avoid the use of apt-key?

Note: Previously added repository keys can be fixed, with solution like here. I'm asking here for a solution that does not require to first use a deprecated tool then fix what this tool has done.

4
  • Those links don't indicate that apt-key is deprecated. They indicate that your keys are stored in a deprecated format, and provide instructions for upgrading the storage format. See also techrepublic.com/article/…. Commented Sep 15, 2022 at 17:14
  • man apt-key indicates "Deprecated APT key management utility". Using add-apt-repository will issue Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).. The link you provide fix previously added repositories. I want a tool that will not require a fix and won't use deprecated tools Commented Sep 15, 2022 at 17:38
  • Fair enough! I didn't see any deprecation errors or key related problems while working with add-apt-repository and apt-key on an ubuntu 20.04 system, but I'm not going to argue with the documentation! Thanks for the pointer. Commented Sep 15, 2022 at 17:44
  • The warning message appeared when I upgraded to Mint 21, so that would be equivalent to Ubuntu 22.04. Previous version probably did not issue warning or implement the deprecation Commented Sep 15, 2022 at 17:46

2 Answers 2

2

Digital Ocean recommends using gpg as an alternative to add-apt-repository.

The following is an example of how gpg can be used to install the R language, you will just need to adapt the commands for the repository that you are interested in adding:

# Download the key from the keyserver
sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/R.gpg \
  --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9

# Add the repository to a `.list` file
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/R.gpg] https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" | sudo tee /etc/apt/sources.list.d/R.list > /dev/null

# Update your repository list
sudo apt update

# Install the package
sudo apt install r-base

The explanation for the flags to the gpg commands are as follows, courtesy of the Digital Ocean article:

  • --no-default-keyring combined with --keyring allows outputting to a new file instead of importing into an existing keyring, which is the default behavior of gpg in this scenario.
  • --keyserver combined with --recv-keys provides the specific key and location you’re downloading from.
  • --homedir is used to overwrite the gpg default location for creating temporary files. gpg needs to create these files to complete the command, otherwise gpg will attempt to write to /root which causes a permission error. Instead, this command places the temporary files in the appropriate /tmp directory.
2
  • 2
    How do I find the keyserver adress and key? (in the example "E298A3..."), given just the name of the repo or ppa? Commented Sep 21, 2022 at 15:46
  • 2
    @sayanel look for the Launchpad web page of the PPA. Commented Feb 18 at 17:00
1

If you are on Linux Mint, there is an easy and correct solution (for the time being):
(For Ubuntu, see below.)

There is a version available that works fine, but it’s somehow not in the repositories for literal months now. (I would be ashamed, if I were the maintainer.)
You can install it manually though:

  • Grab the latest mintsources_*.zip from https://github.com/linuxmint/mintsources/issues/240
  • Unzip to a temporary dir.
  • Open all the .deb files in there, and click on “Install”.
  • Remove the temporary dir again.
  • Don’t forget to make sure if the package ever ends up in the official repositories, that newer versions that what you have installed are actually picked up. (E.g. Set a reminder to come here again in a couple of months, and find if there are newer versions than what you have installed.)

I just tried it, and it correctly puts the files in /etc/apt/keyrings and uses the correct deb [arch=… signed-by=/etc/apt/keyrings/….gpg] … syntax in /etc/apt/sources.list.d/*.list.

Maybe it works in plain Ubuntu too. CLI apt-key and apt-add-repository should work at least, even if mintsources (the GUI tool) clearly is made for Mint. If the .deb are a hassle, maybe unpacking stuff from mintsources_2.1.11.tar.xz:/usr/ to you /usr/local/ (!!) should get it to work (provided the dependencies are there).

I hope this finally solves this miserable situation.

2
  • @muru: Hey, yeah, I see it. I had a bad connection, which seems to have caused a case of the two generals problem. (youtube.com/watch?v=IP-rGJKSZ3s) Commented Dec 9, 2022 at 13:41
  • @terdon: Thanks for deleting the duplicate. Commented Dec 9, 2022 at 13:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.