diff --git a/man/paru.conf.5 b/man/paru.conf.5 index b2944f9c8..94804bfce 100644 --- a/man/paru.conf.5 +++ b/man/paru.conf.5 @@ -8,7 +8,7 @@ paru.conf \- paru configuration file $PARU_CONF, $XDG_CONFIG_HOME/paru/paru.conf, $HOME/.config/paru/paru.conf, /etc/paru.conf .SH DESCRIPTION -Paru's config file. Based on the format used by +Paru's config file. Based on the format used by .BR pacman.conf (5) Paru first attempts to read the file at $PARU_CONF. If $PARU_CONF is not @@ -187,7 +187,7 @@ during builds allowing an option to be chosen then. .TP .B UpgradeMenu Show a detailed list of updates in a similar format to pacman's VerbosePkgLists -option. (See +option. (See .BR pacman.conf(5)). Upgrades can be skipped using numbers, number ranges, or repo names. @@ -217,7 +217,7 @@ visible here: https://aur.archlinux.org/packages/ .TP .B SearchBy = -Defaults to name-desc. Search AUR packages according to the options in +Defaults to name-desc. Search AUR packages according to the options in "Search by" visible here: https://aur.archlinux.org/packages/ .TP @@ -498,3 +498,87 @@ Skip review for this repository. .B GenerateSrcinfo Force regeneration of the .SRCINFO file even if it exists on disk. This is useful for repositories that forget to update their .SRCINFO files. + +.SH PER-PACKAGE BUILD OVERRIDES +Per-package build overrides allow customizing build settings for specific packages. +There are two types of override sections: package overrides and group overrides. + +Package overrides always take precedence over group overrides. When multiple group +overrides apply to the same package, later groups in the config file merge over +earlier ones, with conflicting keys being overwritten. + +.SS PACKAGE OVERRIDES + +A package override section targets a single package by name: + +.RS +\fB[override.package.\fR\fIpkgname\fR\fB]\fR +.RE + +.TP +.B MakepkgConf = /path/to/makepkg.conf +Use a different makepkg.conf for building this package. This overrides the global +MakepkgConf option for this package only. + +.TP +.B Overrides = { KEY = value, KEY2 = "value2" } +Set environment variables for building this package. Values may optionally be +quoted with double quotes. Multiple key-value pairs are separated by commas. + +.TP +.B PkgbuildPatches = { https://url-patch.patch, /local/patch.patch } +List patches for the PKGBUILD to apply to the PKGBUILD before building this +package. You may for example add patches to the source of PKGBUILD by adding them +locally then generating a PKGBUILD patch. + +.SS GROUP OVERRIDES + +A group override section applies the same settings to multiple packages: + +.RS +\fB[override.group.\fR\fIgroupname\fR\fB]\fR +.RE + +.TP +.B Packages = pkg1 pkg2 pkg3 +Space-separated list of package names this group applies to. This directive is +required for group overrides. + +.TP +.B MakepkgConf = /path/to/makepkg.conf +Same as the package override equivalent. + +.TP +.B Overrides = { KEY = value, KEY2 = "value2" } +Same as the package override equivalent. + +.SS EXAMPLES + +Use a custom makepkg.conf for a specific package: + +.RS +.nf +[override.package.firefox] +MakepkgConf = /etc/makepkg-pgo.conf +.fi +.RE + +Set custom compiler flags for a group of packages: + +.RS +.nf +[override.group.lto-builds] +Packages = mesa vulkan-radeon +MakepkgConf = /etc/makepkg-lto.conf +Overrides = { MAKEFLAGS = "-j$(nproc)", CFLAGS = "-O3 -march=native" } +.fi +.RE + +Override environment variables for a single package: + +.RS +.nf +[override.package.linux-zen] +Overrides = { MAKEFLAGS = "-j4", CARGO_BUILD_JOBS = "4" } +.fi +.RE diff --git a/src/config.rs b/src/config.rs index c86fbcb53..2e9c5dfb0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,15 +4,17 @@ use crate::exec::{self, Status}; use crate::fmt::color_repo; use crate::info::get_terminal_width; use crate::pkgbuild::PkgbuildRepos; -use crate::util::{get_provider, reopen_stdin}; +use crate::util::{get_provider, reopen_stdin, split_by_comma}; use crate::{alpm_debug_enabled, help, printtr, repo}; +use std::collections::HashMap; use std::env::consts::ARCH; use std::env::var; use std::fmt; use std::fs::{OpenOptions, remove_file}; use std::io::{BufRead, IsTerminal, stderr, stdin, stdout}; use std::path::{Path, PathBuf}; +use std::process::Command; use std::str::FromStr; use alpm::{ @@ -25,6 +27,7 @@ use anyhow::{Context, Error, Result, anyhow, bail, ensure}; use bitflags::bitflags; use cini::{Callback, CallbackKind, Ini}; use globset::{Glob, GlobSet, GlobSetBuilder}; +use reqwest::get; use tr::tr; use url::Url; @@ -395,6 +398,108 @@ impl ConfigEnum for YesNoAllTree { ]; } +#[derive(Debug, Clone)] +pub enum PatchSource { + Path(PathBuf), + Url(Url), +} + +impl PatchSource { + pub async fn apply(&self, config: &Config, dir: &Path) -> Result<()> { + match self { + PatchSource::Path(path) => { + let patch_path = if path.is_absolute() { + path.clone() + } else { + dir.join(path) + }; + + let mut cmd = Command::new(&config.git_bin); + cmd.arg("apply").arg("-v").arg(&patch_path).current_dir(dir); + + exec::command(&mut cmd) + .with_context(|| tr!("failed to apply patch '{}'", patch_path.display()))?; + } + PatchSource::Url(url) => { + let bytes = get(url.clone()) + .await + .with_context(|| tr!("Failed to download patch from {}", url))? + .error_for_status() + .with_context(|| tr!("Failed to download patch from {}", url))? + .bytes() + .await?; + + // tempfile for patch. + let mut temp = tempfile::NamedTempFile::new()?; + use std::io::Write; + temp.write_all(&bytes)?; + + let mut cmd = Command::new(&config.git_bin); + cmd.arg("apply").arg("-v").arg(temp.path()).current_dir(dir); + + exec::command(&mut cmd) + .with_context(|| tr!("failed to apply patch '{}'", temp.path().display()))?; + } // tempfile cleaned up safely by drop. + } + + Ok(()) + } +} + +impl FromStr for PatchSource { + type Err = Error; + + fn from_str(s: &str) -> Result { + if let Ok(url) = Url::parse(s) { + Ok(PatchSource::Url(url)) + } else { + Ok(PatchSource::Path(PathBuf::from(s))) + } + } +} + +#[derive(Debug, Default, Clone)] +pub struct PackageOverride { + pub makepkg_conf: Option, + pub env: Vec<(String, String)>, + pub pkgbuild_patches: Vec, +} + +impl PackageOverride { + pub(crate) fn merge_from(&mut self, src: &PackageOverride) { + if src.makepkg_conf.is_some() { + self.makepkg_conf = src.makepkg_conf.clone(); + } + + for (k, v) in &src.env { + if let Some(existing) = self.env.iter_mut().find(|(ek, _)| ek == k) { + existing.1 = v.clone(); + } else { + self.env.push((k.clone(), v.clone())); + } + } + + self.pkgbuild_patches + .extend(src.pkgbuild_patches.iter().cloned()); + } +} + +#[derive(Debug)] +enum OverrideParseState { + Package { + name: String, + makepkg_conf: Option, + env: Vec<(String, String)>, + pkgbuild_patches: Vec, + }, + Group { + name: String, + packages: Vec, + makepkg_conf: Option, + env: Vec<(String, String)>, + }, +} + #[derive(SmartDefault, Debug)] pub struct Config { section: Option, @@ -547,6 +652,9 @@ pub struct Config { pub env: Vec<(String, String)>, + pub overrides: HashMap, + override_parse_state: Option, + //pacman pub db_path: Option, pub root: Option, @@ -573,15 +681,41 @@ impl Ini for Config { fn callback(&mut self, cb: Callback) -> Result<(), Self::Err> { let err = match cb.kind { CallbackKind::Section(section) => { + self.finalize_override()?; self.section = Some(section.to_string()); if !matches!(section, "options" | "bin" | "env") && self.pkgbuild_repos.repo(section).is_none() { - if matches!(section, "local" | "aur" | "pkg" | "base") || section.contains('.') - { + if matches!(section, "local" | "aur" | "pkg" | "base") { + bail!(tr!("section can not be called {}", section)); + } + if let Some(rest) = section.strip_prefix("override.package.") { + ensure!( + !rest.is_empty(), + tr!("override.package section requires a package name") + ); + self.override_parse_state = Some(OverrideParseState::Package { + name: rest.to_string(), + makepkg_conf: None, + env: Vec::new(), + pkgbuild_patches: Vec::new(), + }); + } else if let Some(rest) = section.strip_prefix("override.group.") { + ensure!( + !rest.is_empty(), + tr!("override.group section requires a group name") + ); + self.override_parse_state = Some(OverrideParseState::Group { + name: rest.to_string(), + packages: Vec::new(), + makepkg_conf: None, + env: Vec::new(), + }); + } else if section.contains('.') { bail!(tr!("section can not be called {}", section)); + } else { + self.pkgbuild_repos.add_repo(section.to_string()); } - self.pkgbuild_repos.add_repo(section.to_string()); } Ok(()) } @@ -697,6 +831,8 @@ impl Config { } pub fn parse_args, I: IntoIterator>(&mut self, iter: I) -> Result<()> { + self.finalize_override()?; + let iter = iter.into_iter(); let mut iter = iter.peekable(); let mut op_count = 0; @@ -994,6 +1130,10 @@ then initialise it with: let section = section.to_string(); + if section.starts_with("override.") { + return self.parse_override_directive(key, value); + } + match section.as_str() { "options" => self.parse_option(key, value), "bin" => self.parse_bin(key, value), @@ -1200,6 +1340,134 @@ then initialise it with: Ok(()) } + fn parse_override_directive(&mut self, key: &str, value: Option<&str>) -> Result<()> { + let state = self + .override_parse_state + .as_mut() + .context("override directive outside of override section")?; + + match key { + "MakepkgConf" => { + let value = value + .context(tr!("value can not be empty for key '{}'", key))? + .to_string(); + match state { + OverrideParseState::Package { makepkg_conf, .. } + | OverrideParseState::Group { makepkg_conf, .. } => { + *makepkg_conf = Some(value); + } + } + } + "Packages" => { + let value = value.context(tr!("value can not be empty for key '{}'", key))?; + match state { + OverrideParseState::Package { .. } => { + bail!(tr!( + "'Packages' is not valid in [override.package.*] sections" + )); + } + OverrideParseState::Group { packages, .. } => { + packages.extend(value.split_whitespace().map(|s| s.to_string())); + } + } + } + "Overrides" => { + let value = value.context(tr!("value can not be empty for key '{}'", key))?; + let parsed = parse_overrides_map(value)?; + match state { + OverrideParseState::Package { env, .. } + | OverrideParseState::Group { env, .. } => { + env.extend(parsed); + } + } + } + "PkgbuildPatches" => { + let value = value.context(tr!("value can not be empty for key '{}'", key))?; + let parsed = parse_patches_list(value)?; + match state { + OverrideParseState::Package { + pkgbuild_patches, .. + } => { + pkgbuild_patches.extend(parsed); + } + OverrideParseState::Group { .. } => { + bail!(tr!( + "'PkgbuildPatches' is not valid in [override.group.*] sections" + )); + } + } + } + _ => eprintln!( + "{}", + tr!("error: unknown option '{}' in override section", key) + ), + } + + Ok(()) + } + + fn finalize_override(&mut self) -> Result<()> { + let state = match self.override_parse_state.take() { + Some(s) => s, + None => return Ok(()), + }; + + match state { + OverrideParseState::Package { + name, + makepkg_conf, + env, + pkgbuild_patches, + } => { + ensure!( + makepkg_conf.is_some() || !env.is_empty() || !pkgbuild_patches.is_empty(), + tr!( + "override.package.{} must have MakepkgConf, Overrides or PkgbuildPatches", + name + ) + ); + self.overrides.insert( + name, + PackageOverride { + makepkg_conf, + env, + pkgbuild_patches, + }, + ); + } + OverrideParseState::Group { + name, + packages, + makepkg_conf, + env, + } => { + ensure!( + !packages.is_empty(), + tr!("override.group.{} must have a Packages directive", name) + ); + ensure!( + makepkg_conf.is_some() || !env.is_empty(), + tr!("override.group.{} must have MakepkgConf or Overrides", name) + ); + for pkg in packages { + let entry = self.overrides.entry(pkg).or_default(); + if let Some(ref conf) = makepkg_conf { + entry.makepkg_conf = Some(conf.clone()); + } + for (k, v) in &env { + if let Some(existing) = entry.env.iter_mut().find(|(ek, _)| ek == k) { + existing.1 = v.clone(); + } else { + entry.env.push((k.clone(), v.clone())); + } + } + } + } + } + + Ok(()) + } + pub fn aur_namespace(&self) -> &'static str { if self.pacman.repos.iter().any(|r| r.name == "aur") { // hack for search install @@ -1210,6 +1478,82 @@ then initialise it with: } } +fn parse_overrides_map(input: &str) -> Result> { + let input = input.trim(); + let inner = input + .strip_prefix('{') + .and_then(|s| s.strip_suffix('}')) + .context(tr!("Overrides value must be wrapped in { }"))? + .trim(); + + if inner.is_empty() { + return Ok(Vec::new()); + } + + let mut result = Vec::new(); + let pairs = split_by_comma(inner); + + for pair in &pairs { + let pair = pair.trim(); + if pair.is_empty() { + continue; + } + let (key, value) = pair + .split_once('=') + .context(tr!("invalid override entry, expected KEY = value"))?; + let key = key.trim().to_string(); + let value = value.trim(); + let value = value + .strip_prefix('"') + .and_then(|s| s.strip_suffix('"')) + .unwrap_or(value) + .to_string(); + + ensure!(!key.is_empty(), tr!("override key can not be empty")); + ensure!( + !key.contains('\0'), + tr!("override key can not contain null bytes") + ); + ensure!( + !value.contains('\0'), + tr!("override value can not contain null bytes") + ); + + result.push((key, value)); + } + + Ok(result) +} + +fn parse_patches_list(input: &str) -> Result> { + let input = input.trim(); + let inner = input + .strip_prefix('{') + .and_then(|s| s.strip_suffix('}')) + .context(tr!("PkgbuildPatches value must be wrapped in { }"))? + .trim(); + + if inner.is_empty() { + return Ok(Vec::new()); + } + + let parts = split_by_comma(inner); + + let mut result = Vec::new(); + for part in parts { + let value = part + .strip_prefix('"') + .and_then(|s| s.strip_suffix('"')) + .unwrap_or(part.as_str()) + .to_string(); + + ensure!(!value.is_empty(), tr!("Patch source can not be empty")); + result.push(value.parse()?); + } + + Ok(result) +} + pub fn version() { let ver = option_env!("PARU_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")); print!("paru v{}", ver); @@ -1359,7 +1703,7 @@ mod sort_tests { #[cfg(test)] mod tests { - use super::{Config, parse_release_age}; + use super::{Config, parse_overrides_map, parse_release_age}; use globset::{Glob, GlobSetBuilder}; #[test] @@ -1419,4 +1763,44 @@ mod tests { assert!(!config.is_too_new("trusted-pkg", 100, 100, 60)); assert!(config.is_too_new("pkg", 100, 100, 60)); } + + #[test] + fn test_parse_overrides_map_comma_in_quoted_value() { + let result = parse_overrides_map(r#"{ LDFLAGS = "-Wl,--as-needed" }"#).unwrap(); + assert_eq!( + result, + vec![("LDFLAGS".to_string(), "-Wl,--as-needed".to_string())] + ); + } + + #[test] + fn test_parse_overrides_map_comma_in_quoted_value_multiple() { + let result = + parse_overrides_map(r#"{ LDFLAGS = "-Wl,--as-needed", CFLAGS = "-O2" }"#).unwrap(); + assert_eq!( + result, + vec![ + ("LDFLAGS".to_string(), "-Wl,--as-needed".to_string()), + ("CFLAGS".to_string(), "-O2".to_string()), + ] + ); + } + + #[test] + fn test_parse_overrides_map_basic() { + let result = parse_overrides_map(r#"{ CFLAGS = "-O3", MAKEFLAGS = "-j8" }"#).unwrap(); + assert_eq!( + result, + vec![ + ("CFLAGS".to_string(), "-O3".to_string()), + ("MAKEFLAGS".to_string(), "-j8".to_string()), + ] + ); + } + + #[test] + fn test_parse_overrides_map_empty() { + let result = parse_overrides_map("{ }").unwrap(); + assert!(result.is_empty()); + } } diff --git a/src/exec.rs b/src/exec.rs index 509d9d084..1152a4bd2 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -214,6 +214,10 @@ fn new_makepkg>( pkgdest: Option<&str>, ) -> Command { let mut cmd = Command::new(&config.makepkg_bin); + cmd.envs(config.env.iter().map(|(key, value)| (key, value))); + if config.chroot { + cmd.env_remove("PKGEXT"); + } if let Some(mconf) = &config.makepkg_conf { cmd.arg("--config").arg(mconf); } @@ -255,3 +259,28 @@ pub fn makepkg_output>(config: &Config, dir: &Path, args: &[S]) pub fn has_command(name: &str) -> bool { Command::new(name).arg("--version").output().is_ok() } + +#[cfg(test)] +mod tests { + use super::makepkg_output; + use crate::config::Config; + use std::path::Path; + + #[test] + fn makepkg_overrides_reach_child_without_changing_parent_environment() { + let key = "PARU_TEST_MAKEPKG_OVERRIDE"; + let inherited = std::env::var_os(key); + let mut config = Config::default(); + config.makepkg_bin = "/bin/sh".into(); + config.env = vec![(key.into(), "package-specific".into())]; + let output = makepkg_output( + &config, + Path::new("."), + &["-c", "printf '%s' \"$PARU_TEST_MAKEPKG_OVERRIDE\""], + ) + .unwrap(); + assert!(output.status.success()); + assert_eq!(output.stdout, b"package-specific"); + assert_eq!(std::env::var_os(key), inherited); + } +} diff --git a/src/install.rs b/src/install.rs index f00a2ae0e..022e4786e 100644 --- a/src/install.rs +++ b/src/install.rs @@ -13,7 +13,9 @@ use crate::args::{Arg, Args}; use crate::chroot::Chroot; use crate::clean::clean_untracked; use crate::completion::update_aur_cache; -use crate::config::{Config, LocalRepos, Mode, Op, Sign, YesNoAllTree, YesNoAsk}; +use crate::config::{ + Config, LocalRepos, Mode, Op, PackageOverride, PatchSource, Sign, YesNoAllTree, YesNoAsk, +}; use crate::devel::{DevelInfo, fetch_devel_info, load_devel_info, save_devel_info}; use crate::download::{self, Bases}; use crate::exec::{command_status, has_command}; @@ -515,16 +517,55 @@ impl Installer { } // TODO: sort out args - fn build_pkgbuild( + async fn build_pkgbuild( &mut self, config: &mut Config, base: &mut Base, repo: Option<(&str, &str)>, dir: &Path, + cwd: &Path, ) -> Result<(HashMap, String)> { - let c = config.color; let pkgdest = repo.map(|r| r.1); + // Apply per-package overrides + let pkg_override = get_base_override(config, base); + let saved_makepkg_conf = config.makepkg_conf.clone(); + let saved_chroot_makepkg_conf = self.chroot.makepkg_conf.clone(); + let saved_env = config.env.clone(); + + if let Some(ref ov) = pkg_override { + apply_patches(config, cwd, &ov.pkgbuild_patches).await?; + + if let Some(ref conf) = ov.makepkg_conf { + config.makepkg_conf = Some(conf.clone()); + if config.chroot { + self.chroot.makepkg_conf = conf.clone(); + } + } + // Keep overrides local to child commands; Tokio may already have threads running. + config.env.extend(ov.env.iter().cloned()); + } + + let result = self.build_pkgbuild_inner(config, base, repo, dir, pkgdest); + + // Restore original config + config.makepkg_conf = saved_makepkg_conf; + self.chroot.makepkg_conf = saved_chroot_makepkg_conf; + config.env = saved_env; + + result + } + + fn build_pkgbuild_inner( + &mut self, + config: &mut Config, + base: &mut Base, + repo: Option<(&str, &str)>, + dir: &Path, + pkgdest: Option<&str>, + ) -> Result<(HashMap, String)> { + let c = config.color; + if config.chroot { let mut extra = Vec::new(); if config.repos == LocalRepos::None { @@ -707,11 +748,12 @@ impl Installer { Ok(()) } - fn build_install_pkgbuild( + async fn build_install_pkgbuild( &mut self, config: &mut Config, base: &mut Base, repo: Option<(&str, &str)>, + cwd: &Path, ) -> Result<()> { let dir = match base { Base::Aur(_) => config.build_dir.join(base.package_base()), @@ -789,7 +831,7 @@ impl Installer { } let (mut pkgdest, version) = if build { - self.build_pkgbuild(config, base, repo, &dir)? + self.build_pkgbuild(config, base, repo, &dir, cwd).await? } else { printtr!("{}: parsing pkg list...", base); let (pkgdests, version) = parse_package_list(config, &dir, pkgdest)?; @@ -845,6 +887,7 @@ impl Installer { &mut self, config: &mut Config, build: &mut [Base], + cwd: &Path, ) -> Result<()> { if config.devel { printtr!("fetching devel info..."); @@ -877,9 +920,9 @@ impl Installer { .as_ref() .map(|(name, file)| (name.as_str(), file.as_str())); - let err = self.build_install_pkgbuild(config, base, repo_server); + let err = self.build_install_pkgbuild(config, base, repo_server, cwd); - match err { + match err.await { Ok(_) => { self.failed.pop().unwrap(); } @@ -944,7 +987,8 @@ impl Installer { config.pkgbuild_repos.refresh(config)?; self.done_something = true; } - self.resolve_targets(config, &repo_targets, &aur_targets) + let cwd = std::env::current_dir()?; + self.resolve_targets(config, &repo_targets, &aur_targets, &cwd) .await } @@ -953,6 +997,7 @@ impl Installer { config: &mut Config, repo_targets: &[Targ<'a>], aur_targets: &[Targ<'a>], + cwd: &Path, ) -> Result<()> { if (config.mode.aur() || config.mode.pkgbuild()) && (self.sysupgrade != 0 || !aur_targets.is_empty()) @@ -1001,7 +1046,7 @@ impl Installer { targets.extend(self.upgrades.repo_keep.iter().map(Targ::from)); - if self.shoud_just_pacman(config.mode, aur_targets, &self.upgrades, self.ran_pacman) { + if self.should_just_pacman(config.mode, aur_targets, &self.upgrades, self.ran_pacman) { print_warnings(config, &cache, None); let mut args = config.pacman_args(); let targets = targets.iter().map(|t| t.to_string()).collect::>(); @@ -1048,7 +1093,7 @@ impl Installer { let mut err = Ok(()); if !build.is_empty() { - err = self.build_install_pkgbuilds(config, &mut build).await; + err = self.build_install_pkgbuilds(config, &mut build, cwd).await; } if err.is_ok() && config.chroot { @@ -1064,7 +1109,7 @@ impl Installer { err } - fn shoud_just_pacman( + fn should_just_pacman( &self, mode: Mode, aur_targets: &[Targ<'_>], @@ -1272,6 +1317,28 @@ impl Installer { } } +async fn apply_patches(config: &Config, dir: &Path, patches: &[PatchSource]) -> Result<()> { + for patch in patches { + patch.apply(config, dir).await?; + } + Ok(()) +} + +fn get_base_override(config: &Config, base: &Base) -> Option { + let mut result: Option = None; + + for pkg_name in base.packages() { + if let Some(ov) = config.overrides.get(pkg_name) { + match result { + None => result = Some(ov.clone()), + Some(ref mut merged) => merged.merge_from(ov), + } + } + } + + result +} + fn is_debug(pkg: &alpm::Package) -> bool { if let Some(base) = pkg.base() && pkg.name().ends_with("-debug") diff --git a/src/util.rs b/src/util.rs index 790ae369c..f1f514e24 100644 --- a/src/util.rs +++ b/src/util.rs @@ -452,6 +452,29 @@ pub fn is_arch_repo(name: &str) -> bool { ) } +pub fn split_by_comma(inner: &str) -> Vec { + let mut items = Vec::new(); + let mut current = String::new(); + let mut in_quotes = false; + + for ch in inner.chars() { + if ch == '"' { + in_quotes = !in_quotes; + current.push(ch); + } else if ch == ',' && !in_quotes { + items.push(std::mem::take(&mut current)); + } else { + current.push(ch); + } + } + + if !current.is_empty() { + items.push(current); + } + + items +} + #[cfg(all(test, feature = "mock"))] mod provider_tests { use super::split_repo_aur_targets; diff --git a/testdata/overrides/firefox-comment-addition.patch b/testdata/overrides/firefox-comment-addition.patch new file mode 100644 index 000000000..17b8dd057 --- /dev/null +++ b/testdata/overrides/firefox-comment-addition.patch @@ -0,0 +1,22 @@ +From 02db1a2f0f393209c4b8274de2755f12abe7859f Mon Sep 17 00:00:00 2001 +From: Toria +Date: Sat, 18 Apr 2026 20:11:43 +0100 +Subject: [PATCH] Test comment, PKGBUILD for url test. + +Signed-off-by: Toria +--- + PKGBUILD | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/PKGBUILD b/PKGBUILD +index 04f2e7d..a634854 100644 +--- a/PKGBUILD ++++ b/PKGBUILD +@@ -1,3 +1,4 @@ ++# This is for a test! + # Maintainer: Jan Alexander Steffens (heftig) + # Contributor: Ionut Biru + # Contributor: Jakub Schmidtke +-- +2.53.0 + diff --git a/testdata/overrides/firefox-pkgrel-bump.patch b/testdata/overrides/firefox-pkgrel-bump.patch new file mode 100644 index 000000000..5d74ce240 --- /dev/null +++ b/testdata/overrides/firefox-pkgrel-bump.patch @@ -0,0 +1,25 @@ +From cc955c6b5a182f8d0f0cd7dfa1cdc44bf5b0d11d Mon Sep 17 00:00:00 2001 +From: Toria +Date: Sat, 18 Apr 2026 20:04:10 +0100 +Subject: [PATCH] PKGREL bump for paru test. + +Signed-off-by: Toria +--- + PKGBUILD | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/PKGBUILD b/PKGBUILD +index 04f2e7d..ae4b0ee 100644 +--- a/PKGBUILD ++++ b/PKGBUILD +@@ -4,7 +4,7 @@ + + pkgname=firefox + pkgver=149.0.2 +-pkgrel=1 ++pkgrel=2 + pkgdesc="Fast, Private & Safe Web Browser" + url="https://www.mozilla.org/firefox/" + arch=(x86_64) +-- +2.53.0 diff --git a/testdata/paru.conf b/testdata/paru.conf index 99eb98f34..0544222c7 100644 --- a/testdata/paru.conf +++ b/testdata/paru.conf @@ -15,3 +15,13 @@ CARCH = x86_64 [pkgbuild] Path = testdata/pkgbuild-repo + +[override.package.firefox] +MakepkgConf = /etc/makepkg-pgo.conf +Overrides = { CFLAGS = "-O3", MAKEFLAGS = "-j8" } +PkgbuildPatches = { "overrides/firefox-pkgrel-bump.patch", "https://raw.githubusercontent.com/ninetailedtori/paru/refs/heads/pkgbuild-patches/testdata/overrides/firefox-comment-addition.patch" } + +[override.group.lto-builds] +Packages = mesa vulkan-radeon +MakepkgConf = /etc/makepkg-lto.conf +Overrides = { CFLAGS = "-flto" }