# Copyright 2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: vim.eclass # @MAINTAINER: # Thomas Bracht Laumann Jespersen # $ECHANGELOG_USER # @AUTHOR: Thomas Bracht Laumann Jespersen # $ECHANGELOG_USER # @SUPPORTED_EAPIS: 8 # @BLURB: Provides common set of functionality for vim-core, vim and gvim # @DESCRIPTION: # Provides common functionality for app-editors/{vim,gvim,vim-core} packages. # They all share the same setup, patching and post install/remove phases (more # or less), the major differences are the configuration and installation phases. case ${PN} in vim-core|vim|gvim) ;; *) die "This eclass is only for vim-core, vim and gvim" ;; esac case ${EAPI} in 8) ;; *) die "${ECLASS}: EAPI ${EAPI} unsupported." ;; esac if [[ ! ${_VIM_ECLASS} ]]; then _VIM_ECLASS=1 # Common inherits inherit vim-doc flag-o-matic bash-completion-r1 xdg-utils # @ECLASS_VARIABLE: VIM_VERSION # @PRE_INHERIT # @DEFAULT_UNSET # @DESCRIPTION: # The "MAJOR.MINOR" version of vim, like "9.0" (not actually used by the eclass, # but is used in the install phase). # @ECLASS_VARIABLE: VIM_PATCH_TAG # @PRE_INHERIT # @DEFAULT_UNSET # @DESCRIPTION: # The tag name of the patchset to fetch in a snapshot from # https://gitweb.gentoo.org/proj/vim-patches if [[ ${PV} == 9999* ]] ; then inherit git-r3 EGIT_REPO_URI="https://github.com/vim/vim.git" EGIT_CHECKOUT_DIR=${WORKDIR}/vim-${PV} else SRC_URI="https://github.com/vim/vim/archive/v${PV}.tar.gz -> ${P}.tar.gz" if [[ ${VIM_PATCH_TAG} ]]; then SRC_URI+=" https://gitweb.gentoo.org/proj/vim-patches.git/snapshot/vim-patches-${VIM_PATCH_TAG}.tar.gz" fi fi S="${WORKDIR}/vim-${PV}" # @FUNCTION: vim_pkg_setup # @DESCRIPTION: # Unsets LANG and LC_ALL, exports LC_COLLATE="C" vim_pkg_setup() { # people with broken alphabets run into trouble. bug #82186. unset LANG LC_ALL export LC_COLLATE="C" } # @FUNCTION: vim_src_prepare # @DESCRIPTION: # Applies patches and performs other minor adjustments to the source code vim_src_prepare() { if [[ ${PV} != 9999* ]] && [[ ${VIM_PATCH_TAG} ]] ; then # Gentoo patches to fix runtime issues, cross-compile errors, etc eapply "${WORKDIR}"/vim-patches-${VIM_PATCH_TAG} fi # Fixup a script to use awk instead of nawk sed -i \ -e '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' \ "${S}"/runtime/tools/mve.awk || die "sed failed" # See bug #77841. We remove this file after the tarball extraction. rm -v "${S}"/runtime/tools/vimspell.sh || die "rm failed" # Read vimrc and gvimrc from /etc/vim echo '#define SYS_VIMRC_FILE "'${EPREFIX}'/etc/vim/vimrc"' >> "${S}"/src/feature.h || die echo '#define SYS_GVIMRC_FILE "'${EPREFIX}'/etc/vim/gvimrc"' >> "${S}"/src/feature.h || die # Use exuberant ctags which installs as /usr/bin/exuberant-ctags. # Hopefully this pattern won't break for a while at least. # This fixes bug #29398 (27 Sep 2003 agriffis) sed -i 's/\> "$c" || die "echo failed" done # Try to avoid sandbox problems. Bug #114475. if [[ -d "${S}"/src/po ]]; then sed -i -e \ '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \ "${S}"/src/po/Makefile || die "sed failed" fi cp -v "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk || die "cp failed" # Bug #378107 - Build properly with >=perl-core/ExtUtils-ParseXS-3.20.0 sed -i -e \ "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:" \ "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed' # Fix bug #76331: -O3 causes problems, use -O2 instead. We'll do this for # everyone since previous flag filtering bugs have turned out to affect # multiple archs... replace-flags -O3 -O2 # Fix bug #18245: Prevent "make" from the following chain: # (1) Notice configure.ac is newer than auto/configure # (2) Rebuild auto/configure # (3) Notice auto/configure is newer than auto/config.mk # (4) Run ./configure (with wrong args) to remake auto/config.mk sed -i 's# auto/config\.mk:#:#' src/Makefile || die "Makefile sed failed" # Remove src/auto/configure file. rm -v src/auto/configure || die "rm configure failed" eapply_user } # Not overriding a phase function! This is just common src_configure steps for # vim-core, vim and gvim. vim_common_src_configure() { # Fix bug #37354: Disallow -funroll-all-loops on amd64 # Bug #57859 suggests that we want to do this for all archs filter-flags -funroll-all-loops # Fix bug 76331: -O3 causes problems, use -O2 instead. We'll do this for # everyone since previous flag filtering bugs have turned out to affect # multiple archs... replace-flags -O3 -O2 emake -j1 -C src autoconf # This should fix a sandbox violation (see bug #24447). The hvc # things are for ppc64, see bug #86433. for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc*; do [[ -e "${file}" ]] && addwrite "${file}" done } vim_src_compile() { # The following allows emake to be used emake -j1 -C src auto/osdef.h objects if [[ ${PN} == "vim-core" ]]; then emake tools else emake fi } # Common function for pkg_postinst and pkg_postrm vim_common_pkg_postinst_postrm() { # update documentation tags (from vim-doc.eclass) update_vim_helptags # Call eselect vi update with --if-unset to respect user's choice (bug # #187449) [[ ${PN} != "vim-core" ]] && eselect vi update --if-unset # update fdo mime stuff, bug #78394 [[ ${PN} == "gvim" ]] && xdg_desktop_database_update # update icon cache xdg_icon_cache_update } vim_pkg_postinst() { vim_common_pkg_postinst_postrm } vim_pkg_postrm() { vim_common_pkg_postinst_postrm } fi EXPORT_FUNCTIONS pkg_setup src_prepare src_compile pkg_postinst pkg_postrm