Alien-pkgconf

 view release on metacpan or  search on metacpan

script/stage.pl  view on Meta::CPAN

      {
        $status{dll} = $fn;
      }
    }
    closedir $dh;
  }
}

{
  my $filename = File::Spec->catfile($share_dir, 'status.json');
  open my $fh, '>', $filename;
  print $fh JSON::PP->new->utf8->canonical->encode(\%status);
  close $fh;
}

{
  open my $fh, '>', $status_filename;
  print $fh JSON::PP->new->utf8->canonical->encode(\%status);
  close $fh;
}

{
  my $dir = File::Spec->catdir(qw( blib arch auto Alien pkgconf ));
  my $fn  = File::Spec->catfile($dir, 'pkgconf.txt');
  mkpath $dir, 0, 0744;
  open my $fh, '>', $fn;
  print $fh "Alien based distribution with architecture specific file in share\n";
  close $fh;
}

sub recurse
{
  my($root, $path, $shae_dir) = @_;
  my $dir = File::Spec->catdir($root, @$path);
  my $dh;
  opendir $dh, $dir;
  while(my $fn = readdir $dh)
  {
    next if $fn =~ /^\.\.?$/;
    if(-d File::Spec->catdir($dir, $fn))
    {
      recurse($root, [@$path, $fn]);
    }
    else
    {
      print "stage ", File::Spec->catfile(@$path, $fn), "\n";
      my $from = File::Spec->catfile($dir, $fn);
      my $sdir = File::Spec->catdir ($share_dir, @$path);
      my $to   = File::Spec->catfile($share_dir, @$path, $fn);
      mkpath $sdir, 0, 0744;

      if(-l $from)
      {
        my $target = readlink $from;
        symlink $target, $to;
      }
      else
      {
        cp($from, $to) || die "Copy $from => $to failed $!";
        # Perl 5.8 and 5.10 cp doesn't preserve perms apparently
        eval { chmod 0755, $to } if -x $from && $] < 5.012;
      }
    }
  }
  closedir $dh;
}



( run in 1.163 second using v1.01-cache-2.11-cpan-2398b32b56e )