123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- # $Id$
- # This PKGBUILD is based on the anki-20 from AUR by
- # Sławomir Kowalski <suawekk+aur@gmail.com>
- # Adapted to CCBC by nona (labs.parabola.nu)
- pkgname=CCBC
- pkgver=v0.1.0.r330.2197d20
- pkgrel=1
- pkgdesc="Anki alternative front end using QtWebkit. Helps you remember facts (like words/phrases in a foreign language) efficiently."
- url="https://github.com/lovac42/CCBC.git"
- license=('AGPL3')
- arch=('any')
- makedepends=("git" "python")
- depends=(
- "python-beautifulsoup4"
- "python-decorator"
- "python-httplib2"
- "python-markdown"
- "python-pillow"
- "python-pyaudio"
- "python-pyqt5"
- "python-requests"
- "python-send2trash"
- "python-sqlalchemy"
- "qt5-webkit"
- )
- optdepends=('mplayer: sound playing')
- provides=("anki")
- conflicts=("anki")
- source=("git+https://github.com/lovac42/CCBC.git"
- "git+https://github.com/rferrazz/pyqt4topyqt5.git")
- sha512sums=('SKIP' "SKIP")
- install="CCBC.install"
- pkgver() {
- cd "$srcdir/$pkgname"
- tag=$(git describe --tags $(git rev-list --tags --max-count=1))
- printf "%s.r%s.%s" $tag "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
- }
- prepare() {
- cd "$srcdir"
- ##########################
- # Migrate PyQt4 to PyQt5 #
- ##########################
- # There are many
- # self.connect(m.actionSwitchProfile, s, self.unloadProfile)
- # which pyqt4topyqt5 may handle, but need the right format
- sed -i 's%s = SIGNAL("triggered()")%%g; s%\(self.connect([^,]\+, \)s\([^)]\+\))%\1SIGNAL("triggered()")\2)%g' ${pkgname}/aqt/main.py
- # I'm sorry for the lack of references to where I found
- # the answers to solve this, but I lost my previous notes,
- # and now I just knew how to solve it.
- rm -fr ${pkgname}_qt5 || echo "INFO: ${pkgname}_qt5 safe"
- python pyqt4topyqt5/pyqt4topyqt5.py --nolog -o ${pkgname}_qt5 ${pkgname}/
- cp -a ${pkgname}_qt5/* ${pkgname}/
- # There are many things which were changed between QtCore, QtGui and QtWidgets
- qt4qt5str=(
- # QIcon and QPixmap are now in Gui
- 's%QtWidgets.Q\(Icon\|Pixmap\)%QtGui.Q\1%g;'
- # Some enums and defaults are now somewhere else
- 's%QDesktopServices.storageLocation%QStandardPaths.standardLocations%g;'
- 's%QDesktopServices.\(Documents\|Home\)\(Location\)%QStandardPaths.\1\2%g;'
- 's%self.setMargin(0)%self.setContentsMargins(0, 0, 0, 0)%;'
- # 's%Q%%;'
- # #
- # 's%QtGui.QWidget%QtWidgets.QWidget%g' QtWidgets.QSizePolicy QSplitter
- )
- sed -i "${qt4qt5str[*]}" ${pkgname}/aqt/{,forms/}*.py
- # For some reason, it was fine to combine Core and Gui into Widgets
- sed -i 's%\(from PyQt5 import \)\(.*QtCore, QtGui\).*as.*\( QtWidgets\)%\1\2\n\1\3%g;' ${pkgname}/aqt/forms/*.py
- # QMessageBox is now in QtWidgets
- sed -i 's%\(from PyQt5\.\)\(QtGui\)\( import \*\)%\1\2\3\n\1\QtWidgets\3%g' ${pkgname}/aqt/qt.py
- # loc is originally a list, but needs to be a string. Get
- # the last element (consider first as alternative)
- 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
- # cgi.escape has been depreceated in Python 3.8
- # https://github.com/posativ/isso/issues/603
- sed -i 's/cgi/html/g' ${pkgname}/aqt/{browser.py,reviewer.py}
- sed -i 's/\(import cgi\)/\# \1/g' ${pkgname}/aqt/{browser.py,reviewer.py}
- ##################
- # Adapt Makefile #
- ##################
- # Remove some parts from Makefile which go into
- # CCBC.install
- sed -i 's%^\([[:space:]]*\)\(.*xdg-mime.*\)%\1@echo "skipped \2"%g' CCBC/Makefile
- # Change default target directory
- sed -i "s%PREFIX=/usr%PREFIX=$pkgdir/usr%g; s%\${DESTDIR}%%g" CCBC/Makefile
- }
- package() {
- cd "$srcdir"/"$pkgname"
- make install
- # Fix final path
- sed -i "s%$pkgdir/usr%/usr%" "$pkgdir"/usr/bin/anki
- rm -rf "$pkgdir"/usr/share/anki/{tests,thirdparty/[!s]*,tools,anki.bat}
- }
|