Debian Codegraph @

upstream/debian-trixie/update-manpages.sh

raw
1 #!/bin/sh
2 #
3 # Copyright © 2010-2019 Dr. Tobias Quathamer <[email protected]>
4 # © 2023,2025 Dr. Helge Kreutzmann <[email protected]>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 # Start with clean directories and no leftover links.txt
20 rm -rf man* links.txt
21
22 mkdir man1 man2 man3 man4 man5 man6 man7 man8
23
24 # Process packages
25 while read package; do
26 mkdir tmp
27
28 # Download HTML page and discover the correct link
29 echo -n "Downloading and updating package '$package'"
30 url=""
31 while [ -z "$url" ]; do
32 url=$(wget --quiet -O - "http://packages.debian.org/trixie-backports/amd64/$package/download" |
33 grep "http://ftp.de.debian.org/debian/pool/" |
34 sed -e "s,.*\(http://ftp.de.debian.org/debian/pool/[^\"]*\).*,\1,")
35
36 if [ -z $url ]; then
37 url=$(wget --quiet -O - "http://packages.debian.org/trixie/amd64/$package/download" |
38 grep "http://ftp.de.debian.org/debian/pool/" |
39 sed -e "s,.*\(http://ftp.de.debian.org/debian/pool/[^\"]*\).*,\1,")
40
41 if [ -z $url ]; then
42 url=$(wget --quiet -O - "http://packages.debian.org/trixie/amd64/$package/download" |
43 grep "http://security.debian.org/debian-security/pool/updates/" |
44 sed -e "s,.*\(http://security.debian.org/debian-security/pool/updates/[^\"]*\).*,\1,")
45 # wget --quiet --directory-prefix=tmp/downloads "$url"
46 fi
47 fi
48 echo -n "."
49 done
50 echo
51
52 # Update the manpages from the package
53 wget -t 40 --quiet --directory-prefix=tmp/downloads "$url"
54 latest_deb=$(ls tmp/downloads/$package\_*.deb)
55 if [ -z $latest_deb ]; then
56 echo "Warning: Could not find .deb for package '$package'"
57 else
58 data_tar=$(ar t $latest_deb | grep data.tar)
59 ar x $latest_deb $data_tar
60 tar xaf $data_tar --directory=tmp 2>/dev/null
61 ./move-manpages.sh
62 fi
63 # Finally, remove the tarball, so that the regexp
64 # matching does not match the wrong tarball.
65 # See pacman and pacman-contrib for an example.
66 rm -rf tmp data.tar.*
67 done < packages.txt
68
69 if [ -f links.txt ]; then
70 LC_ALL=C sort links.txt > tmp.links
71 mv tmp.links links.txt
72 fi
73
74 # Special case for grub-mknetdir.1. This file contains an unprintable
75 # character (detected as "\v") which po4a can't handle.
76 # See https://savannah.gnu.org/bugs/?58936
77 if [ -f ./man1/grub-mknetdir.1 ]; then
78 sed -i -e "s| Prepares|Prepares|" ./man1/grub-mknetdir.1
79 fi
80
81 # Remove some files due to licensing issues
82 rm -f ./man1/hpcdtoppm.1
83 rm -f ./man1/zipgrep.1