summaryrefslogtreecommitdiffstats
path: root/upstream/opensuse-leap-15-6/update-manpages.sh
blob: 38cc1b1ee14b0d11b805d7dcb1604191314576d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
#
# Copyright © 2019 Dr. Tobias Quathamer <toddy@debian.org>
#           © 2024 Dr. Helge Kreutzmann <debian@helgefjell.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Start with clean directories and no leftover links.txt
rm -rf man* links.txt untranslated.txt

mkdir man1 man2 man3 man4 man5 man6 man7 man7mp man8

# Download HTML page for x86_64
page=$(mktemp)
cpio_archive=$(mktemp)
wget --quiet -O "$page" "https://ftp.gwdg.de/pub/opensuse/distribution/leap/15.6/repo/oss/x86_64/"

# Process packages
while read package; do
	mkdir tmp

  # Discover the correct link in HTML page.
  # Sometimes, there are multiple versions of a package
  # in the download page, e.g.
  #   man-pages-4.16-2.mga7.noarch.rpm
  #   man-pages-5.01-1.mga8.noarch.rpm
  # Because those links are sorted alphabetically, the newest
  # version should come last. Therefore, convert spaces
  # the the grep'ed string to newlines and use only the
  # last line.
	echo -n "Downloading and updating package '$package' "
  url=$(grep "\"$package-[0-9][^\"]*\.rpm[^.]" "$page" |
        grep -v "\-32bit\-" |
        sed -e "s,.*<a href=\"\($package-[^\"]*\).*,\1," |
        perl -pe "s/ /\n/g" |
        tail -n1)

  url="https://ftp.gwdg.de/pub/opensuse/distribution/leap/15.6/repo/oss/x86_64/$url"
  wget --quiet --directory-prefix=tmp/downloads "$url"

	# Update the manpages from the package
	latest_rpm=$(ls tmp/downloads/$package-*.rpm)
	if [ -z $latest_rpm ]; then
		echo "Warning: Could not find .rpm for package '$package'"
	else
		rpm2cpio $latest_rpm > $cpio_archive
		cd tmp && bsdcpio -i --make-directories < "$cpio_archive"
		cd ..
		./move-manpages.sh "$package"
	fi
	# Finally, remove the tarball, so that the regexp
	# matching does not match the wrong tarball.
	# See pacman and pacman-contrib for an example.
	rm -rf tmp
done < packages.bin.txt
rm "$page" "$cpio_archive"

# Download HTML page for noarch
page=$(mktemp)
cpio_archive=$(mktemp)
wget --quiet -O "$page" "https://ftp.gwdg.de/pub/opensuse/distribution/leap/15.6/repo/oss/noarch/"

# Process packages
while read package; do
	mkdir tmp

  # Discover the correct link in HTML page.
  # Sometimes, there are multiple versions of a package
  # in the download page, e.g.
  #   man-pages-4.16-2.mga7.noarch.rpm
  #   man-pages-5.01-1.mga8.noarch.rpm
  # Because those links are sorted alphabetically, the newest
  # version should come last. Therefore, convert spaces
  # the the grep'ed string to newlines and use only the
  # last line.
	echo -n "Downloading and updating package '$package' "
  url=$(grep "\"$package-[0-9][^\"]*\.rpm[^.]" "$page" |
        sed -e "s,.*<a href=\"\($package-[^\"]*\).*,\1," |
        perl -pe "s/ /\n/g" |
        tail -n1)

  url="https://ftp.gwdg.de/pub/opensuse/distribution/leap/15.6/repo/oss/noarch/$url"
  wget --quiet --directory-prefix=tmp/downloads "$url"

	# Update the manpages from the package
	latest_rpm=$(ls tmp/downloads/$package-*.rpm)
	if [ -z $latest_rpm ]; then
		echo "Warning: Could not find .rpm for package '$package'"
	else
		rpm2cpio $latest_rpm > $cpio_archive
		cd tmp && bsdcpio -i --make-directories < "$cpio_archive"
		cd ..
		./move-manpages.sh "$package"
	fi
	# Finally, remove the tarball, so that the regexp
	# matching does not match the wrong tarball.
	# See pacman and pacman-contrib for an example.
	rm -rf tmp
done < packages.noarch.txt
rm "$page" "$cpio_archive"

	# Special case for grub2-mknetdir.1. This file contains an unprintable
	# character (detected as "\v") which po4a can't handle.
	# See https://savannah.gnu.org/bugs/?58936
	if [ -f ./man1/grub2-mknetdir.1 ]; then
	  sed -i -e "s|Prepares|Prepares|" ./man1/grub2-mknetdir.1
	fi
	
	# Remove some files due to licensing issues
	rm -f ./man1/hpcdtoppm.1
	rm -f ./man1/zipgrep.1