#!/bin/bash export LC_ALL=C if [ $# -eq 2 ]; then dist="$1" arch="$2" else dist='arch' arch='x86_64' fi provided=$(mktemp --suffix=".${dist}.${arch}") sources=( "http://pkgcache.eckner.net/${dist}/${arch}/${dist}linuxewe/${dist}linuxewe.db.tar.gz" ) if [ "${dist}" = 'arch' ]; then sources+=( "http://pkgcache.eckner.net/${dist}/${arch}/core/core.db.tar.gz" "http://pkgcache.eckner.net/${dist}/${arch}/extra/extra.db.tar.gz" ) else sources+=( "http://pkgcache.eckner.net/${dist}/${arch}/system/system.db.tar.gz" "http://pkgcache.eckner.net/${dist}/${arch}/world/world.db.tar.gz" "http://pkgcache.eckner.net/${dist}/${arch}/galaxy/galaxy.db.tar.gz" ) fi for i in "${!sources[@]}"; do source="${sources["${i}"]}" if [ -z "${source##*://*}" ]; then curl -Ss "${source}" \ | bsdtar -Oxz else find "${sources["${i}"]}" -name '*.db' \ -exec bsdtar -Oxzf {} \; \ 2>/dev/null fi \ | sed -n ' /^%\(NAME\|VERSION\)%$/ { N s/\n/ / p } /^%PROVIDES%$/,/^$/ { /^[^%]/ p } ' \ | sed -n ' s/^\(\S\+\)=\(\S\+\)-\(64\|32\)$/\2 \1/ T no_provides p d :no_provides /^%NAME%/ { N s/^%NAME% \(\S\+\)\n%VERSION% \(\S\+\)-\S\+$/\2 \1/ T p } ' \ | sed ' /^\(\S\+\) \1$/d s/^/'"${i}"' / ' done \ | sort -k3,3 -k1n,1 -k2Vr,2 \ | uniq -f2 \ | cut -d' ' -f2,3 \ >"${provided}" printf '%s\n' "${provided}"