Skip to content

Commit bf60f06

Browse files
committed
feat: add --rootchrootpkgs to customize chroot base packages
Introduces a new --rootchrootpkgs flag and BaseChrootPkgs config option to allow customization of packages installed when creating the base chroot. This solves the problem of multilib packages failing to build in chroot environments because multilib-devel was not available in the default base-devel installation. Related: #1355
1 parent c496199 commit bf60f06

File tree

8 files changed

+50
-5
lines changed

8 files changed

+50
-5
lines changed

man/paru.8

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,21 @@ Note that this is only a temp fix and only applies to this one build. You should
420420
ideally patch the package yourself or report the problem to the maintainer.
421421

422422
If you want to permanently add a package to the chroot use \fBparu -Ci package\fR
423-
to install packages into the master chroot.
423+
to install packages into the root chroot, or use \-\-rootchrootpkgs to specify
424+
packages that should be installed when the chroot is created.
425+
426+
.TP
427+
.B \-\-rootchrootpkgs <packages>
428+
Comma-separated list of packages to install when creating the root chroot.
429+
430+
Defaults to "base-devel" if not specified.
431+
432+
Unlike \-\-chrootpkgs (which installs packages temporarily before each build),
433+
\-\-rootchrootpkgs packages become part of the root chroot and persist across
434+
all builds.
435+
436+
This only affects chroot creation. To apply changes to an existing chroot,
437+
you must delete and recreate it.
424438

425439
.TP
426440
.B \-\-completioninterval <days>

man/paru.conf.5

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,23 @@ Passes arguments to makechrootpkg. These flags get passed to every instance
362362
where makechrootpkg is called by paru. Arguments are split on whitespace before
363363
being passed to makechrootpkg.
364364

365+
.TP
366+
.B RootChrootPkgs = Packages...
367+
Space-separated list of packages to install when creating the root chroot.
368+
369+
Defaults to "base-devel" if not specified.
370+
371+
Unlike \-\-chrootpkgs (which installs packages temporarily before each build),
372+
\-\-rootchrootpkgs packages become part of the root chroot and persist across
373+
all builds.
374+
375+
This only affects chroot creation. To apply changes to an existing chroot,
376+
you must delete and recreate it.
377+
378+
See \-\-rootchrootpkgs in
379+
.BR paru(8)
380+
for more details.
381+
365382
.TP
366383
.B Pager = Command
367384
Command to use for paging

src/chroot.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct Chroot {
1919
pub ro: Vec<String>,
2020
pub rw: Vec<String>,
2121
pub extra_pkgs: Vec<String>,
22+
pub root_pkgs: Vec<String>,
2223
}
2324

2425
fn pacman_conf(pacman_conf: &str) -> Result<tempfile::NamedTempFile> {
@@ -44,7 +45,7 @@ impl Chroot {
4445
self.path.join("root").exists()
4546
}
4647

47-
pub fn create<S: AsRef<OsStr>>(&self, config: &Config, pkgs: &[S]) -> Result<()> {
48+
pub fn create(&self, config: &Config) -> Result<()> {
4849
let mut cmd = Command::new(&config.sudo_bin);
4950
cmd.arg("install").arg("-dm755").arg(&self.path);
5051
exec::command(&mut cmd)?;
@@ -59,7 +60,7 @@ impl Chroot {
5960
.arg("-M")
6061
.arg(&self.makepkg_conf)
6162
.arg(dir)
62-
.args(pkgs);
63+
.args(&self.root_pkgs);
6364

6465
exec::command(&mut cmd)?;
6566
Ok(())

src/command_line.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ impl Config {
198198
Arg::Long("chrootpkgs") => self
199199
.chroot_pkgs
200200
.extend(value?.split(',').map(|s| s.to_string())),
201+
Arg::Long("rootchrootpkgs") => self
202+
.root_chroot_pkgs
203+
.extend(value?.split(',').map(|s| s.to_string())),
201204

202205
Arg::Long("develsuffixes") => self.devel_suffixes = split_whitespace(value?),
203206
Arg::Long("installdebug") => self.install_debug = true,
@@ -412,6 +415,7 @@ fn takes_value(arg: Arg) -> TakesValue {
412415
Arg::Long("fmflags") => TakesValue::Required,
413416
Arg::Long("chrootflags") => TakesValue::Required,
414417
Arg::Long("chrootpkgs") => TakesValue::Required,
418+
Arg::Long("rootchrootpkgs") => TakesValue::Required,
415419
Arg::Long("completioninterval") => TakesValue::Required,
416420
Arg::Long("sortby") => TakesValue::Required,
417421
Arg::Long("searchby") => TakesValue::Required,

src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@ pub struct Config {
516516
pub chroot_dir: PathBuf,
517517
pub chroot: bool,
518518
pub chroot_pkgs: Vec<String>,
519+
#[default(vec!["base-devel".to_string()])]
520+
pub root_chroot_pkgs: Vec<String>,
519521
pub install: bool,
520522
pub uninstall: bool,
521523
pub sysupgrade: bool,
@@ -1100,6 +1102,10 @@ then initialise it with:
11001102
.ok_or_else(|| anyhow!(tr!("value can not be empty for key '{}'", key)));
11011103

11021104
match key {
1105+
"RootChrootPkgs" => {
1106+
self.root_chroot_pkgs
1107+
.extend(value?.split_whitespace().map(|s| s.to_string()));
1108+
}
11031109
"AurUrl" => self.aur_url = value?.parse()?,
11041110
"AurRpcUrl" => self.aur_rpc_url = Some(value?.parse()?),
11051111
"BuildDir" | "CloneDir" => self.build_dir = PathBuf::from(value?),

src/help.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub fn help() {
8686
printtr!(" --[no]signdb Sign databases with gpg");
8787
printtr!(" --[no]localrepo Build packages into a local repo");
8888
printtr!(" --nocheck Don't resolve checkdepends or run the check function");
89+
printtr!(" --rootchrootpkgs Packages to install in the root chroot (default: base-devel)");
8990
printtr!(" --develsuffixes Suffixes used to decide if a package is a devel package");
9091
printtr!(" --ignoredevel Ignore devel upgrades for specified packages");
9192
printtr!(" --bottomup Shows AUR's packages first and then repository's");

src/install.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ impl Installer {
856856

857857
if config.chroot {
858858
if !self.chroot.exists() {
859-
self.chroot.create(config, &["base-devel"])?;
859+
self.chroot.create(config)?;
860860
} else {
861861
self.chroot.update()?;
862862
}
@@ -1851,6 +1851,7 @@ fn chroot(config: &Config) -> Chroot {
18511851
ro: repo::all_files(config),
18521852
rw: config.pacman.cache_dir.clone(),
18531853
extra_pkgs: config.chroot_pkgs.clone(),
1854+
root_pkgs: config.root_chroot_pkgs.clone(),
18541855
};
18551856

18561857
if config.args.count("d", "nodeps") > 1 {

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ fn handle_chroot(config: &Config) -> Result<i32> {
429429
ro: repo::all_files(config),
430430
rw: config.pacman.cache_dir.clone(),
431431
extra_pkgs: config.chroot_pkgs.clone(),
432+
root_pkgs: config.root_chroot_pkgs.clone(),
432433
};
433434

434435
if config.print {
@@ -437,7 +438,7 @@ fn handle_chroot(config: &Config) -> Result<i32> {
437438
}
438439

439440
if !chroot.exists() {
440-
chroot.create(config, &["base-devel"])?;
441+
chroot.create(config)?;
441442
}
442443

443444
if config.sysupgrade {

0 commit comments

Comments
 (0)