mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-30 00:28:44 +08:00
Fix config rule reload
This commit is contained in:
parent
5dfb3d6e6a
commit
e455f6139e
@ -514,32 +514,9 @@ fn parse_args(args: Vec<String>) -> anyhow::Result<(CliConfig, CliCommand, Vec<C
|
||||
}
|
||||
}
|
||||
};
|
||||
match last_rule {
|
||||
// build from source as usual
|
||||
"source" => {}
|
||||
// keep local changes
|
||||
"local" => recipe.recipe.source = None,
|
||||
// download from remote build
|
||||
"binary" => {
|
||||
recipe.recipe.source = None;
|
||||
recipe.recipe.build.set_as_remote();
|
||||
}
|
||||
// don't build this recipe (unlikely to go here unless some deps need it)
|
||||
// TODO: Note that we're assuming this being ignored from e.g. metapackages
|
||||
// TODO: Will totally broke build if this recipe needed as some other build dependencies
|
||||
"ignore" => {
|
||||
recipe.recipe.source = None;
|
||||
recipe.recipe.build.set_as_none();
|
||||
}
|
||||
rule => {
|
||||
bail!(
|
||||
// Fail fast because we could risk losing local changes if "local" was typo'ed
|
||||
"Invalid pkg config {} = \"{}\"\nExpecting either 'source', 'local', 'binary' or 'ignore'",
|
||||
recipe.name.as_str(),
|
||||
rule
|
||||
);
|
||||
}
|
||||
}
|
||||
recipe
|
||||
.apply_filesystem_config(last_rule)
|
||||
.map_err(|e| anyhow!(e))?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -200,6 +200,7 @@ pub struct CookRecipe {
|
||||
pub target: &'static str,
|
||||
/// If false, it's listed on install config
|
||||
pub is_deps: bool,
|
||||
pub rule: String,
|
||||
}
|
||||
|
||||
impl Recipe {
|
||||
@ -254,6 +255,7 @@ impl CookRecipe {
|
||||
recipe,
|
||||
target,
|
||||
is_deps: false,
|
||||
rule: "".into(),
|
||||
})
|
||||
}
|
||||
|
||||
@ -420,8 +422,8 @@ impl CookRecipe {
|
||||
}
|
||||
|
||||
pub fn reload_recipe(&mut self) -> Result<(), PackageError> {
|
||||
let r = Self::from_path(&self.dir, true, self.name.is_host())?;
|
||||
self.recipe = r.recipe;
|
||||
self.recipe = Self::from_path(&self.dir, true, self.name.is_host())?.recipe;
|
||||
let _ = self.apply_filesystem_config(&self.rule.clone());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -437,6 +439,38 @@ impl CookRecipe {
|
||||
pub fn target_dir(&self) -> PathBuf {
|
||||
self.dir.join("target").join(self.target)
|
||||
}
|
||||
|
||||
pub fn apply_filesystem_config(&mut self, rule: &str) -> Result<(), String> {
|
||||
match rule {
|
||||
// build from source as usual
|
||||
"source" => {}
|
||||
// keep local changes
|
||||
"local" => self.recipe.source = None,
|
||||
// download from remote build
|
||||
"binary" => {
|
||||
self.recipe.source = None;
|
||||
self.recipe.build.set_as_remote();
|
||||
}
|
||||
// don't build this recipe (unlikely to go here unless some deps need it)
|
||||
// TODO: Note that we're assuming this being ignored from e.g. metapackages
|
||||
// TODO: Will totally broke build if this recipe needed as some other build dependencies
|
||||
"ignore" => {
|
||||
self.recipe.source = None;
|
||||
self.recipe.build.set_as_none();
|
||||
}
|
||||
rule => {
|
||||
return Err(format!(
|
||||
// Fail fast because we could risk losing local changes if "local" was typo'ed
|
||||
"Invalid pkg config {} = \"{}\"\nExpecting either 'source', 'local', 'binary' or 'ignore'",
|
||||
self.name.as_str(),
|
||||
rule
|
||||
));
|
||||
}
|
||||
}
|
||||
self.rule = rule.to_string();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user