apt install, I would get a list of packages that need to be installed, under the line:
The following NEW packages will be installed:
and if there are none, it would continue without prompt. I tried to retrieve this list, but would fail if there are none because the install would just proceed. I want to get this list without installing it.
I tried something like this:
apt-cache depends --recurse packagename | grep -v " " | sort -u
But it gives a full list including those that are already installed. I want to limit it to those that need to be installed.
I know I can compare the output above with the result of
to see which are installed and which are not, but it would involve loops within loops and both lists are quite long. There surely must be a more elegant way to do this.
Thanks for any suggestions. (This is my first time to ask a question here)
Edit: I checked out the method using
rdepends as given in this question:
It would have been what I am looking for, except that it results in a different list from what
apt install gives. It even lists dependencies that are uninstallable (which can't be, given that the package itself installs successfully). What I'm looking for is the list of packages that
apt would install before the given package. Anyway, I don't understand why the list is different. It should be the same result, right? But since it isn't, then it is not what I am looking for. I would appreciate, however, if someone can explain to me why they give different results.