# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=gdbm
pkgver=1.24
# latest, versioned translation from https://translationproject.org/domain/gdbm.html
_translation_version=1.23.90
pkgrel=1
pkgdesc="GNU database library"
arch=(x86_64)
url="https://www.gnu.org/software/gdbm/gdbm.html"
license=(GPL-3.0-or-later)
depends=(
  glibc
  sh
)
makedepends=(
  git
  readline
)
provides=(
  libgdbm_compat.so
  libgdbm.so
)
source=(
  git+https://git.gnu.org.ua/gdbm.git?signed#tag=v$pkgver
  https://translationproject.org/PO-files/da/$pkgname-$_translation_version.da.po
  https://translationproject.org/PO-files/de/$pkgname-$_translation_version.de.po
  https://translationproject.org/PO-files/eo/$pkgname-$_translation_version.eo.po
  https://translationproject.org/PO-files/es/$pkgname-$_translation_version.es.po
  https://translationproject.org/PO-files/fi/$pkgname-$_translation_version.fi.po
  https://translationproject.org/PO-files/fr/$pkgname-$_translation_version.fr.po
  https://translationproject.org/PO-files/ja/$pkgname-$_translation_version.ja.po
  https://translationproject.org/PO-files/ka/$pkgname-$_translation_version.ka.po
  https://translationproject.org/PO-files/pl/$pkgname-$_translation_version.pl.po
  https://translationproject.org/PO-files/pt_BR/$pkgname-$_translation_version.pt_BR.po
  https://translationproject.org/PO-files/ro/$pkgname-$_translation_version.ro.po
  https://translationproject.org/PO-files/ru/$pkgname-$_translation_version.ru.po
  https://translationproject.org/PO-files/sr/$pkgname-$_translation_version.sr.po
  https://translationproject.org/PO-files/sv/$pkgname-$_translation_version.sv.po
  https://translationproject.org/PO-files/uk/$pkgname-$_translation_version.uk.po
  https://translationproject.org/PO-files/vi/$pkgname-$_translation_version.vi.po
)
sha512sums=('6763173ed38c1c61a85926d57f09f2664acf72315bf7ea4d4d038987c622cacf106dbc0fdd5a4b198ff8a96125eadcf93cdffbbe3f7ecc535e6f59579048f152'
            'e5c46a6cdcf9f8af4ea9de8ece93fb7b995ad9d62a0f1cb46386a0b5dc3b5d281812e9d900929cc9e1dd65bd78467a343d6539b750b43d10bda48974137bf540'
            '455e46f44b4b21e053b4a9f58a8c1e13b6da230cc950ad182938baf81662884127ebeaede3ee7507210af8aa4b8b7f92b167af78a030b9b0cca849df8a9722c6'
            '82fb3182e29d94c32e079693eb8d1bcf43ba853260fb11fd56a2ef5a9be30c4d9f7280e36a2222c42abca3ab1c863354c8ca258c0e09991e7f5cfb54615ddf6f'
            '45293bf77d6250e92f998c2b06661e87b5481c1105d3e407c486ec70573d277a7b086bfca49cf6a92783dc7a97f2128c3fa76cfce7321ae32b4018f6dc85ff49'
            '91c8e2d0332595c98d49cf61c915119a4bed8a60dc4aaa29af06d58e16c04d6e7d20f90d5a8bc42c762d49dde5e0f9b63171f87f852c840f6ba152411cc8aa34'
            '4612d452a4bd46c3337966ead5fcab58a2ac370a1f6132b724eff97732ea212a2ff5be8bf49402e19d7e1597ecbcfb384790b483cb87bd0275cb21cce482e382'
            '3bf01bdd8eee74181e0fcfc18fcdd1b6a7e1ff88e83a7057d814858b12b497041046058f173d83882b2100d452f750c1f859ea2f6ca1bd51a6d11840a9666d5d'
            '0071407680fd095e1d7b13c451e1013e0ddaa2154a59cf814da7d6bacc18ce7f9ab750d5d92b5fd9d34ce469ade0b35b00864bb63dd3fe99c7c760b98c00e588'
            '69cfcda9bca6e46e2fa1946b6bfa573e80f8f118d87c9bd5058fa89d6a65be4502751d71b452731217649a08829b7fef11822ff47659f022ad7847b3b473bbcb'
            'e1d6be1cb8dd06d295eebdc9bb4628163fae9d34f48b935957322cee8ea0513979130522957b320b3b76d53cfbafc329d3d9f4561b651b40e8d92181a306aed8'
            '0b6ca1e943db0ac736981d25a83a5800e183cf232db447d8a9ae2268c85fd3224f875251084aa48dbafdc8439b5f048694f1fb7f9f466ef9c7a35d98b2c186c4'
            '6c8a1f4d68177f89553fc9a7d28b6d5177491bf755cb82210ea2c4c1417d86daf611f9963229768d7d71fbd4b837a655e07df2557cded0659206bbd49a3c6a7a'
            '0081120a95238c47884b5ae25398cdb43fb18faa7b8e3417673de3aaac74871814ffbf5a878726cd4bf4805f8a33404054f0fe068ce2b4221e38d173f61255ee'
            '6168015b9e711ec04fe07cf2e70088aaa1907723d96aefaea98918220baf6bc3dba5b2ef741b8cfa1bd94172e24d38d488b97e64cce6fdea2307597dd189ce22'
            '7e9cb0304cb9ed4c16ecdffab5c7999f371d459510ce17762ab9fb05f78b138fababe46083a8ca2f8a941e23ca58dcd1e4914fc4bb285cb5ab603ca674a22c4e'
            'af607dd5cc3423996eb92ede2392115e7b92cc26683825ca522e133fa2a7a2f66fa68f961ca0639dca91ae4a899c4e86eb4cc1cfb3a68aefcb1d0e2b968fb1e1')
b2sums=('ee6002080a96cbea157ca127b96ad583609f1dca65e911ae9ab3624bc0b47f12cc4081da977ddc9061d0bc05f09ba69d4dd40389aff7d02f104a1a2df3542e88'
        '1785df235ef1a70fb2097117243dafed1e6b211ae675d3a36c391627d7a26eab71ac5e24300edcf32c9c43f9d172bbe54013320f090f912036f7137be5263ad5'
        '3ba3526ee677023fab4cb493a80f9cde2cfa92a9ea19b5896f01664647b77d389c6796dfa5d894a358951c1a77353d070ec74c61eaabb2b7d5fb81354cb07535'
        '181fbe787fb00e83e25806ad9afe28615faa9cae520f338f35a677918005cb7579802eb68fd6c331afb322e1ab3f1b354c4f2fdda23fe5ddc103d0065b381b38'
        'f1c258d4804fc975fe3f8428b4185f3c607e0e0f758ada5454a03e83b62a4222393f56e8ec4485afebd3ed8ce0d9232405b34d8d6fe84dc9cdb0534a94e178a8'
        '94c1310e01f4588e452cd2e19f6f08d3e3fa199964d4e0e00be91052ac72e7b16d5588efc46aa00731bfdaf97f6b3ed28cfb5a293201b965812ddfde518b6411'
        '2637e89726ecf7095a1e513223191e3410379993dd03d537f37a5e28bb99f77818e388c238ccf4f0d091277cdb00a5f507f2aec759a3cdbd8b2320839333ec97'
        '5eba65e9acdf184a6d3d5acd7d964707b241390efa426dc4cd00d09a1bf439b59a129dcbd89cadeedfad48c70638e6ec6f77aebe8033b2ec777a351fd7de96e4'
        '1bbd4bec6c7aeaf41d56c76ac3a9797b6012305dbdcf1bbd7747d0e69cf65f35d9fca93c2d24a030cb5541a943ec55ffebd432914fcd4d979e83bae27919c52f'
        '3ceda4d58a46887849fd32810578e8b27d3a0955e4364eac15dfbc6820b39b266076f0ddb3d1b9db5c5951814a716136ad6bf5f43c8a885e5b3138f2f9b297a6'
        'a11e727fcc75e7105af48c41efb50323b9776bed56a7eb7c58aeaca42940e0605b60f63f29838ddacfa55ceeb99c521349c88f3689cf931a45d3246a82d49108'
        'a4de0606e32d73ec66cabd05ebc0e5266fc9f33893b14878a79541ed0836947e74596f4570c78d7b2ed45ec159976267ecc332bd541b5ae1ed77b8a5fb17bca6'
        '289fc5bffc6557889ec0f8951c97369108a79bf887d00d643688546ccca5fef87151ef0df62347c859fbb2acc31009482061264f78b204757c1f554756f56112'
        '95a792c151a6ebae5381addc6d2cf2b4ed49a5e57419967bbd1199b01289ebf81f4e30c485b2691a95d703b01157e9005c25208f0e3a6d3394a25d7482832bae'
        'e960e620d789af38282c586bc2e60f60cb4f6ab47631c4c82314654d3486c6a5167256e3f346f3251348c4f20fa5530508e14eadb6d1d4cf43829d968dcb4633'
        '26014f9c3968e6562b9c4faf608db5af452b75ded76fd6323f2ad84a2808871c9000ad6a44ffdaf3f2499162ca0ea25b37dd0fdd2c9e8f88f1830f7148e7f7a5'
        '4feaf9371c77136cd67dc15a2deafefbb7b46019b554aa6815a763efe70212489c55050da2264d59df980de3a33abeceabc90ad4cb7068db84005df988e4c4b8')

prepare() {
  local po_file new_po

  # prepare translations
  touch $pkgname/po/LINGUAS
  for po_file in *.po; do
    new_po="${po_file/$pkgname-$_translation_version./}"
    cp -v $po_file $pkgname/po/$new_po
    printf "%s\n" ${new_po/.po/} >> $pkgname/po/LINGUAS
  done

  cd $pkgname
  autoreconf -fiv
}

build() {
  local configure_options=(
    --prefix=/usr
    --enable-libgdbm-compat
  )

  cd $pkgname
  ./configure "${configure_options[@]}"
  make
}

check() {
  make check -C $pkgname
}

package() {
  depends+=(
    readline libreadline.so
  )

  make DESTDIR="$pkgdir" install -C $pkgname
  install -vDm 644 $pkgname/{NOTE-WARNING,AUTHORS,NEWS,README} -t "$pkgdir/usr/share/doc/$pkgname"
}
