Add make target to set a recipe rule to local or ignore

This commit is contained in:
Wildan M 2026-05-16 02:22:00 +07:00
parent 114833df68
commit 0ea9983bf9
No known key found for this signature in database
GPG Key ID: 01AC53185C679C79
2 changed files with 48 additions and 2 deletions

View File

@ -284,6 +284,22 @@ else
$(REPO_BIN) change-rule --set-rule=source $(foreach f,$(subst $(comma), ,$*),$(f)) --with-package-deps
endif
# Set specific recipe rule to "local" then invoke clean
lc.%: $(FSTOOLS_TAG) FORCE
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
$(REPO_BIN) change-rule-local --set-rule=local $(foreach f,$(subst $(comma), ,$*),$(f))
endif
# Set specific recipe rule to "ignore" then invoke clean
nc.%: $(FSTOOLS_TAG) FORCE
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
$(REPO_BIN) change-rule-local --set-rule=ignore $(foreach f,$(subst $(comma), ,$*),$(f))
endif
# Reset recipe rule then invoke clean
cc.%: $(FSTOOLS_TAG) FORCE
ifeq ($(PODMAN_BUILD),1)
@ -302,6 +318,26 @@ scr.%: $(FSTOOLS_TAG) FORCE
$(MAKE) sc.$*
$(MAKE) r.$*,--with-package-deps
# Set specific recipe rule to "local" then invoke clean and rebuild
lcr.%: $(FSTOOLS_TAG) FORCE
$(MAKE) lc.$*
$(MAKE) r.$*
# Set specific recipe rule to "ignore" then invoke clean and rebuild
ncr.%: $(FSTOOLS_TAG) FORCE
$(MAKE) nc.$*
$(MAKE) r.$*
# Set recipe rule to "binary" then invoke clean, rebuild and push
bcrp.%: $(FSTOOLS_TAG) FORCE
$(MAKE) bcr.$*
$(MAKE) p.$*
# Set recipe rule to "source" then invoke clean, rebuild and push
scrp.%: $(FSTOOLS_TAG) FORCE
$(MAKE) scr.$*
$(MAKE) p.$*
# Save current git rev for next recipe fetch, locking git recipes frozen in time
repo-lock: $(FSTOOLS_TAG) FORCE
ifeq ($(PODMAN_BUILD),1)

View File

@ -57,6 +57,7 @@ const REPO_HELP_STR: &str = r#"
push-tree show tree of recipe packages
capture-rev write lock to git recipes
change-rule override rule to recipes
change-rule-local override rule to specific recipes
common flags:
--cookbook=<cookbook_dir> the "recipes" folder, default to $PWD/recipes
@ -115,6 +116,7 @@ enum CliCommand {
Find,
CaptureRev,
ChangeRule,
ChangeRuleLocal,
}
impl CliCommand {
@ -154,6 +156,7 @@ impl FromStr for CliCommand {
"find" => Ok(CliCommand::Find),
"capture-rev" => Ok(CliCommand::CaptureRev),
"change-rule" => Ok(CliCommand::ChangeRule),
"change-rule-local" => Ok(CliCommand::ChangeRuleLocal),
_ => bail_options_err!("Unknown command {:?}", s),
}
}
@ -173,6 +176,7 @@ impl ToString for CliCommand {
CliCommand::Find => "find".to_string(),
CliCommand::CaptureRev => "capture-rev".to_string(),
CliCommand::ChangeRule => "change-rule".to_string(),
CliCommand::ChangeRuleLocal => "change-rule-local".to_string(),
}
}
}
@ -263,7 +267,10 @@ fn main_inner() -> Result<()> {
if command == CliCommand::Push {
return handle_push(&recipes, &config);
}
if matches!(command, CliCommand::ChangeRule | CliCommand::CaptureRev) {
if matches!(
command,
CliCommand::ChangeRule | CliCommand::ChangeRuleLocal | CliCommand::CaptureRev
) {
return handle_change_rule(&recipes, &config, &command);
}
@ -975,7 +982,10 @@ fn handle_change_rule(
) -> Result<()> {
let mut lock = get_config().recipe_lock.clone();
let cookbook_date = get_git_commit_date(&PathBuf::from("."))?;
let is_change_rule = matches!(command, CliCommand::ChangeRule);
let is_change_rule = matches!(
command,
CliCommand::ChangeRule | CliCommand::ChangeRuleLocal
);
let is_capture_rev = matches!(command, CliCommand::CaptureRev);
for recipe in recipes {
if is_change_rule && recipe.name.is_host() {