~adeodato/ blog/ debian/ grep-dctrl over any dist/component/arch

grep-dctrl over any dist/component/arch

grep-dctrl has proven, at least for me, an utterly useful tool; I suspect this will probably be the case for many others as well. (As I side comment, I believe it’d be nice for AMs to make sure their applicants do at least know about the existance of grep-dctrl, and ideally have basic knowledge about how to use it.)

Many times, though, using its grep-available form is not fine-grained enough, and one needs full control over the distribution to make the search in. A valid workaround for this is to run grep-dctrl over /var/lib/apt/lists/whatever; I’ve been using this for some time now, with shell aliases like grep-sid or grep-s-etch (for sources), but sometimes I wanted a grep over two dists, or several components (e.g., main and contrib), or a set of arches.

For this, I decided to write a grep-dctrl wrapper that, relying on the structure of a normal mirror, allows to run a search over any combination of dist/component/arch. At home, where I do not have a local mirror, I have populated /org/ftp.root/debian/dists with a pool of symlinks towards /var/lib/apt/lists, and whenever I need more than i386/source, I can run it on any debian.org machine with a local mirror, e.g. merkel.

For example, to know which packages in sid but also present in testing are still kdelibs4c2a-untransitioned, but ignoring hppa and m68k, I’d run on merkel the following:

    % grep-archive sid:main,contrib:alpha,arm,i386,ia64,mips,mipsel,powerpc,s390,sparc \
            -Fdepends -e 'kdelibs4(c2)?( |,|$)' -ns source,package |
      unique-sources | xargs madison -s testing | awk '{print $1}'
  

In case somebody finds it of interest, the script is available here, together with the dirty hack that is unique-sources, needed since not all binary packages have a Source header (sigh).

NP: Jacques Brel, Au suivant