Debian Codegraph @

upstream/mageia-cauldron/update-manpages.sh

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