| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Copyright © 2019 Dr. Tobias Quathamer <[email protected]> |
| 4 |
# © 2024 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 man3attr man3const man3head man3type man4 man5 man6 man7 man8 |
| 23 |
|
| 24 |
# Download HTML page for x86_64 |
| 25 |
page=$(mktemp) |
| 26 |
cpio_archive=$(mktemp) |
| 27 |
wget --quiet -O "$page" "https://ftp.gwdg.de/pub/opensuse/tumbleweed/repo/oss/x86_64/" |
| 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 |
grep -v "\-32bit\-" | |
| 45 |
sed -e "s,.*<a href=\"\($package-[^\"]*\).*,\1," | |
| 46 |
perl -pe "s/ /\n/g" | |
| 47 |
tail -n1) |
| 48 |
|
| 49 |
url="https://ftp.gwdg.de/pub/opensuse/tumbleweed/repo/oss/x86_64/$url" |
| 50 |
wget --quiet --directory-prefix=tmp/downloads "$url" |
| 51 |
|
| 52 |
# Update the manpages from the package |
| 53 |
latest_rpm=$(ls tmp/downloads/$package-*.rpm) |
| 54 |
if [ -z $latest_rpm ]; then |
| 55 |
echo "Warning: Could not find .rpm for package '$package'" |
| 56 |
else |
| 57 |
rpm2cpio $latest_rpm > $cpio_archive |
| 58 |
cd tmp && bsdcpio -i --make-directories < "$cpio_archive" |
| 59 |
cd .. |
| 60 |
./move-manpages.sh "$package" |
| 61 |
fi |
| 62 |
# Finally, remove the tarball, so that the regexp |
| 63 |
# matching does not match the wrong tarball. |
| 64 |
# See pacman and pacman-contrib for an example. |
| 65 |
rm -rf tmp |
| 66 |
done < packages.bin.txt |
| 67 |
rm "$page" "$cpio_archive" |
| 68 |
|
| 69 |
# Download HTML page for noarch |
| 70 |
page=$(mktemp) |
| 71 |
cpio_archive=$(mktemp) |
| 72 |
wget --quiet -O "$page" "https://ftp.gwdg.de/pub/opensuse/tumbleweed/repo/oss/noarch/" |
| 73 |
|
| 74 |
# Process packages |
| 75 |
while read package; do |
| 76 |
mkdir tmp |
| 77 |
|
| 78 |
# Discover the correct link in HTML page. |
| 79 |
# Sometimes, there are multiple versions of a package |
| 80 |
# in the download page, e.g. |
| 81 |
# man-pages-4.16-2.mga7.noarch.rpm |
| 82 |
# man-pages-5.01-1.mga8.noarch.rpm |
| 83 |
# Because those links are sorted alphabetically, the newest |
| 84 |
# version should come last. Therefore, convert spaces |
| 85 |
# the the grep'ed string to newlines and use only the |
| 86 |
# last line. |
| 87 |
echo -n "Downloading and updating package '$package' " |
| 88 |
url=$(grep "\"$package-[0-9][^\"]*\.rpm[^.]" "$page" | |
| 89 |
sed -e "s,.*<a href=\"\($package-[^\"]*\).*,\1," | |
| 90 |
perl -pe "s/ /\n/g" | |
| 91 |
tail -n1) |
| 92 |
|
| 93 |
url="https://ftp.gwdg.de/pub/opensuse/tumbleweed/repo/oss/noarch/$url" |
| 94 |
wget --quiet --directory-prefix=tmp/downloads "$url" |
| 95 |
|
| 96 |
# Update the manpages from the package |
| 97 |
latest_rpm=$(ls tmp/downloads/$package-*.rpm) |
| 98 |
if [ -z $latest_rpm ]; then |
| 99 |
echo "Warning: Could not find .rpm for package '$package'" |
| 100 |
else |
| 101 |
rpm2cpio $latest_rpm > $cpio_archive |
| 102 |
cd tmp && bsdcpio -i --make-directories < "$cpio_archive" |
| 103 |
cd .. |
| 104 |
./move-manpages.sh "$package" |
| 105 |
fi |
| 106 |
# Finally, remove the tarball, so that the regexp |
| 107 |
# matching does not match the wrong tarball. |
| 108 |
# See pacman and pacman-contrib for an example. |
| 109 |
rm -rf tmp |
| 110 |
done < packages.noarch.txt |
| 111 |
rm "$page" "$cpio_archive" |
| 112 |
|
| 113 |
# Special case for grub2-mknetdir.1. This file contains an unprintable |
| 114 |
# character (detected as "\v") which po4a can't handle. |
| 115 |
# See https://savannah.gnu.org/bugs/?58936 |
| 116 |
if [ -f ./man1/grub2-mknetdir.1 ]; then |
| 117 |
sed -i -e "s|Prepares|Prepares|" ./man1/grub2-mknetdir.1 |
| 118 |
fi |
| 119 |
|
| 120 |
# Remove some files due to licensing issues |
| 121 |
rm -f ./man1/hpcdtoppm.1 |
| 122 |
rm -f ./man1/zipgrep.1 |