#!/bin/sh

VERSION="2.0"

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

    Command to deploy OBJECTS from binary packages into IMGDIR.
    After that packages from OBJECTS can be used as build dependencies.

    Location of binary packages is given with any_pkg option.
    By default, the directory is PACKDIR.
"
}

# TODO remove all this, multicheck for PACKDIR inside deploy

eval "$(dumprdd -g "${@}" rdd_prf_id="output" )"
if test -z "${ANYAPI}" ; then
    printf "%s\n" "
Failed to init shell environment, needed for command execution.
The command must be launched within working directory.
Check your cmd arguments and correctness of data.
Check your dumprdd executable as well.
"
    exit 2
fi

if test -d "${any_pkg}" ; then
    pack_dir="$(cd "${any_pkg}" ; pwd -P)"
else
    pack_dir="${PACKDIR}"
fi

# install the needed from binaries
any do "${@}" \
    any_pkg="${pack_dir}" \
    any_host_update=0 \
    rdd_prf_id="deploy" \
    rdd_map_entry="pkg_deploy"
