# Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/eclass/vim.eclass,v 1.65 2004/07/31 22:15:01 ciaranm Exp $ # Authors: # Ryan Phillips # Seemant Kulleen # Aron Griffis # Ciaran McCreesh inherit eutils vim-doc flag-o-matic ECLASS=vim INHERITED="$INHERITED $ECLASS" EXPORT_FUNCTIONS src_unpack IUSE="$IUSE selinux ncurses nls acl" if [ ${PN} != vim-core ]; then IUSE="$IUSE cscope gpm perl python ruby" DEPEND="$DEPEND cscope? ( dev-util/cscope ) gpm? ( >=sys-libs/gpm-1.19.3 ) perl? ( dev-lang/perl ) python? ( dev-lang/python ) selinux? ( sys-libs/libselinux ) acl? ( sys-apps/acl ) ruby? ( dev-lang/ruby )" RDEPEND="$RDEPEND cscope? ( dev-util/cscope ) gpm? ( >=sys-libs/gpm-1.19.3 ) perl? ( dev-lang/perl ) python? ( dev-lang/python ) selinux? ( sys-libs/libselinux ) acl? ( sys-apps/acl ) ruby? ( dev-lang/ruby )" if [ ${PN} = vim ] ; then IUSE="$IUSE vim-with-x minimal" DEPEND="$DEPEND vim-with-x? ( virtual/x11 )" RDEPEND="$RDEPEND vim-with-x? ( virtual/x11 )" elif [ ${PN} = gvim ] ; then IUSE="$IUSE gnome gtk gtk2 motif" fi fi HOMEPAGE="http://www.vim.org/" SLOT="0" LICENSE="vim" # Portage dependancy is for use_with/use_enable. # ctags dependancy allows help tags to be rebuilt properly, along # with detection of exuberant-ctags by configure. DEPEND="$DEPEND >=sys-apps/portage-2.0.45-r3 >=sys-apps/sed-4 sys-devel/autoconf ncurses? ( >=sys-libs/ncurses-5.2-r2 ) !ncurses? ( sys-libs/libtermcap-compat ) dev-util/ctags " RDEPEND="$RDEPEND ncurses? ( >=sys-libs/ncurses-5.2-r2 ) !ncurses? ( sys-libs/libtermcap-compat ) dev-util/ctags " apply_vim_patches() { local p cd ${S} || die "cd ${S} failed" # Scan the patches, applying them only to files that either # already exist or that will be created by the patch einfo "Filtering vim patches..." p=${WORKDIR}/${VIM_ORG_PATCHES%.tar*}.patch ls ${WORKDIR}/vimpatches | sort | \ xargs -i gzip -dc ${WORKDIR}/vimpatches/{} | awk ' /^Subject: Patch/ { if (patchnum) {printf "\n" >"/dev/stderr"} patchnum = $3 printf "%s:", patchnum >"/dev/stderr" } $1=="***" && $(NF-1)~/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/ { # First line of a patch; suppress printing firstlines = $0 next } $1=="---" && $(NF-1)~/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/ { # Second line of a patch; try to open the file to see # if it exists. thisfile = $2 if (!seen[thisfile] && (getline tryme < thisfile) == -1) { # Check if it will be created firstlines = firstlines "\n" $0 getline firstlines = firstlines "\n" $0 getline if ($0 != "*** 0 ****") { # Non-existent and not created, stop printing printing = 0 printf " (%s)", thisfile >"/dev/stderr" next } } # Print the previous lines and start printing print firstlines printing = 1 printf " %s", thisfile >"/dev/stderr" # Remember that we have seen this file seen[thisfile] = 1 } printing { print } END { if (patchnum) {printf "\n" >"/dev/stderr"} } ' > ${p} || die # For reasons yet unknown, epatch fails to apply this cleanly ebegin "Applying filtered vim patches..." TMPDIR=${T} patch -f -s -p0 < ${p} eend 0 } vim_src_unpack() { unpack ${A} # Apply any patches available from vim.org for this version [ -n "$VIM_ORG_PATCHES" ] && apply_vim_patches # Unpack the runtime snapshot if available (only for vim-core) if [ -n "$VIM_RUNTIME_SNAP" ]; then cd ${S} || die ebegin "Unpacking vim runtime snapshot" rm -rf runtime bzip2 -dc ${DISTDIR}/${VIM_RUNTIME_SNAP} | tar xf - assert # this will check both parts of the pipeline; eend would not eend 0 fi # Another set of patches borrowed from src rpm to fix syntax errors etc. cd ${S} || die "cd ${S} failed" EPATCH_SUFFIX="gz" EPATCH_FORCE="yes" \ epatch ${WORKDIR}/gentoo/patches-all/ # Fixup a script to use awk instead of nawk sed -i '1s|.*|#!/usr/bin/awk -f|' ${S}/runtime/tools/mve.awk \ || die "mve.awk sed failed" # Patch to build with ruby-1.8.0_pre5 and following sed -i 's/defout/stdout/g' ${S}/src/if_ruby.c # Read vimrc and gvimrc from /etc/vim echo '#define SYS_VIMRC_FILE "/etc/vim/vimrc"' >> ${S}/src/feature.h echo '#define SYS_GVIMRC_FILE "/etc/vim/gvimrc"' >> ${S}/src/feature.h # 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/\6.2a, etc. It also # seems to be completely unnecessary, so I'm removing it. # (24 Apr 2003 agriffis) # # fix problems with vim not finding its data files. #echo "VIMRUNTIME=/usr/share/vim/vim${VIM_VERSION/.}" > 40vim #insinto /etc/env.d #doins 40vim # default vimrc is installed by vim-core since it applies to # both vim and gvim insinto /etc/vim/ doins ${FILESDIR}/vimrc elif [ "${PN}" = "gvim" ]; then dobin src/gvim dosym gvim /usr/bin/gvimdiff dosym gvim /usr/bin/evim dosym gvim /usr/bin/eview insinto /etc/vim doins ${FILESDIR}/gvimrc else dobin src/vim ln -s vim ${D}/usr/bin/vimdiff && \ ln -s vim ${D}/usr/bin/rvim && \ ln -s vim ${D}/usr/bin/ex && \ ln -s vim ${D}/usr/bin/view && \ ln -s vim ${D}/usr/bin/rview \ || die "/usr/bin symlinks failed" fi } # Make convenience symlinks, hopefully without stepping on toes. Some # of these links are "owned" by the vim ebuild when it is installed, # but they might be good for gvim as well (see bug 45828) update_vim_symlinks() { local f syms="vi vimdiff rvim ex view rview" # Make or remove convenience symlink, vim -> gvim if [[ -f /usr/bin/gvim ]]; then ln -s gvim /usr/bin/vim 2>/dev/null elif [[ -L /usr/bin/vim && ! -f /usr/bin/vim ]]; then rm /usr/bin/vim fi # Make or remove convenience symlinks to vim if [[ -f /usr/bin/vim ]]; then for f in ${syms}; do ln -s vim /usr/bin/${f} 2>/dev/null done else for f in ${syms}; do if [[ -L /usr/bin/${f} && ! -f /usr/bin/${f} ]]; then rm -f /usr/bin/${f} fi done fi # This will still break if you merge then remove the vi package, # but there's only so much you can do, eh? Unfortunately we don't # have triggers like are done in rpm-land. } pkg_postinst() { # Update documentation tags (from vim-doc.eclass) update_vim_helptags einfo if [ ${PN} = gvim ] ; then einfo "To enable UTF-8 viewing, set guifont and guifontwide: " einfo ":set guifont=-misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1" einfo ":set guifontwide=-misc-fixed-medium-r-normal-*-18-120-100-100-c-180-iso10646-1" einfo einfo "note: to find out which fonts you can use, please read the UTF-8 help:" einfo ":h utf-8" einfo einfo "Then, set read encoding to UTF-8:" einfo ":set encoding=utf-8" elif [ ${PN} = vim ] ; then einfo "gvim has now a seperate ebuild, 'emerge gvim' will install gvim" fi einfo if [ ${PN} != "vim-core" ] ; then einfo "To see what's new in this release, use :help version${VIM_VERSION/.*}.txt" einfo fi # Warn about VIMRUNTIME if [ -n "$VIMRUNTIME" -a "${VIMRUNTIME##*/vim}" != "${VIM_VERSION/.}" ]; then ewarn ewarn "WARNING: You have VIMRUNTIME set in your environment from an old" ewarn "installation. You will need to either unset VIMRUNTIME in each" ewarn "terminal, or log out completely and back in. This problem won't" ewarn "happen again since the ebuild no longer sets VIMRUNTIME." ewarn fi # Make convenience symlinks update_vim_symlinks } pkg_postrm() { # Update documentation tags (from vim-doc.eclass) update_vim_helptags # Make convenience symlinks update_vim_symlinks } src_test() { if [ "${PN}" == "vim-core" ] ; then einfo "No testing needs to be done for vim-core" return fi einfo " " einfo "Starting vim tests. Several error messages will be shown " einfo "whilst the tests run. This is normal behaviour and does not " einfo "indicate a fault." einfo " " ewarn "If the tests fail, your terminal may be left in a strange " ewarn "state. Usually, running 'reset' will fix this." ewarn " " sleep 5 # Don't let vim talk to X unset DISPLAY if [ "${PN}" == "gvim" ] ; then # Make gvim not try to connect to X. See :help gui-x11-start # in vim for how this evil trickery works. ln -s ${S}/src/gvim ${S}/src/testvim testprog="../testvim" else testprog="../vim" fi # We've got to call make test from within testdir, since the Makefiles # don't pass through our VIMPROG argument cd ${S}/src/testdir # Test 49 won't work inside a portage environment sed -i -e 's~test49.out~~g' Makefile # We don't want to rebuild vim before running the tests sed -i -e 's,: \$(VIMPROG),: ,' Makefile # Don't try to do the additional GUI test make VIMPROG=${testprog} nongui \ || die "At least one test failed" }