Tuesday, May 10, 2016

apt - Automatically install packages/dependencies for installation of an arbitrary package?



Scenario



When starting with a fresh Ubuntu 16.04 installation, my goal is to solely install and use the package default-jre as quickly as possible for debugging purposes. I can install this by running the commands:



yes | sudo apt update && sudo apt upgrade



and:




yes | sudo apt install default-jre



However the first command takes approximately 30 minutes on my current device, and whilst it is a great exercise thinking well about my code before I run it, I am trying to increase the speed at which I can test my code, which means increasing the speed with which I can execute a .jar file starting from a fresh Ubuntu 16.04 installation.



Attempts



First I solely ran:



yes | sudo apt install default-jre



And that returned:



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?


Hence I tried:



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


But that returned:




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.



Based on How to run 'apt-get install' to install all dependencies? I tried the following command after yes | sudo apt install default-jre returned perhaps run with --fix-missing?



sudo apt-get install -f


Which returned:



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.


Now using the feedback of the yes | sudo apt install default-jre I could select the required packages and generate a list of commands that installs those packages specifically potentially circumventing the sudo apt update && sudo apt upgrade command.




Question



But I was curious whether there is a command that automatically installs the required packages/dependencies when you run it to install ?



You get the 404 errors because the package indexes that come with your fresh install are out of date, hence they cause Apt to try to fetch old packages which no longer exist. To refresh your indexes you must run sudo apt update. Running sudo apt upgrade however is not required, in the sense that sudo apt install default-jre will work even if you don't run sudo apt upgrade. Not running it, however, will leave you with out-of-date packages, which may contain bugs. Proceed at your own risk.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...