#!/bin/sh
#
# Fetch list of packages with firmware to store in the data package,
# while we wait for DEP-11 to gain support for it and a lightweight
# method to look it up.

set -e

mirror=http://http.debian.net/debian

mkdir -p generated

for arch in amd64 i386 armel powerpc; do
    for dist in wheezy jessie sid; do
	for section in "main" "contrib" "non-free"; do
            # "" is main in Wheezy.
	    if [  main = "$section" ] && [ wheezy = "$dist" ]; then
		url="$mirror/dists/$dist/Contents-$arch.gz"
	    else
		url="$mirror/dists/$dist/$section/Contents-$arch.gz"
	    fi
	    echo "fetching $url"
	    GET $url | gunzip | grep ^lib/firmware > generated/Fw-Contents-$arch-$dist-$section
	done
    done
done
