Perl6-Pugs

 view release on metacpan or  search on metacpan

util/package-osx.pl  view on Meta::CPAN

        else {
            print "Copied $from to $dest$from\n";
        }
    }
}


# @files are all files that will be removed. The last one passed in is the
# remover that will be installed on the target machine (hence the $file[-1]).
sub create_remover {
    my ($dest, @files) = @_;
    my $dirs = $files[-1];
    $dirs =~ s#/[^/]+$##;
    make_dir($dirs) unless (-d $dirs);
    
    open  REMOVER, '>', "$dest$files[-1]" or die "Can't open $dest$files[-1]!";

    my @header = qq(
        #!/usr/bin/perl
        # $files[-1]
        use strict;
        use warnings;\n
        chdir '/usr/local/bin';\n
        my \@files = qw\(
    );
    @header = map { s/^(?:\s{9}|\s{5}$)//; $_ } split /$/m, $header[0];

    my @footer = qq(
        \ 
        \);\n
        for my \$file \(\@files\) \{
            if \( `which parrot` !~ /^no / and \$file =~ /\(?:parrot\).*\\.\(?:dylib|3|info\)\$/ \) \{
                print "Not removing \$file\\n"; 
                next;
            \}
            if \(\$file =~ /\(?:readline|history\).*\\.\(?:dylib|3|info\)\$/ \) \{
                print "Not removing \$file\\n"; 
                next;
            \}
            print "Removing \$file\\n"\;
            print "Removing \$file\\n"\;
            if \( \$_ \= qx\/rm \-rf \$file 2>&1 \/ \) \{
                print "Problem removing \$file\: \$_\\n";
            \}
            else \{
                print "Successfully removed \$file\\n";
            \}
        \}
    );
    @footer = map { s/^(?:\s{9}|\s{5}$)//; $_ } split /$/m, $footer[0];

    print REMOVER "$_\n" for @header;
    print REMOVER "    $_\n" for @files; 
    print REMOVER "$_\n" for @footer;

    close REMOVER;
    chmod 0755, "$dest$files[-1]";
    print "Made $dest$files[-1]\n";
}

sub chown_all {
    my ($dest) = @_;
    system("sudo -S chown -R root:wheel $dest < ~/.pass");
}

&change_files($dest, %change_files) if (keys %change_files > 0);
&copy_files($dest, @files);
&make_symlinks($dest, %symlinks) if (keys %symlinks > 0);
&create_remover($dest, values %change_files, @files, %symlinks, $remover);
&chown_all($dest);



( run in 0.819 second using v1.01-cache-2.11-cpan-5511b514fd6 )