Skip to content
Permalink
Browse files

Use implicit bin/ for running scripts

It made sense for the .files/.candidates api to take an explicit
bin/ (if looking for bin/foo). It could make sense for this
.run-script + wrapper, but it also make sense without since the
method name implies the name-path prefix is a bin/ script.

Since a rakudo installation can be upgraded with distributions
(i.e. bin/ scripts) already installed we should continue to use
the current behavior of an implicit bin/ prefix.
  • Loading branch information...
ugexe committed Aug 5, 2017
1 parent 2d007bf commit 07f62c603930ac4ef2a181b81a2d79610fe4b78e
Showing with 5 additions and 4 deletions.
  1. +3 −2 src/core/CompUnit/Repository/Installation.pm
  2. +2 −2 src/core/CompUnit/RepositoryRegistry.pm
@@ -52,7 +52,7 @@ __END__
:endofperl
';
my $perl_wrapper = '#!/usr/bin/env #perl#
sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {
sub MAIN(:$name, :$auth, :$ver, *@, *%) {
CompUnit::RepositoryRegistry.run-script("#name#", :$name, :$auth, :$ver);
}';

@@ -223,12 +223,13 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {
# bin/ scripts
for %files.kv -> $name-path, $file is copy {
next unless $name-path.starts-with('bin/');
my $name = $name-path.subst(/^bin\//, '');
my $id = self!file-id(~$file, $dist-id);
my $destination = $resources-dir.add($id); # wrappers are put in bin/; originals in resources/
my $withoutext = $name-path.subst(/\.[exe|bat]$/, '');
for '', '-j', '-m' -> $be {
$.prefix.add("$withoutext$be").IO.spurt:
$perl_wrapper.subst('#name#', $name-path, :g).subst('#perl#', "perl6$be");
$perl_wrapper.subst('#name#', $name, :g).subst('#perl#', "perl6$be");
if $is-win {
$.prefix.add("$withoutext$be.bat").IO.spurt:
$windows_wrapper.subst('#perl#', "perl6$be", :g);
@@ -217,9 +217,9 @@ class CompUnit::RepositoryRegistry {
shift @*ARGS if $ver;

my @installations = $*REPO.repo-chain.grep(CompUnit::Repository::Installation);
my @candidates = @installations.map({ .files($script, :$name, :$auth, :$ver).head }).grep(*.defined);
my @candidates = @installations.map({ .files("bin/$script", :$name, :$auth, :$ver).head }).grep(*.defined);
unless +@candidates {
@candidates = flat @installations.map({ .files($script).Slip }).grep(*.defined);
@candidates = flat @installations.map({ .files("bin/$script").Slip }).grep(*.defined);
if +@candidates {
note "===SORRY!===\n"
~ "No candidate found for '$script' that match your criteria.\n"

0 comments on commit 07f62c6

Please sign in to comment.
You can’t perform that action at this time.