chiark / gitweb /
New --edit[s]-sources mode, still undocumented
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 10 Oct 2020 15:40:12 +0000 (16:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 10 Oct 2020 15:40:33 +0000 (16:40 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
nailing-cargo

index 69ad16e660d3473f07ac7d88818bd0d394fc0fa8..ff658530a1b6c80c4c5f55c2b9a0c0fcea7636dc 100755 (executable)
@@ -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;