add-root.pl 463 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/perl
  2. my $lxr_dir = '.';
  3. if ($#ARGV <= 0) {
  4. print "Syntax: $0 tree path/to/tree [prefix]
  5. ";
  6. exit;
  7. }
  8. my ($tree, $path, $prefix);
  9. $tree = $ARGV[0];
  10. $path = $ARGV[1];
  11. $prefix = $ARGV[2] if $#ARGV > 1;
  12. die "invalid tree name" if $tree =~ /[\s:]/;
  13. open LXRCONF, ">> $lxr_dir/lxr.conf";
  14. print LXRCONF "sourceroot: $tree $path
  15. ";
  16. if (defined $prefix) {
  17. print LXRCONF "sourceprefix: $tree $prefix
  18. ";
  19. }
  20. chdir($lxr_dir);
  21. symlink('.', $tree);
  22. close LXRCONF;