# Maintainer: Developer <dev@opalos.org>

pkgname=devtools
epoch=1
pkgver=%version%
pkgrel=%release%
pkgdesc='Tools for Tuxcore package maintainers'
arch=('any')
license=('GPL-3.0-or-later')
url='https://gitlab.archlinux.org/archlinux/devtools'
depends=(
  archiso
  awk
  bash
  binutils
  coreutils
  curl
  diffutils
  fakeroot
  findutils
  grep
  jq
  openssh
  parallel
  rsync
  sed
  util-linux

  breezy
  git
  mercurial
  subversion
)
makedepends=(
  asciidoc
  shellcheck
  asciidoctor
)
optdepends=(
  'btrfs-progs: btrfs support'
  'bat: pretty printing for pkgctl search'
  'nvchecker: pkgctl version subcommand'
  'pacman-contrib: support for the --update-checksums option'
)
replaces=(devtools-git-poc)
source=(https://gitlab.archlinux.org/archlinux/devtools/-/releases/v${pkgver}/downloads/devtools-${pkgver}.tar.gz)

sha256sums=('SKIP')
b2sums=('SKIP')

build() {
  cd ${pkgname}-${pkgver}
    grep -rl PACMAN "$srcdir" | xargs sed -i 's/PACMAN/TPKG/g'
    grep -rl pacman . | xargs sed -i 's/pacman/tpkg/g'
    echo "GREP DONE!"
    find . -mindepth 1 -maxdepth 1 -name "*pacman*" -exec bash -c ' mv $0 ${0/\pacman/tpkg}' {} \;
    find . -mindepth 2 -maxdepth 2 -name "*pacman*" -exec bash -c ' mv $0 ${0/\pacman/tpkg}' {} \;
    find . -mindepth 3 -maxdepth 3 -name "*pacman*" -exec bash -c ' mv $0 ${0/\pacman/tpkg}' {} \;
    find . -mindepth 4 -maxdepth 4 -name "*pacman*" -exec bash -c ' mv $0 ${0/\pacman/tpkg}' {} \;
    find . -mindepth 5 -maxdepth 5 -name "*pacman*" -exec bash -c ' mv $0 ${0/\pacman/tpkg}' {} \;

    find . -mindepth 1 -maxdepth 1 -name "*PACMAN*" -exec bash -c ' mv $0 ${0/\PACMAN/TPKG}' {} \;
    find . -mindepth 2 -maxdepth 2 -name "*PACMAN*" -exec bash -c ' mv $0 ${0/\PACMAN/TPKG}' {} \;
    find . -mindepth 3 -maxdepth 3 -name "*PACMAN*" -exec bash -c ' mv $0 ${0/\PACMAN/TPKG}' {} \;
    find . -mindepth 4 -maxdepth 4 -name "*PACMAN*" -exec bash -c ' mv $0 ${0/\PACMAN/TPKG}' {} \;
    find . -mindepth 5 -maxdepth 5 -name "*PACMAN*" -exec bash -c ' mv $0 ${0/\PACMAN/TPKG}' {} \;

  make BUILDTOOLVER="${epoch}:${pkgver}-${pkgrel}-${arch}" PREFIX=/usr
}

package() {
  cd ${pkgname}-${pkgver}
  make PREFIX=/usr DESTDIR="${pkgdir}" install
}

# vim: ts=2 sw=2 et:
