#!/bin/sh -e ## e.g. # # $ ./scripts/setup # $ ./scripts/deplist system | ./scripts/depsort # HERE="$(dirname $(readlink -f ${0}))"; BASE="${HERE}/.."; ## # Usage # if test ${#} = 0; then cat <&2; exit 1; fi done ## # Find a package by name or find the parent package of a subpackage. # Note that the index is padded by a space on either side for easy grep. # # Usage: parent PACKAGE # parent () { a=$("${HERE}"/sgrep " ${1} " "${HERE}"/.index | cut -d' ' -f2 | xargs); if test -n "${a}"; then r=${a}; else b=$(grep " ${1} " "${HERE}"/.index | cut -d' ' -f2 | xargs); r=${b}; fi printf "%s" "${r}"; } ## # Do everything at once. # for repo in ${@}; do find "${BASE}/${repo}" -mindepth 1 -maxdepth 1 -type d | while read k; do ( ## # Source APKBUILD in a subshell to avoid contamination. # . "${k}/APKBUILD"; ## # Special-case some options. For example, '!check' means # that the 'checkdepends=' variable is not used. Ignore. # for m in ${options}; do case ${m} in !check) checkdepends=; ;; esac done ## # Aggregate all possible depends. Obviously if something # is not specified, it will be empty anyway. # # FIXME: Clean this up somehow. # cats=$(tr ' ' '\n' <*}; # remove >version _d=${_d%<*}; # remove &2; exit 1; fi path="${repo}/${_d}"; ;; user) # packages in user might depend on something in system if ! test -f "${BASE}/${repo}/${_d}/APKBUILD"; then if test -f "${BASE}/system/${_d}/APKBUILD"; then path="system/${_d}"; else printf "E: dependency '%s' not found or excepted\n" "${_d}" 1>&2; exit 1; fi else path="${repo}/${_d}"; fi ;; esac ## # Print remaining columns of output if not parent. # printf " %s" "${path}"; done | tr ' ' '\n' | sed -e "\@${p}\$@d" | sort -u | xargs; # sort and remove duplicates ) done | sort; # sort only within a repo done