diff options
author | V3n3RiX <venerix@koprulu.sector> | 2024-01-21 14:09:19 +0000 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2024-01-21 14:09:19 +0000 |
commit | abf4414edcea5e56092faea23c24176d361c2900 (patch) | |
tree | 499629ff3a8b3f107ed29b867af194f16e3498b8 /app-misc/anki/files | |
parent | 5adb1b3ff590f0911922679849a7fdacc8b4f217 (diff) |
gentoo auto-resync : 21:01:2024 - 14:09:19
Diffstat (limited to 'app-misc/anki/files')
-rw-r--r-- | app-misc/anki/files/23.12.1/configure-offline-build.patch | 63 | ||||
-rw-r--r-- | app-misc/anki/files/23.12.1/ninja-gentoo-setup.patch | 81 | ||||
-rw-r--r-- | app-misc/anki/files/23.12.1/no-git-submodule-sync.patch | 69 | ||||
-rw-r--r-- | app-misc/anki/files/23.12.1/pseudo-venv.patch | 127 | ||||
-rw-r--r-- | app-misc/anki/files/23.12.1/remove-formatter-dep.patch | 11 | ||||
-rw-r--r-- | app-misc/anki/files/23.12.1/remove-yarn-dep.patch | 69 | ||||
-rw-r--r-- | app-misc/anki/files/23.12.1/use-system-nextest.patch | 26 |
7 files changed, 446 insertions, 0 deletions
diff --git a/app-misc/anki/files/23.12.1/configure-offline-build.patch b/app-misc/anki/files/23.12.1/configure-offline-build.patch new file mode 100644 index 000000000000..28c77916e555 --- /dev/null +++ b/app-misc/anki/files/23.12.1/configure-offline-build.patch @@ -0,0 +1,63 @@ +This is an adapted patch from the games/anki FreeBSD port. +https://github.com/freebsd/freebsd-ports/blob/109c3d4629b84972e660b689d169ac0761c1a519/games/anki/files/patch-build_configure_src_main.rs + +It replaces or skips network-reliant methods of the build setup and disables +the setup for bundles and for offline documentation. This way, we achieve a +lean offline build. +Delete setup_python call to avoid setting an extra environment variable to +prevent network access. + +The FreeBSD port offers greater flexibility with additional environment +variables such as OFFLINE_BUILD and should probably be upstreamed. I +have contacted the port maintainer (Kai Knoblich <kai@FreeBSD.org>). + +From: Lucio Sauer <watermanpaint@posteo.net> +--- a/build/configure/src/main.rs ++++ b/build/configure/src/main.rs +@@ -11,25 +11,21 @@ mod web; + + use anyhow::Result; + use aqt::build_and_check_aqt; +-use bundle::build_bundle; + use ninja_gen::glob; + use ninja_gen::inputs; + use ninja_gen::protobuf::check_proto; + use ninja_gen::protobuf::setup_protoc; +-use ninja_gen::python::setup_python; + use ninja_gen::Build; + use pylib::build_pylib; + use pylib::check_pylib; + use python::check_python; +-use python::setup_venv; ++use python::setup_venv_stub; + use rust::build_rust; + use rust::check_minilints; + use rust::check_rust; + use web::build_and_check_web; + use web::check_sql; + +-use crate::python::setup_sphix; +- + fn anki_version() -> String { + std::fs::read_to_string(".version") + .unwrap() +@@ -44,16 +40,15 @@ fn main() -> Result<()> { + setup_protoc(build)?; + check_proto(build, inputs![glob!["proto/**/*.proto"]])?; + +- setup_python(build)?; +- setup_venv(build)?; ++ println!("Patch: Using Python system environment."); ++ setup_venv_stub(build)?; + + build_rust(build)?; + build_pylib(build)?; + build_and_check_web(build)?; + build_and_check_aqt(build)?; +- build_bundle(build)?; + +- setup_sphix(build)?; ++ println!("Patch: Skipping build of bundles."); + + check_rust(build)?; + check_pylib(build)?; diff --git a/app-misc/anki/files/23.12.1/ninja-gentoo-setup.patch b/app-misc/anki/files/23.12.1/ninja-gentoo-setup.patch new file mode 100644 index 000000000000..8671057d4054 --- /dev/null +++ b/app-misc/anki/files/23.12.1/ninja-gentoo-setup.patch @@ -0,0 +1,81 @@ +This is an adapted patch from the games/anki FreeBSD port. +https://github.com/freebsd/freebsd-ports/blob/109c3d4629b84972e660b689d169ac0761c1a519/games/anki/files/patch-build_runner_src_build.rs + +It adapts the ninja(-compatible) build system to the Gentoo system and +prevents repo sync via git. +* Mimic ninja-utils.eclass behavior to respect NINJA_VERBOSE. + Can also be implemented in the ebuild via runner args when the rest + of the patch gets dropped. +* Respect NINJA_STATUS if already set. +* Respect app-alternatives/ninja symlink (n2 is not yet in the tree). + This is a workaround. A proper implementation similar to + the LTO implementation (c6f429) should allow the build system to be set at + configure time. + +From: Lucio Sauer <watermanpaint@posteo.net> +--- a/build/ninja_gen/src/build.rs ++++ b/build/ninja_gen/src/build.rs +@@ -49,7 +49,7 @@ impl Build { + output_text: Default::default(), + action_names: Default::default(), + groups: Default::default(), +- have_n2: which::which("n2").is_ok(), ++ have_n2: false, + }; + + build.add_action("build:configure", ConfigureBuild {})?; +--- a/build/runner/src/build.rs ++++ b/build/runner/src/build.rs +@@ -56,11 +56,15 @@ pub fn run_build(args: BuildArgs) { + + let start_time = Instant::now(); + let mut command = Command::new(get_ninja_command()); ++ ++ if env::var("NINJA_VERBOSE").unwrap_or(String::from("ON")).eq("ON") { ++ command.arg("-v"); ++ } ++ + command + .arg("-f") + .arg(&build_file) + .args(ninja_args) +- .env("NINJA_STATUS", "[%f/%t; %r active; %es] ") + .env("PATH", &path) + .env( + "MYPY_CACHE_DIR", +@@ -75,6 +79,11 @@ pub fn run_build(args: BuildArgs) { + // Updating svelte-check or its deps will likely remove the need for it. + .env("NODE_OPTIONS", "--no-experimental-fetch"); + ++ if env::var("NINJA_STATUS").is_err() { ++ command.env("NINJA_STATUS", "[%f/%t; %r active; %es] "); ++ } ++ ++ + // run build + let mut status = command.status().expect("ninja not installed"); + if !status.success() && Instant::now().duration_since(start_time).as_secs() < 3 { +@@ -109,11 +118,7 @@ pub fn run_build(args: BuildArgs) { + } + + fn get_ninja_command() -> &'static str { +- if which::which("n2").is_ok() { +- "n2" +- } else { +- "ninja" +- } ++ "ninja" + } + + fn setup_build_root() -> Utf8PathBuf { +@@ -154,8 +159,9 @@ fn bootstrap_build() { + + fn maybe_update_buildhash(build_root: &Utf8Path) { + // only updated on release builds ++ println!("Patch: Skipping buildhash update if {build_root}/buildhash exists."); + let path = build_root.join("buildhash"); +- if env::var("RELEASE").is_ok() || !path.exists() { ++ if !path.exists() { + write_if_changed(&path, &get_buildhash()) + } + } diff --git a/app-misc/anki/files/23.12.1/no-git-submodule-sync.patch b/app-misc/anki/files/23.12.1/no-git-submodule-sync.patch new file mode 100644 index 000000000000..df09a09b91a4 --- /dev/null +++ b/app-misc/anki/files/23.12.1/no-git-submodule-sync.patch @@ -0,0 +1,69 @@ +This is an adapted patch from the games/anki FreeBSD port. +https://github.com/freebsd/freebsd-ports/blob/109c3d4629b84972e660b689d169ac0761c1a519/games/anki/files/patch-build_configure_src_rust.rs +https://github.com/freebsd/freebsd-ports/blob/109c3d4629b84972e660b689d169ac0761c1a519/games/anki/files/patch-build_ninja__gen_src_git.rs + +It prevents the build system from issuing the repo sync that +requires git and an internet connection. + +From: Lucio Sauer <watermanpaint@posteo.net> +--- a/build/configure/src/rust.rs ++++ b/build/configure/src/rust.rs +@@ -10,7 +10,7 @@ use ninja_gen::cargo::CargoClippy; + use ninja_gen::cargo::CargoFormat; + use ninja_gen::cargo::CargoTest; + use ninja_gen::cargo::RustOutput; +-use ninja_gen::git::SyncSubmodule; ++use ninja_gen::git::SyncSubmoduleOffline; + use ninja_gen::glob; + use ninja_gen::hash::simple_hash; + use ninja_gen::input::BuildInput; +@@ -27,15 +27,16 @@ pub fn build_rust(build: &mut Build) -> Result<()> { + + fn prepare_translations(build: &mut Build) -> Result<()> { + // ensure repos are checked out ++ println!("Patch: Skipping git repository sync for translation files."); + build.add_action( + "ftl:repo:core", +- SyncSubmodule { ++ SyncSubmoduleOffline { + path: "ftl/core-repo", + }, + )?; + build.add_action( + "ftl:repo:qt", +- SyncSubmodule { ++ SyncSubmoduleOffline { + path: "ftl/qt-repo", + }, + )?; +--- a/build/ninja_gen/src/git.rs ++++ b/build/ninja_gen/src/git.rs +@@ -12,6 +12,10 @@ pub struct SyncSubmodule { + pub path: &'static str, + } + ++pub struct SyncSubmoduleOffline { ++ pub path: &'static str, ++} ++ + impl BuildAction for SyncSubmodule { + fn command(&self) -> &str { + "git -c protocol.file.allow=always submodule update --init $path" +@@ -37,6 +41,17 @@ impl BuildAction for SyncSubmodule { + } + } + ++impl BuildAction for SyncSubmoduleOffline { ++ fn command(&self) -> &str { ++ "echo Running SyncSubmoduleOffline stub function for $path" ++ } ++ ++ fn files(&mut self, build: &mut impl build::FilesHandle) { ++ build.add_variable("path", self.path); ++ build.add_output_stamp(format!("git/{}", self.path)); ++ } ++} ++ + /// We check the mtime of .git/HEAD to detect when we should sync submodules. + /// If this repo is a submodule of another project, .git/HEAD will not exist, + /// and we fall back on .git/modules/*/HEAD in a parent folder instead. diff --git a/app-misc/anki/files/23.12.1/pseudo-venv.patch b/app-misc/anki/files/23.12.1/pseudo-venv.patch new file mode 100644 index 000000000000..8c173021a5b7 --- /dev/null +++ b/app-misc/anki/files/23.12.1/pseudo-venv.patch @@ -0,0 +1,127 @@ +This is an adapted patch from the games/anki FreeBSD port. +https://github.com/freebsd/freebsd-ports/blob/109c3d4629b84972e660b689d169ac0761c1a519/games/anki/files/patch-build_configure_src_python.rs +https://github.com/freebsd/freebsd-ports/blob/109c3d4629b84972e660b689d169ac0761c1a519/games/anki/files/patch-build_ninja__gen_src_python.rs + +Use the "PythonEnvironmentStub" function to use a native Python environment +instead of a Python venv. +* Avoid the use of Python's pip (network access). +* Remove the python_binary input for PythonEnvironmentStub since we create the + pseudo venv manually in the ebuild. This saves us from setting an extra + environment variable to prevent network access. + + The python_binary input should really only be added to PythonEnvironment, if + the venv is not set up. +* TODO: add dev-python/mypy-protobuf to tree for fully typed Anki. + +From: Lucio Sauer <watermanpaint@posteo.net> +--- a/build/configure/src/python.rs ++++ b/build/configure/src/python.rs +@@ -13,6 +13,7 @@ use ninja_gen::input::BuildInput; + use ninja_gen::inputs; + use ninja_gen::python::python_format; + use ninja_gen::python::PythonEnvironment; ++use ninja_gen::python::PythonEnvironmentStub; + use ninja_gen::python::PythonLint; + use ninja_gen::python::PythonTypecheck; + use ninja_gen::rsync::RsyncFiles; +@@ -81,6 +82,25 @@ pub fn setup_venv(build: &mut Build) -> Result<()> { + Ok(()) + } + ++pub fn setup_venv_stub(build: &mut Build) -> Result<()> { ++ build.add_action( ++ "pyenv", ++ PythonEnvironmentStub { ++ folder: "pyenv", ++ extra_binary_exports: &[ ++ "mypy", // Required in some parts of the code, but not for build ++ "black", // dito ++ "isort", // dito ++ "pylint", // dito ++ "pytest", // dito ++ "protoc-gen-mypy", ++ ], ++ }, ++ )?; ++ ++ Ok(()) ++} ++ + pub struct GenPythonProto { + pub proto_files: BuildInput, + } +@@ -88,9 +108,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" + } + +@@ -108,7 +126,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); + } + +@@ -254,7 +271,6 @@ impl BuildAction for Sphinx { + + fn files(&mut self, build: &mut impl FilesHandle) { + build.add_inputs("python", inputs![":pyenv:bin"]); +- build.add_inputs("pip", inputs![":pyenv:pip"]); + build.add_inputs("", &self.deps); + build.add_output_stamp("python/sphinx/stamp"); + } +--- a/build/ninja_gen/src/python.rs ++++ b/build/ninja_gen/src/python.rs +@@ -86,6 +86,11 @@ pub struct PythonEnvironment { + pub extra_binary_exports: &'static [&'static str], + } + ++pub struct PythonEnvironmentStub { ++ pub folder: &'static str, ++ pub extra_binary_exports: &'static [&'static str], ++} ++ + impl BuildAction for PythonEnvironment { + fn command(&self) -> &str { + "$runner pyenv $python_binary $builddir/$pyenv_folder $system_pkgs $base_requirements $requirements" +@@ -118,6 +123,34 @@ impl BuildAction for PythonEnvironment { + } + } + ++impl BuildAction for PythonEnvironmentStub { ++ fn command(&self) -> &str { ++ "echo Running PythonEnvironmentStub..." ++ } ++ ++ fn files(&mut self, build: &mut impl crate::build::FilesHandle) { ++ let bin_path = |binary: &str| -> Vec<String> { ++ let folder = self.folder; ++ let path = if cfg!(windows) { ++ format!("{folder}/scripts/{binary}.exe") ++ } else { ++ format!("{folder}/bin/{binary}") ++ }; ++ vec![path] ++ }; ++ ++ build.add_variable("pyenv_folder", self.folder); ++ build.add_outputs_ext("bin", bin_path("python"), true); ++ for binary in self.extra_binary_exports { ++ build.add_outputs_ext(*binary, bin_path(binary), true); ++ } ++ } ++ ++ fn check_output_timestamps(&self) -> bool { ++ true ++ } ++} ++ + pub struct PythonTypecheck { + pub folders: &'static [&'static str], + pub deps: BuildInput, diff --git a/app-misc/anki/files/23.12.1/remove-formatter-dep.patch b/app-misc/anki/files/23.12.1/remove-formatter-dep.patch new file mode 100644 index 000000000000..2d02db3324fc --- /dev/null +++ b/app-misc/anki/files/23.12.1/remove-formatter-dep.patch @@ -0,0 +1,11 @@ +Remove dependency on dev-python/black used to format the generated hooks.py +file as it's not relevant in a packaging use case. + +From: Lucio Sauer <watermanpaint@posteo.net> +--- 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) diff --git a/app-misc/anki/files/23.12.1/remove-yarn-dep.patch b/app-misc/anki/files/23.12.1/remove-yarn-dep.patch new file mode 100644 index 000000000000..d4cfb30b80b4 --- /dev/null +++ b/app-misc/anki/files/23.12.1/remove-yarn-dep.patch @@ -0,0 +1,69 @@ +This is an adapted patch from the games/anki FreeBSD port. +https://github.com/freebsd/freebsd-ports/blob/109c3d4629b84972e660b689d169ac0761c1a519/games/anki/files/patch-build_runner_src_yarn.rs + +The ebuild ships a ready-to-use node_modules tarball which does not require +sys-apps/yarn to be installed. Pre-built node_modules allows us to run JS tests. +* Don't add inputs that depend on the yarn:bin target. This saves us from +setting an extra environment variable. + +Rework when nodejs.eclass (GitHub PR 33426) gets added to the tree? +The benefit of `yarn install --cache-folder .yarn --offline --ignore-scripts` +is the hackability of `.yarn` contents in src_prepare. +The drawback is that we lose JS tests since some npm test deps (which?) access +the network to update their dependency graph before building. + +From: Lucio Sauer <watermanpaint@posteo.net> +--- a/build/ninja_gen/src/node.rs ++++ b/build/ninja_gen/src/node.rs +@@ -76,12 +76,11 @@ pub struct YarnInstall<'a> { + + impl BuildAction for YarnInstall<'_> { + fn command(&self) -> &str { +- "$runner yarn $yarn $out" ++ "$runner yarn $out" + } + + fn files(&mut self, build: &mut impl build::FilesHandle) { + build.add_inputs("", &self.package_json_and_lock); +- build.add_inputs("yarn", inputs![":yarn:bin"]); + build.add_outputs("out", vec!["node_modules/.marker"]); + for (key, value) in &self.exports { + let outputs: Vec<_> = value.iter().map(|o| format!("node_modules/{o}")).collect(); +@@ -139,9 +138,7 @@ pub fn setup_node( + ); + build.add_dependency("yarn:bin", inputs![path]); + } +- Err(_) => { +- build.add_action("yarn", YarnSetup {})?; +- } ++ Err(_) => () + }; + + for binary in binary_exports { +--- a/build/runner/src/yarn.rs ++++ b/build/runner/src/yarn.rs +@@ -2,23 +2,18 @@ + // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html + + use std::path::Path; +-use std::process::Command; + + use clap::Args; + +-use crate::run::run_command; +- + #[derive(Args)] + pub struct YarnArgs { +- yarn_bin: String, + stamp: String, + } + + pub fn setup_yarn(args: YarnArgs) { ++ println!("Patch: Linking pre-built node_modules."); + link_node_modules(); + +- run_command(Command::new(&args.yarn_bin).arg("install")); +- + std::fs::write(args.stamp, b"").unwrap(); + } + diff --git a/app-misc/anki/files/23.12.1/use-system-nextest.patch b/app-misc/anki/files/23.12.1/use-system-nextest.patch new file mode 100644 index 000000000000..8f931b97da86 --- /dev/null +++ b/app-misc/anki/files/23.12.1/use-system-nextest.patch @@ -0,0 +1,26 @@ +Provide the binary ourselves to prevent network access. +Set test runner options in the ebuild. + +From: Lucio Sauer <watermanpaint@posteo.net> +--- a/build/ninja_gen/src/cargo.rs ++++ b/build/ninja_gen/src/cargo.rs +@@ -152,19 +152,11 @@ impl BuildAction for CargoTest { + + fn files(&mut self, build: &mut impl FilesHandle) { + build.add_inputs("", &self.inputs); +- build.add_inputs("", inputs![":cargo-nextest"]); + build.add_env_var("ANKI_TEST_MODE", "1"); + build.add_output_stamp("tests/cargo_test"); + } + + fn on_first_instance(&self, build: &mut Build) -> Result<()> { +- build.add_action( +- "cargo-nextest", +- CargoInstall { +- binary_name: "cargo-nextest", +- args: "cargo-nextest --version 0.9.57 --locked", +- }, +- )?; + setup_flags(build) + } + } |