#!/usr/bin/env sh
# kama — the Keru OS package manager
#
# Kama (窯, "kiln") builds packages from source by executing shell recipes.
# It is deliberately minimal: it reads make.conf and runs whatever each
# recipe tells it to. No dependency resolver, no package database.
#
# Usage:
#   kama <command> [package ...]
#
# Commands:
#   fetch   <pkg>   download + extract source into the cache
#   build   <pkg>   stage-build one package
#   install <pkg>   build + install into $ROOT (staging-aware)
#   cmake   <pkg>   high-level: fetch deps, build, install, purge temp deps
#   purge           remove temp build-time deps after a successful install
#   info    <pkg>   show a recipe's metadata

set -eu

SELF_DIR="$(cd "$(dirname "$0")" && pwd)"
. "$SELF_DIR/lib/kama.sh"

cmd="${1:-help}"
shift || true

case "$cmd" in
    fetch)   kama_fetch "$@" ;;
    build)   kama_build "$@" ;;
    install) kama_install "$@" ;;
    make)    kama_make "$@" ;;
    purge)   kama_purge ;;
    info)    kama_info "$@" ;;
    help|--help|-h)
        msg "Keru OS — Kama (窯) package manager"
        cycle
        ;;
    *)
        die "unknown command: $cmd (try: kama help)"
        ;;
esac
