#/usr/bin/env bash

pkgname="makedeb"
pkgver=0.0.2.0.g175943a
pkgrel=1
arch="all"
pkgcommit=""
section="utils"             # https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
priority="optional"         # https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
pkgdesc="A painless selfhost git service."
url="https://git.leafee98.com/leafee98/makedeb"
maintainer="Leafee98 <me@leafee98.com>"

source=(
    "LICENSE::https://git.leafee98.com/leafee98/makedeb/raw/branch/main/LICENSE"    # from http (existed file will skip, without checking hash)
    "makedeb-repo::git+https://git.leafee98.com/leafee98/makedeb.git#branch=main"   # from git with https
    "README.md::README.md"                                       # from local file
)

# This will be run just after extracting source, and re-assign to `pkgver`
#
# If extracting version from source is not needed, don't define this function.
function pkgver {
    git describe --tags --long | sed 's/^v//;s/-/./g'
}

function build {
    echo "Here should do something like compile sources."
    echo "But for this package we just print some messages."
}

function package {
    install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/makedeb/LICENSE"
    install -Dm755 "${srcdir}/makedeb-repo/makedeb" "${pkgdir}/usr/bin/makedeb"
    install -Dm755 "${srcdir}/README.md" "${pkgdir}/usr/share/doc/makedeb/README.md"
}

# The function describing hook for (pre|post)(inst|rm) should
# *print* content of those hook file.
# If the any hook is not needed, don't define those function.

#function debian_preinst {
#}

function debian_postinst {
    cat << EOF
#!/usr/bin/env bash
echo "successfully installed makedeb"
EOF
}

#function debian_prerm {
#}

function debian_postrm {
    cat << EOF
#!/usr/bin/env bash
echo "successfully removed makedeb"
EOF
}