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