pkgname=texinfo
pkgver=7.2
pkgdesc='GNU documentation system for on-line information and printed output'
arch=(x86_64)
homepage='https://www.gnu.org/software/texinfo/'
license=(GPL3)
sources=("${pkgname}-${pkgver}.tar.xz")
urls=("https://ftp.gnu.org/gnu/${pkgname}/${sources[0]}")
md5sums=("11939a7624572814912a18e76c8d8972")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  sed 's/! $output_file eq/$output_file ne/' -i tp/Texinfo/Convert/*.pm
  cat > texinfo.HOOK << "EOF"
target=(/usr/share/info/*.info*)
triggers=(install remove)
operation() {
  echo -e "${GREEN_COLOR}>>>HOOK: update info cache${CLEAR_COLOR}"
  rm -fv /usr/share/info/dir
  for _info in /usr/share/info/*.info*; do
    /usr/bin/install-info $_info /usr/share/info/dir
  done
}
EOF
}

src_build() {
  ./configure --prefix=/usr
  make
}

src_check() {
  make check
}

src_install() {
  make DESTDIR="${pkgdir}" install
  leaf_install_hook texinfo.HOOK
}
