File rakudo-fix-module-installation.diff of Package rakudo

diff --git a/src/core.c/CompUnit/Repository/Installation.pm6 b/src/core.c/CompUnit/Repository/Installation.pm6
index d4512847c..e668475b7 100644
--- a/src/core.c/CompUnit/Repository/Installation.pm6
+++ b/src/core.c/CompUnit/Repository/Installation.pm6
@@ -332,7 +332,7 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
             # Precomp files should only depend on downstream repos
             PROCESS::<$REPO> := self;
 
-            my $precomp = $head.precomp-repository;
+            my $precomp = self.precomp-repository;
             my $repo-prefix = self!repo-prefix;
             my $*DISTRIBUTION = CompUnit::Repository::Distribution.new($dist, :repo(self), :$dist-id);
             my $*RESOURCES = Distribution::Resources.new(:repo(self), :$dist-id);
diff --git a/lib/CompUnit/Repository/Staging.rakumod b/lib/CompUnit/Repository/Staging.rakumod
index 7fdc73e4e..a25eb2ca5 100644
--- a/lib/CompUnit/Repository/Staging.rakumod
+++ b/lib/CompUnit/Repository/Staging.rakumod
@@ -1,36 +1,10 @@
-use nqp;  # we're using nqp::iscont() for convenience
-
 class CompUnit::Repository::Staging is CompUnit::Repository::Installation {
-    has Str:D $.name is required;
-    has Bool:D $!replace is built(:bind) = False;
+    has Str $.name;
     has CompUnit::Repository $!parent;
-    # repo to (re)set next-repo of, if $!replace is set, and this isn't
-    # then the $!parent was the first repo in the chain
-    has CompUnit::Repository $!prev-repo;
 
     submethod TWEAK(--> Nil) {
         $!parent = CompUnit::RepositoryRegistry.repository-for-name($!name);
-
-        if $!replace {
-            my $repo := $*REPO;
-            if $repo ~~ $!parent {
-                self.next-repo = $repo.next-repo;
-                nqp::iscont($repo)
-                  ?? ($repo = self)
-                  !! (PROCESS::<$REPO> := self);
-            }
-            else {
-                $!prev-repo := $repo;
-                while ($repo := $repo.next-repo) && $repo !~~ $!parent {
-                    $!prev-repo := $repo;
-                }
-                die "Repository '$!name' is not part of the REPO-chain"
-                  unless $repo;
-
-                self.next-repo        = $!prev-repo.next-repo;
-                $!prev-repo.next-repo = self;
-            }
-        }
+        CompUnit::RepositoryRegistry.register-name($!name, self);
     }
 
     method short-id(--> Str:D) { 'staging' }
@@ -39,24 +13,6 @@ class CompUnit::Repository::Staging is CompUnit::Repository::Installation {
         self.^name ~ '#name(' ~ $!name ~ ')#' ~ self.prefix.absolute
     }
 
-    # make sure we include any candidates of the repo being shadowed
-    method candidates(|c) {
-        if callsame() -> @staging_candidates {
-            if $!parent.candidates(|c) -> @installed_candidates {
-                (|@installed_candidates, |@staging_candidates)
-                  .sort(*.meta<ver>)
-                  .sort(*.meta<api>)
-                  .reverse
-            }
-            else {
-                @staging_candidates
-            }
-        }
-        else {
-            $!parent.candidates(|c)
-        }
-    }
-
     method source-file(CompUnit::Repository::Staging:D:
       Str:D $name
     --> IO::Path) {
@@ -89,6 +45,7 @@ class CompUnit::Repository::Staging is CompUnit::Repository::Installation {
             .throw without $io.unlink;      # throw actual failures
         }
     }
+
     method remove-artifacts(CompUnit::Repository::Staging:D: --> Nil) {
         my $io := self.prefix;
         really-unlink($io.child("version"));
@@ -115,13 +72,6 @@ class CompUnit::Repository::Staging is CompUnit::Repository::Installation {
     }
     method self-destruct(CompUnit::Repository::Staging:D: --> Nil) {
         self-destruct self.prefix;
-        if $!replace {
-            $!prev-repo
-              ?? ($!prev-repo.next-repo = $!parent)
-              !! nqp::iscont($*REPO)
-                ?? ($*REPO = $!parent)
-                !! (PROCESS::<$REPO> := $!parent);
-        }
     }
 }
 
openSUSE Build Service is sponsored by