Score:11

How to install a package via `apt-get` without flagging it as manually installed

in flag

I want to install some package (apt-get install XXX) but I don't want that it will be added to the list of manually installed packages (apt-mark showmanual). How?

In Gentoo, the corresponding flag for emerge is --oneshot, which says to not add it to the world file (which corresponds to the list of manually installed packages).


One use case is that I want to write some scripts which would automatically install or reinstall some packages via apt-get install in order to fix up some messed up system, but I do not want to mark those packages as manually installed.

I imagine there are other use cases as well. As emerge also has such flag, I wondered if there is a similar flag for apt-get install.

Maybe the answer is simply no, and I have to manually mark it as auto (apt-mark auto XXX) afterwards.

Score:9
us flag

You can add it to the list of automatically installed packages once again.

sudo apt install package
sudo apt-mark auto package
N0rbert avatar
zw flag
This is good, but will not allow user to determine which package were installed on top of initially installed system. So it will not allow tools like mine https://github.com/N0rbert/srslsud to operate in save-restore manner.
us flag
@N0rbert Is there an alternative?
N0rbert avatar
zw flag
For me it sounds like XY-problem. There are no alternatives, the question is questionable as for me. Command reference is at https://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_basic_package_management_operations_with_the_commandline .
us flag
@N0rbert May not be an XY problem. I can give an similar example from my use case. Sometimes I install a lot of dependencies to compile software. I may not need those dependencies afterwards, and sometimes, it is a hassle to remove them one by one.
N0rbert avatar
zw flag
Good point, I agree about `*-dev` packages.
in flag
@N0rbert Also, e.g on Gentoo, `emerge` has the `--oneshot` flag for this purpose.
in flag
@N0rbert Another example for why you would want to do this (based on personal experience): Package A is a weak dependency of package B (`Recommends` or more likely `Suggests` in Debian packaging parlance) that was not installed at the time package B was installed, and you want to add package A but want it to be properly handled as a dependency of package B (for example, if you manually remove package B, package A should be removed).
N0rbert avatar
zw flag
@AustinHemmelgarn ok, I know about this problem. So really, not an XY-problem.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.