

pkgname=fish
pkgver=3.7.1
pkgrel=5
epoch=
pkgdesc='Smart and user friendly shell intended mostly for interactive use'
arch=('i686' 'x86_64')
url="https://fishshell.com/"
msys2_repository_url="https://github.com/fish-shell/fish-shell"
msys2_references=(
  "cpe: cpe:/a:fishshell:fish"
)
license=('spdx:GPL-2.0-only')
depends=('gcc-libs' 'gettext' 'libpcre2_16' 'man-db' 'ncurses')
makedepends=('gcc' 'gettext-devel' 'intltool' 'ncurses-devel' 'pcre2-devel' 'cmake')
optdepends=('python: for manual page completion parser and web configuration tool')
install=fish.install
backup=('etc/fish/config.fish' 'etc/fish/msys2.fish' 'etc/fish/perlbin.fish')
source=("https://github.com/fish-shell/fish-shell/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.xz"{,.asc}
        config.fish
        msys2.fish
        msystem.fish
        perlbin.fish
        0001-cmake-4-backport.patch)
sha256sums=('614c9f5643cd0799df391395fa6bbc3649427bb839722ce3b114d3bbc1a3b250'
            'SKIP'
            '983c3273e0249957ed6c40785e005739da30f31d4f029383f257f9990d38811a'
            '8bb0d28df47b66e6785f7db00a2c4316bc15960e67bdec0daca7f811f5bf3895'
            '71c6990b39caf5d50c10f10074283adfc6a36aafff30fd54f7eb451d4e007496'
            'b136a9fa94abf53e302f7a1cc28def03b58dd2326990c5f02ceb4988341a5ac6'
            '5b6168131d30cf0f4a5b39b1e8728eb882414586792101e571879d92efcaac5c')
validpgpkeys=('003837986104878835FA516D7A67D962D88A709A') # David Adam <zanchey@gmail.com>

prepare() {
  cd "${pkgname}-${pkgver}"

  # https://github.com/fish-shell/fish-shell/issues/11116
  patch -p1 < "${srcdir}/0001-cmake-4-backport.patch"
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  export CXXFLAGS+=" ${CPPFLAGS}"
  cmake \
    -B build \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_SYSCONFDIR=/etc \
    -DCMAKE_BUILD_TYPE=None \
    -Wno-dev

  cmake --build build
}

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

  DESTDIR="${pkgdir}" cmake --install .

  install -D -m644 "${srcdir}/config.fish" "${pkgdir}/etc/fish/config.fish"
  install -D -m644 "${srcdir}/msys2.fish" "${pkgdir}/etc/fish/msys2.fish"
  install -D -m644 "${srcdir}/msystem.fish" "${pkgdir}/etc/fish/msystem.fish"
  install -D -m644 "${srcdir}/perlbin.fish" "${pkgdir}/etc/fish/perlbin.fish"
}
