From 39a90f5ebefc8a57e902c74bb806dcf64e5a401f Mon Sep 17 00:00:00 2001 From: Bodebojo Date: Mon, 10 Nov 2025 14:11:03 +0100 Subject: [PATCH] fix(pkgfile): make pkgfile opt-in (#1449) Co-authored-by: Gideon <87426140+GideonBear@users.noreply.github.com> --- config.example.toml | 7 +++++++ src/config.rs | 17 +++++++++++++++++ src/steps/os/linux.rs | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/config.example.toml b/config.example.toml index a9e5846f..c7131d85 100644 --- a/config.example.toml +++ b/config.example.toml @@ -228,6 +228,13 @@ # enable = true +[pkgfile] +# Enable the pkgfile step (to update the pkgfile database). +# Pkgfile is sometimes installed by default, but often not used and heavy to update. +# (default: false) +# enable = true + + [git] # How many repos to pull at max in parallel # max_concurrency = 5 diff --git a/src/config.rs b/src/config.rs index 7015e429..ac9f9d9c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -402,6 +402,12 @@ pub struct Rustup { channels: Option>, } +#[derive(Deserialize, Default, Debug, Merge)] +#[serde(deny_unknown_fields)] +pub struct Pkgfile { + enable: Option, +} + #[derive(Deserialize, Default, Debug, Merge)] #[serde(deny_unknown_fields)] /// Configuration file @@ -492,6 +498,9 @@ pub struct ConfigFile { #[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)] rustup: Option, + + #[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)] + pkgfile: Option, } fn config_directory() -> PathBuf { @@ -1783,6 +1792,14 @@ impl Config { .and_then(|doom| doom.aot) .unwrap_or(false) } + + pub fn enable_pkgfile(&self) -> bool { + self.config_file + .pkgfile + .as_ref() + .and_then(|pkgfile| pkgfile.enable) + .unwrap_or(false) + } } #[cfg(test)] diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index c5fefe51..f526d8cc 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -710,6 +710,10 @@ pub fn run_pacstall(ctx: &ExecutionContext) -> Result<()> { pub fn run_pkgfile(ctx: &ExecutionContext) -> Result<()> { let pkgfile = require("pkgfile")?; + if !ctx.config().enable_pkgfile() { + return Err(SkipStep("Pkgfile isn't enabled".to_string()).into()); + } + print_separator("pkgfile"); let sudo = ctx.require_sudo()?;