Skip to main content

2 posts tagged with "apt-cache"

View All Tags

Minimal apt install

· 4 min read
Ubuntu logo

I was recently working on a bootstrap script that, among other things, needed to install a fairly large number of apt packages. The list of packages was pre-existing, and had grown organically over several years. As most apt users would know, many packages require a significant number of dependenecies, and so it's pretty likely that any significant list of apt packages would include at least some transitive redundancy. So, mostly as a mental exercise, I started pondering how I could go about reducing any set of required apt packages to tha minimal set that would still include all of the same dependencies.

It actually proved to be pretty easy in the end. But first, I needed to find a reliable way to fetch the list of dependencies for any given package. The apt-cache utility does the job, but I had to sort through some misinformation online re the command's output format. You read about that in the previous Pipes in apt-cache Output post.

Pipes in apt-cache Output

· 6 min read
Ubuntu logo

Whilst pondering a thought-experiment related to installing Ubuntu packages (more on that in another post), I was looking to understand the output of the apt-cache depends command. However, while doing a quick Google search, I found that the top two results were wrong - one subtly (though sort-of right), the other blatently wrong. So, I did a little digging to figure it out for myself.

Before we get to the right answer, let's start with those top two results. The first search result says:

As you guessed the | indicates "or". The control line normally shows foo | bar, but apt-cache depends appears to reformat it by showing each alternative on its own line and prefixing the first with the |. In other words, the pipe flags the preferred option and the next line is the alternative.

(emphasis mine)

This is actually pretty close, but not quite true, as we'll soon see.