From 19fbfa9bb5a620d7e1b13a5977b5ea66ef3484da Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Fri, 5 Nov 2010 15:55:15 +0000
Subject: vi: replace vi with ex or true vi ref #647

---
 abs/core/vi/PKGBUILD            |  99 ++++++++++++----------------------
 abs/core/vi/__changelog         |   3 --
 abs/core/vi/exrc.sample         |   5 ++
 abs/core/vi/fetch_patches.sh    |  61 ---------------------
 abs/core/vi/fetch_runtime.sh    | 117 ----------------------------------------
 abs/core/vi/increase-tube.patch |  13 +++++
 abs/core/vi/navkeys.patch       |  55 +++++++++++++++++++
 abs/core/vi/vi.install          |  37 -------------
 8 files changed, 107 insertions(+), 283 deletions(-)
 delete mode 100644 abs/core/vi/__changelog
 create mode 100644 abs/core/vi/exrc.sample
 delete mode 100644 abs/core/vi/fetch_patches.sh
 delete mode 100644 abs/core/vi/fetch_runtime.sh
 create mode 100644 abs/core/vi/increase-tube.patch
 create mode 100644 abs/core/vi/navkeys.patch
 delete mode 100644 abs/core/vi/vi.install

diff --git a/abs/core/vi/PKGBUILD b/abs/core/vi/PKGBUILD
index b65cb93..83151a8 100644
--- a/abs/core/vi/PKGBUILD
+++ b/abs/core/vi/PKGBUILD
@@ -1,71 +1,40 @@
-# $Id: PKGBUILD 17437 2008-10-29 18:56:25Z tobias $
+# $Id: PKGBUILD 71573 2010-03-07 19:09:56Z paul $
 # Maintainer: tobias [ tobias at archlinux org ]
 
 pkgname=vi
-_srcver=7.2
-_patchlevel=148
-pkgver=${_srcver}.${_patchlevel}
+pkgver=050325
 pkgrel=3
-pkgdesc="a highly configurable, improved version of the vi text editor (basic version)"
-arch=(i686 x86_64)
-license=('custom:vim')
-url="http://www.vim.org"
+pkgdesc='The original ex/vi text editor.'
+arch=('i686' 'x86_64')
+url='http://ex-vi.sourceforge.net/'
+license=('custom:ex')
+depends=('ncurses')
 groups=('base')
-depends=('glibc' 'ncurses' 'coreutils')
-makedepends=('wget' 'sed' 'grep' 'gettext')
-backup=(etc/virc)
-install=${pkgname}.install
-# we need the extra-stuff to get all patches applied smoothly
-source=(ftp://ftp.vim.org/pub/vim/unix/vim-${_srcver}.tar.bz2 \
-        ftp://ftp.vim.org/pub/vim/extra/vim-${_srcver}-extra.tar.gz \
-        ftp://ftp.vim.org/pub/vim/extra/vim-${_srcver}-lang.tar.gz \
-        fetch_patches.sh fetch_runtime.sh)
-
-build()
-{
-  # pull in patches from vim.org (or the src cache alternatively)
-  . ${startdir}/src/fetch_patches.sh
-  . ${startdir}/src/fetch_runtime.sh
-  get_patches || return 1
-  cd ${startdir}/src/vim$(echo ${_srcver} | sed "s/\.//")
-  # set the virc different from vimrc
-  sed -i 's|^.*\(#define SYS_VIMRC_FILE.*"\) .*$|\1|' src/feature.h
-  sed -i 's|^.*\(#define VIMRC_FILE.*"\) .*$|\1|' src/feature.h
-  sed -i 's|^.*\(#define USR_VIMRC_FILE\t"\).*$|\1$HOME/.virc"|' src/feature.h
-  sed -i 's|/etc/vimrc|/etc/virc|' src/feature.h
-  sed -i 's|\.vimrc|.virc|' src/feature.h
-  # build party
-  ./configure --prefix=/usr --localstatedir=/var/lib/vim --mandir=/usr/share/man \
-    --with-compiledby=ArchLinux --with-features=normal \
-    --with-global-runtime=/usr/share/vim --with-vim-name=vi \
-    --disable-gpm --disable-acl --with-x=no --disable-gui --enable-multibyte
-  make || return 1
-  make  VIMRCLOC=/etc DESTDIR=${startdir}/pkg VIMRTDIR= install
-  cd ${startdir}/pkg/usr/bin
-  rm -f vim rvim view rview vidiff
-  ln -s vi evi
-
-  # delete the manpages for vidiff, we don't bother with that symlink since vidiff doesn't work
-  find ${startdir}/pkg/usr/share/man -type d -name 'man1' 2> /dev/null | \
-   while read mandir; do
-    cd ${mandir}
-    rm -f vidiff.1
-  done
-
-  _runtimedir="${startdir}/pkg/usr/share/vim/"
-  update_runtime
-  install -Dm644 ${startdir}/pkg/usr/share/vim/vimrc_example.vim \
-    ${startdir}/pkg/etc/virc
-  rm -f ${startdir}/pkg/usr/share/vim/gvimrc_example.vim
-  install -dm755 ${startdir}/pkg/usr/share/licenses/vim
-  cd ${startdir}/pkg/usr/share/licenses/vim
-  ln -s ../../vim/doc/uganda.txt license.txt
-
-#               Changes to remove mouse support  VERY IMPORTANT!
-  ########################################################################################
-   sed -i "s/mouse=a/mouse-=a/g" $startdir/pkg/etc/virc
-
-
-  ############################################################################
-
+options=(force strip !libtool emptydirs)
+source=(http://downloads.sourceforge.net/sourceforge/ex-vi/ex-${pkgver}.tar.bz2
+        navkeys.patch increase-tube.patch exrc.sample)
+md5sums=('e668595254233e4d96811083a3e4e2f3' 'aac133930047eafa4f28736cfaf976b3'
+         'e596e05a00a24187b576e389fa1de45d' 'd3b483c994d859232ce369b82a4b5668')
+
+build() {
+  cd ${srcdir}/ex-${pkgver} || return 1
+
+  # apply patches
+  patch -Np1 -i  ../navkeys.patch || return 1
+  patch -Np0 -i ../increase-tube.patch || return 1
+
+  # correct paths in manpages
+  sed -i -e 's/^\.B \/usr\/libexec/.B \/usr\/lib\/ex/' vi.1 \
+      || return 1
+  sed -i -e 's/^\.B \/var\/preserve$/.B \/var\/lib\/ex/' vi.1 \
+      || return 1
+
+  make PREFIX=/usr LIBEXECDIR=/usr/lib/ex PRESERVEDIR=/var/lib/ex \
+      'FEATURES=-DCHDIR -DFASTTAG -DUCVISUAL -DMB -DBIT8' TERMLIB=ncurses \
+      || return 1
+  make PREFIX=/usr LIBEXECDIR=/usr/lib/ex PRESERVEDIR=/var/lib/ex INSTALL=/bin/install \
+      "DESTDIR=$pkgdir" install || return 1
+
+  install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE \
+      || return 1
 }
diff --git a/abs/core/vi/__changelog b/abs/core/vi/__changelog
deleted file mode 100644
index 47cbb5f..0000000
--- a/abs/core/vi/__changelog
+++ /dev/null
@@ -1,3 +0,0 @@
-Remove mouse support from  /etc/vimrc.  This new found ability is truely annoying.
-
-
diff --git a/abs/core/vi/exrc.sample b/abs/core/vi/exrc.sample
new file mode 100644
index 0000000..44b3045
--- /dev/null
+++ b/abs/core/vi/exrc.sample
@@ -0,0 +1,5 @@
+" A sample .exrc file. Copy it to your home dir as ~/.exrc in order to work.
+set showmode
+set noflash
+set autoindent
+set shiftwidth=2
diff --git a/abs/core/vi/fetch_patches.sh b/abs/core/vi/fetch_patches.sh
deleted file mode 100644
index 2ce1019..0000000
--- a/abs/core/vi/fetch_patches.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-# the external logic for pulling in patches
-
-get_patches() {
-  _patchdir=${startdir}/src/patches
-  cd ${startdir}/src/vim$(echo ${_srcver} | sed "s/\.//")
-  if [ -d ${_patchdir} ]; then
-    rm -rf ${_patchdir}
-    echo -e "\tremove patches from old build"
-  fi
-  mkdir ${_patchdir} && cd ${_patchdir}
-  _rpath=ftp://ftp.vim.org/pub/vim/patches/${_srcver}
-
-  # change IFS to loop line-by-line
-  _OLDIFS=$IFS
-  IFS="
-"
-  echo -e "\tfetching checksumfile for patches"
-  wget ${_rpath}/MD5SUMS >/dev/null 2>&1
-
-  downloads=-1
-  for _line in $(/bin/cat MD5SUMS); do
-    downloads=$((${downloads} + 1))
-    _md5=$(echo $_line | cut -d ' ' -f1)
-    _file=$(echo $_line | cut -d ' ' -f3)
-    if [ -f ${SRCDEST}/vim-${_srcver}/${_file} ]; then
-      echo -e "\thaving patch file:${_file}"
-      cp ${SRCDEST}/vim-${_srcver}/${_file} ./
-    else
-      echo -n -e "\t... fetching patch file: ${_file} ..."
-      wget ${_rpath}/${_file} >/dev/null 2>&1
-      if [ -w ${SRCDEST} ]; then
-        if [ ! -d ${SRCDEST}/vim-${_srcver} ]; then
-          mkdir -p ${SRCDEST}/vim-${_srcver}
-        fi
-        cp ${_file} ${SRCDEST}/vim-${_srcver}/
-        echo " done!"
-      fi
-    fi
-
-    if [ $(echo "${_md5}  ${_file}" | md5sum --status -c -) ]; then
-      echo ${_file} md5sums do not match
-      return 1
-    fi
-  done
-  cd $startdir/src/patches
-  rm 7.2.001-100.gz
-  ########
-
-  if [ ${downloads} != ${_patchlevel} ]; then
-    echo -e "Number of patches does not match the patchlevel!\nEdit the PKGBUILD accordingly!"
-    return 1
-  fi
-  IFS=$_OLDIFS
-  rm MD5SUMS
-  cd ${startdir}/src/vim$(echo ${_srcver} | sed "s/\.//")
-  for _patch in $(/bin/ls ${_patchdir}); do
-    patch -Np0 -i ${_patchdir}/${_patch} || return 1
-  done
-  rm -rf ${_patchdir}
-  return 0
-}
diff --git a/abs/core/vi/fetch_runtime.sh b/abs/core/vi/fetch_runtime.sh
deleted file mode 100644
index f244ea5..0000000
--- a/abs/core/vi/fetch_runtime.sh
+++ /dev/null
@@ -1,117 +0,0 @@
-# the purpose of this magic is to pull in the latest runtime files for vim
-# we start withe theruntime provoded by the tarballs and compare MD5s against
-# the latest runtime
-# if this fails we look in the local source cache if they have been fetched
-# for an earlier build and compare those MD5 files
-# if this fails, we fetch the stuff from online and store it in the local src
-# cache.
-# The local cache has to be set (makepkg.conf) AND it has to be writable
-
-update_runtime() {
-  _OLDDIR=$(pwd) #get absolute path
-  _errors=0
-  _ftp="ftp://ftp.vim.org/pub/vim/runtime"
-
-  # we're gonna be sneaky and grok the A-A-P recipe for the files we need
-  _recipe="getunix.aap"
-  _srccache="${SRCDEST}/vim-${_srcver}/"
-
-  echo "getting runtime recipe"
-  cd ${startdir}/src
-  [ -f "${_recipe}" ] && rm "${_recipe}"
-  wget "${_ftp}/${_recipe}" >/dev/null 2>&1
-
-  cd "${_runtimedir}"
-  _runtimedir=$(pwd) #get absolute path
-
-  # change IFS to loop line-by-line
-  _OLDIFS=$IFS
-  IFS="
-"
-  echo "begin fetching updated runtime files..."
-  for _file in $(grep "file = " "${startdir}/src/${_recipe}"); do
-    _file=$(echo ${_file} | sed "s|.*file = \(.*\)|\1|")
-    _md5=$(grep -A2 "file = ${_file} *$" "${startdir}/src/${_recipe}" | \
-          grep "get_md5" | \
-          sed 's|@if get_md5(file) != "\(.*\)":|\1|g')
-    _dir=$(dirname "${_file}")
-
-    mkdir -p "${_dir}"
-
-    echo -e "\t${_file}"
-    _havefile=0
-    # if we have the file and the MD5sum fails, we technically don't have the file
-    if [ -f ${_file} ]; then
-      # MD5 fails ? ... we don't have the file
-      if [ $(echo "${_md5}  ${_file}" | md5sum --status -c -) ]; then
-        rm ${_file}
-      else
-        _havefile=1
-      fi
-    fi
-    # look files that were not copied from the unzipped sources
-    _cachefile=${startdir}/src/vim$(echo ${_srcver} | sed "s/\.//")/runtime/${_file}
-    if [ ${_havefile} -ne 1 -a -f ${_cachefile} ]; then
-      # MD5 fails ? ... we lookup if we downloaded another version earlier
-      if [ $(echo "${_md5}  ${_cachefile}" | md5sum --status -c -) ]; then
-        _cachefile=${_srccache}/${_file}
-        if [ -f ${_cachefile} ]; then
-          if [ $(echo "${_md5}  ${_cachefile}" | md5sum --status -c -) ]; then
-            rm ${_cachefile}
-          else
-            cp ${_cachefile} ${_dir}
-            _havefile=1
-          fi
-        fi
-      else
-        cp ${_cachefile} ${_dir}
-        _havefile=1
-      fi
-    fi
-    # look up the local $SRCDEST
-    _cachefile=${_srccache}/${_file}
-    if [ ${_havefile} -ne 1 -a -f ${_cachefile} ]; then
-      # MD5 fails ? ... we don't have the file
-      if [ $(echo "${_md5}  ${_cachefile}" | md5sum --status -c -) ]; then
-        rm ${_cachefile}
-      else
-        cp ${_cachefile} ${_dir}
-        _havefile=1
-      fi
-    fi
-    # so we finally have to fetch it and store it to $SRCDEST (cache)
-    if [ ${_havefile} -ne 1 ]; then
-      echo -n -e "\t ... fetching file ${_file} ..."
-      cd "${_dir}"
-      wget "${_ftp}/${_file}" >/dev/null 2>&1
-      cd "${_runtimedir}"
-      # store freshly downloaded file in SRCDEST
-      mkdir -p ${_srccache}/${_dir}
-      cp ${_file} ${_srccache}/${_dir}
-      echo -e " done!"
-    fi
-
-   # check the MD5 sum finally
-    if [ $(echo "${_md5}  ${_file}" | md5sum --status -c -) ]; then
-      echo "!!!! md5sum check for ${_file} failed !!!!"
-      errors=$((${_errors} + 1))
-    fi
-  done
-  IFS=${_OLDIFS}
-
-  echo "vim runtime got updated"
-
-  if [ ${_errors} -gt 0 ]; then
-    echo "${_errors} failed MD5 checks while updating runtime files -> build can't be completed"
-    return 1
-  else
-    echo -e "\tpatching filetype.vim for better handling of pacman related files ..."
-    sed -i "s/rpmsave/pacsave/;s/rpmnew/pacnew/;s/,\*\.ebuild/\0,PKGBUILD*,*.install/" filetype.vim
-    sed -i "/find the end/,+3{s/changelog_date_entry_search/changelog_date_end_entry_search/}" ftplugin/changelog.vim
-  fi
-  # make Aaron happy
-  wget http://www.vim.org/scripts/download_script.php\?src_id=7766 \
-    -O autoload/pythoncomplete.vim
-  cd "${_OLDDIR}"
-  return 0
-}
diff --git a/abs/core/vi/increase-tube.patch b/abs/core/vi/increase-tube.patch
new file mode 100644
index 0000000..5010798
--- /dev/null
+++ b/abs/core/vi/increase-tube.patch
@@ -0,0 +1,13 @@
+--- config.h	2005-02-19 05:25:39.000000000 -0500
++++ config.h.fixed	2010-01-04 22:02:01.000000000 -0500
+@@ -95,8 +95,8 @@
+ #define TUBESIZE        6000    /* Maximum screen size for visual */
+ #else	/* VMUNIX */
+ #define TUBELINES       100
+-#define TUBECOLS        160
+-#define TUBESIZE        16000
++#define TUBECOLS        320
++#define TUBESIZE        32000
+ #endif	/* VMUNIX */
+ 
+ /*
diff --git a/abs/core/vi/navkeys.patch b/abs/core/vi/navkeys.patch
new file mode 100644
index 0000000..4692437
--- /dev/null
+++ b/abs/core/vi/navkeys.patch
@@ -0,0 +1,55 @@
+diff -ru ex-050325/ex_tty.c ex-050325-du/ex_tty.c
+--- ex-050325/ex_tty.c	2005-03-04 13:42:58.000000000 +0100
++++ ex-050325-du/ex_tty.c	2009-06-25 20:06:57.000000000 +0200
+@@ -132,7 +132,8 @@
+ 	&ED, &EI, &F0, &F1, &F2, &F3, &F4, &F5, &F6, &F7, &F8, &F9,
+ 	&HO, &IC, &IM, &IP, &KD, &KE, &KH, &KL, &KR, &KS, &KU, &LL, &ND, &xNL,
+ 	&xPC, &RC, &SC, &SE, &SF, &SO, &SR, &TA, &TE, &TI, &UP, &VB, &VS, &VE,
+-	&AL_PARM, &DL_PARM, &UP_PARM, &DOWN_PARM, &LEFT_PARM, &RIGHT_PARM
++	&AL_PARM, &DL_PARM, &UP_PARM, &DOWN_PARM, &LEFT_PARM, &RIGHT_PARM,
++ 	&kI, &kD, &kh, &at7, &kP, &kN
+ };
+ bool *sflags[] = {
+ 	&AM, &BS, &DA, &DB, &EO, &HC,
+@@ -170,7 +171,12 @@
+ 	addmac1(KD, "j", "down", arrows, 1);
+ 	addmac1(KL, "h", "left", arrows, 1);
+ 	addmac1(KR, "l", "right", arrows, 1);
+-	addmac1(KH, "H", "home", arrows, 1);
++	addmac1(kI, "i", "insert", arrows, 1);
++	addmac1(kD, "x", "delete", arrows, 1);
++	addmac1(kh, "^", "home", arrows, 1);
++	addmac1(at7, "$", "end", arrows, 1);
++	addmac1(kP, "", "pgup", arrows, 1);
++	addmac1(kN, "", "pgdn", arrows, 1);
+ 
+ 	/*
+ 	 * Handle funny termcap capabilities
+@@ -341,7 +347,7 @@
+ 		*(*fp++) = flag;
+ 		namp += 2;
+ 	} while (*namp);
+-	namp = "albcbtcdceclcmcrcsdcdldmdoedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullndnlpcrcscsesfsosrtatetiupvbvsveALDLUPDOLERI";
++	namp = "albcbtcdceclcmcrcsdcdldmdoedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullndnlpcrcscsesfsosrtatetiupvbvsveALDLUPDOLERIkIkDkh@7kPkN";
+ 	sp = sstrs;
+ 	do {
+ 		string = tgetstr(namp, &aoftspace);
+diff -ru ex-050325/ex_tty.h ex-050325-du/ex_tty.h
+--- ex-050325/ex_tty.h	2004-12-01 19:21:06.000000000 +0100
++++ ex-050325-du/ex_tty.h	2009-06-25 20:06:05.000000000 +0200
+@@ -183,6 +183,15 @@
+ var	bool	XX;		/* Tektronix 4025 insert line */
+ 	/* X? is reserved for severely nauseous glitches */
+ 	/* If there are enough of these we may need bit masks! */
++/*
++ * Insert, Delete, Home, End, PgUp an PgDown keys
++ */
++var	char	*kI;
++var	char	*kD;
++var	char	*kh;
++var	char	*at7;
++var	char	*kP;
++var	char	*kN;
+ 
+ /*
+  * From the tty modes...
diff --git a/abs/core/vi/vi.install b/abs/core/vi/vi.install
deleted file mode 100644
index ebb73c0..0000000
--- a/abs/core/vi/vi.install
+++ /dev/null
@@ -1,37 +0,0 @@
-post_install() {
-  # if we have vim installed create view/rview symlinks to vim
-  if [ ! -f usr/bin/vim ] ; then
-    cd usr/bin
-    ln -s vi view
-    ln -s vi rview
-    cd ${OLDPWD}
-    echo "Create vi related symlinks..."
-  fi
-  echo -n "Updating vi help tags..."
-  usr/bin/vi --noplugins -u NONE -U NONE \
-    --cmd ":helptags usr/share/vim/doc" --cmd ":q" > /dev/null 2>&1
-  echo "done."
-}
-
-pre_remove() {
-  # if vi is a binary instead of a symlink we have an intact gvim installation
-  # with a different binary/symlink structure
-  # we recover what pacmans database knows about Vim
-  if [ ! -f usr/bin/vim ] ; then
-    rm -f usr/bin/view usr/bin/rview
-    echo "Remove vi related symlinks ..."
-  fi
-}
-
-post_upgrade() {
-  post_install $1
-}
-
-pre_upgrade() {
-  pre_remove $2
-}
-
-
-op=$1
-shift
-[ "$(type -t "$op")" = "function" ] && $op "$@"
-- 
cgit v0.12

