Recipe rule improvements

This commit is contained in:
Wildan M 2026-07-10 12:32:47 +07:00
parent 35734c605f
commit bf76d8ad18
No known key found for this signature in database
GPG Key ID: 01AC53185C679C79
3 changed files with 25 additions and 11 deletions

View File

@ -42,6 +42,7 @@ fetch: prefix $(FSTOOLS_TAG) FORCE
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
rm -f $(REPO_TAG)
export PATH="$(PREFIX_PATH):$$PATH" && \
export COOKBOOK_HOST_SYSROOT="$(ROOT)/$(PREFIX_INSTALL)" && \
$(REPO_BIN) fetch $(COOKBOOK_OPTS) --with-package-deps
@ -150,7 +151,7 @@ else
endif
# Push all recipes specified by the filesystem config
push: $(FSTOOLS_TAG) FORCE
push: $(REPO_TAG) $(FSTOOLS_TAG) FORCE
ifeq ($(ALLOW_FSTOOLS),1)
@rm -f $(MOUNTED_TAG)
@if [ ! -d "$(MOUNT_DIR)" ]; then \
@ -172,7 +173,6 @@ endif
# Rebuild and push all recipes specified by the filesystem config
rebuild-push: $(FSTOOLS_TAG) FORCE
rm -f $(REPO_TAG)
$(MAKE) repo
$(MAKE) push
@ -244,7 +244,6 @@ install:
# Rebuild and install all recipes specified by the filesystem config
rebuild-install: $(FSTOOLS_TAG) FORCE
rm -f $(REPO_TAG)
$(MAKE) repo
$(MAKE) install
@ -336,6 +335,11 @@ scrp.%: $(FSTOOLS_TAG) FORCE
$(MAKE) scr.$*
$(MAKE) p.$*
# Set specific recipe rule to "local" then invoke clean, rebuild and push
lcrp.%: $(FSTOOLS_TAG) FORCE
$(MAKE) lcr.$*
$(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

@ -866,15 +866,21 @@ fn handle_nonstop_fail(recipe: &CookRecipe) -> cookbook::Result<()> {
fn handle_clean(recipe: &CookRecipe, _config: &CliConfig, command: &CliCommand) -> Result<bool> {
let mut dir = recipe.dir.join("target");
let mut cached = true;
let unfetch = matches!(*command, CliCommand::Unfetch);
let mut clean_target = true;
if matches!(*command, CliCommand::CleanTarget) {
dir = dir.join(redoxer::target())
}
if dir.exists() {
if unfetch && recipe.rule == "binary" {
// may contains downloaded binaries
clean_target = false;
}
if clean_target && dir.exists() {
remove_all(&dir)?;
cached = false;
}
let dir = recipe.dir.join("source");
if dir.exists() && matches!(*command, CliCommand::Unfetch) {
if dir.exists() && unfetch {
remove_all(&dir)?;
cached = false;
}
@ -1100,12 +1106,7 @@ fn handle_change_rule(
let mut fetch_cached = true;
if is_change_rule_local && !recipe.dir.join("source").exists() {
// previously, this is "binary", then user wants to hack around with the source, so we do fetch here
let mut recipe = recipe.clone();
recipe.rule = "source".into();
recipe.reload_recipe()?;
if recipe.recipe.source.is_some() {
fetch_cached = handle_fetch(&recipe, config, false, &None)?.cached;
}
fetch_cached = handle_fetch(&recipe, config, false, &None)?.cached;
}
let clean_cached = if !cached && is_change_rule {
handle_clean(recipe, config, &CliCommand::Clean)?

View File

@ -137,6 +137,15 @@ pub fn fetch_offline(recipe: &CookRecipe, logger: &PtyOut) -> Result<FetchResult
pub fn fetch(recipe: &CookRecipe, check_source: bool, logger: &PtyOut) -> Result<FetchResult> {
let recipe_dir = &recipe.dir;
let source_dir = recipe_dir.join("source");
let mut recipe = recipe;
let mut recipe_owned;
if recipe.rule == "local" && !source_dir.exists() {
// local source, but the source is missing
recipe_owned = recipe.clone();
recipe_owned.rule = "source".into();
recipe_owned.reload_recipe()?;
recipe = &recipe_owned;
}
match recipe.recipe.build.kind {
BuildKind::None => {
// the build function doesn't need source dir exists