自动安装任意包的安装包/依赖项?

自动安装任意包的安装包/依赖项?

设想

当开始全新安装 Ubuntu 16.04 时,我的目标是尽快安装并使用该软件包default-jre进行调试。我可以通过运行以下命令来安装它:

yes | sudo apt update && sudo apt upgrade

和:

yes | sudo apt install default-jre

然而,第一个命令在我当前的设备上大约需要 30 分钟,虽然在运行代码之前仔细思考代码是一个很好的练习,但我正在尝试提高测试代码的速度,这意味着提高从.jar全新安装的 Ubuntu 16.04 开始执行文件的速度。

尝试

首先我单独运行了:

yes | sudo apt install default-jre

返回结果:

a@DESKTOP-:~$ yes | sudo apt install default-jre --fix-missing
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ca-certificates-java default-jre-headless fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-extra
  hicolor-icon-theme java-common libasound2 libasound2-data libasyncns0 libatk1.0-0 libatk1.0-data libavahi-client3
  libavahi-common-data libavahi-common3 libcairo2 libcups2 libdatrie1 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2
  libdrm-radeon1 libflac8 libfontconfig1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgif7 libgl1-mesa-dri
  libgl1-mesa-glx libglapi-mesa libgraphite2-3 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libharfbuzz0b libjbig0
  libjpeg-turbo8 libjpeg8 liblcms2-2 libllvm6.0 libnspr4 libnss3 libnss3-nssdb libogg0 libpango-1.0-0
  libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcsclite1 libpixman-1-0 libpulse0 libsensors4 libsndfile1
  libthai-data libthai0 libtiff5 libtxc-dxtn-s2tc0 libvorbis0a libvorbisenc2 libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0
  libxcb-glx0 libxcb-present0 libxcb-render0 libxcb-shm0 libxcb-sync1 libxcomposite1 libxcursor1 libxdamage1
  libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 openjdk-8-jre
  openjdk-8-jre-headless x11-common
Suggested packages:
  default-java-plugin libasound2-plugins alsa-utils cups-common librsvg2-common gvfs liblcms2-utils pcscd pulseaudio
  lm-sensors icedtea-8-plugin libnss-mdns fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
  fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  ca-certificates-java default-jre default-jre-headless fontconfig fontconfig-config fonts-dejavu-core
  fonts-dejavu-extra hicolor-icon-theme java-common libasound2 libasound2-data libasyncns0 libatk1.0-0 libatk1.0-data
  libavahi-client3 libavahi-common-data libavahi-common3 libcairo2 libcups2 libdatrie1 libdrm-amdgpu1 libdrm-intel1
  libdrm-nouveau2 libdrm-radeon1 libflac8 libfontconfig1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgif7
  libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgraphite2-3 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common
  libharfbuzz0b libjbig0 libjpeg-turbo8 libjpeg8 liblcms2-2 libllvm6.0 libnspr4 libnss3 libnss3-nssdb libogg0
  libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcsclite1 libpixman-1-0 libpulse0 libsensors4
  libsndfile1 libthai-data libthai0 libtiff5 libtxc-dxtn-s2tc0 libvorbis0a libvorbisenc2 libx11-xcb1 libxcb-dri2-0
  libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-render0 libxcb-shm0 libxcb-sync1 libxcomposite1 libxcursor1
  libxdamage1 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 openjdk-8-jre
  openjdk-8-jre-headless x11-common
0 upgraded, 83 newly installed, 0 to remove and 0 not upgraded.
Need to get 28.8 MB/57.9 MB of archives.
After this operation, 341 MB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libavahi-common-data amd64 0.6.32~rc+dfsg-1ubuntu2.2
  404  Not Found [IP: 91.189.88.161 80]
Err:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libavahi-common3 amd64 0.6.32~rc+dfsg-1ubuntu2.2
  404  Not Found [IP: 91.189.88.161 80]
Err:3 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libavahi-client3 amd64 0.6.32~rc+dfsg-1ubuntu2.2
  404  Not Found [IP: 91.189.88.161 80]
Err:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libcups2 amd64 2.1.3-4ubuntu0.5
  404  Not Found [IP: 91.189.88.161 80]
Ign:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libnss3-nssdb all 2:3.28.4-0ubuntu0.16.04.3
Ign:6 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libnss3 amd64 2:3.28.4-0ubuntu0.16.04.3
Ign:7 http://security.ubuntu.com/ubuntu xenial-security/main amd64 openjdk-8-jre-headless amd64 8u181-b13-0ubuntu0.16.04.1
Ign:8 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libtiff5 amd64 4.0.6-1ubuntu0.4
Err:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgdk-pixbuf2.0-common all 2.32.2-1ubuntu1.5
  404  Not Found [IP: 91.189.88.161 80]
Err:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgdk-pixbuf2.0-0 amd64 2.32.2-1ubuntu1.5
  404  Not Found [IP: 91.189.88.161 80]
Ign:11 http://security.ubuntu.com/ubuntu xenial-security/main amd64 openjdk-8-jre amd64 8u181-b13-0ubuntu0.16.04.1
Err:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libcups2 amd64 2.1.3-4ubuntu0.5
  404  Not Found [IP: 91.189.88.161 80]
Err:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libnss3-nssdb all 2:3.28.4-0ubuntu0.16.04.3
  404  Not Found [IP: 91.189.88.161 80]
Err:6 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libnss3 amd64 2:3.28.4-0ubuntu0.16.04.3
  404  Not Found [IP: 91.189.88.161 80]
Err:7 http://security.ubuntu.com/ubuntu xenial-security/main amd64 openjdk-8-jre-headless amd64 8u181-b13-0ubuntu0.16.04.1
  404  Not Found [IP: 91.189.88.161 80]
Err:8 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libtiff5 amd64 4.0.6-1ubuntu0.4
  404  Not Found [IP: 91.189.88.161 80]
Err:11 http://security.ubuntu.com/ubuntu xenial-security/main amd64 openjdk-8-jre amd64 8u181-b13-0ubuntu0.16.04.1
  404  Not Found [IP: 91.189.88.161 80]
Unable to correct missing packages.
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/avahi/libavahi-common-data_0.6.32~rc+dfsg-1ubuntu2.2_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/avahi/libavahi-common3_0.6.32~rc+dfsg-1ubuntu2.2_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/avahi/libavahi-client3_0.6.32~rc+dfsg-1ubuntu2.2_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/cups/libcups2_2.1.3-4ubuntu0.5_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/n/nss/libnss3-nssdb_3.28.4-0ubuntu0.16.04.3_all.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/n/nss/libnss3_3.28.4-0ubuntu0.16.04.3_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openjdk-8/openjdk-8-jre-headless_8u181-b13-0ubuntu0.16.04.1_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/t/tiff/libtiff5_4.0.6-1ubuntu0.4_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-common_2.32.2-1ubuntu1.5_all.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-0_2.32.2-1ubuntu1.5_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openjdk-8/openjdk-8-jre_8u181-b13-0ubuntu0.16.04.1_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-common_2.32.2-1ubuntu1.5_all.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-0_2.32.2-1ubuntu1.5_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openjdk-8/openjdk-8-jre_8u181-b13-0ubuntu0.16.04.1_amd64.deb
404  Not Found [IP: 91.189.88.161 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

因此我尝试:

yes | sudo apt install default-jre --fix-missing

但结果却是:

a@DESKTOP-:~$ yes | sudo apt install default-jre --fix-missing
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ca-certificates-java default-jre-headless fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-extra
  hicolor-icon-theme java-common libasound2 libasound2-data libasyncns0 libatk1.0-0 libatk1.0-data libavahi-client3
  libavahi-common-data libavahi-common3 libcairo2 libcups2 libdatrie1 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2
  libdrm-radeon1 libflac8 libfontconfig1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgif7 libgl1-mesa-dri
  libgl1-mesa-glx libglapi-mesa libgraphite2-3 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libharfbuzz0b libjbig0
  libjpeg-turbo8 libjpeg8 liblcms2-2 libllvm6.0 libnspr4 libnss3 libnss3-nssdb libogg0 libpango-1.0-0
  libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcsclite1 libpixman-1-0 libpulse0 libsensors4 libsndfile1
  libthai-data libthai0 libtiff5 libtxc-dxtn-s2tc0 libvorbis0a libvorbisenc2 libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0
  libxcb-glx0 libxcb-present0 libxcb-render0 libxcb-shm0 libxcb-sync1 libxcomposite1 libxcursor1 libxdamage1
  libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 openjdk-8-jre
  openjdk-8-jre-headless x11-common
Suggested packages:
  default-java-plugin libasound2-plugins alsa-utils cups-common librsvg2-common gvfs liblcms2-utils pcscd pulseaudio
  lm-sensors icedtea-8-plugin libnss-mdns fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
  fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  ca-certificates-java default-jre default-jre-headless fontconfig fontconfig-config fonts-dejavu-core
  fonts-dejavu-extra hicolor-icon-theme java-common libasound2 libasound2-data libasyncns0 libatk1.0-0 libatk1.0-data
  libavahi-client3 libavahi-common-data libavahi-common3 libcairo2 libcups2 libdatrie1 libdrm-amdgpu1 libdrm-intel1
  libdrm-nouveau2 libdrm-radeon1 libflac8 libfontconfig1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgif7
  libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgraphite2-3 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common
  libharfbuzz0b libjbig0 libjpeg-turbo8 libjpeg8 liblcms2-2 libllvm6.0 libnspr4 libnss3 libnss3-nssdb libogg0
  libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcsclite1 libpixman-1-0 libpulse0 libsensors4
  libsndfile1 libthai-data libthai0 libtiff5 libtxc-dxtn-s2tc0 libvorbis0a libvorbisenc2 libx11-xcb1 libxcb-dri2-0
  libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-render0 libxcb-shm0 libxcb-sync1 libxcomposite1 libxcursor1
  libxdamage1 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 openjdk-8-jre
  openjdk-8-jre-headless x11-common
0 upgraded, 83 newly installed, 0 to remove and 0 not upgraded.
Need to get 28.8 MB/57.9 MB of archives.
After this operation, 341 MB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libavahi-common-data amd64 0.6.32~rc+dfsg-1ubuntu2.2
  404  Not Found [IP: 91.189.88.161 80]
Err:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libavahi-common3 amd64 0.6.32~rc+dfsg-1ubuntu2.2
  404  Not Found [IP: 91.189.88.161 80]
Err:3 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libavahi-client3 amd64 0.6.32~rc+dfsg-1ubuntu2.2
  404  Not Found [IP: 91.189.88.161 80]
Err:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libcups2 amd64 2.1.3-4ubuntu0.5
  404  Not Found [IP: 91.189.88.161 80]
Ign:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libnss3-nssdb all 2:3.28.4-0ubuntu0.16.04.3
Ign:6 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libnss3 amd64 2:3.28.4-0ubuntu0.16.04.3
Ign:7 http://security.ubuntu.com/ubuntu xenial-security/main amd64 openjdk-8-jre-headless amd64 8u181-b13-0ubuntu0.16.04.1
Ign:8 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libtiff5 amd64 4.0.6-1ubuntu0.4
Err:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgdk-pixbuf2.0-common all 2.32.2-1ubuntu1.5
  404  Not Found [IP: 91.189.88.161 80]
Err:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgdk-pixbuf2.0-0 amd64 2.32.2-1ubuntu1.5
  404  Not Found [IP: 91.189.88.161 80]
Ign:11 http://security.ubuntu.com/ubuntu xenial-security/main amd64 openjdk-8-jre amd64 8u181-b13-0ubuntu0.16.04.1
Err:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libcups2 amd64 2.1.3-4ubuntu0.5
  404  Not Found [IP: 91.189.88.161 80]
Err:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libnss3-nssdb all 2:3.28.4-0ubuntu0.16.04.3
  404  Not Found [IP: 91.189.88.161 80]
Err:6 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libnss3 amd64 2:3.28.4-0ubuntu0.16.04.3
  404  Not Found [IP: 91.189.88.161 80]
Err:7 http://security.ubuntu.com/ubuntu xenial-security/main amd64 openjdk-8-jre-headless amd64 8u181-b13-0ubuntu0.16.04.1
  404  Not Found [IP: 91.189.88.161 80]
Err:8 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libtiff5 amd64 4.0.6-1ubuntu0.4
  404  Not Found [IP: 91.189.88.161 80]
Err:11 http://security.ubuntu.com/ubuntu xenial-security/main amd64 openjdk-8-jre amd64 8u181-b13-0ubuntu0.16.04.1
  404  Not Found [IP: 91.189.88.161 80]
Unable to correct missing packages.
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/avahi/libavahi-common-data_0.6.32~rc+dfsg-1ubuntu2.2_amd64.deb  404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/avahi/libavahi-common3_0.6.32~rc+dfsg-1ubuntu2.2_amd64.deb  404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/avahi/libavahi-client3_0.6.32~rc+dfsg-1ubuntu2.2_amd64.deb  404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/cups/libcups2_2.1.3-4ubuntu0.5_amd64.deb  404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/n/nss/libnss3-nssdb_3.28.4-0ubuntu0.16.04.3_all.deb  404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/n/nss/libnss3_3.28.4-0ubuntu0.16.04.3_amd64.deb  404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openjdk-8/openjdk-8-jre-headless_8u181-b13-0ubuntu0.16.04.1_amd64.deb  404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/t/tiff/libtiff5_4.0.6-1ubuntu0.4_amd64.deb  404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-common_2.32.2-1ubuntu1.5_all.deb  404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-0_2.32.2-1ubuntu1.5_amd64.deb  404  Not Found [IP: 91.189.88.161 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openjdk-8/openjdk-8-jre_8u181-b13-0ubuntu0.16.04.1_amd64.deb  404  Not Found [IP: 91.189.88.161 80]

E: Aborting install.

基于如何运行“apt-get install”来安装所有依赖项?我尝试了以下命令,返回后也许用?yes | sudo apt install default-jre运行--fix-missing

sudo apt-get install -f

返回:

DESKTOP-:~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

现在使用反馈,yes | sudo apt install default-jre我可以选择所需的包并生成一个命令列表,安装这些包,特别是潜在地规避命令sudo apt update && sudo apt upgrade

问题

但我很好奇,当你运行它来安装时,是否有一个命令可以自动安装所需的包/依赖项<some package>

答案1

您收到 404 错误是因为新安装附带的软件包索引已过期,因此它们导致 Apt 尝试获取不再存在的旧软件包。要刷新索引,您必须运行sudo apt update。但是,运行sudo apt upgrade不是必需的,也就是说,sudo apt install default-jre即使您不运行sudo apt upgrade, 也会起作用。但是,不运行它将使您获得过期的软件包,这些软件包可能包含错误。继续操作需要您自担风险。

相关内容