##
##  vim-plugin-shell.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_vimproc         20110212
%define       V_vimshell        20110212
%define       V_conque          2.1

#   package information
Name:         vim-plugin-shell
Summary:      Vim Editor Plugins
URL:          http://www.vim.org/
Vendor:       Vim Community
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Editor
License:      Sharityware
Version:      0
Release:      20110731

#   list of sources
Source0:      http://download.openpkg.org/components/versioned/vim/vimproc-%{V_vimproc}.tar.gz
Source1:      http://download.openpkg.org/components/versioned/vim/vimshell-%{V_vimshell}.tar.gz
Source2:      http://conque.googlecode.com/files/conque_%{V_conque}.tar.gz
Patch0:       vim-plugin-shell.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, gcc, make
PreReq:       OpenPKG, openpkg >= 20160101
PreReq:       vim, vim::with_python = yes, vim::with_multibyte = yes

%description
    This is a set of embedded shell plugins for the Vim editor.

%track
    prog vim-plugin-shell:vimproc = {
        version   = %{V_vimproc}
        url       = http://download.openpkg.org/components/versioned/vim/
        regex     = vimproc-(__VER__)\.tar\.gz
    }
    prog vim-plugin-shell:vimshell = {
        version   = %{V_vimproc}
        url       = http://download.openpkg.org/components/versioned/vim/
        regex     = vimproc-(__VER__)\.tar\.gz
    }
    prog vim-plugin-shell:conque = {
        version   = %{V_conque}
        url       = http://code.google.com/p/conque/downloads/list
        regex     = conque-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -c
    %setup -q -T -D -a 1
    %setup -q -T -D -a 2
    %patch -p0

%build
    #   cleanup
    find . -name ".git" -type d -print | xargs rm -rf
    find . -name "*.orig" -type f -print | xargs rm -f
    rm -rf conque*/tests

    #   build VimProc plugin
    ( cd vimproc
      type="gcc"
      case "%{l_platform -p}" in
          *-macosx* ) type="mac" ;;
      esac
      %{l_make} %{l_mflags} -f make_${type}.mak
    ) || exit $?

%install
    #   create installation area
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/vim

    #   install VimProc plugin
    ( cd vimproc
      cp -rp doc plugin \
          $RPM_BUILD_ROOT%{l_prefix}/lib/vim/
      %{l_shtool} mkdir -f -p -m 755 \
          $RPM_BUILD_ROOT%{l_prefix}/lib/vim/autoload
      cp -rp autoload/proc.so autoload/vimproc* \
          $RPM_BUILD_ROOT%{l_prefix}/lib/vim/autoload/
    ) || exit $?

    #   install VimShell plugin
    ( cd vimshell && %{l_tar} cf - . ) |\
    ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/vim && %{l_tar} xf - ) || exit $?

    #   install Conque plugin
    ( cd conque* && %{l_tar} cf - . ) |\
    ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/vim && %{l_tar} xf - ) || exit $?

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

%post
    #   update Vim "helptags"
    $RPM_INSTALL_PREFIX/bin/vim -u NONE -esX \
        -c "helptags $RPM_INSTALL_PREFIX/lib/vim/doc" \
        -c "quit"

