diff --git a/mingw-w64-repgrep/PKGBUILD b/mingw-w64-repgrep/PKGBUILD new file mode 100644 index 0000000000..e2004183a7 --- /dev/null +++ b/mingw-w64-repgrep/PKGBUILD @@ -0,0 +1,70 @@ +# Maintainer: Maksim Bondarenkov + +_realname=repgrep +pkgbase=mingw-w64-${_realname} +pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" +pkgver=0.15.0 +pkgrel=1 +pkgdesc="An interactive replacer for ripgrep that makes it easy to find and replace across files on the command line. (mingw-w64)" +arch=('any') +mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64') +url='https://github.com/acheronfail/repgrep/' +license=('spdx:Apache-2.0 OR MIT OR Unlicense') +depends=("${MINGW_PACKAGE_PREFIX}-ripgrep") +makedepends=("${MINGW_PACKAGE_PREFIX}-rust" + "${MINGW_PACKAGE_PREFIX}-asciidoctor") +options=('!strip' '!lto') +source=("https://github.com/acheronfail/repgrep/archive/${pkgver}/${_realname}-${pkgver}.tar.gz" + "asciidoctor-use-full-path.patch") +sha256sums=('24e8b317cda9fb7df6fa7e596708145ca4052380d680fe712cc5871d25b7d485' + '045bcd49c03ad51c7cb6dbbb8a120daf9e1a63acf8a85ececf4cd671d2031c07') + +prepare() { + cd "${srcdir}/${_realname}-${pkgver}" + + local _target="${CARCH}-pc-windows-gnu" + if [[ $MINGW_PACKAGE_PREFIX == *-clang-aarch64 ]]; then + _target="${CARCH}-pc-windows-gnullvm" + fi + cargo fetch --locked --target "${_target}" + + patch -Np1 -i "${srcdir}/asciidoctor-use-full-path.patch" + + local _asciidoctor=$(cygpath -am $(where asciidoctor | grep "asciidoctor\$")) + sed -i "s|\"ASCIIDOCTOR\"|\"${_asciidoctor}\"|g" build.rs +} + +build() { + cd "${srcdir}/${_realname}-${pkgver}" + + WINAPI_NO_BUNDLED_LIBRARIES=1 \ + cargo build --release --frozen +} + +check() { + cd "${srcdir}/${_realname}-${pkgver}" + + WINAPI_NO_BUNDLED_LIBRARIES=1 \ + cargo test --release --frozen +} + +package() { + cd "${srcdir}/${_realname}-${pkgver}" + + install -Dm755 target/release/rgr "${pkgdir}${MINGW_PREFIX}/bin/rgr" + + out_dir=$(find target -name repgrep-stamp -print0 | xargs -0 ls -t | head -n1 | xargs dirname) + install -Dm644 "${out_dir}/rgr.1" -t "${pkgdir}${MINGW_PREFIX}/share/man/man1" + + # upstream just reuse rg completions + # see https://github.com/acheronfail/repgrep/commit/fae1ed5fe9a464fbc7367e441ccc0a2999a72e70 + echo 'complete -F _rg rgr' | + install -Dm644 /dev/stdin "${pkgdir}${MINGW_PREFIX}/share/bash-completion/completions/rgr" + echo 'compdef $_comps[rg] rgr' | + install -Dm644 /dev/stdin "${pkgdir}${MINGW_PREFIX}/share/zsh/site-functions/_rgr" + rg --generate complete-fish | + sed -e 's/-c rg/-c rgr/' | + install -Dm644 /dev/stdin "${pkgdir}${MINGW_PREFIX}/share/fish/vendor_completions.d/rgr.fish" + + install -Dm644 LICENSE-{APACHE,MIT,UNLICENSE} -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/" +} diff --git a/mingw-w64-repgrep/asciidoctor-use-full-path.patch b/mingw-w64-repgrep/asciidoctor-use-full-path.patch new file mode 100644 index 0000000000..ed75311bb9 --- /dev/null +++ b/mingw-w64-repgrep/asciidoctor-use-full-path.patch @@ -0,0 +1,24 @@ +somehow `build.rs` script can't invoke `asciidoctor`, so we use full path of it +(placeholder "ASCIIDOCTOR"). as Windows doesn't support running sh executables natively, invoke sh +with full path of `asciidoctor` +--- a/build.rs ++++ b/build.rs +@@ -5,7 +5,7 @@ use std::{env, fs, io}; + fn generate_manpage>(outdir: P) -> io::Result<()> { + // If asciidoctor isn't installed, don't do anything. + // This is for platforms where it's unsupported. +- if let Err(err) = Command::new("asciidoctor").output() { ++ if let Err(err) = Command::new("sh").arg("ASCIIDOCTOR").output() { + eprintln!("Could not run 'asciidoctor' binary, skipping man page generation."); + eprintln!("Error from running 'asciidoctor': {}", err); + return Ok(()); +@@ -15,7 +15,8 @@ fn generate_manpage>(outdir: P) -> io::Result<()> { + let cwd = env::current_dir()?; + let template_path = cwd.join("doc").join("rgr.1.template"); + +- let result = Command::new("asciidoctor") ++ let result = Command::new("sh") ++ .arg("ASCIIDOCTOR") + .arg("--doctype") + .arg("manpage") + .arg("--backend")