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 9 10 require 5.10.0; 11 use warnings; 12 use strict; 13 14 use FindBin; 15 use lib "$FindBin::Bin/perl"; 16 17 use OpenSSL::Util::Pod; 18 19 if ($#ARGV + 1 != 5 || $ARGV[0] !~ /^(un)?install$/) { 20 print "Usage: write-man-symlinks [install|uninstall] src-dir build-dir man-page-name target-dir\n"; 21 exit; 22 } 23 24 my $action = $ARGV[0]; 25 my $srcdir = $ARGV[1]; 26 my $builddir = $ARGV[2]; 27 my $manname = $ARGV[3]; 28 my $targetdir = $ARGV[4]; 29 30 $manname =~ m|(.+)\.(.+)|; 31 my $mainf = $1; 32 my $section = $2; 33 die "Bad src file" if !defined $mainf; 34 my $podfile = "$srcdir/$mainf.pod"; 35 #Some pod files are generated and are in the build dir 36 unless (-e $podfile) { 37 $podfile = "$builddir/$mainf.pod"; 38 } 39 my %podinfo = extract_pod_info($podfile); 40 41 for my $name (@{$podinfo{names}}) { 42 next if $name eq $mainf; 43 if ($action eq "install") { 44 symlink "$manname", "$targetdir/$name.$section"; 45 } else { 46 unlink "$targetdir/$name.$section"; 47 } 48 } 49