summaryrefslogtreecommitdiff
path: root/pcr-testing/anki-ccbc
diff options
context:
space:
mode:
Diffstat (limited to 'pcr-testing/anki-ccbc')
-rw-r--r--pcr-testing/anki-ccbc/PKGBUILD106
-rw-r--r--pcr-testing/anki-ccbc/anki-ccbc.install11
-rw-r--r--pcr-testing/anki-ccbc/pyqt4topyqt5-binary-to-utf.patch11
3 files changed, 128 insertions, 0 deletions
diff --git a/pcr-testing/anki-ccbc/PKGBUILD b/pcr-testing/anki-ccbc/PKGBUILD
new file mode 100644
index 000000000..5119ab851
--- /dev/null
+++ b/pcr-testing/anki-ccbc/PKGBUILD
@@ -0,0 +1,106 @@
+# Contributor (AUR): SÅ‚awomir Kowalski <suawekk+aur@gmail.com>
+# Contributor: bill-auger <bill-auger@programmer.net>
+
+
+pkgname=anki-ccbc
+pkgver=0.1.0
+_pyqt4topyqt5_cid='ca307cdcf66cee7f0c4838ea4ef5174b95d6b6f8'
+pkgrel=1
+pkgdesc="helps you remember facts (eg: foreign words/phrases) efficiently (front-end for anki flash cards)"
+arch=(any)
+url=https://github.com/lovac42/CCBC
+license=(AGPL3)
+
+depends=(desktop-file-utils python-beautifulsoup4 python-decorator python-httplib2
+ python-markdown python-pillow python-pyaudio python-pyqt5 python-requests python-send2trash
+ python-sqlalchemy qt5-webkit)
+optdepends=("mplayer: for playing sounds")
+provides=(anki)
+conflicts=(anki)
+replaces=(anki)
+
+install=${pkgname}.install
+source=(${pkgname}-${pkgver}.tar.gz::https://github.com/lovac42/CCBC/archive/v${pkgver}.tar.gz
+ pyqt4topyqt5-${_pyqt4topyqt5_cid}.tar.gz::https://github.com/rferrazz/pyqt4topyqt5/archive/${_pyqt4topyqt5_cid}.tar.gz
+ pyqt4topyqt5-binary-to-utf.patch)
+sha512sums=('674a1bc5d4733be9f2068ffa7878fe7ad7639deab04ca3fdde12c398adfadade7d594bcd6ab3e9d8754d653a105be8c182f5aa2218ed5198934d0f1892b747ff'
+ '0bdf2a7f8d58e51fd2d32d87b1ab8f91fc8a7f822b1ed29c7e22a61aebfd7768cef6a077829e0f0e0e1791c800e2c71a188be68c3a33b897f9a585c3e1a4091f'
+ '4626a231cd14b86bc9af2927ac5ead5685c4c1aaf10fd0d3ca7020aeb96ec928975be7290a4dc4814ff9c70c8f8e1d80f271e45c4130d7afe6cd90ef618e740f')
+
+
+prepare()
+{
+ mv "${srcdir}"/{CCBC,${pkgname}}-${pkgver}
+ cd "${srcdir}"/${pkgname}-${pkgver}/
+
+ ## convert pyqt4 to pyqt5 ##
+
+ local rx='s!s = SIGNAL("triggered()")!!g; s!\(self.connect([^,]\+, \)s\([^)]\+\))!\1SIGNAL("triggered()")\2)!g'
+ sed -i "${rx}" aqt/main.py
+ local pyqt4to5_script=../pyqt4topyqt5-${_pyqt4topyqt5_cid}/pyqt4topyqt5.py
+ local pyqt4to5_patch="${srcdir}"/pyqt4topyqt5.patch
+ local success_msg="pyqt4topyqt5.py: generated and applied diff file: ${pyqt4to5_patch#${srcdir}/*}"
+
+
+ ## generate pyqt4topyqt5 patch file for source package ##
+
+ # pyqt4topyqt5 creates malformed patch files
+ # https://github.com/rferrazz/pyqt4topyqt5/pull/24
+ patch ${pyqt4to5_script} < "${srcdir}"/pyqt4topyqt5-binary-to-utf.patch
+ python ${pyqt4to5_script} --nolog --diff=${pyqt4to5_patch} -o ../${pkgname}-qt5 . > /dev/null
+ cp -a ../${pkgname}-qt5/* . ; rm -rf ../${pkgname}-qt5/ ;
+
+ # validate and sanitize patch
+ if [[ -f ${pyqt4to5_patch} ]]
+ then echo ${success_msg}
+ perl -0777 -i -pe "s|^--- ${srcdir}/${pkgname}-${pkgver}/([^\t\n]*)[^\n]*\n\+\+\+ [^\n]*$|--- \1\n+++ \1|gms" ${pyqt4to5_patch}
+ else echo "pyqt4topyqt5 failure" ; return 1 ;
+ fi
+
+
+ ## more pyqt4 to pyqt5 adaptations ##
+
+ # QIcon and QPixmap are now in Gui
+ rx='s!QtWidgets.Q\(Icon\|Pixmap\)!QtGui.Q\1!g;'
+ sed -i "${rx}" aqt/{,forms/}*.py
+ # Some enums and defaults are now somewhere else
+ rx='s!QDesktopServices.storageLocation!QStandardPaths.standardLocations!g;'
+ sed -i "${rx}" aqt/{,forms/}*.py
+ rx='s!QDesktopServices.\(Documents\|Home\)\(Location\)!QStandardPaths.\1\2!g;'
+ sed -i "${rx}" aqt/{,forms/}*.py
+ # For some reason, it was fine to combine Core and Gui into Widgets
+ rx='s!\(from PyQt5 import \)\(.*QtCore, QtGui\).*as.*\( QtWidgets\)!\1\2\n\1\3!g;'
+ sed -i "${rx}" aqt/forms/*.py
+ # QMessageBox is now in QtWidgets
+ rx='s!\(from PyQt5\.\)\(QtGui\)\( import \*\)!\1\2\3\n\1\QtWidgets\3!g'
+ sed -i "${rx}" aqt/qt.py
+ # 'loc' is originally a list, but needs to be a string.
+ # Get the last element (consider first as alternative)
+ rx='s!\(if loc\[\):\(-1\] == QStandardPaths.standardLocations\)!\1\2!g; s!\(return os.path.join(loc\)\(, "Anki")\)!\1[-1]\2!g'
+ sed -i "${rx}" aqt/profiles.py
+ # cgi.escape has been depreceated in Python 3.8
+ # https://github.com/posativ/isso/issues/603
+ sed -i 's!cgi!html!g' aqt/{browser.py,reviewer.py}
+ sed -i 's!\(import cgi\)!\# \1!g' aqt/{browser.py,reviewer.py}
+
+
+ ## tweak Makefile ##
+
+ # defer XDG integration to .install hook
+ sed -i 's!^ -xdg-mime .*!!g' Makefile
+}
+
+package()
+{
+ cd "${srcdir}"/${pkgname}-${pkgver}/
+
+ make install DESTDIR="${pkgdir}"
+
+ # rename system meta-data files
+ mv "${pkgdir}"/usr/share/{anki,${pkgname}}/
+ mv "${pkgdir}"/usr/share/applications/{anki,${pkgname}}.desktop
+ sed -i "s!/usr/share/anki!/usr/share/${pkgname}!" "${pkgdir}"/usr/bin/anki
+
+ # install XDG meta-data
+ install -Dm644 anki.xml "${pkgdir}"/usr/share/${pkgname}/anki.xml
+}
diff --git a/pcr-testing/anki-ccbc/anki-ccbc.install b/pcr-testing/anki-ccbc/anki-ccbc.install
new file mode 100644
index 000000000..8fd036a16
--- /dev/null
+++ b/pcr-testing/anki-ccbc/anki-ccbc.install
@@ -0,0 +1,11 @@
+post_install()
+{
+ xdg-mime install /usr/share/anki-ccbc/anki.xml --novendor
+ xdg-mime default /usr/share/applications/anki-ccbc.desktop application/x-anki
+ xdg-mime default /usr/share/applications/anki-ccbc.desktop application/x-apkg
+}
+
+pre_remove()
+{
+ xdg-mime uninstall /usr/share/mime/packages/anki.xml
+}
diff --git a/pcr-testing/anki-ccbc/pyqt4topyqt5-binary-to-utf.patch b/pcr-testing/anki-ccbc/pyqt4topyqt5-binary-to-utf.patch
new file mode 100644
index 000000000..98d26c00c
--- /dev/null
+++ b/pcr-testing/anki-ccbc/pyqt4topyqt5-binary-to-utf.patch
@@ -0,0 +1,11 @@
+--- pyqt4topyqt5.py 2017-05-03 12:55:07.000000000 -0400
++++ pyqt4topyqt5.py 2020-07-08 23:28:51.149813392 -0400
+@@ -2737,7 +2737,7 @@
+ cmd = ['diff', '-u', orig, dest]
+ with open(diffname, 'a') as outf:
+ reply = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+- outf.write(str(reply.communicate()[0]))
++ outf.write(reply.communicate()[0].decode('utf-8'))
+
+ def print_(self, msg):
+ if self.log: