chiark / gitweb /
Make a shallow symlink farm
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Jul 2020 15:49:36 +0000 (16:49 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Jul 2020 16:16:47 +0000 (17:16 +0100)
Fighting Cargo to avoid this has become too much hard work.

In particular, otherwise with workspaces we would have to edit all of
the member paths.  And having done that the sources themselves claim
to be part of a different workspace, so it's all awful.

I have also seen some weird behaviours where cargo didn't work quite
right because the package wasn't convincing enough.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
README.md
nailing-cargo

index 672ddd455760417e63ca9afbbf0fb116088e2dfa..eb516de7e3fd2cf743e0eb7eb083c53f7013a3c0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -302,8 +302,8 @@ Options
 
     With this enabled, in an out-of-tree build the `Cargo.lock` and
     `Cargo.toml` are copied to the build directory along with a
-    skeleton just big enough to fool cargo.  After cargo has run, the
-    resulting `Cargo.lock` is copied back to the source tree.
+    linkfarm, to fool cargo.  After cargo has run, the resulting
+    `Cargo.lock` is copied back to the source tree.
 
     Default is no update unless the whole point of the cargo
     subcommand is to update `Cargo.lock`.
index 8eb65ec6308334af724a8777b2b79c80651ef433..354f1e779d0609eedb117250d4832f65f8fcf85a 100755 (executable)
@@ -510,21 +510,19 @@ sub oot_massage_cmdline () {
     $pre =  <<'END';
         cd "$1"; shift;
         mkdir -p -- "$1"; cd "$1"; shift;
-        cp -- "$1"/Cargo.toml
+       clean () { find -lname "$1/*" -print0 | xargs -0r rm --; }; clean;
+       find "$1" -maxdepth 1 \! -name Cargo.lock -print0 | xargs -0r -I_ ln -sf -- _ .;
 END
     $pre .= <<'ENDLK' if stat_exists 'Cargo.lock', 'working cargo lockfile';
-              "$1"/Cargo.lock
+       rm -f Cargo.lock;
+        cp -- "$1"/Cargo.lock .;
 ENDLK
-    $pre .= <<'ENDCP';
-                              .;
-ENDCP
     $pre .= <<'ENDPRE';
         shift;
-        mkdir -p src; >src/lib.rs; >build.rs
 ENDPRE
-    $post = <<'ENDPOST';
-        rm -r src Cargo.toml build.rs;
-ENDPOST
+#    $post = <<'ENDCLEAN';
+#        clean;
+#ENDCLEAN
   }
   my $addpath = (cfg_uc qw(oot path_add)) //
     $use eq 'really' ? Types::Serialiser::true : Types::Serialiser::false;