2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Debian】 aptでtrusted.gpgのdeprecationが出た際の対処

Posted at

これは何?

Debian系のLinuxでaptを使い、サードパーティーのリポジトリを追加してる場合に警告が出た際の対処方。

原因

こちらの記事が詳しい。

対応

はじめに

最近Ubuntuを22.04にアップグレードしたところ以下のような警告が表示されるようになりました。

W: https://storage.googleapis.com/download.dartlang.org/linux/debian/dists/stable/Release.gpg: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

どういう事かと調べると先述のURLの記事の通りでした。

やること

先述の記事の通り、keyringに追加してやれば良さそう。
スクリプト作ってしまおう。

#!/bin/bash

if [ $# -ne 2 ]; then
  echo "$(basename $0) KEY_URL ID"
  exit 1
fi

KEY_FILE="/dev/shm/${$}.key"
GPG_FILE="/dev/shm/${$}.gpg"
KEYRING="${2}.gpg"

wget -q -O "$KEY_FILE" "$1" || exit 2

gpg --no-default-keyring --keyring "$GPG_FILE" --import "$KEY_FILE" || exit 3
gpg --no-default-keyring --keyring "$GPG_FILE" --export --output "$KEYRING" || exit 4

rm "$KEY_FILE"
rm "$GPG_FILE"

sudo mv "$KEYRING" /usr/share/keyrings/ || exit 5
echo "sources.listに以下のオプションを追記してください"
echo
echo "[signed-by=/usr/share/keyrings/${KEYRING}]"
echo

自分用なのでまぁ雑ですが、これでやりたいことはやれるようになりました。

さっそく実行してみます。

apt-key-import https://dl-ssl.google.com/linux/linux_signing_key.pub dart

上書きするかどうか聞かれたので上書きを選択しました。
最後にオプション入れろと出るので(自分で出してるやつ)sources.listを編集します。

vim /etc/apt/sources.list.d/dart_stable.list

deb [arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main

最初から [arch=amd64] のオプションが入っていたので、スペースで区切って追記します。

deb [arch=amd64 signed-by=/usr/share/keyrings/dart.gpg] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main

あとはおなじみの apt update で糸冬了。

結果

これで無事により安全な形で鍵を追加し、 apt upgrade -y 等を行えるようになりました。

余談ですがUbuntuならdartはsnapで入れるのが手軽かと思います……


それでは良いLinuxライフを。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?