Replace COOKBOOK_OFFLINE with --offline

This commit is contained in:
bjorn3 2025-09-02 21:30:57 +02:00
parent 13d9e4794f
commit 04d88c6109
3 changed files with 12 additions and 15 deletions

View File

@ -3,15 +3,4 @@ set -e
source config.sh
recipes=""
for arg in "${@:1}"
do
if [ "$arg" == "--offline" ]
then
export COOKBOOK_OFFLINE="1"
else
recipes+=" $arg"
fi
done
target/release/cook --fetch-only $recipes
target/release/cook --fetch-only ${@:1}

View File

@ -20,7 +20,7 @@ do
COOK_OPT+=" --nonstop"
elif [ "$arg" == "--offline" ]
then
export COOKBOOK_OFFLINE="1"
COOK_OPT+=" --offline"
else
recipes+=" $arg"
fi

View File

@ -1237,12 +1237,12 @@ fn cook(
name: &PackageName,
recipe: &Recipe,
fetch_only: bool,
is_offline: bool,
) -> Result<(), String> {
if recipe.build.kind == BuildKind::None {
return cook_meta(recipe_dir, name, recipe, fetch_only);
}
let is_offline = env::var("COOKBOOK_OFFLINE").unwrap_or("".to_string()) == "1";
let source_dir = match is_offline {
true => fetch_offline(recipe_dir, &recipe.source),
false => fetch(recipe_dir, &recipe.source),
@ -1283,6 +1283,7 @@ fn main() {
let mut with_package_deps = false;
let mut quiet = false;
let mut nonstop = false;
let mut is_offline = false;
let mut recipe_names = Vec::new();
for arg in env::args().skip(1) {
match arg.as_str() {
@ -1292,6 +1293,7 @@ fn main() {
"--fetch-only" if matching => fetch_only = true,
"-q" | "--quiet" if matching => quiet = true,
"--nonstop" => nonstop = true,
"--offline" => is_offline = true,
_ => recipe_names.push(arg.try_into().expect("Invalid package name")),
}
}
@ -1346,7 +1348,13 @@ fn main() {
}
Ok(())
} else {
cook(&recipe.dir, &recipe.name, &recipe.recipe, fetch_only)
cook(
&recipe.dir,
&recipe.name,
&recipe.recipe,
fetch_only,
is_offline,
)
};
match res {