Tip of the day: fetching all Debian source packages

A few weeks ago, the Linutop team received a request for its source code. We had already anticipated the GPL source offer clause in our development plan, so it was just a matter of myself getting around producing a source code ISO image. Piece of cake, right?

Almost. You see, Linutop includes a custom kernel package and several separate wireless module packages, so the the following command would not work as expected:

apt-get --download-only --ignore-missing source $(dpkg --get-selections | cut -f 1)

Why is that? Because APT ignores the --ignore-missing option whenever executing the source command. Instead, Roland Mas suggested that I used this simple Bourne loop:

for p in $(dpkg --get-selections | cut -f 1) ; do apt-get --download-only source $p ; done

Done this way, the source code of each package is fetched individually and, if any package's source is not available, APT exits but the Bourne loop moves on to the next package in the list. Nifty, isn't it?

Ei kommentteja: