use TOML::Tiny::Faithful;
our $worksphere = getcwd() // die "$self: getcwd failed: $!\n";
-$worksphere =~ s{/[^/]+$}{} or die "$self: cwd \`$worksphere' unsupported!\n";
+$worksphere =~ s{/([^/]+)$}{}
+ or die "$self: cwd \`$worksphere' unsupported!\n";
+our $subdir = $1;
our $lockfile = "../.nailing-cargo.lock";
+our $oot_cargo_lock_faff;
our @configs;
our $verbose=1;
close N or die "$self: close new $nailing: $!\n";
}
}
+s
+our $oot_dir;
+our @out_command;
+
+sub calculate_oot () {
+ my $oot = $nail->{oot};
+ return unless $oot && (defined $oot->{dir} or defined $oot->{use});
+ if (@ARGV && $ARGV[0] =~ m/generate-lockfile|update/) {
+ $oot_cargo_lock_faff = 1;
+ }
+ my ($pre,$post);
+ my @xargs;
+ if (!$oot_cargo_lock_faff) {
+ @xargs = $xxx_subdir;
+ ($pre, $post) = ('cd "$1"; shift', '');
+ } else {
+ @xargs = $xxx_builddir, $xxx_subdir, $xxx_src_abs_dir;
+ ($pre, $post) = (<<'END', <<'END');
+ cd "$1"; shift;
+ mkdir -p -- "$1"; cd "$1"; shift;
+ cp -- "$1"/Cargo.toml "$1"/Cargo.lock .; shift;
+ mkdir -p src; >src/lib.rs;
+END
+ rm -r src Cargo.toml;
+END
+ $pre =~ s/^\s+//mg; $pre =~ s/^\s+\n/ /g;
+ $post =~ s/^\s+//mg; $post =~ s/^\s+\n/ /g;
+ }
+ my $use = $oot->{use} // die "$self: [oot] specified, need oot.use\n";
+ my $getuser = sub {
+ scalar($oot->{user} // die "$self: oot.use $use requires oot.user\n")
+ };
+ my @command;
+ my $sh_ec = sub {
+ if (!length $post) {
+ @command = @_, 'sh','-ec',$pre.' exec "$@"','--',@xargs;
+ } else {
+ @command = @_, 'sh','-ec',$pre.' "$@"; '.$post,'--',@xargs;
+ }
+ };
+ my $command_sh = sub {
+ my $quoted = join ' ', map {
+ return $_ if !m/\W/;
+ s/\'/\'\\'\'/g;
+ "'$_'"
+ } @ARGV;
+ @command = @_, "set -e; $pre $quoted; $post";
+ };
+ if ($use eq 'really') {
+ my $user = $getuser->();
+ my @pw = getpwnam $user or "die $self: oot.user lookup failed\n";
+ my $homedir = $pw[7];
+ $sh_ec->('really','-u',$user,'env',"HOME=$homedir");
+ } elsif ($use eq 'ssh') {
+ my $user = $getuser->();
+ $user .= '@localhost' unless $user =~ m/\@/;
+ $command_sh->('ssh',$user);
+ } elsif ($use eq 'command_sh') {
+ $command_sh->(@{ $oot->{command} // die "$self: need oot.command\n" });
+ } elsif ($use eq 'command_args') {
+ $sh_ec->(@{ $oot->{command} // die "$self: need oot.command\n" });
+ } else {
+ die "$self: oot.use mode $use not recognised\n";
+ }
+ die unless @command;
+ @ARGV = @command;
+}
our $want_uninstall;
$noact++;
} elsif (s{^-D}{-}) {
$dump++;
+ } elsif (s{^-L}{-}) {
+ $oot_cargo_lock_faff=1;
} else {
die "$self: unknown short option(s) $_\n";
}
readnail();
readorigs();
calculate();
+calculate_oot();
if ($dump) {
eval '
use Data::Dumper;
- print STDERR Dumper(\%manifests, \%packagemap);
+ print STDERR Dumper(\%manifests, \%packagemap, \@ARGV);
' or die $@;
}
uninstall();
$want_uninstall = 1;
-print STDERR "$self: unnailed.\n" if $verbose;
+
+get_cargo_lock() if $oot_cargo_lock_faff;
+
+print STDERR "$self: unnailed. status $estatus.\n" if $verbose;
exit $estatus;