fix(pkgfile): make pkgfile opt-in (#1449)

Co-authored-by: Gideon <87426140+GideonBear@users.noreply.github.com>
This commit is contained in:
Bodebojo
2025-11-10 14:11:03 +01:00
committed by GitHub
parent 80c4bd5065
commit 39a90f5ebe
3 changed files with 28 additions and 0 deletions

View File

@@ -228,6 +228,13 @@
# enable = true # 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] [git]
# How many repos to pull at max in parallel # How many repos to pull at max in parallel
# max_concurrency = 5 # max_concurrency = 5

View File

@@ -402,6 +402,12 @@ pub struct Rustup {
channels: Option<Vec<String>>, channels: Option<Vec<String>>,
} }
#[derive(Deserialize, Default, Debug, Merge)]
#[serde(deny_unknown_fields)]
pub struct Pkgfile {
enable: Option<bool>,
}
#[derive(Deserialize, Default, Debug, Merge)] #[derive(Deserialize, Default, Debug, Merge)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
/// Configuration file /// Configuration file
@@ -492,6 +498,9 @@ pub struct ConfigFile {
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)] #[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
rustup: Option<Rustup>, rustup: Option<Rustup>,
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
pkgfile: Option<Pkgfile>,
} }
fn config_directory() -> PathBuf { fn config_directory() -> PathBuf {
@@ -1783,6 +1792,14 @@ impl Config {
.and_then(|doom| doom.aot) .and_then(|doom| doom.aot)
.unwrap_or(false) .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)] #[cfg(test)]

View File

@@ -710,6 +710,10 @@ pub fn run_pacstall(ctx: &ExecutionContext) -> Result<()> {
pub fn run_pkgfile(ctx: &ExecutionContext) -> Result<()> { pub fn run_pkgfile(ctx: &ExecutionContext) -> Result<()> {
let pkgfile = require("pkgfile")?; let pkgfile = require("pkgfile")?;
if !ctx.config().enable_pkgfile() {
return Err(SkipStep("Pkgfile isn't enabled".to_string()).into());
}
print_separator("pkgfile"); print_separator("pkgfile");
let sudo = ctx.require_sudo()?; let sudo = ctx.require_sudo()?;