#!/bin/sh

VERSION="2.0"

print_help()
{
    printf "%s\n" "
Usage:
any buildtree DATA OBJECTS

    Build given OBJECTS with their dependencies.
    The resulting set is minimised: deployed packages are not rebuilding.
"
}

# TODO cheap check for tool correctness, but no entire dump

printf "%s\n" "Calculating dependencies..."
deps="$( lspkg -d "${@}" | tr '\n' ',')"
deps="${deps%,}"

if test -n "${deps}" ; then
    printf "%s\n%s\n" "Building the result:" "${deps}"
    any do "${@}" \
        rdd_list_entry="${deps}"
else
    printf "%s\n" "No result in output of command:
lspkg -d ${@}"
fi
