apt相關問題

apt找不到key或重複套件,刪掉有問題的apt key

sudo rm /etc/apt/sources.list.d/*cuda*

查看所有可以安裝的版本

apt-cache madison cuda

https://askubuntu.com/questions/447/how-can-i-see-all-versions-of-a-package-that-are-available-in-the-archive

刪除apt key

  • 顯示所有key
    apt-key list顯示結果如下

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    /etc/apt/trusted.gpg
    --------------------
    pub rsa4096 2022-05-05 [SCEA]
    8298 D919 610D E70B 90CE DAAE EE38 2EF7 8230 7095
    uid [ unknown] TensorRT <svc_tensorrt@nvidia.com>

    /etc/apt/trusted.gpg.d/flexiondotorg_ubuntu_nvtop.gpg
    -----------------------------------------------------
    pub rsa1024 2011-03-16 [SC]
    824A 27DD 09DE DA33 BF78 3596 2EA8 F357 93D8 809A
    uid [ unknown] Launchpad PPA for Martin Wimpress

    /etc/apt/trusted.gpg.d/graphics-drivers_ubuntu_ppa.gpg
    ------------------------------------------------------
    pub rsa4096 2015-08-12 [SC]
    2388 FF3B E10A 76F6 38F8 0723 FCAE 110B 1118 213C
    uid [ unknown] Launchpad PPA for Graphics Drivers Team
  • 刪掉key
    以下面為例,key ID就是最後8碼82307095sudo apt-key del 82307095就可以刪除

1
2
3
4
5
/etc/apt/trusted.gpg
--------------------
pub rsa4096 2022-05-05 [SCEA]
8298 D919 610D E70B 90CE DAAE EE38 2EF7 8230 7095
uid [ unknown] TensorRT <svc_tensorrt@nvidia.com>

解決Unmet dependencies問題

  • dpkg -P package-name來移除有問題的套件,他會顯示不能移除的原因,然後依序移除即可

  • 直接用dpkg安裝套件,如果有缺少的相依套件,之後使用apt install就會顯示E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).錯誤,必須要手動解決相依性問提

apt install使用local repo

參考: https://wiki.debian.org/DebianRepository/Setup?action=show&redirect=DebianRepository%2FHowTo%2FTrivialRepository#trivialArchive

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Quick instructions to create a trivial local archive with apt-ftparchive
We use /var/lib/mydebs as the example location

Create the directory

mkdir -p /var/lib/mydebs
Every time you put new files in the directory, you'll have to scan the directory and update:

cd /var/lib/mydebs
apt-ftparchive packages . > Packages
apt-ftparchive release . > Release
Add this line to /etc/apt/sources.list

deb [allow-insecure=yes] file:/var/lib/mydebs ./
Now you can install the package normally. If apt-get asks "Install these packages without verification?", answer "Y" to install. That's because this local repository is not signed.

apt-get update
apt-get install mydeb

刪除apt gpg key 和repo

https://itslinuxfoss.com/delete-repository-and-gpg-key-ubuntu/#2

查看套件版本

dpkg-query -W tensorrt

用apt 查看可安裝的版本

apt-cache policy <package name>

例如

1
2
3
4
5
6
7
8
$ apt-cache policy gparted
gparted:
Installed: 0.16.1-1
Candidate: 0.16.1-1
Version table:
*** 0.16.1-1 0
500 http://ubuntu.inode.at/ubuntu/ saucy/main amd64 Packages
100 /var/lib/dpkg/status

安裝指定版本
sudo apt-get install <package name>=<version>
例如上面的例子

1
2
3
4
5
6
$ sudo apt-get install gparted=0.16.1-1
Reading package lists... Done
Building dependency tree
Reading state information... Done
gparted is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 265 not upgraded.
Author

Steven

Posted on

2023-10-27

Updated on

2025-01-14

Licensed under

Comments