#!/bin/sh # get reverse dependencies for a specific arch from # the gentoo tinderbox and print the atoms # (with USE-dep syntax) out, so your arch-testing tool # can emerge them. REPODIR="${HOME}/git/gentoo" BASE_URL="http://qa-reports.gentoo.org/output/genrdeps/dindex/" if [[ $# -ne 2 ]]; then echo "usage:" echo " ${0} arch category/package" echo echo "Examples: ${0} arm media-gfx/graphviz" exit 1 fi arch="${1}" pkg="${2}" pkg="${pkg/=/}" pkg="${pkg/-[0-9]*/}" if [[ ! -d ${REPODIR} ]]; then echo "your \${REPODIR}='${REPODIR}' does not exist." exit 1 fi if [[ ! -x $(which q) ]] ; then echo "you need portage-utils" echo "emerge app-portage/portage-utils" exit 1 fi if [[ $(egrep "\<${arch/\~/}\>" ${REPODIR}/profiles/arch.list | wc -l) == 0 ]]; then echo "invalid arch ${arch}" exit 1 fi if [[ ! -d ${REPODIR}/${pkg} ]]; then echo "package ${pkg} not found" exit 1 fi tmp="$(mktemp)" wget -o /dev/null -O "${tmp}" "${BASE_URL}/${pkg}" res=$? if [[ ${res} -ne 0 ]] ; then echo "failed to fetch reverse deps (wget returned ${res})" rm "${tmp}" exit 1 fi last_pn="" for p in $(grep -v '^[B]' ${tmp}); do cpv="${p/:*/}" use="${p/*:/}" [[ ${use} == ${p} ]] && use="" # negative use deps are !use and no -use # multiple use-deps are separated by '+' if [[ -n ${use} ]]; then use="${use//!/-}" use="${use//+/,}" fi # split up the category/package-version with q declare -a qatom qatom=($(qatom ${cpv})) [[ ${qatom#} < 2 ]] && die "invalid atom ${cpv}" category=${qatom[0]/=} pn=${qatom[1]} version=${qatom[2]} revision=${qatom[3]} [[ -n "${revision}" ]] && version="${version}-${revision}" # make sure that the file exists, as the local or remote tree # may be out of date ebuild="${REPODIR}/${category}/${pn}/${pn}-${version}.ebuild" [[ "${arch}" != "${arch/\~/}" ]] && expr="KEYWORDS=.*\<${arch/\~/}\>" \ || expr="KEYWORDS=.*( |\")\<${arch}\>" if [[ -e ${ebuild} && $(egrep -H "${expr}" \ ${ebuild} | wc -l) == 1 ]]; then slot=$(portageq metadata / ebuild ${cpv} SLOT) slot=${slot/\/*/} # kill subslot if [[ ${last_pn} != ${category}/${pn}:${slot} ]]; then [[ -z ${use} ]] && echo "${category}/${pn}:${slot}" || echo "${category}/${pn}:${slot}[${use}]" fi last_pn="${category}/${pn}:${slot}" fi done rm "${tmp}"