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
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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

+3
−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?

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

0 comment threads

1 answer

+5
−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.
History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

General comments (1 comment)

Sign up to answer this question »