### this file is sourced not run
# vim: ft=sh:

# This recipe can only work for version-tagged github releases.
# Interim commits (master.zip) are excluded.
# Tag label format: x.y.z; append -<hash> or -RCn for temporary tags.
# Files image/* are excluded except for *".pub."* and *"-${fnrversion}-"*.

fnrversion=2.2.0_7dc3aa7 # unofficial release
fnrversion=4.0.2 # official release
PKGVER=$fnrversion
PKGBUILD=1
PKGARCH=noarch

LOCALNAME=findnrun REPONAME=find-n-run
TARBALL=${LOCALNAME}-${fnrversion}.tar.gz
MD5SUM=45d9f6673d4c5139d9cd60446f63d306
SRC_URL=https://github.com/step-/find-n-run/archive/${fnrversion}.tar.gz

SLACKDESC='findnrun: findnrun '${fnrversion}' (GUI search utility)
findnrun:  
findnrun: Findnrun is a gtkdialog-based desktop application starter.
findnrun: With plugins it can search and use other data types.
findnrun: 
findnrun: 
findnrun: 
findnrun: 
findnrun: 
findnrun: 
findnrun: https://github.com/step-/find-n-run/ 
'
# http://software.jaos.org/git/slapt-get/plain/FAQ.html#slgFAQ19
SLACKREQ='gtkdialog >= 2013.514-x86_64-1
gawk >= 4.1.0-x86_64-1
yad'
# http://software.jaos.org/git/slapt-get/plain/FAQ.html#slgFAQ44
SLACKSUG='findnrun_nls = 4.0.2-noarch-1
mdview
exiftool'
# http://software.jaos.org/git/slapt-get/plain/FAQ.html#slgFAQ31
SLACKCON=

### default pkg_prepare

### build
pkg_build() {
  cd /tmp &&
  mv ${REPONAME}-${fnrversion} ${LOCALNAME}-${fnrversion} &&
  cd ${LOCALNAME}-${fnrversion} &&

  # Shrink down to base package.
  rm -rd .github/ README.md LICENSE \
    usr/share/doc/nls/ \
    usr/share/doc/findnrun/*.tar.gz usr/share/locale &&
  find usr/share/doc/findnrun/images -type f \
    \( \
      \! -name "*-${fnrversion%_RC*}-*" \
    -a \
      \! -name "*-${fnrversion%_[a-f0-9]*}-*" \
    -a \
      \! -name "*-2.0.0-*" \
    -a \
      \! -name "*-3.1.0-*" \
    -a \
      \! -name "*.pub.*" \
    \) -delete &&

  # Clean install chroot tree from development links/files.
  # Note: this may leave whiteout files behind, which would prevent
  # removing empty dirs. Later on pkg_package() takes care of that.
  find /usr \! -type d -name '*findnrun*' -delete &&
  find /usr -depth -type d -name '*findnrun*' -exec rm -rd '{}' \; &&

  # Install.
  cp -rp --parents usr / &&

  # Add meta info.
  pkg_build_slackdesc
}

# package, see Note above.
pkg_package() {
  #touch "$BUILD_DIR/keep"
  pkg_remove_whiteout usr &&
    pkg_remove_empty_dirs usr &&
    pkg_build_pet_file ${PKG} \
      "Category='Filesystem;find'" \
      "Dependencies='+busybox,+gawk,+gtkdialog,+mdview,+yad'"

}


