#Maintainer: Dimitris Tzemos <djemos~at~slackel.gr>
#produce binary with " slkbuild -X"
pkgname=slpkg
pkgver=2.3.0
pkgrel=1dj
source=("https://github.com/dslackw/slpkg/archive/v2.3.0.tar.gz")
#source=(http://people.salixos.org/djemos/salix/slpkg/$pkgname-$pkgver.tar.gz")
url="https://github.com/dslackw/slpkg"
docs=("CHANGELOG" "README.rst" "ISSUES" "REPOSITORIES" "LICENSE" "TESTING")
options=('noautodotnew')

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"slpkg (Slackware Packaging Tool)"
"Slpkg is a software package manager that installs, updates, and"
"removes packages on Slackware based systems. It automatically"
"computes dependencies and figures out what things should occur"
"to install packages. Slpkg makes it easier to maintain groups of"
"of machines without having to manually update."
""
"Homepage: https://github.com/dslackw/slpkg"
)

build() {
cd $SRC/${pkgname}-${pkgver}
# avoid install man page and slpkg.conf, blacklist over setup.py
sed -i 's/if "install"/if ""/' setup.py || return 1

python setup.py install --root=$PKG  || return 1

mkdir -p $PKG/etc/slpkg
# install configurations files
CONFIGS="slpkg.conf blacklist slackware-mirrors custom-repositories"
for file in $CONFIGS; do
  install -D -m0644 conf/$file $PKG/etc/slpkg/${file}  || return 1
done

# install bash completion file
mkdir -p $PKG/etc/bash_completion.d
 install -D -m0744 conf/${pkgname}.bash-completion \
    $PKG/etc/bash_completion.d/${pkgname}.bash-completion  || return 1

# install fish completion file
if [ -d "/etc/fish/completions" ]; then
   install -D -m0744 conf/${pkgname}.fish \
        $PKG/etc/fish/completions/${pkgname}.fish  || return 1
fi

# install man page
mkdir -p $PKG/usr/man/man8
gzip -9 man/$pkgname.8
 install -D -m0644 man/$pkgname.8.gz $PKG/usr/man/man8/$pkgname.8.gz  || return 1
}
