# Maintainer: Jeremy Drake <github@jdrake.com>

pkgname='etc-update'
pkgver=3.0.82.2
pkgrel=1
pkgdesc='CLI to interactively merge .pacnew configuration files'
arch=('any')
url='https://wiki.gentoo.org/wiki/Handbook:X86/Portage/Tools#etc-update'
msys2_repository_url='https://github.com/gentoo/portage'
msys2_references=(
  'anitya: 191471'
  'archlinux: etc-update'
  'cpe: cpe:/a:gentoo:portage'
  'gentoo: sys-apps/portage'
)
license=('spdx:GPL-2.0-or-later')
depends=(
  'bash'
  'diffutils'
)
optdepends=(
  'dialog: for the menu mode (not automode)'
)
backup=('etc/etc-update.conf')
source=("https://github.com/gentoo/portage/archive/portage-${pkgver}.tar.gz")
sha256sums=('869ca972058b9e8dcda49adbb689e64d8a7f560f4f8151339946aa28637e1a8d')
noextract=("portage-${pkgver}.tar.gz")

prepare() {
  cd "${srcdir}"

  plain "Extracting portage-${pkgver}.tar.gz due to symlink(s) without pre-existing target(s)"

  rm -rf "portage-portage-${pkgver}"
  tar -xzf "portage-${pkgver}.tar.gz" || true
}

package() {
  cd "${srcdir}/portage-portage-${pkgver}"

  install -Dm755 -t "${pkgdir}/usr/bin" "bin/${pkgname}"
  install -Dm644 -t "${pkgdir}/etc" "cnf/${pkgname}.conf"
}
