Debian Codegraph @

upstream/debian-unstable/move-manpages.sh

raw
1 #!/bin/sh
2 #
3 # Copyright © 2018 Dr. Tobias Quathamer <[email protected]>
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 for mandir in tmp/usr/share/man/man*; do
19 section=$(echo $mandir | cut -d/ -f5)
20 # Only copy directories with files
21 files=$(ls $mandir)
22 if [ -n "$files" ]; then
23 # Remove manpages which are links, add them to links.txt
24 for manpage in $mandir/*; do
25 existing=$(readlink $manpage)
26 if [ -n "$existing" ]; then
27 linked_section=$(basename $existing .gz | sed -e "s/.\+\.//")
28 echo man$linked_section/$(basename $existing) $section/$(basename $manpage) >> links.txt
29 rm $manpage
30 fi
31 done
32 # See if there are regular files left
33 files=$(ls $mandir)
34 if [ -n "$files" ]; then
35 mkdir tmp/$section
36 # Copy remaining manpages
37 cp $mandir/* tmp/$section
38 gzip -d tmp/$section/*
39 # Remove manpages which contain only .so links
40 for manpage in tmp/$section/*; do
41 existing=$(grep "^\.so" $manpage | sed -e "s/^\.so //")
42 if [ -n "$existing" ]; then
43 echo $existing.gz $section/$(basename $manpage).gz >> links.txt
44 rm $manpage
45 fi
46 done
47 # Copy remaining manpages
48 cp tmp/$section/* $section
49 fi
50 fi
51 done