
Originally Posted by
garycheng12
understanding the unlikely scenarios could help me better understand
Okay, let's say you install an application, Foo, and a dependency, libfoo, using the package manager.
Code:
sudo apt-get install foo
(you already know that you don't need to specify dependencies)
Having installed it, you choose to delete all the stored package files in the cache at /var/cache/apt/achives
Now you go offline, and decide to reinstall libfoo.
Code:
sudo apt-get install --reinstall libfoo
The reinstallation will, of course, fail: apt no longer has a package stored in the cache, and you're not online.
Next, let's install another application, Bar, from a tarball on some random website on the wild internet (Tip: DON'T do that). It also depends upon libfoo...but the package manager doesn't know that since you installed from a tarball instead of a package.
Let's uninstall Foo but keep libfoo. Bar still needs libfoo.
Code:
sudo apt-mark manual libfoo
sudo apt-get remove foo
libfoo is not an orphan because you explicitly told the package manager to keep it.
Let's change that.
Code:
sudo apt-mark auto libfoo
Now the package manager thinks libfoo is an orphan for three reasons:
1) Nothing else installed, according to the package manager database, depends upon libfoo.
2) Bar does depend upon libfoo, but it's not a package. So it's not in that database.
3) It's now marked as 'automatically installed', and eligible for autoremoval.
When you autoremove the 'orphan' libfoo at the next opportunity, you will unintentionally break Bar.
Finally, let's say you still have libfoo installed, and you install the shiny new foo-ee package, which happens to also depend upon libfoo. Libfoo is no longer an orphan, since the package manager database shows that foo-ee needs it. If libfoo is already installed, another won't be downloaded and installed over it. The package manager is smart about that.
That's really one of the glues that holds a distro together - it's a bunch of packages that share the _same_ dependencies. There's just one version of libfoo, and all the packages that need it rely upon the same one. Of course, there are exceptions to that, too.
See how it works? It's not easy to defeat the package manager and break your system, but it is also not difficult. It's a tool intended to protect you from mild negligence only. It's not magic or super-smart or intended to protect you from foolishness. If you tell it to uninstall your kernel and render your system unbootable...it will do that; you are it's master.
Bookmarks