write-man-symlinks 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #! /usr/bin/env perl
  2. # Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. require 5.10.0;
  9. use warnings;
  10. use strict;
  11. use FindBin;
  12. use lib "$FindBin::Bin/perl";
  13. use OpenSSL::Util::Pod;
  14. if ($#ARGV + 1 != 5 || $ARGV[0] !~ /^(un)?install$/) {
  15. print "Usage: write-man-symlinks [install|uninstall] src-dir build-dir man-page-name target-dir\n";
  16. exit;
  17. }
  18. my $action = $ARGV[0];
  19. my $srcdir = $ARGV[1];
  20. my $builddir = $ARGV[2];
  21. my $manname = $ARGV[3];
  22. my $targetdir = $ARGV[4];
  23. $manname =~ m|(.+)\.(.+)|;
  24. my $mainf = $1;
  25. my $section = $2;
  26. die "Bad src file" if !defined $mainf;
  27. my $podfile = "$srcdir/$mainf.pod";
  28. #Some pod files are generated and are in the build dir
  29. unless (-e $podfile) {
  30. $podfile = "$builddir/$mainf.pod";
  31. }
  32. my %podinfo = extract_pod_info($podfile);
  33. for my $name (@{$podinfo{names}}) {
  34. next if $name eq $mainf;
  35. if ($action eq "install") {
  36. symlink "$manname", "$targetdir/$name.$section";
  37. } else {
  38. unlink "$targetdir/$name.$section";
  39. }
  40. }