Debian Codegraph @

upstream/fedora-44/update-manpages.sh

raw
1 #!/bin/sh
2 #
3 # Copyright © 2019 Dr. Tobias Quathamer <[email protected]>
4 # 2021 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 untranslated.txt
21
22 mkdir man1 man2 man2const man2type man3 man3const man3head man3type man4 man5 man6 man7 man8
23
24 cpio_archive=$(mktemp)
25 mirror="https://ftp.fau.de/fedora/linux/releases/44/Everything/x86_64/os/Packages/"
26
27 # Process packages
28 while read package; do
29 mkdir -p tmp/downloads
30 page=$(mktemp)
31 group=$(echo $package| awk '{print(tolower(substr($1,1,1)))}')
32
33 # Download HTML page
34 wget --quiet -O "$page" "$mirror/$group/"
35
36 # Discover the correct link in HTML page.
37 # Sometimes, there are multiple versions of a package
38 # in the download page, e.g.
39 # man-pages-4.16-2.mga7.noarch.rpm
40 # man-pages-5.01-1.mga8.noarch.rpm
41 # Because those links are sorted alphabetically, the newest
42 # version should come last. Therefore, convert spaces
43 # the the grep'ed string to newlines and use only the
44 # last line.
45 echo -n "Downloading and updating package '$package' from group '$group'"
46 url=$(grep "\"$package-[0-9][^\"]*\.rpm[^.]" "$page" |
47 sed -e "s,.*<a href=\"\($package-[^\"]*\).*,\1," |
48 perl -pe "s/ /\n/g" |
49 tail -n1)
50 url="$mirror/$group/$url"
51 wget --quiet --directory-prefix=tmp/downloads "$url"
52
53 # echo -n " with url '$url'"
54
55 # Update the manpages from the package
56 latest_rpm=$(ls tmp/downloads/$package-*.rpm)
57 if [ -z $latest_rpm ]; then
58 echo "Warning: Could not find .rpm for package '$package'"
59 else
60 rpm2cpio $latest_rpm > $cpio_archive
61 cd tmp && bsdcpio -i --make-directories < "$cpio_archive"
62 cd ..
63 ./move-manpages.sh "$package"
64 fi
65 # Finally, remove the tarball, so that the regexp
66 # matching does not match the wrong tarball.
67 # See pacman and pacman-contrib for an example.
68 rm -rf tmp $page
69 done < packages.txt
70 rm "$cpio_archive"
71
72 # Special case for grub2-mknetdir.1. This file contains an unprintable
73 # character (detected as "\v") which po4a can't handle.
74 # See https://savannah.gnu.org/bugs/?58936
75 if [ -f ./man1/grub2-mknetdir.1 ]; then
76 sed -i -e "s| Prepares|Prepares|" ./man1/grub2-mknetdir.1
77 fi
78
79 # Remove some files due to licensing issues
80 rm -f ./man1/hpcdtoppm.1
81 rm -f ./man1/zipgrep.1