#!/usr/bin/env bash

source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../etc/bash/common.lib.sh"

reset_cache() {
    for package in $(locate_packages); do
        if ! is_package_cache_fresh "${package}"; then
            echo "--reset-cache"
            break
        fi
    done
}

install_package="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/install-package"

locate_packages | parallel -j "$(get_number_of_jobs_for_parallel)" --gnu "${install_package} {} $* $(reset_cache)"
