change index.AddFile() to return errors instead of logging them
[debiancodesearch.git] / debian / symlink.pl
blob17e0526cd509ab4ab1aefba8c13f71343a65886f
1 #!/usr/bin/env perl
2 # vim:ts=4:sw=4:expandtab
4 use strict;
5 use warnings;
6 use File::Basename;
8 sub link_contents {
9 my ($src, $dst) = @_;
11 my @contents = <$src/*>;
12 # Safety-Check: We are already _in_ a Go library. Don’t copy its
13 # subfolders, this has no use and potentially only screws things up.
14 # This situation should never happen, unless some package ships files that
15 # are already shipped in another package.
16 my @gosrc = grep { /\.go$/ } @contents;
17 return if @gosrc > 0;
18 my @dirs = grep { -d } @contents;
19 for my $dir (@dirs) {
20 my $base = basename($dir);
21 if (-d "$dst/$base") {
22 link_contents("$src/$base", "$dst/$base");
23 } else {
24 symlink("$src/$base", "$dst/$base");
29 my $src = shift;
30 my $dst = shift;
31 link_contents($src, $dst);