pkg_name=bpm
version=0.10.1
revision=1
build_style=custom
short_desc="basix package manager"
home_page="https://github.com/kkrruumm/bpm"
license="BSD-3-Clause"
dist_files="https://github.com/kkrruumm/bpm/archive/refs/tags/${version}.tar.gz"
checksum="05bbe1862544ba8682c2108c8e2cd28ddfb9c7ce57579b392ef529b8aa6d4618"

depends="b3sum curl git"

do_build() { :; }

do_install() {
    if [ -f lib/core.sh ]; then
        :
    elif [ -f bpm/lib/core.sh ]; then
        cd bpm
    else
        die "no lib/core.sh in $PWD"
    fi

    bbin bpm

    for f in lib/*.sh lib/graph.awk; do
        binstall "$f" 0644 /usr/lib/bpm
    done
    for f in lib/style/*.sh; do
        binstall "$f" 0644 /usr/lib/bpm/style
    done

    for f in etc/bpm.conf etc/repos.conf etc/package.use; do
        if [ -f "$f" ]; then binstall "$f" 0644 /etc/bpm; fi
    done

    for d in pre-install post-install pre-remove post-remove; do
        bmkdir "/etc/bpm/hooks/$d"
    done
    if [ -f etc/hooks/post-install/00-ldconfig ]; then
        binstall etc/hooks/post-install/00-ldconfig 0755 /etc/bpm/hooks/post-install
    fi

    bmkdir /var/db/bpm/repos /var/cache/bpm

    # this is here incase i forget to bump PROGVER upstream
    bsed "s/^BPM_PROGVER=.*/BPM_PROGVER=$version/" "$DESTDIR/usr/bin/bpm"
}
