Debian Codegraph @

gen-docs-list

raw
1 #!/bin/sh
2 #
3 # Copyright © 2019 - 2022 Red Hat, Inc.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17
18
19 collect()
20 (
21 if $1; then
22 postfix="_toolbox"
23 else
24 postfix=""
25 fi
26
27 manpages_list=""
28 for dir in /usr/share/man/man*/ ; do
29 for docs in $dir*; do
30 package=$(rpm -qf $docs --qf "%{NAME}\n")
31 if ! [[ $package = *"is not owned by any"* ]]; then
32 manpages_list="$manpages_list$package\n"
33 fi
34 done
35 done
36
37 mkdir -p tmp
38 echo -e "$manpages_list" | sort | uniq > tmp/docs_list$postfix
39 rpm -qa --qf "%{NAME}\n" | sort | uniq > tmp/rpm_list$postfix
40 )
41
42
43 generate()
44 (
45 diff -c tmp/rpm_list_toolbox tmp/rpm_list | grep -E "^\+" | tr -d '+ ' > tmp/missing_packages
46 diff -c tmp/docs_list_toolbox tmp/docs_list | grep -E "^\+" | tr -d '+ ' > tmp/missing_manpages
47 manpages_list=$(comm -1 -3 tmp/missing_packages tmp/missing_manpages)
48 manpages_final=""
49 while read -r line; do
50 if [ "$(man $line)" != "" ]; then
51 manpages_final="$manpages_final$line\n"
52 fi
53 done <<< "$manpages_list"
54 echo -e "$manpages_final" >> missing-docs
55 )
56
57
58 case $1 in
59 collect )
60 shift
61 toolbox=false
62 case $1 in
63 -t | --toolbox )
64 toolbox=true
65 ;;
66 esac
67 collect "$toolbox"
68 exit
69 ;;
70 generate )
71 generate
72 exit
73 ;;
74 clean )
75 rm -rf tmp
76 exit
77 ;;
78 * )
79 exit 1
80 esac