1

Today I installed Elementary OS Loki into a VM.

I was surprised, that the system is so fast and pretty.

But to the point:

How to install .deb packages and resolve any dependencies on Elementary OS?

2

I actually prefer to use aptitude package manager to install/solve package dependencies. You install it with:

sudo apt-get install aptitude

The commands are quite similar to apt/ apt-get.

aptitudeseems to be smarter than the other tools dealing with dependencies. It also show menus with alternatives to deal with deleting/installing procedures, and show alternatives (if and when they exist) when you refuse the first choice.

$sudo aptitude purge libasound2
The following packages will be REMOVED:  
  libasound2{p} libasound2-data{u} 

The following packages have unmet dependencies:
 openjdk-8-jre : Depends: libasound2 (>= 1.0.16) but it is not going to be installed
The following actions will resolve these dependencies:

Remove the following packages:              
1)     openjdk-8-jre [8u111-b14-3 (now, testing)]



Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

     Keep the following packages at their current version:    
1)     libasound2 [1.1.2-1 (now, testing)]                
2)     libasound2-data [1.1.2-1 (now, testing)]           

Accept this solution? [Y/n/q/?] 

From the debian Aptitude wiki:

Aptitude has a number of useful features, including:

  • a mutt-like syntax for matching packages in a flexible manner mark
  • packages as "automatically installed" or "manually installed" so that packages can be auto-removed when no longer required
  • colorful preview of actions about to be taken
  • dselect-like persistence of user actions
  • the ability to retrieve and display the Debian changelog of most packages
  • AptCLI-like (= apt-get + apt-cache) command line mode ("aptitude install foo")
  • Score-based and (usually) smarter dependency resolver than apt-get

Albeit it has been classified as many years as obsolete, and it can be argued other tools provide a similar functionality, I also recommend debfoster to clean up the cruft of a system. debfoster is particularly interesting, for instance in helping trimming down a base VM to use as base install/template.

You install it with:

sudo apt-get install debfoster

I often also use it in pre-production VMs to save the actual state of packages before doing tests, and then using it´s saved state to revert to delete all the added packages as they were before I ran it.

From HOWTO: using debfoster in practice

debfoster - weed unnecessary Debian packages

debfoster maintains a list of installed packages that were explicitly requested rather than installed as a dependency. Arguments are entirely optional, debfoster can be invoked per se after each run of dpkg and/or apt-get.

Alternatively you can use debfoster to install and remove packages by specifying the packages on the command line. Packages suffixed with a - are removed while packages without a suffix are installed.

If a new package is encountered or if debfoster notices that a package that used to be a dependency is now an orphan, it will ask you what to do with it. If you decide to keep it, debfoster will just take note and continue. If you decide that this package is not interesting enough it will be removed as soon as debfoster is done asking questions. If your choises cause other packages to become orphaned more questions will ensue.

$sudo debfoster

smem is keeping the following 27 packages installed:
  blt fonts-lyx libglade2-0 libjs-jquery libjs-jquery-ui liblapack3 libtk8.6 libwebp6
  libwebpdemux2 libwebpmux2 libxss1 python-cairo python-cycler python-dateutil
  python-glade2 python-gobject-2 python-gtk2 python-imaging python-matplotlib
  python-matplotlib-data python-numpy python-pil python-pyparsing python-tk python-tz
  tk8.6-blt2.5 ttf-bitstream-vera
Keep smem? [Ynpsiuqx?], [H]elp: Y

imvirt is keeping the following 9 packages installed:
  imvirt-helper libemail-date-format-perl libfile-slurp-perl libfile-which-perl
  libimvirt-perl libmime-lite-perl libmime-types-perl libmodule-find-perl pciutils
Keep imvirt? [Ynpsiuqx?], [H]elp: Y

linux-image-4.8.0-1-amd64-unsigned is keeping the following 9 packages installed:
  busybox firmware-linux-free initramfs-tools initramfs-tools-core irqbalance
  klibc-utils libklibc libnuma1 linux-base
Keep linux-image-4.8.0-1-amd64-unsigned? [Ynpsiuqx?], [H]elp: Y

faketime is keeping the following 1 packages installed:
  libfaketime
Keep faketime? [Ynpsiuqx?], [H]elp: N

haveged is keeping the following 1 packages installed:
  libhavege1
Keep haveged? [Ynpsiuqx?], [H]elp: Y
Keep libfaketime? [Ynpsiuqx?], [H]elp: N
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  faketime* libfaketime*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 127 kB disk space will be freed.
Do you want to continue? [Y/n]
1

As there are more ways to achieve the goal, I list two CLI options, where apt is, subjectively, the best and recommended:

1st choice: apt (and apt-get)

sudo apt install ./long-package-name.deb

Note, that I specifically mean apt, not apt-get, because it does not auto-complete the file names, otherwise you may of course do this, if you insist on using apt-get, e.g. in scripts:

PACKAGE=$(echo long-package-name.deb)

sudo apt-get install ./$PACKAGE

2nd choice: gdebi

sudo gdebi long-package-name.deb

As I don't use gdebi, I can't recommend it, nor say something against it, apart from what I just tried, I will share this with you:

  1. I installed a .deb package with apt
  2. I ran sudo apt update
  3. I ran sudo apt install ./long-package-name.deb with the expected result:

    PACKAGE is already the newest version (VERSION).

  4. I ran sudo gdebi long-package-name.deb with undesirable result:

    Do you want to install the software package?

Maybe it's just me, that I don't know how to properly use gdebi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.