[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Use apt-get indextargets instead of accessing /var/lib/apt/lists/ directly (was: Bug#833388: ITP: metaphlan2 Metagenomic Phylogenetic Analysis)



Hi,

Quoting Christian Seiler (2016-08-04 10:03:04)
> Shell snipped I used to get this data:
> awk '/^Package:/ { pkg = $2; }
>      /^Installed-Size:/ { is = $2; }
>      /^Size:/ { print pkg, $2, is }' \
>      < /var/lib/apt/lists/*_debian_dists_sid_main_binary-amd64_Packages \
>   | sort -k3 -n \
>   | awk '{ print $1, $2 / 1024.0 / 1024.0 / 1024.0, $3 / 1024.0 / 1024.0 }' \
>   | tail -n 5 \
>   | tac

using the files in /var/lib/apt/lists/ directly should be avoided because the
naming scheme can change arbitrarily and the files might be compressed. You
should use "apt-get indextargets" instead.

Also, instead of awk, you might want to use grep-dctrl instead.

So the first part above until the sort would become:

apt-get indextargets \
    | grep-dctrl -s Filename -n \
      -F Created-By Packages \
      -a -F Suite unstable \
      -a -F Component main \
      -a -F Architecture amd64 \
    | xargs /usr/lib/apt/apt-helper cat-file \
    | grep-dctrl -n -sPackage,Installed-Size,Size -FInstalled-Size '' \
    | paste -sd "   \n" \
    | sort ...

One can avoid the first grep-dctrl call by using "apt-get indextargets" command
line options like so:

apt-get indextargets \
      --format '$(FILENAME)' \
      "Created-By: Packages" \
      "Suite: unstable" \
      "Component: main" \
      "Architecture: amd64" \
    | xargs ...

I just personally like to use grep-dctrl because then I don't have to learn yet
another syntax of how to filter deb822 files.

Thanks!

cheers, josch

Attachment: signature.asc
Description: signature


Reply to: