Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users

Dashboard
Notifications
Mark all as read
Q&A

Is this a robust way to distinguish explicitly installed packages from those pulled in as dependencies?

+2
−0

When exploring the commands from this answer to my previous question, I found that the ist of packages includes a lot that were automatically installed due to dependencies. Obviously I'm interested only in those packages that I explicitly requested (the others would be pulled in automatically again, if needed).

Since I didn't figure out a way to explicitly query whether a package was installed explicitly or as dependency, I figured the best way would be to determine whether a package depends on another installed package.

This information turns out to be available with apt-cache rdepends --installed $packagename but I still need to extract the information I need from the output.

Unfortunately the line "Reverse Depends:" is always output, even if there are no reverse dependencies. However I noticed that the dependency lines all start with a space, while the others don't. Therefore my idea is to use the following:

apt-cache rdepends --installed $packagename | grep -q "^ "

If there are no dependencies, the exit status of grep will be 1, otherwise it will be 0.

My question now is: Is this a robust way to test for this? If not, what are better ways to achieve what I want?

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comments

1 answer

+4
−0

apt-mark aims to do this: the commands apt-mark showmanual and apt-mark showauto should show you respectively the packages which you explicitly installed and the ones which were added as dependencies.

There are caveats.

  1. There seems to be a common complaint that it shows too many packages as manual; it's possible that running apt-mark minimize-manual would address that complaint.
  2. It's quite likely that some of the initially installed packages will be marked as manual, because apt autoremove will remove any package marked as auto which isn't a dependency of a package marked as manual. Running apt-mark showmanual at install and saving for future comparison would largely address this issue.
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment

Thank you. I hope that combining this with the previous answer will solve the issue with initially installed packages. celtschk‭ 27 days ago

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!