# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Tim S. <stahta01@gmail.com>

_realname=kicad-doc
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}-ca"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-de"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-en"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-es"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-fr"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-id"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-it"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-ja"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-pl"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-ru"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-zh")
# https://gitlab.com/kicad/services/kicad-doc/-/jobs/11909427490/artifacts/browse/archive/
_job_id='11909427490' # this is needed to change for new version
pkgver=9.0.6
pkgrel=1
pkgdesc="Documentation for KiCad (mingw-w64)"
arch=(any)
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: kicad'
)
url="https://www.kicad.org/"
license=("spdx:GPL-3.0-or-later OR CC-BY-3.0")
optdepends=("${MINGW_PACKAGE_PREFIX}-kicad-meta"
            "${MINGW_PACKAGE_PREFIX}-kicad")

# Use the more current build artifact from the release tag instead:
# https://gitlab.com/kicad/services/kicad-doc/-/artifacts
source=("${_realname}-${pkgver}.tar.gz::https://gitlab.com/kicad/services/kicad-doc/-/jobs/${_job_id}/artifacts/raw/archive/kicad-doc-unknown.tar.gz")
sha256sums=('ab804200ac57042b3ae64d2727b8a0d3843013e8c3b4b5fef343604197ab37ab')

build_lang() {
  cd "${srcdir}/kicad-doc-unknown/share/doc/kicad/help"
  mkdir -p "${pkgdir}${MINGW_PREFIX}/share/doc/kicad/help/"
  cp -R ${langid} "${pkgdir}${MINGW_PREFIX}/share/doc/kicad/help/"
}

for _n in ${pkgname[@]}; do
  eval "package_${_n}() {
    langid="${_n#${MINGW_PACKAGE_PREFIX}-${_realname}-}" build_lang
  }"
done
