Skip to content

Commit

Permalink
fix(neovim): add in update-aternatives support (#6168)
Browse files Browse the repository at this point in the history
Co-authored-by: oklopfer <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 10, 2024
1 parent 5f057e2 commit 8f4e32b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/neovim/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pkgbase = neovim
pkgver = 0.10.0
pkgrel = 2
pkgdesc = Neovim is a vim fork maintained by the community
url = https://neovim.io/
makedepends = gettext
Expand All @@ -10,7 +11,12 @@ pkgbase = neovim
makedepends = cmake
makedepends = g++
makedepends = pkg-config
conflicts = neovim
conflicts = neovim-git
conflicts = nvim
conflicts = neovim-runtime
replaces = neovim
replaces = neovim-git
replaces = nvim
replaces = neovim-runtime
maintainer = Elsie19 <[email protected]>
Expand Down
63 changes: 60 additions & 3 deletions packages/neovim/neovim.pacscript
Original file line number Diff line number Diff line change
@@ -1,23 +1,80 @@
pkgname="neovim"
pkgver="0.10.0"
pkgrel="2"
source=("https://github.com/neovim/neovim/archive/refs/tags/v${pkgver}.tar.gz")
url='https://neovim.io/'
makedepends=("gettext" "libtool" "libtool-bin" "autoconf" "automake" "cmake" "g++" "pkg-config")
replaces=("neovim" "nvim" "neovim-runtime")
replaces=("neovim" "neovim-git" "nvim" "neovim-runtime")
conflicts=("${replaces[@]}")
pkgdesc="Neovim is a vim fork maintained by the community"
sha256sums=("372ea2584b0ea2a5a765844d95206bda9e4a57eaa1a2412a9a0726bab750f828")
maintainer=("Elsie19 <[email protected]>")
external_connection=true
repology=("project: ${pkgname}")

build() {
cd "${_archive}"
cd "${pkgname}-${pkgver}"
make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX=/usr -j"${NCPU}"
}

package() {
cd "${_archive}"
cd "${pkgname}-${pkgver}"
make install DESTDIR="${pkgdir}"
install -Dm644 "LICENSE.txt" -t "${pkgdir}/usr/share/licenses/${pkgname}"
install -Dm644 "README.md" -t "${pkgdir}/usr/share/doc/${pkgname}"
install -Dm755 /dev/stdin "${pkgdir}/usr/libexec/${pkgname}/ex" << 'EOF'
#!/bin/sh
exec /usr/bin/nvim -e "$@"
EOF
install -Dm755 /dev/stdin "${pkgdir}/usr/libexec/${pkgname}/rview" << 'EOF'
#!/bin/sh
exec /usr/bin/nvim -RZ "$@"
EOF
install -Dm755 /dev/stdin "${pkgdir}/usr/libexec/${pkgname}/rvim" << 'EOF'
#!/bin/sh
exec /usr/bin/nvim -Z "$@"
EOF
install -Dm755 /dev/stdin "${pkgdir}/usr/libexec/${pkgname}/view" << 'EOF'
#!/bin/sh
exec /usr/bin/nvim -R "$@"
EOF
install -Dm755 /dev/stdin "${pkgdir}/usr/libexec/${pkgname}/vimdiff" << 'EOF'
#!/bin/sh
exec /usr/bin/nvim -d "$@"
EOF
}

post_install() {
update-alternatives --install /usr/bin/editor editor /usr/bin/nvim 30 \
--slave /usr/share/man/man1/editor.1.gz editor.1.gz \
/usr/share/man/man1/nvim.1.gz
update-alternatives --install /usr/bin/ex ex "/usr/libexec/${pkgname}/ex" 30
update-alternatives --install /usr/bin/rvim rvim "/usr/libexec/${pkgname}/rvim" 30
update-alternatives --install /usr/bin/rview rview "/usr/libexec/${pkgname}/rview" 30
update-alternatives --install /usr/bin/vi vi /usr/bin/nvim 30
update-alternatives --install /usr/bin/vim vim /usr/bin/nvim 30
update-alternatives --install /usr/bin/view view "/usr/libexec/${pkgname}/view" 30
update-alternatives --install /usr/bin/vimdiff vimdiff "/usr/libexec/${pkgname}/vimdiff" 30
}

pre_remove() {
case "$1" in
remove | deconfigure)
update-alternatives --remove editor /usr/bin/nvim
update-alternatives --remove ex "/usr/libexec/${pkgname}/ex"
update-alternatives --remove rvim "/usr/libexec/${pkgname}/rvim"
update-alternatives --remove rview "/usr/libexec/${pkgname}/rview"
update-alternatives --remove vi /usr/bin/nvim
update-alternatives --remove vim /usr/bin/nvim
update-alternatives --remove view "/usr/libexec/${pkgname}/view"
update-alternatives --remove vimdiff "/usr/libexec/${pkgname}/vimdiff"
;;

upgrade | failed-upgrade) ;;

*)
echo "prerm called with unknown argument '$1'" >&2
exit 0
;;
esac
}

0 comments on commit 8f4e32b

Please sign in to comment.