# $Id: PKGBUILD 67774 2012-03-14 11:35:18Z giovanni $
# Maintainer: Jaroslav Lichtblau <dragonlord@aur.archlinux.org>
# Contributor: Douglas Soares de Andrade <dsa@aur.archlinux.org>
# Contributor: Andrew Conkling <andrewski@fr.st>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=scribes
pkgver=0.4.954
pkgrel=2
pkgdesc="An ultra minimalist text editor that combines simplicity with power"
arch=('any')
url='http://scribes.sourceforge.net'
license=('GPL')
depends=('dbus-python' 'yelp' 'pygtk' 'pygtksourceview2' 'python2-gtkspell' 'python2-distribute' 'pyxdg')
makedepends=('intltool' 'gnome-doc-utils')
install=$pkgname.install
source=(http://launchpad.net/scribes/${pkgver%.*}/scribes-milestone1/+download/${pkgname}-${pkgver%.*}-dev-build${pkgver##*.}.tar.bz2)
sha256sums=('f4cb765d5690f7549eb0336ce23fd0648ba548b9a9e259876e5ee2c095a4b0f1')

build() {
  cd ${srcdir}/${pkgname}-${pkgver%.*}-dev-build${pkgver##*.}

  sed -i 's/python depcheck.py/python2 depcheck.py/' configure
  sed -i 's/python removepyc.py/python2 removepyc.py/' Makefile.in
  sed -i 's/python -OO compile.py/python2 -OO compile.py/' Makefile.in
  sed -i 's|#!/usr/bin/env python|#!/usr/bin/env python2|' LanguagePlugins/Sparkup/sparkup.py
  sed -i 's|#! */usr/bin/env python|#!/usr/bin/env python2|' LanguagePlugins/PythonErrorChecker/ErrorCheckerProcess/{pychecker/checker.py,ScribesPylint/logilab/common/setup.py,ScribesPythonErrorChecker.py,ScribesPylint/logilab/astng/setup.py}
  sed -i 's|#!/usr/bin/env python|#!/usr/bin/env python2|' LanguagePlugins/zencoding/filters/{haml.py,comment.py,escape.py,format.py,format-css.py,html.py,xsl.py}
  sed -i 's|#!/usr/bin/env python|#!/usr/bin/env python2|' LanguagePlugins/zencoding/{zen_actions.py,zen_core.py,html_matcher.py}
  sed -i 's|#! */usr/bin/env python|#!/usr/bin/env python2|' GenericPlugins/{RecentOpen/ExternalProcess/ScribesRecentFilesIndexer.py,WordCompletion/SuggestionProcess/ScribesWordCompletionSuggestionGenerator.py} SCRIBES/SaveSystem/ExternalProcess/ScribesSaveProcess.py
  sed -i 's|#! */usr/bin/env python|#!/usr/bin/env python2|' scribesmodule scribesplugin
  sed -i 's|#! /usr/bin/python|#! /usr/bin/python2|' scribes.in 
  sed -i 's|return join(prefix, "bin", "python")|return join(prefix, "bin", "python2")|' SCRIBES/SaveProcessInitializer/Initializer.py

  PYTHON=python2 ./configure --prefix=/usr
  make
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver%.*}-dev-build${pkgver##*.}
  make DESTDIR=${pkgdir} install
}
