# shellcheck shell=dash

___x_cmd_pkg_sphere_boot_pkg(){
    ___x_cmd_pkg_sphere_boot_pkg___inner "boot" "$@"
}

___x_cmd_pkg_sphere_unboot_pkg(){
    ___x_cmd_pkg_sphere_boot_pkg___inner "unboot" "$@"
}

___x_cmd_pkg_sphere_boot_pkg___inner(){
    local op="$1"; shift
    pkg:sphere:parse:args

    local script_path
    script_path="$(___x_cmd_pkg___get_script_path "$name" "$version" "$osarch" "$op")" || return 1
    [ -n "$script_path" ] || {
        pkg:debug "Not found ${name} ${version} ${op}.sh"
        return 0
    }

    pkg:debug --script_path "$script_path" "Loading $name $version $op script file"

    ___x_cmd_pkg_osarch_
    local x_treename=; ___x_cmd_pkg_treename_ "$name" "$version" "$___X_CMD_PKG_OSARCH" || return $?
    local ___X_CMD_PKG___META_OS="${___X_CMD_PKG_OSARCH%%/*}"
    local ___X_CMD_PKG___META_ARCH="${___X_CMD_PKG_OSARCH#*/}"
    local ___X_CMD_PKG___META_TGT="$___X_CMD_PKG_ROOT_SPHERE/$sphere_name/$x_treename/$name/$version"
    local ___X_CMD_PKG___META_NAME="$name"
    local ___X_CMD_PKG___META_VERSION="$version"
    . "$script_path" || N=pkg M="Source $script_path failed" log:ret:1
}
