File PKGBUILD of Package osc

# Maintainer: Sebastian Wiesner <sebastian@swsnr.de>
# Contributor: Oleksandr Natalenko <oleksandr@natalenko.name>

pkgname=osc
pkgver=1.21.0
pkgrel=1
pkgdesc="Command Line Interface for Open Build Service"
arch=(any)
url=https://github.com/openSUSE/osc
license=(GPL-2.0-or-later)
# See https://github.com/openSUSE/osc/blob/master/contrib/osc.spec for dependencies
depends=(
	python-cryptography
	python-urllib3
	python-ruamel-yaml
)
optdepends=(
	'python-argcomplete: git-obs completions'
	'python-progressbar: download progressbars'
	'python-distro: Set the default editor by distro'
	'python-keyring: Store credentials in system keyring'
	'python-zstandard: Open control.tar.zst in debquery'
	'diffstat'
	'sudo'
	'git: Build from git'
	'git-lfs: Build from git'
	'openssh: SSH signatures'
	'xdg-utils: osc browse'
)
makedepends=(python-setuptools python-argparse-manpage python-sphinx git)
source=("git+${url}.git#tag=${pkgver}")
sha256sums=('dc681e9a6e8aeaf26c0709ed46099fabe92f6f401e739688259b9235611ffdab')

build() {
	cd "${pkgname}" || exit 1

	python setup.py build

	# Build manpages, see https://github.com/openSUSE/osc/blob/master/contrib/osc.spec
	PYTHONPATH=. argparse-manpage \
    	--output=osc.1 \
    	--format=single-commands-section \
    	--module=osc.commandline \
    	--function=argparse_manpage_get_parser \
    	--project-name=osc \
    	--prog=osc \
    	--description="openSUSE Commander" \
    	--author="Contributors to the osc project. See the project's GIT history for the complete list." \
    	--url="${url}"
	PYTHONPATH=. argparse-manpage \
	    --output=git-obs.1 \
	    --format=single-commands-section \
	    --module=osc.commandline_git \
	    --function=argparse_manpage_get_parser \
	    --project-name=osc \
	    --prog=git-obs \
	    --description="Git based command-line client for Open Build Service" \
	    --author="Contributors to the osc project. See the project's GIT history for the complete list." \
	    --url="https://github.com/openSUSE/osc/"

	sphinx-build -b man doc .
}

package() {
	cd "${pkgname}" || exit 1

	python setup.py install --root="${pkgdir}" --optimize=1 --prefix=/usr

	install -Dt "${pkgdir}"/usr/share/man/man1 -m0644 {git-obs-quickstart,git-obs-metadata,osc,git-obs}.1
	install -Dt "${pkgdir}"/usr/share/man/man5 -m0644 oscrc.5

	install -Dm0644 contrib/complete.sh "${pkgdir}"/usr/share/bash-completion/completions/osc
	install -Dm0644 contrib/osc.zsh "${pkgdir}"/usr/share/zsh/site-functions/_osc
	install -Dt "${pkgdir}"/usr/share/fish/vendor_completions.d -m0644 contrib/osc.fish
}
openSUSE Build Service is sponsored by