Is apt dependency resolution different as that of apt-get?

News and discussion about development of the Debian OS itself

Is apt dependency resolution different as that of apt-get?

Postby fabien » 2020-01-25 19:36

Is apt dependency resolution algorithm different as that of apt-get?

apt(8) manual states «apt provides a high-level commandline interface for the package management system», from which I feel allowed to infer that it's merely a set of commands (and possibly prechosen options) over a lower infrastructure that does the real job. For me using apt or apt-get will therefore lead to the same result.
Moreover, Debian Reference '2.2.1. apt vs. apt-get / apt-cache vs. aptitude' https://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_literal_apt_literal_vs_literal_apt_get_literal_literal_apt_cache_literal_vs_literal_aptitude_literal says «The apt command is a high-level commandline interface for package management. It is basically a wrapper of apt-get, apt-cache and similar commands, originally intended as an end-user interface and enables some options better suited for interactive usage by default» and also «The use of "apt full-upgrade" or "apt-get dist-upgrade" is recommended for [the release-to-release system upgrade]»: apt OR apt-get, conveying once more the idea of same result.

But on the other hand, the Release Notes for Debian 10 '4.4. Upgrading packages' https://www.debian.org/releases/stable/amd64/release-notes/ch-upgrading.en.html#upgradingpackages indicates «The recommended way to upgrade from previous Debian releases is to use the package management tool apt», without mentioning apt-get. I think that's because they find apt a better advice for newcomers, but that also instills doubt even if they do not state not to use apt-get.

I find it important to be sure that apt and apt-get do the same job, because if they do not I want to be able to choose knowingly.

Has one of you experienced real differences between apt and apt-get? Or has one of you links to documents that may permit clear assessment? Thanks.
User avatar
fabien
 
Posts: 15
Joined: 2019-12-03 12:51
Location: Toulouse, France

Re: Is apt dependency resolution different as that of apt-ge

Postby L_V » 2020-01-25 20:35

fabien wrote:Is apt dependency resolution algorithm different as that of apt-get ?

No because dependencies are declared in each deb package (control.tar.xz).
I personally never use apt-get, but either apt for basic operations, and aptitude for more tricky operations.

You can locally install a deb package with apt, and directly manage its dependencies. You cannot with apt-get.
Code: Select all
apt install <path to>/package.deb

Other example:
Code: Select all
apt list --installed 'firefox*'
L_V
 
Posts: 1270
Joined: 2007-03-19 09:04

Re: Is apt dependency resolution different as that of apt-ge

Postby Soul Singin' » 2020-01-25 21:18

L_V wrote:You can locally install a deb package with apt, and directly manage its dependencies. You cannot with apt-get.
Code: Select all
apt install <path to>/package.deb

You can install a DEB package with apt-get. Try it:

Code: Select all
$ cd /home/soul/
$ curl -O http://ftp.us.debian.org/debian/pool/main/h/hello/hello_2.10-2_amd64.deb
$ su -
Password:
# cd /home/soul/
# apt-get install ./hello_2.10-2_amd64.deb
User avatar
Soul Singin'
 
Posts: 1607
Joined: 2008-12-21 07:02

Re: Is apt dependency resolution different as that of apt-ge

Postby Chrisdb » 2020-01-25 21:41

A while ago I was also searching for the difference between these two and I found this link helpful:
Https://itsfoss.com/apt-vs-apt-get-difference/

I would only use apt-get if you want to use very specific options like f.e. in scripts. In all other cases I would just use apt
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16

Re: Is apt dependency resolution different as that of apt-ge

Postby L_V » 2020-01-25 21:47

I admit I've never been familiar with apt-get and installed deb packages in 2 steps: 1/dpkg, then 2/dependency with any apt tool.
apt and aptitude are enough for me.
I have the feeling apt will progressively supersede apt-get.
But in summary for fabien : apt or apt-get is the same for basic operations.

apt-get is still more powerful to manage recommends or hold.
Code: Select all
apt-get install --no-install-recommends

Should I use apt or apt-get ?
You might be thinking if you should use apt or apt-get. And as a regular Linux user, my answer is to go with apt.
apt is the command that is being recommended by the Linux distributions.
It provides the necessary option to manage the packages.
Most important of all, it is easier to use with its fewer but easy to remember options.
I see no reason to stick with apt-get unless you are going to do specific operations that utilize more features of apt-get.
.../...
"I use apt, because apt is easy typing than apt-get"
https://itsfoss.com/apt-vs-apt-get-difference/

In line with what I said.
L_V
 
Posts: 1270
Joined: 2007-03-19 09:04

Re: Is apt dependency resolution different as that of apt-ge

Postby Head_on_a_Stick » 2020-01-26 11:40

L_V wrote:
fabien wrote:Is apt dependency resolution algorithm different as that of apt-get ?

No because dependencies are declared in each deb package

The OP is referring to the resolution algorithms that are used when there are complicated dependency chains.

It is certainly true that apt{,-get} and aptitude handle such situations very differently, here's how apt(8) installs elogind in my GNOME desktop:
Code: Select all
empty@E485:~ $ apt -s install elogind
NOTE: This is only a simulation!
      apt needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  accountsservice apg bolt colord-data cracklib-runtime eject exfat-fuse exfat-utils gdebi-core gir1.2-accountsservice-1.0 gir1.2-atspi-2.0 gir1.2-clutter-gst-3.0 gir1.2-dazzle-1.0 gir1.2-gck-1 gir1.2-gcr-3 gir1.2-gdm-1.0
  gir1.2-gmenu-3.0 gir1.2-gnomebluetooth-1.0 gir1.2-grilo-0.3 gir1.2-ibus-1.0 gir1.2-mediaart-2.0 gir1.2-mutter-3 gir1.2-nm-1.0 gir1.2-nma-1.0 gir1.2-packagekitglib-1.0 gir1.2-polkit-1.0 gir1.2-upowerglib-1.0 gnome-control-center-data
  gnome-session-bin gnome-session-common gnome-shell-common gvfs-libs libaccountsservice0 libatasmart4 libblockdev-crypto2 libblockdev-fs2 libblockdev-loop2 libblockdev-part-err2 libblockdev-part2 libblockdev-swap2 libblockdev-utils2
  libblockdev2 libcolord-gtk1 libcolorhug2 libcrack2 libept1.5.0 libgdm1 libgnome-autoar-0-0 libgnome-bluetooth13 libgnome-menu-3-0 libibus-1.0-5 libmusicbrainz5-2 libmusicbrainz5cc2v5 libnm0 libnma0 libnss-myhostname
  libpolkit-agent-1-0 libpolkit-backend-1-0 libpwquality-common libpwquality1 libudisks2-0 libvolume-key1 mousetweaks nautilus-data python3-software-properties realmd software-properties-common software-properties-gtk switcheroo-control
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  libelogind0 sysvinit-core
Suggested packages:
  bootlogd
Recommended packages:
  policykit-1
The following packages will be REMOVED:
  chrome-gnome-shell colord dbus-user-session gdebi gdm3 gnome-color-manager gnome-control-center gnome-disk-utility gnome-music gnome-session gnome-settings-daemon gnome-shell gnome-shell-extensions gnome-sushi gnome-tweaks gvfs
  gvfs-backends gvfs-daemons gvfs-fuse iio-sensor-proxy libnss-systemd libpam-systemd nautilus nautilus-extension-brasero policykit-1 rtkit synaptic systemd systemd-sysv udisks2
The following NEW packages will be installed:
  elogind libelogind0 sysvinit-core
0 upgraded, 3 newly installed, 30 to remove and 1 not upgraded.
Remv chrome-gnome-shell [10.1-5]
Remv gnome-control-center [1:3.30.3-2~deb10u1]
Remv gnome-color-manager [3.30.0-2]
Remv colord [1.4.3-4]
Remv dbus-user-session [1.12.16-1]
Remv gdebi [0.9.5.7+nmu3]
Remv gdm3 [3.30.2-3]
Remv gnome-disk-utility [3.30.2-3]
Remv gnome-music [3.30.2-1]
Remv gnome-session [3.30.1-2]
Remv gnome-tweaks [3.30.2-1]
Remv gnome-shell-extensions [3.30.1-1]
Remv gnome-settings-daemon [3.30.2-3] [gnome-shell:amd64 ]
Remv gnome-shell [3.30.2-11~deb10u1]
Remv gnome-sushi [3.30.0-2]
Remv gvfs-backends [1.38.1-5]
Remv nautilus [3.30.5-2]
Remv gvfs [1.38.1-5] [gvfs-fuse:amd64 nautilus-extension-brasero:amd64 ]
Remv gvfs-daemons [1.38.1-5] [gvfs-fuse:amd64 nautilus-extension-brasero:amd64 ]
Remv gvfs-fuse [1.38.1-5] [nautilus-extension-brasero:amd64 ]
Remv iio-sensor-proxy [2.4-2] [nautilus-extension-brasero:amd64 ]
Remv libnss-systemd [241-7~deb10u2] [nautilus-extension-brasero:amd64 ]
Remv udisks2 [2.8.1-4] [nautilus-extension-brasero:amd64 ]
Remv synaptic [0.84.6] [nautilus-extension-brasero:amd64 ]
Remv rtkit [0.11-6] [nautilus-extension-brasero:amd64 ]
Remv policykit-1 [0.105-25] [nautilus-extension-brasero:amd64 ]
Remv libpam-systemd [241-7~deb10u2] [nautilus-extension-brasero:amd64 ]
Remv nautilus-extension-brasero [3.12.2-5]
Remv systemd-sysv [241-7~deb10u2] [init:amd64 ]
Inst sysvinit-core (2.93-8 Debian:10.2/stable [amd64])
Remv systemd [241-7~deb10u2]
Inst libelogind0 (239.3+20190131-1+debian1 Debian:10.2/stable [amd64])
Inst elogind (239.3+20190131-1+debian1 Debian:10.2/stable [amd64])
Conf sysvinit-core (2.93-8 Debian:10.2/stable [amd64])
Conf libelogind0 (239.3+20190131-1+debian1 Debian:10.2/stable [amd64])
Conf elogind (239.3+20190131-1+debian1 Debian:10.2/stable [amd64])
empty@E485:~ $

But aptitude(8) behaves differently:
Code: Select all
empty@E485:~ $ aptitude -s install elogind
The following NEW packages will be installed:
  elogind{b} libelogind0{a}
0 packages upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 798 kB of archives. After unpacking 2,388 kB will be used.
The following packages have unmet dependencies:
 elogind : Conflicts: systemd but 241-7~deb10u2 is installed
           Conflicts: systemd:i386 but it is not going to be installed
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     elogind [Not Installed]                           



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

As you can see, it initially refuses to install it at all but does offer more suggestions. If we ask for another solution:
Code: Select all
Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

      Remove the following packages:                                   
1)      chrome-gnome-shell [10.1-5 (now, stable, unstable)]             
2)      colord [1.4.3-4 (now, stable)]                                 
3)      dbus-user-session [1.12.16-1 (now, stable)]                     
4)      gdebi [0.9.5.7+nmu3 (now, stable, unstable)]                   
5)      gdm3 [3.30.2-3 (now, stable)]                                   
6)      gnome-color-manager [3.30.0-2 (now, stable)]                   
7)      gnome-control-center [1:3.30.3-2~deb10u1 (now, stable)]         
8)      gnome-disk-utility [3.30.2-3 (now, stable)]                     
9)      gnome-music [3.30.2-1 (now, stable)]                           
10)     gnome-session [3.30.1-2 (now, stable)]                         
11)     gnome-settings-daemon [3.30.2-3 (now, stable)]                 
12)     gnome-shell [3.30.2-11~deb10u1 (now, stable)]                   
13)     gnome-shell-extensions [3.30.1-1 (now, stable)]                 
14)     gnome-sushi [3.30.0-2 (now, stable)]                           
15)     gnome-tweaks [3.30.2-1 (now, stable)]                           
16)     gvfs [1.38.1-5 (now, stable)]                                   
17)     gvfs-backends [1.38.1-5 (now, stable)]                         
18)     gvfs-daemons [1.38.1-5 (now, stable)]                           
19)     gvfs-fuse [1.38.1-5 (now, stable)]                             
20)     iio-sensor-proxy [2.4-2 (now, stable)]                         
21)     libnss-systemd [241-7~deb10u2 (now, stable)]                   
22)     libpam-systemd [241-7~deb10u2 (now, stable)]                   
23)     nautilus [3.30.5-2 (now, stable)]                               
24)     nautilus-extension-brasero [3.12.2-5 (now, stable)]             
25)     policykit-1 [0.105-25 (now, stable)]                           
26)     rtkit [0.11-6 (now, stable)]                                   
27)     synaptic [0.84.6 (now, stable)]                                 
28)     systemd [241-7~deb10u2 (now, stable)]                           
29)     systemd-sysv [241-7~deb10u2 (now, stable)]                     
30)     udisks2 [2.8.1-4 (now, stable)]                                 

      Install the following packages:                                   
31)     sysvinit-core [2.93-8 (now, stable)]                           

      Leave the following dependencies unresolved:                     
32)     argyll recommends libpam-systemd                               
33)     cheese recommends gvfs                                         
34)     libcolord-gtk1 recommends colord                               
35)     elogind recommends policykit-1                                 
36)     file-roller recommends gvfs                                     
37)     geoclue-2.0 recommends iio-sensor-proxy                         
38)     gnome-calculator recommends gvfs                               
39)     gnome-online-accounts recommends gnome-control-center (>= 3.6.1)
40)     gnome-session-bin recommends libpam-systemd                     
41)     gnome-shell recommends gdm3 (>= 3.10.0.1-3~)                   
42)     gnome-shell recommends gnome-control-center (>= 1:3.25.2)       
43)     gnome-system-monitor recommends gvfs                           
44)     gnome-terminal recommends gvfs                                 
45)     gvfs-common recommends gvfs                                     
46)     hitori recommends gvfs                                         
47)     kodi-bin recommends udisks2                                     
48)     nautilus recommends gvfs-backends                               
49)     pinentry-gnome3 recommends dbus-user-session                   
50)     pulseaudio recommends rtkit                                     
51)     pulseaudio recommends libpam-systemd                           
52)     pulseaudio recommends dbus-user-session                         
53)     realmd recommends policykit-1                                   
54)     rhythmbox recommends gvfs-backends                             
55)     rygel recommends dbus-user-session                             
56)     systemd-sysv recommends libnss-systemd                         
57)     thunar recommends gvfs                                         
58)     thunar recommends policykit-1-gnome | polkit-1-auth-agent       
59)     thunar recommends udisks2                                       
60)     udisks2 recommends policykit-1                                 
61)     upower recommends policykit-1                                   
62)     vino recommends gvfs                                           
63)     xfce4-power-manager recommends libpam-systemd                   
64)     xserver-xorg-core recommends libpam-systemd                     



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

^ That solution is the same as offered by apt(8) (except that aptitude auto-autoremoves) but it's not finished yet and has more suggestions :-)

For apt-get(8) I see the same output as for apt(8) so I think the OP is correct in their assertion that the apt command is a user-friendly wrapper for apt-get (and apt-cache) with some eye-candy options applied to make it a more pleasing interface.

@OP: thanks for raising this, looks like I was wrong :)
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12493
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Is apt dependency resolution different as that of apt-ge

Postby L_V » 2020-01-26 12:42

Head_on_a_Stick wrote:The OP is referring to the resolution algorithms that are used when there are complicated dependency chains.

Only aptitude is able to solve complex situations (and do much more).
Aptitude even has a dedicated doc package: aptitude-doc-en
=> apt / apt-get : no difference for basic dependency management.

Assuming aptitude is a must to manage complex dependencies, apt-get is not necessary anymore.
Furthermore, apt also supersedes apt-cache.

Code: Select all
apt-cache depends nano
apt depends nano
L_V
 
Posts: 1270
Joined: 2007-03-19 09:04

Re: Is apt dependency resolution different as that of apt-ge

Postby Head_on_a_Stick » 2020-01-26 12:59

L_V wrote:Assuming aptitude is a must to manage complex dependencies, apt-get is not necessary anymore

^ This is incorrect, the apt(8) man page says that apt-get and apt-cache should still be preferred for scripts because apt's interface is not stable enough and also to maintain backward compatibility.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12493
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Is apt dependency resolution different as that of apt-ge

Postby L_V » 2020-01-26 13:14

Head_on_a_Stick wrote:apt-cache should still be preferred for scripts because apt's interface is not stable enough
"Stability" will come.... I use apt 1.9.7 with no problem at all.
https://tracker.debian.org/pkg/apt
Don't see the problem to keep apt-cache for "scripts" (not the point of OP focused on dependency management).
I really never use apt-get, which is probably a sign I don't need it.
However, I really need aptitude to make different things apt or apt-get are not able to do.
L_V
 
Posts: 1270
Joined: 2007-03-19 09:04

Re: Is apt dependency resolution different as that of apt-ge

Postby Head_on_a_Stick » 2020-01-26 13:22

L_V wrote:"Stability" will come.... I use apt 1.9.7 with no problem at all

Just for clarity: I am using the word "stable" to refer to the changes in the API rather than reliability.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12493
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Is apt dependency resolution different as that of apt-ge

Postby Chrisdb » 2020-01-27 10:55

So can we assume that the following is a decent summary then:

- Use apt-get/apt-cache in scripts
- Use aptitude for complex operations (f.e. remove packages with orphaned Dependencies, ...)
- Use apt for everything else

:D
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16

Re: Is apt dependency resolution different as that of apt-ge

Postby L_V » 2020-01-27 13:32

I don't understand the focus on "scripts". A command inside or outside a script is the same command.
When you make a script, you test it and you choose the command which fits your need.
If "stability" means stability over Debian upgrades, ok, don't use '/usr/bin/apt' right now in scripts.
If the script just contains "apt-get install $A", it will give the same result as "apt install $A".

apt-cache will give much more options than "apt cache", but 99% of apt-cache operations is "apt-cache depends XX" which will give the same result and "reliability" as "apt depends XX".
It is just easier to group most common used apt-xyz_commands in one command: apt.

Again and again (and again) / OP question:" Is apt dependency resolution different as that of apt-get ?"
Of course and hopefully no. Same result.

What is not yet clearly understood is that apt is not an extra/new tool package.
APT is a core Debian package, and '/usr/bin/apt' & '/usr/bin/apt-get' are both provided by apt package !

"apt is the main command-line package manager for Debian and its derivatives. It provides command-line tools for searching and managing as well as querying information about packages as well as low-level access to all features provided by the libapt-pkg and libapt-inst libraries which higher-level package managers can depend upon.
* Included tools are:
    apt-get for retrieval of packages and information about them from authenticated sources and for installation, upgrade and removal of packages together with their dependencies
    apt-cache for querying available information about installed as well as available packages
    apt-cdrom to use removable media as a source for packages
    apt-config as an interface to the configuration settings
    apt-key as an interface to manage authentication keys
    apt-extracttemplates to be used by debconf to prompt for configuration questions before installation
    apt-ftparchive creates Packages and other index files needed to publish an archive of deb packages
    apt-sortpkgs is a Packages/Sources file normalizer
    apt is a high-level command-line interface for better interactive usage"
Why some older apt packages are warning about apt command "stability" ?
It means that the definition of "better interactive usage" is still under discussion.
Example: "apt install" will show a progress bar, and not "apt-get install", although they will give exactly the same package management.
Now the next progress bar can be red or blue or green, the user interface is then not granted "stable".

Aptitude is always the first package I install because I know I will need it (for advanced operations).
However, 90% of Debian users will probably never need aptitude.
Maybe too early for Buster, but for next stable, 90% of Debian "normal" users will probably use apt and not apt-get anymore.

Then, maybe not "one" summary, but your summary based on your experience.

List of what /usr/bin/apt is able to manage, and compare with apt-get

Code: Select all
# /usr/bin/apt according to https://salsa.debian.org/apt-team/apt/blob/master/cmdline/apt.cc
auto-clean
auto-remove
autoclean
autopurge
autoremove
build-dep
changelog
clean
depends
dist-upgrade
download
edit-sources
full-upgrade
info
install
list
moo
policy
purge
rdepends
reinstall
remove
satisfy
search
show
showsrc
source
update
upgrade
L_V
 
Posts: 1270
Joined: 2007-03-19 09:04

Re: Is apt dependency resolution different as that of apt-ge

Postby Chrisdb » 2020-01-28 06:00

L_V wrote:I don't understand the focus on "scripts". A command inside or outside a script is the same command.


'apt' is not YET fully supported for use in scripts.

Take this example and put it in a script:
Code: Select all
apt show gedit > show.log


If you would execute this, you will get the following warning:

Code: Select all
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16

Re: Is apt dependency resolution different as that of apt-ge

Postby L_V » 2020-01-28 07:11

Yes man. Comments already made concerning this "WARNING" for apt version 1.8.2 used by Buster.
You will not have it soon. I don't have it with apt 1.9.7.
=> https://tracker.debian.org/pkg/apt
I said: "If "stability" means stability over Debian upgrades, ok, don't use '/usr/bin/apt' right now in scripts.".
Not clear enough ?

Now, concretely, you don't take a good example.
"apt show XX" just read the content of file control.tar.xz of package XX (written in dpkg status file).
You can use any other "show" commands (apt-cache or what you want,) you will get the same output.

The main difference for a script will be with apt-cache which will change the presentation of the output, "apt" target being "user friendliness".
L_V
 
Posts: 1270
Joined: 2007-03-19 09:04

Re: Is apt dependency resolution different as that of apt-ge

Postby Chrisdb » 2020-01-28 07:25

L_V wrote:Yes man. Comments already made concerning this "WARNING" for apt version 1.8.2 used by Buster.
You will not have it soon. I don't have it with apt 1.9.7.
=> https://tracker.debian.org/pkg/apt
I said: "If "stability" means stability over Debian upgrades, ok, don't use '/usr/bin/apt' right now in scripts.".
Not clear enough ?


I was just responding to your statement:
I don't understand the focus on "scripts".

Nothing more.

Most people just like the idea of a single answer for 1 problem and not something like: we will see how it works out in this scenario...
And yes I know, this is not always possible :wink:
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16

Next

Return to Debian Development

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable