mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-18 22:54:00 +00:00
temporarily add community/docutils
This commit is contained in:
parent
a9c9e252bd
commit
c9c72c5a86
3 changed files with 163 additions and 0 deletions
68
community/docutils/01-rst2odt_prepstyles-elementtree.patch
Normal file
68
community/docutils/01-rst2odt_prepstyles-elementtree.patch
Normal file
|
@ -0,0 +1,68 @@
|
|||
--- a/tools/rst2odt_prepstyles.py
|
||||
+++ b/tools/rst2odt_prepstyles.py
|
||||
@@ -12,7 +12,15 @@
|
||||
#
|
||||
# Author: Michael Schutte <michi@uiae.at>
|
||||
|
||||
-from lxml import etree
|
||||
+try:
|
||||
+ from xml.etree import ElementTree as etree
|
||||
+except ImportError:
|
||||
+ try:
|
||||
+ from elementtree import ElementTree as etree
|
||||
+ except ImportError:
|
||||
+ raise ImportError('Missing an implementation of ElementTree. ' \
|
||||
+ 'Please install either Python >= 2.5 or ElementTree.')
|
||||
+
|
||||
import sys
|
||||
import zipfile
|
||||
from tempfile import mkstemp
|
||||
@@ -27,12 +35,22 @@
|
||||
def prepstyle(filename):
|
||||
|
||||
zin = zipfile.ZipFile(filename)
|
||||
- styles = zin.read("styles.xml")
|
||||
-
|
||||
- root = etree.fromstring(styles)
|
||||
- for el in root.xpath("//style:page-layout-properties",
|
||||
- namespaces=NAMESPACES):
|
||||
- for attr in el.attrib:
|
||||
+ styles = zin.open("styles.xml")
|
||||
+
|
||||
+ root = None
|
||||
+ # some extra effort to preserve namespace prefixes
|
||||
+ for event, elem in etree.iterparse(styles, events=("start", "start-ns")):
|
||||
+ if event == "start-ns":
|
||||
+ etree.register_namespace(elem[0], elem[1])
|
||||
+ elif event == "start":
|
||||
+ if root is None:
|
||||
+ root = elem
|
||||
+
|
||||
+ styles.close()
|
||||
+
|
||||
+ for el in root.findall(".//style:page-layout-properties",
|
||||
+ namespaces=NAMESPACES):
|
||||
+ for attr in el.attrib.keys():
|
||||
if attr.startswith("{%s}" % NAMESPACES["fo"]):
|
||||
del el.attrib[attr]
|
||||
|
||||
@@ -42,7 +60,7 @@
|
||||
|
||||
for item in zin.infolist():
|
||||
if item.filename == "styles.xml":
|
||||
- zout.writestr(item, etree.tostring(root))
|
||||
+ zout.writestr(item, etree.tostring(root, encoding="UTF-8"))
|
||||
else:
|
||||
zout.writestr(item, zin.read(item.filename))
|
||||
|
||||
@@ -54,8 +72,8 @@
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
if len(args) != 1:
|
||||
- print >> sys.stderr, __doc__
|
||||
- print >> sys.stderr, "Usage: %s STYLE_FILE.odt\n" % sys.argv[0]
|
||||
+ sys.stderr.write(__doc__)
|
||||
+ sys.stderr.write("\nUsage: %s STYLE_FILE.odt\n" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
filename = args[0]
|
||||
prepstyle(filename)
|
86
community/docutils/PKGBUILD
Normal file
86
community/docutils/PKGBUILD
Normal file
|
@ -0,0 +1,86 @@
|
|||
# $Id$
|
||||
# Maintainer: Sébastien Luttringer
|
||||
# Contributor : Ionut Biru <ibiru@archlinux.org>
|
||||
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
|
||||
|
||||
# Remove when bumped upstream
|
||||
|
||||
pkgbase=docutils
|
||||
pkgname=('python-docutils' 'python2-docutils')
|
||||
pkgver=0.12
|
||||
pkgrel=1
|
||||
pkgdesc='Set of tools for processing plaintext docs into formats such as HTML, XML, or LaTeX'
|
||||
arch=('any')
|
||||
url='http://docutils.sourceforge.net'
|
||||
license=('custom')
|
||||
makedepends=('python' 'python2')
|
||||
source=("http://downloads.sourceforge.net/$pkgbase/$pkgbase-$pkgver.tar.gz"
|
||||
'01-rst2odt_prepstyles-elementtree.patch')
|
||||
md5sums=('4622263b62c5c771c03502afa3157768'
|
||||
'34952e8a50692b628a8aa2dde3072f07')
|
||||
|
||||
build() {
|
||||
cd $pkgbase-$pkgver
|
||||
for _p in "$srcdir"/*.patch; do
|
||||
msg2 "${_p##*/}"
|
||||
patch -p1 -i "$_p"
|
||||
done
|
||||
msg2 python3
|
||||
python3 setup.py build --build-lib=build/python
|
||||
find build/python -type f -exec \
|
||||
sed -i '1s,^#! \?/usr/bin/\(env \|\)python$,#!/usr/bin/python3,' {} \;
|
||||
msg2 python2
|
||||
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 $pkgbase-$pkgver
|
||||
# we need utf locale to valid utf8 tests
|
||||
export LANG=en_US.UTF-8
|
||||
# Disable python3 check
|
||||
#msg2 'python checks'
|
||||
#PYTHONPATH="$PWD/build/python/" python3 test3/alltests.py
|
||||
msg2 'python2 checks'
|
||||
PYTHONPATH="$PWD/build/python2/" python2 test/alltests.py
|
||||
}
|
||||
|
||||
package_python-docutils() {
|
||||
depends=('python')
|
||||
|
||||
cd $pkgbase-$pkgver
|
||||
python setup.py build --build-lib=build/python \
|
||||
install --root="$pkgdir" --optimize=1
|
||||
# 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/"
|
||||
}
|
||||
|
||||
package_python2-docutils() {
|
||||
depends=('python2')
|
||||
provides=("docutils=$pkgver")
|
||||
replaces=('docutils')
|
||||
install=python2-docutils.install
|
||||
|
||||
cd $pkgbase-$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/"
|
||||
}
|
||||
|
||||
# vim:set ts=2 sw=2 et:
|
9
community/docutils/python2-docutils.install
Normal file
9
community/docutils/python2-docutils.install
Normal file
|
@ -0,0 +1,9 @@
|
|||
post_upgrade() {
|
||||
[ $(vercmp '0.8.1-2' "$2") -gt 0 ] && cat <<EOF || :
|
||||
python2-docutils:
|
||||
rst* binaries have been renamed to rst*2 to avoid conflict with python-docutils
|
||||
remember to update your scripts
|
||||
EOF
|
||||
}
|
||||
|
||||
# vim:set ts=2 sw=2 ft=sh et:
|
Loading…
Reference in a new issue