From c59471096599a5356ebddc1354323fb42a1737ab Mon Sep 17 00:00:00 2001 From: itmodulo Date: Sun, 28 Jan 2024 18:14:14 +0100 Subject: [PATCH] Add gtkcord4 Add anki from testing --- srcpkgs/anki/APKBUILD | 155 ++++++++++++++++++ srcpkgs/anki/disable-git-checks.patch | 30 ++++ .../anki/dprint-update-for-musl-aarch64.patch | 11 ++ srcpkgs/anki/no-update.patch | 13 ++ srcpkgs/anki/strip-formatter-deps.patch | 9 + srcpkgs/anki/strip-type-checking-deps.patch | 23 +++ 6 files changed, 241 insertions(+) create mode 100644 srcpkgs/anki/APKBUILD create mode 100644 srcpkgs/anki/disable-git-checks.patch create mode 100644 srcpkgs/anki/dprint-update-for-musl-aarch64.patch create mode 100644 srcpkgs/anki/no-update.patch create mode 100644 srcpkgs/anki/strip-formatter-deps.patch create mode 100644 srcpkgs/anki/strip-type-checking-deps.patch diff --git a/srcpkgs/anki/APKBUILD b/srcpkgs/anki/APKBUILD new file mode 100644 index 0000000..ec46148 --- /dev/null +++ b/srcpkgs/anki/APKBUILD @@ -0,0 +1,155 @@ +# Maintainer: Frank Oltmanns +# Contributor: Alexander Bocken + +pkgname=anki +pkgver=23.12.1 +pkgrel=0 +# Remember to update the following lines when updating the pkgver +# anki -> git rev-parse $pkgver --short=8 +# ftl -> git submodule +_tags_ftl_core="fb301cc62da3b7a83b4ea266d9a2e70cfc1a8418" +_tags_ftl_desktop="8c2191a7c797747cec767e3953bbbcc50acc5246" +_anki_commit="c0f2fa48" + +# This APKBUILD and the patches use the PKGBUILD for Anki 23.10 as +# a basis. +_caches_yarn="yarn-cache" +_caches_cargo="cargo-cache" + +# For translations +_core_i18n_repo="anki-core-i18n" +_qtftl_i18n_repo="anki-desktop-ftl" + +pkgdesc="flashcard program using spaced repetition" +url="https://apps.ankiweb.net/" + +# py3-pyqt6-webengine is only available for +# - x86_64 +# - aarch64 +# - x86 +# But upstream only supports 64-bit architectures: +arch="x86_64 aarch64" +license="AGPL-3.0-or-later" +options="!check" # no test suite provided + +# The makedepends and depends are copied from the PKGBUILD +# for 23.10 in the Arch User Repository, with the exception +# that libxcrypt-compat has been removed from that list. +makedepends=" + bash + rsync + ninja + git + cargo + py3-installer + py3-wheel + nodejs + yarn + protoc + " + +depends=" + python3 + py3-stringcase + py3-beautifulsoup4 + py3-waitress + py3-requests + + py3-decorator + py3-markdown + py3-orjson + py3-protobuf + py3-pysocks + py3-distro + + py3-jsonschema + py3-send2trash + py3-certifi + py3-flask-cors + py3-qt6 + py3-pyqt6-webengine + qt6-qtmultimedia + qt6-qtsvg + " +subpackages="$pkgname-pyc" +source=" + https://github.com/ankitects/anki/archive/$pkgver/anki-$pkgver.tar.gz + anki-core-i18n-$_tags_ftl_core.tar.gz::https://github.com/ankitects/anki-core-i18n/archive/$_tags_ftl_core.tar.gz + anki-desktop-ftl-$_tags_ftl_desktop.tar.gz::https://github.com/ankitects/anki-desktop-ftl/archive/$_tags_ftl_desktop.tar.gz + disable-git-checks.patch + no-update.patch + strip-formatter-deps.patch + strip-type-checking-deps.patch + dprint-update-for-musl-aarch64.patch + " + +prepare() { + default_prepare + + # Notes: + # - The original PKGBUILD changes the optimization level to "3". Instead + # the APKBUILD sticks to upstream's optimization settings. + # - The original PKGBUILD changes the rust toolchain channel to + # "stable". Since, the APKBUILD doesn't use rustup, we can skip that. + + # Build process wants .git/HEAD to be present. Workaround to be able to use tarballs + # (together with disable-git-checks.patch) + mkdir -p .git + touch .git/HEAD + sed -i "s/MY_REV/$_anki_commit/" build/runner/src/build.rs + + # place translations in build dir + rm -r ftl/core-repo ftl/qt-repo + mv "$srcdir"/anki-core-i18n-$_tags_ftl_core ftl/core-repo + mv "$srcdir"/anki-desktop-ftl-$_tags_ftl_desktop ftl/qt-repo + + # fetch rust packages + export CARGO_HOME="$srcdir/$_caches_cargo" # do not litter in ~ + cargo fetch --target="$CTARGET" --locked + + # fetch node packages already in prepare() + export YARN_CACHE_FOLDER="$srcdir/$_caches_yarn" # do not litter in ~ + yarn install --immutable --modules-folder out/node_modules + ln -sf out/node_modules ./ + + # mask pip-sync as we provide dependencies ourselves + local venv="out/pyenv" + python -m venv --system-site-packages --without-pip "$venv" + printf '#!/bin/bash\nexit 0' > "$venv/bin/pip-sync" + chmod +x "$venv/bin/pip-sync" +} + +build() { + export YARN_CACHE_FOLDER="$srcdir/$_caches_yarn" # do not litter in ~ + + #use local binaries instead of downloading them + export PYTHON_BINARY=$(which python) + export PROTOC_BINARY=$(which protoc) + export NODE_BINARY=$(which node) + export YARN_BINARY=$(which yarn) + + export CARGO_HOME="$srcdir/$_caches_cargo" # do not litter in ~ + export RELEASE=2 # anki-internal variable for optimization + # set to "1" for faster but less optimized build + export LDFLAGS="$LDFLAGS -fuse-ld=lld" + ./ninja wheels +} + +package() { + for file in out/wheels/*.whl; do + python -m installer --destdir="$pkgdir" $file + done + + install -Dm644 qt/bundle/lin/anki.desktop "$pkgdir"/usr/share/applications/anki.desktop + install -Dm644 qt/bundle/lin/anki.png "$pkgdir"/usr/share/pixmaps/anki.png +} +sha512sums=" +076d3eba5db7dd4b8e00de9b69140a54f73c2e6ce52f46ddce9a6455a8ce7ae5d49bfb2fc60571d851d6b4948a08a0b3deb508aa37c7e79624b6273837a975a5 anki-23.12.1.tar.gz +12e9187bda8f728d06a904fe21f3820aa2acad0e1924933d9db24f3879936b0a7b489934186fcab85440a40b974917ada729b5a7ec276ca2acea70b5c88caa5a anki-core-i18n-fb301cc62da3b7a83b4ea266d9a2e70cfc1a8418.tar.gz +91c3609fa8ca67de2d520798acbb7200d310c4d587270143528a5c18ed341c7dd3b9ddc8d79fe1f44224e83dc06f12cdbcdcf2114969513cbd60e82950343373 anki-desktop-ftl-8c2191a7c797747cec767e3953bbbcc50acc5246.tar.gz +60f2f37d4fc03d7c0681b2d6b9af17b2f7cd341ef6bd4504cd7dd6cb191c666b128a4c2184ced5295fab98c5f83affc4bfd4c5dc23f502371e2e095aa880e526 disable-git-checks.patch +36c3bddb5de84f0f5eebe46b506b9723ecc80dd69281b3d2ffc9842fa2db181ececd8232ae0b3366bcfd5cb68a4d760abcadd3dada2a7ce2d2da26586a132e09 no-update.patch +f71b45b08b8f05d98faab3a88d7ba2847a948a12ca26c682d58541dc423ad72ae8aac5b34155472869ebbf195e5e5c488cfc4e640df7247c7674e5dfad053d60 strip-formatter-deps.patch +2c7d1ab46d81e65f22e63cb5af37daef27a78d348f240570f9250730d6b33311670876027fd1c54d4c69922c18a7458e82211cb232e98591e182ac11c49877db strip-type-checking-deps.patch +627d30af756ad51fa76ea3113e18662c8bfa5ba7e89b418604e13581cc811ce89c674042181566fff962adef0dd5edb2e5af2803c33cee470661f2d2d1f4c331 dprint-update-for-musl-aarch64.patch +" \ No newline at end of file diff --git a/srcpkgs/anki/disable-git-checks.patch b/srcpkgs/anki/disable-git-checks.patch new file mode 100644 index 0000000..5a5528d --- /dev/null +++ b/srcpkgs/anki/disable-git-checks.patch @@ -0,0 +1,30 @@ +We provide source tarballs without git functionality. +'MY_REV' gets replaced with the corresponding revision in prepare(). +--- a/build/ninja_gen/src/git.rs ++++ b/build/ninja_gen/src/git.rs +@@ -13,7 +13,7 @@ pub struct SyncSubmodule { + + impl BuildAction for SyncSubmodule { + fn command(&self) -> &str { +- "git -c protocol.file.allow=always submodule update --init $path" ++ "true" + } + + fn files(&mut self, build: &mut impl build::FilesHandle) { +--- a/build/runner/src/build.rs ++++ b/build/runner/src/build.rs +@@ -161,13 +161,7 @@ fn maybe_update_buildhash(build_root: &Utf8Path) { + } + + fn get_buildhash() -> String { +- let output = Command::new("git") +- .args(["rev-parse", "--short=8", "HEAD"]) +- .output() +- .expect("git"); +- assert!(output.status.success(), +- "Invoking 'git' failed. Make sure you're building from a clone of the git repo, and that 'git' is installed."); +- String::from_utf8(output.stdout).unwrap().trim().into() ++ String::from("MY_REV").trim().into() + } + + fn write_if_changed(path: &Utf8Path, contents: &str) { \ No newline at end of file diff --git a/srcpkgs/anki/dprint-update-for-musl-aarch64.patch b/srcpkgs/anki/dprint-update-for-musl-aarch64.patch new file mode 100644 index 0000000..e01c8c8 --- /dev/null +++ b/srcpkgs/anki/dprint-update-for-musl-aarch64.patch @@ -0,0 +1,11 @@ +--- a/package.json ++++ b/package.json +@@ -23,7 +23,7 @@ + "caniuse-lite": "^1.0.30001431", + "cross-env": "^7.0.2", + "diff": "^5.0.0", +- "dprint": "=0.35.3", ++ "dprint": "^0.42.5", + "esbuild": "^0.18.10", + "esbuild-sass-plugin": "^2", + "esbuild-svelte": "^0.7.4", \ No newline at end of file diff --git a/srcpkgs/anki/no-update.patch b/srcpkgs/anki/no-update.patch new file mode 100644 index 0000000..d7dcb1d --- /dev/null +++ b/srcpkgs/anki/no-update.patch @@ -0,0 +1,13 @@ +diff --git a/qt/aqt/update.py b/qt/aqt/update.py +index 212ddf93d..6f716cc04 100644 +--- a/qt/aqt/update.py ++++ b/qt/aqt/update.py +@@ -11,6 +11,8 @@ from aqt.utils import openLink, show_warning, showText, tr + + + def check_for_update() -> None: ++ return ++ + from aqt import mw + + def do_check(_col: Collection) -> CheckForUpdateResponse: \ No newline at end of file diff --git a/srcpkgs/anki/strip-formatter-deps.patch b/srcpkgs/anki/strip-formatter-deps.patch new file mode 100644 index 0000000..628c7fc --- /dev/null +++ b/srcpkgs/anki/strip-formatter-deps.patch @@ -0,0 +1,9 @@ + Remove dependency on dev-python/black used to format the generated hooks.py + file as it's not relevant in a packaging use case. +--- a/pylib/tools/hookslib.py ++++ b/pylib/tools/hookslib.py +@@ -208,4 +208,3 @@ def write_file(path: str, hooks: list[Hook], prefix: str, suffix: str): + os.environ["USERPROFILE"] = os.environ["HOME"] + with open(path, "wb") as file: + file.write(code.encode("utf8")) +- subprocess.run([sys.executable, "-m", "black", "-q", path], check=True) \ No newline at end of file diff --git a/srcpkgs/anki/strip-type-checking-deps.patch b/srcpkgs/anki/strip-type-checking-deps.patch new file mode 100644 index 0000000..3a30d82 --- /dev/null +++ b/srcpkgs/anki/strip-type-checking-deps.patch @@ -0,0 +1,23 @@ +We don't do type checking (via mypy and related) downstream. +Mypy-protobuf generates mypy stub files from protobuf specs and should +therefore be stripped. +--- a/build/configure/src/python.rs ++++ b/build/configure/src/python.rs +@@ -87,9 +87,7 @@ pub struct GenPythonProto { + impl BuildAction for GenPythonProto { + fn command(&self) -> &str { + "$protoc $ +- --plugin=protoc-gen-mypy=$protoc-gen-mypy $ + --python_out=$builddir/pylib $ +- --mypy_out=$builddir/pylib $ + -Iproto $in" + } + +@@ -107,7 +105,6 @@ impl BuildAction for GenPythonProto { + .collect(); + build.add_inputs("in", &self.proto_files); + build.add_inputs("protoc", inputs![":protoc_binary"]); +- build.add_inputs("protoc-gen-mypy", inputs![":pyenv:protoc-gen-mypy"]); + build.add_outputs("", python_outputs); + } + } \ No newline at end of file