删除 snap 而不删除 ubuntu-server-minimal

删除 snap 而不删除 ubuntu-server-minimal

操作系统:Ubuntu Server 22.04

朋友一直在设置服务器,但他不需要 snap,所以他想删除它,但是一旦他尝试删除它,它就会显示 ubuntu-server-minimal 作为依赖项。

user@server:~$ sudo apt remove snapd
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
        squashfs-tools
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
        snapd ubuntu-server-minimal
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 89.6 MB disk space will be freed.
Do you want to continue? [Y/n]

有没有办法不删除元包?如果他成功删除了没有元包的 snapd,元包升级时会重新添加吗(如果有的话)?(从 apt 阻止它(就像 linux mint 那样)能解决这个问题吗?)

答案1

元软件包是一个“购物清单”,其中包含许多软件包作为依赖项,因此它允许通过安装单个软件包来安装特定配置,例如最小服务器、ubuntu 桌面等。只有当所有依赖项都在系统上时,软件包才能保留在系统上。对于ubuntu-server-minimalsnapd是硬依赖项,与桌面的元软件包不同,其中snapd是推荐的软件包,而不是依赖项。

删除其中一个依赖项将删除元包:这就是 APT 系统的核心定义。您只能删除元包 - 您不会删除与该元包一起安装的其他依赖项或推荐包。由于这些依赖项或推荐包被标记为“手动安装”,因此在sudo apt autoremove删除元包后,它们也不会被删除。

有没有办法不删除元包?

,因为snapd是依赖项。需要构建自定义元包,该元包不包含该特定依赖项,以便获得不带 snapd 的等效元包。如果snapd是推荐的包,则可以将其删除而不删除元包。

如果他成功删除了没有元包的 snapd,那么当元包升级时它会被重新添加吗(如果有的话)?(从 apt 中阻止它(就像 linux mint 那样)能解决这个问题吗?)

如上所述,这种情况不会发生在该ubuntu-server-minimal软件包上。它将被删除。如果snapd安装被阻止,您将无法重新安装ubuntu-server-minimal:将出现错误,因为无法安装其中一个依赖项。

答案2

我不使用果酱或 20.04,但对于我自己的版本,CLI 查询 ( apt-cache show depends ubuntu-server-minimal) 显示

guiverc@d960-ubu2:/de2900/ubuntu_64/slow_boot$   apt-cache show depends ubuntu-server-minimal
Package: ubuntu-server-minimal
Architecture: amd64
Version: 1.487
Priority: optional
Section: metapackages
Source: ubuntu-meta
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 53
Depends: apparmor, apport, apt, bcache-tools, btrfs-progs, cloud-init, cryptsetup, dbus, lvm2, mdadm, multipath-tools, netbase, ntfs-3g, open-iscsi, pollinate, snapd, ssh-import-id, sudo, systemd, systemd-sysv, ubuntu-drivers-common, ubuntu-release-upgrader-core, udev, xfsprogs
Recommends: needrestart, unattended-upgrades
Filename: pool/main/u/ubuntu-meta/ubuntu-server-minimal_1.487_amd64.deb
Size: 2622

作为软件包的依赖项ubuntu-server-minimal...这就是将要发生的事情。如果你删除snapd并保留ubuntu-server-minimal已安装的软件包;你将得到依靠通过重新安装满足规则snapd

CLI 查询显示我的動能的发布,以及 https://packages.ubuntu.com/jammy/ubuntu-server-minimal表明果酱也。

相关内容