PKGBUILD 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # $Id$
  2. # This PKGBUILD is based on the anki-20 from AUR by
  3. # Sławomir Kowalski <suawekk+aur@gmail.com>
  4. # Adapted to CCBC by nona (labs.parabola.nu)
  5. pkgname=CCBC
  6. pkgver=v0.1.0.r330.2197d20
  7. pkgrel=1
  8. pkgdesc="Anki alternative front end using QtWebkit. Helps you remember facts (like words/phrases in a foreign language) efficiently."
  9. url="https://github.com/lovac42/CCBC.git"
  10. license=('AGPL3')
  11. arch=('any')
  12. makedepends=("git" "python")
  13. depends=(
  14. "python-beautifulsoup4"
  15. "python-decorator"
  16. "python-httplib2"
  17. "python-markdown"
  18. "python-pillow"
  19. "python-pyaudio"
  20. "python-pyqt5"
  21. "python-requests"
  22. "python-send2trash"
  23. "python-sqlalchemy"
  24. "qt5-webkit"
  25. )
  26. optdepends=('mplayer: sound playing')
  27. provides=("anki")
  28. conflicts=("anki")
  29. source=("git+https://github.com/lovac42/CCBC.git"
  30. "git+https://github.com/rferrazz/pyqt4topyqt5.git")
  31. sha512sums=('SKIP' "SKIP")
  32. install="CCBC.install"
  33. pkgver() {
  34. cd "$srcdir/$pkgname"
  35. tag=$(git describe --tags $(git rev-list --tags --max-count=1))
  36. printf "%s.r%s.%s" $tag "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
  37. }
  38. prepare() {
  39. cd "$srcdir"
  40. ##########################
  41. # Migrate PyQt4 to PyQt5 #
  42. ##########################
  43. # There are many
  44. # self.connect(m.actionSwitchProfile, s, self.unloadProfile)
  45. # which pyqt4topyqt5 may handle, but need the right format
  46. sed -i 's%s = SIGNAL("triggered()")%%g; s%\(self.connect([^,]\+, \)s\([^)]\+\))%\1SIGNAL("triggered()")\2)%g' ${pkgname}/aqt/main.py
  47. # I'm sorry for the lack of references to where I found
  48. # the answers to solve this, but I lost my previous notes,
  49. # and now I just knew how to solve it.
  50. rm -fr ${pkgname}_qt5 || echo "INFO: ${pkgname}_qt5 safe"
  51. python pyqt4topyqt5/pyqt4topyqt5.py --nolog -o ${pkgname}_qt5 ${pkgname}/
  52. cp -a ${pkgname}_qt5/* ${pkgname}/
  53. # There are many things which were changed between QtCore, QtGui and QtWidgets
  54. qt4qt5str=(
  55. # QIcon and QPixmap are now in Gui
  56. 's%QtWidgets.Q\(Icon\|Pixmap\)%QtGui.Q\1%g;'
  57. # Some enums and defaults are now somewhere else
  58. 's%QDesktopServices.storageLocation%QStandardPaths.standardLocations%g;'
  59. 's%QDesktopServices.\(Documents\|Home\)\(Location\)%QStandardPaths.\1\2%g;'
  60. 's%self.setMargin(0)%self.setContentsMargins(0, 0, 0, 0)%;'
  61. # 's%Q%%;'
  62. # #
  63. # 's%QtGui.QWidget%QtWidgets.QWidget%g' QtWidgets.QSizePolicy QSplitter
  64. )
  65. sed -i "${qt4qt5str[*]}" ${pkgname}/aqt/{,forms/}*.py
  66. # For some reason, it was fine to combine Core and Gui into Widgets
  67. sed -i 's%\(from PyQt5 import \)\(.*QtCore, QtGui\).*as.*\( QtWidgets\)%\1\2\n\1\3%g;' ${pkgname}/aqt/forms/*.py
  68. # QMessageBox is now in QtWidgets
  69. sed -i 's%\(from PyQt5\.\)\(QtGui\)\( import \*\)%\1\2\3\n\1\QtWidgets\3%g' ${pkgname}/aqt/qt.py
  70. # loc is originally a list, but needs to be a string. Get
  71. # the last element (consider first as alternative)
  72. sed -i 's%\(if loc\[\):\(-1\] == QStandardPaths.standardLocations\)%\1\2%g; s%\(return os.path.join(loc\)\(, "Anki")\)%\1[-1]\2%g' ${pkgname}/aqt/profiles.py
  73. # cgi.escape has been depreceated in Python 3.8
  74. # https://github.com/posativ/isso/issues/603
  75. sed -i 's/cgi/html/g' ${pkgname}/aqt/{browser.py,reviewer.py}
  76. sed -i 's/\(import cgi\)/\# \1/g' ${pkgname}/aqt/{browser.py,reviewer.py}
  77. ##################
  78. # Adapt Makefile #
  79. ##################
  80. # Remove some parts from Makefile which go into
  81. # CCBC.install
  82. sed -i 's%^\([[:space:]]*\)\(.*xdg-mime.*\)%\1@echo "skipped \2"%g' CCBC/Makefile
  83. # Change default target directory
  84. sed -i "s%PREFIX=/usr%PREFIX=$pkgdir/usr%g; s%\${DESTDIR}%%g" CCBC/Makefile
  85. }
  86. package() {
  87. cd "$srcdir"/"$pkgname"
  88. make install
  89. # Fix final path
  90. sed -i "s%$pkgdir/usr%/usr%" "$pkgdir"/usr/bin/anki
  91. rm -rf "$pkgdir"/usr/share/anki/{tests,thirdparty/[!s]*,tools,anki.bat}
  92. }