pkgname=xdg-utils
pkgver=1.2.1
pkgdesc="Portland utils for cross-platform/cross-toolkit/cross-desktop interoperability"
homepage="https://www.freedesktop.org/wiki/Software/xdg-utils/"
license=("MIT")
depends=(
  dev-util/desktop-file-utils
  x11-misc/shared-mime-info
  dbus
)
_patches=("xdg-utils-1.2.1-qtpaths.patch"
  "xdg-utils-1.2.1-xdg-mime-default.patch"
)
_patch_sums=("9a7942e38ecad2bdbebdd558557647648c21bfec132f72bb7c3f2ae737345fb1e552e7fa6a118223da663ae4e3ac4d9776ec3f46f031ad2499141ab83db5c99a"
  "0e57d5cf9fa9969738c1d836c4c3b644cc6e1e80cd7486ec5ca0fdb2c86f0f5e3988c4790faf1838ad09946803347a96c0fd47373c5971c691c20d4913845ad1"
)
sources=("${pkgname}-${pkgver}.tar.bz2"
  "${_patches[@]}"
)
urls=("https://gitlab.freedesktop.org/xdg/xdg-utils/-/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.bz2"
  "${_patches[@]}"
)
sha512sums=("d5436449fec2f4db952239ee910bfda203955c8df8cb92379f182dc36f9c82b6ceb092ccbebfd02ed00eb7ef5f6895ef745baca67906ae7490e425db27b1dbfc"
  "${_patch_sums[@]}"
)

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  for _patch in ${_patches[@]}; do
    patch -p1 -i ${filedir}/${_patch}
  done
  autoreconf -fiv
}

src_build() {
  ./configure --prefix=/usr --mandir=/usr/share/man
  make -C scripts scripts-clean

  make
}

src_install() {
  make DESTDIR="$pkgdir" install

  echo XDG_DATA_DIRS=\"/usr/local/share\" > 30xdg-data-local
  echo 'COLON_SEPARATED="XDG_DATA_DIRS XDG_CONFIG_DIRS"' >> 30xdg-data-local
  install -vDm644 30xdg-data-local -t "${pkgdir}"/etc/env.d
  echo XDG_DATA_DIRS=\"/usr/share\" > 90xdg-data-base
  echo XDG_CONFIG_DIRS=\"/etc/xdg\" >> 90xdg-data-base
  install -vDm644 90xdg-data-base -t "${pkgdir}"/etc/env.d
}

# vim:ft=sh syn=sh et sw=2:
