gentoo-ebuilds/app-misc/anki/files/anki-25.09.2-no-yarn-install.patch
Lucio Sauer d6ed58bbe9
app-misc/anki: add 25.09.2
The node_modules tarball now includes the corresponding yarn lockfile.
You can use it to reproduce the prebuilt node_modules folder, provided
you trust the aforementioned lockfile [1]:

$ ebuild anki-25.09.2.ebuild clean unpack
$ pushd "${S}"
$ mv "${WORKDIR}"/yarn.lock .
$ sed -e '/"type": "module"/s/,//' -e '/packageManager/d' -i package.json
$ yarn install --frozen-lockfile --ignore-platform
$ popd

Finally, compare node_modules with its prebuilt counterpart
"${WORKDIR}"/node_modules.

[1]: The yarn.lock file shipped in the node_modules tarball gets
generated when building node_modules for distribution and it is not the
same as the upstream file. Upstream uses Yarn 4, whose lockfile format
is incompatible with sys-apps/yarn-1*. Yarn 4 is not packaged yet.

Bug: https://bugs.gentoo.org/754651
Signed-off-by: Lucio Sauer <watermanpaint@posteo.net>
Part-of: https://github.com/gentoo/gentoo/pull/43914
Signed-off-by: Sam James <sam@gentoo.org>
2025-10-14 21:04:17 +01:00

63 lines
1.8 KiB
Diff

Pre-built node_modules allows us to run JS tests but we lose the ability to
hack node packages' source files in YARN_CACHE_FOLDER.
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();
--- a/build/runner/src/yarn.rs
+++ b/build/runner/src/yarn.rs
@@ -1,40 +1,18 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-use std::env;
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) {
link_node_modules();
- if env::var("OFFLINE_BUILD").is_ok() {
- println!("OFFLINE_BUILD is set");
- println!("Running yarn with '--offline' and '--ignore-scripts'.");
- run_command(
- Command::new(&args.yarn_bin)
- .arg("install")
- .arg("--offline")
- .arg("--ignore-scripts"),
- );
- } else {
- run_command(
- Command::new(&args.yarn_bin)
- .arg("install")
- .arg("--immutable"),
- );
- }
-
std::fs::write(args.stamp, b"").unwrap();
}