summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 50f4a3cd02ca8835a0e2067fbd357998114dc49b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

pkgname=python2-docutils
_pkgname=docutils
# From the release notes: "Docutils 0.18.x is the last version supporting Python 2.7, 3.5, and 3.6."
pkgver=0.18.1
pkgrel=1
pkgdesc='Set of tools for processing plaintext docs into formats such as HTML, XML, or LaTeX (0.18.x is the last version supporting Python 2)'
arch=('any')
url='http://docutils.sourceforge.net'
license=('custom')
depends=('python2')
makedepends=('python2-setuptools')
install=python2-docutils.install
source=("https://downloads.sourceforge.net/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('44404a6cc9d4c1e79c73a6ffee2898e459c9925ab9661e5d41394e13b3d861334cf0c5efcd18e87eb03041374e326cfd00539a6b2ec5979678889e8a536c9542')

build() {
  cd $_pkgname-$pkgver
  python2 setup.py build --build-lib=build/python2
  find build/python2 -type f -exec \
    sed -i '1s,^#! \?/usr/bin/\(env \|\)python$,#!/usr/bin/python2,' {} \;
}

check() {
  cd $_pkgname-$pkgver
  # we need utf locale to valid utf8 tests
  export LANG=en_US.UTF-8
  PYTHONPATH="$PWD/build/python2/" python2 test/alltests.py
}

package() {
  cd $_pkgname-$pkgver
  python2 setup.py build --build-lib=build/python2 \
                   install --root="$pkgdir" --optimize=1
  # fix python-docutils conflict
  for _f in "$pkgdir"/usr/bin/*.py; do
      mv -v "$_f" "${_f%.py}2.py"
  done
  # symlink without .py
  for _f in "$pkgdir"/usr/bin/*.py; do
      ln -s "$(basename $_f)" "$pkgdir/usr/bin/$(basename $_f .py)"
  done
  # setup license
  install -D -m644 COPYING.txt "$pkgdir/usr/share/licenses/$pkgname/COPYING.txt"
  install -D -m644 licenses/python* "$pkgdir/usr/share/licenses/$pkgname/"
}