#!/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 -z "${a}"; then r=${a}; else b=$(grep " ${1} " "${HERE}"/.index | cut -d' ' -f2 | xargs); if ! test -z "${b}"; then r=${b}; else r=${1}; fi fi printf "%s" "${r}"; } ## # Prints a fatal error and exits. # nxdepf () { printf "E: dependency '%s' not found or excepted (needed by '%s')\n" "${1}" "${2}" 1>&2; exit 1; } ## # 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