使用 apt 安装但缺少软件包的程序列表

使用 apt 安装但缺少软件包的程序列表

我想通过命令安装软件包列表

sudo apt-get install app1 app2 etc

我试过了,但由于缺少软件包,apt-get 无法安装任何东西。所以我深入研究了 man apt-get install,找到了 --fix-missing 选项!然而,它似乎不起作用!它说:

E: could not find package xxxxxx 

然后它就停止了。

我需要使用列表选项,无法为每个软件包编写 sudo apt-get install,甚至我需要确保我想要使用此命令的脚本将安装尽可能多的软件包,不关心它是否会错过安装一个。谢谢

实例:

cirelli @ asus: /mnt/data/first-boot-master $ sudo apt-get install atom skype
Reading package lists ... Done
Building dependency tree
Reading state information ... Done
E: Could not find skype package

我在用着Ubuntu Gnome 16.04

apt show apt:
Package: apt
Version: 1.2.12~ubuntu16.04.1

附言:apt-get 手册页

答案1

我没有看到任何可以执行apt(或apt-get)跳过不存在的包并继续安装其他包的选项。

但是,您可以apt install分别对列表中的每个包运行,这样,一个不存在的包就不会中止其他包的安装。

一个简单的 Bashfor循环在这里非常有用:

sudo bash -c 'for pkg in cowsay cowtalk ; do apt install $pkg ; done'

此命令for在具有 root 权限的 Bash shell 中执行循环。循环本身apt install PACKAGE针对列表中的每个 PACKAGE运行cowsay cowtalk

虽然cowsay存在,cowtalk但不存在。您可以在此处看到输出:

$ sudo bash -c 'for package in cowsay cowtalk ; do apt install $package ; done'
[sudo] password for bytecommander: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  cowsay-off
Suggested packages:
  filters
The following NEW packages will be installed
  cowsay cowsay-off
0 to upgrade, 2 to newly install, 0 to remove and 0 not to upgrade.
Need to get 21,7 kB of archives.
After this operation, 112 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://ftp.uni-stuttgart.de/ubuntu xenial/universe amd64 cowsay all 3.03+dfsg1-15 [18,0 kB]
Get:2 http://ftp.uni-stuttgart.de/ubuntu xenial/universe amd64 cowsay-off all 3.03+dfsg1-15 [3.640 B]
Fetched 21,7 kB in 0s (117 kB/s)      
Selecting previously unselected package cowsay.
(Reading database ... 304276 files and directories currently installed.)
Preparing to unpack .../cowsay_3.03+dfsg1-15_all.deb ...
Unpacking cowsay (3.03+dfsg1-15) ...
Selecting previously unselected package cowsay-off.
Preparing to unpack .../cowsay-off_3.03+dfsg1-15_all.deb ...
Unpacking cowsay-off (3.03+dfsg1-15) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up cowsay (3.03+dfsg1-15) ...
Setting up cowsay-off (3.03+dfsg1-15) ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package cowtalk

相关内容