From: Ian Jackson Date: Wed, 17 Jun 2020 22:03:06 +0000 (+0100) Subject: nailing-cargo: offline by default X-Git-Tag: nailing-cargo/1.0.0~183 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=277bf48cf6f24f7d4f22d0aa8a7c505b5c912a4c;p=nailing-cargo.git nailing-cargo: offline by default Signed-off-by: Ian Jackson --- diff --git a/nailing-cargo b/nailing-cargo index bb55540..31eefe7 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -79,6 +79,13 @@ # Done automatically when nailing-cargo sees that the cargo # subcommand is one which needs it, eg `fetch'. # +# --online | --offline +# Whether to allow cargo to make network access. +# (nailing-cargo always passes --offline to cargo, unless +# --online is in force). The default is offline, +# unless the cargo subcommand is one which implies +# online (currently, `fetch'). +# # Cargo.nail: # # # Adds each to the list of directories whose @@ -131,6 +138,11 @@ # or # use = "null" # +# Other settings: +# [misc] +# online = true # forces default to be --online +# online = false # forces default to be --offline +# # Limitations: # # Always dirties everyone's Cargo.toml, but tries to put them @@ -204,6 +216,7 @@ our $cargo_lock_update; our $cargo_manifest_args; our $cargo_target_arg=1; our $alt_cargo_lock; +our $online; our @configs; our $verbose=1; @@ -500,6 +513,8 @@ sub calculate () { } sub addargs () { + $online //= cfg_bool qw(misc online); + if (@ARGV>=2 && $ARGV[0] =~ m{\bcargo\b}) { if ($ARGV[1] =~ m/^(?:generate-lockfile|update)$/) { @@ -508,12 +523,15 @@ sub addargs () { } if ($ARGV[1] =~ m/^(?:fetch)$/) { $cargo_target_arg=0; + $online //= 1; } } $cargo_lock_update //= 0; $cargo_manifest_args //= (defined $oot_dir) && !$cargo_lock_update; + $online //= 0; + if ($cargo_manifest_args) { push @ARGV, "--manifest-path=${src_absdir}/Cargo.toml", qw(--locked); @@ -527,6 +545,8 @@ sub addargs () { } push @ARGV, "--target=$target"; } + + push @ARGV, "--offline" unless $online; } our $oot_absdir; @@ -806,6 +826,8 @@ while (@ARGV && $ARGV[0] =~ m/^-/) { $cargo_manifest_args= !!$1; } elsif (m{^--(no-)?cargo-target-arg}) { $cargo_target_arg= !!$1; + } elsif (m{^--(on|off)line$}) { + $online = $1 eq 'on'; } else { die "$self: unknown long option $_\n"; }