From aa62e20b31779c8ffa844a854234a668511a6f21 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 10 Oct 2020 16:40:12 +0100 Subject: [PATCH] New --edit[s]-sources mode, still undocumented Signed-off-by: Ian Jackson --- nailing-cargo | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/nailing-cargo b/nailing-cargo index 69ad16e..ff65853 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -656,6 +656,19 @@ END_FILES_FULL symlink "$src/$_", "$_" or die "$_ $!"; ' "$src"; END_DEEP + } elsif ($linkfarm_depth eq 'copy-edit') { + $pre .= <<'END_COPY_EDIT'; + find -lname "$src/*" -print0 | xargs -0r rm --; + (set -e; cd "$src"; git ls-files -c -z | + cpio --quiet -p0m --no-preserve-owner -u --make-directories "$bld/$sd"); + clean () { + (set -e; cd "$src"; git ls-files -c -z) | xargs -0r rm -f --; + }; +END_COPY_EDIT + $post .= <<'END_COPY_EDIT_BUNDLE'; + (set -e; cd "$src"; git ls-files -c -z) | + cpio -Hustar -o0 --quiet >"nailing-cargo-update.tar"; +END_COPY_EDIT_BUNDLE } else { die "$linkfarm_depth ?"; } @@ -863,8 +876,16 @@ sub invoke () { } } -sub cargo_lock_update_after () { - if ($do_cargo_lock && $cargo_lock_update && !$just_linkfarm) { +sub files_return_after_update () { + if ($linkfarm_depth eq 'copy-edit') { + system qw(sh -ec), <<'END', 'x', "$build_absdir"; + git ls-files -c -z | \ + tar -x --keep-newer-files --no-same-permissions --no-same-owner \ + --no-acls --no-selinux --no-xattrs --warning=no-ignore-newer \ + -Hustar --null --files-from=- --force-local \ + -f "$1/nailing-cargo-update.tar" +END + } elsif ($do_cargo_lock && $cargo_lock_update && !$just_linkfarm) { # avoids importing File::Copy and the error handling is about as good $!=0; $?=0; my $r= system qw(cp --), "$build_absdir/Cargo.lock", "Cargo.lock"; @@ -992,6 +1013,8 @@ sub parse_args () { $cargo_lock_update= 1; # will set $linkfarm_detph to 1 by default } elsif (m{^--linkfarm(?:=(no|shallow|git|full))?$}) { $linkfarm_depth = $1 || 'git'; + } elsif (m{^--edits?-sources?$}) { + $linkfarm_depth = 'copy-edit'; } elsif (m{^--just-run$}) { $do_nail = $do_cargo_lock = $do_lock = 0; } elsif (m{^--(clean|keep)-linkfarm$}) { @@ -1095,7 +1118,7 @@ printf STDERR "$self: nailed (%s manifests, %s packages)%s\n", print STDERR "$self: invoking: @display_cmd\n" if $verbose; my $estatus = invoke(); -cargo_lock_update_after(); +files_return_after_update(); uninstall() unless $leave_nailed; $want_uninstall = 0; -- 2.30.2