chiark / gitweb /
nailing-cargo: Record $org_subdir in %packagemap and %manifests
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Jul 2020 16:56:26 +0000 (17:56 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Jul 2020 17:09:55 +0000 (18:09 +0100)
No functional change yet.

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

index 108d25977b86bcb4afae7c412c09002dc64a2265..840eba331cfd8bbc6d6c5cc4489e717150d0f920 100755 (executable)
@@ -336,7 +336,7 @@ sub read_manifest ($$$) {
  "$self: warning: $subdir, $why: missing package.name in $try, ignoring\n";
       next;
     }
-    $manifests{$manifest} = $toml if $p;
+    $manifests{$manifest} = [ $toml, $org_subdir ] if $p;
     return ($p, $ws);
   }
   return undef;
@@ -415,7 +415,7 @@ sub readorigs () {
  "$self: warning: honouring Cargo.nail packages.$subdir=$p even though $subdir contains package $gotpackage!\n";
     }
     die if defined $packagemap{$p};
-    $packagemap{$p} = $subdir;
+    $packagemap{$p} = [ $subdir, $subdir ];
   }
   foreach my $subdir (@{ $nail->{subdirs} }) {
     my ($gotpackage,$ws) = read_manifest($subdir, $subdir, "from [subdirs]");
@@ -425,22 +425,22 @@ sub readorigs () {
         unless $ws;
       next;
     }
-    $packagemap{$gotpackage} //= $subdir;
+    $packagemap{$gotpackage} //= [ $subdir, $subdir ];
   }
   while (my ($subdir, $org_subdir, $why) = @{ shift @queued_paths or [] }) {
     next if $manifests{"../$subdir/Cargo.toml"};
     my ($gotpackage, $ws) = read_manifest($subdir, $org_subdir, $why);
     next unless $gotpackage;
-    $packagemap{$gotpackage} //= $subdir;
+    $packagemap{$gotpackage} //= [ $subdir, $org_subdir ];
   }
 }
 
 sub calculate () {
   foreach my $p (sort keys %packagemap) {
-    print STDERR "$self: package $p in $packagemap{$p}\n" if $verbose>=2;
+    print STDERR "$self: package $p in $packagemap{$p}[0]\n" if $verbose>=2;
   }
   foreach my $mf (keys %manifests) {
-    my $toml = $manifests{$mf};
+    my ($toml, $mf_org_subdir) = @{ $manifests{$mf} };
     foreach my $deps (get_dependency_tables $toml) {
       next unless $deps;
       foreach my $p (keys %packagemap) {
@@ -448,7 +448,7 @@ sub calculate () {
        next unless defined $info;
        $deps->{$p} = $info = { } unless ref $info;
        delete $info->{version};
-       my $newpath = $worksphere.'/'.$packagemap{$p};
+       my $newpath = $worksphere.'/'.$packagemap{$p}[0];
        if ($cargo_lock_update and defined $oot_dir and
            $newpath =~ m{^\Q$src_absdir\E(?=$|/)}) {
          our $oot_subdir_realpath;