Commit 0128298a authored by Tobias Quathamer's avatar Tobias Quathamer

Fix extracting package bug and move common login into new script

This bug occured in archlinux with the packages
pacman and pacman-contrib. The '-contrib' part
has been matched by the broad regexp for
extracting the tarball, so the manpages from
pacman got lost.
parent b72f640b
Pipeline #36097 passed with stage
in 2 minutes and 5 seconds
#!/bin/sh
#
# Copyright © 2018 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2018-2019 Dr. Tobias Quathamer <toddy@debian.org>
#
# 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
......@@ -15,67 +15,41 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
mkdir downloads
# Start with clean directories and no leftover links.txt
rm -rf man* links.txt
mkdir man0 man1 man2 man3 man4 man5 man6 man7 man8
# Download packages
# Process packages
while read line; do
mkdir tmp
repo=$(echo "$line" | cut -d" " -f1)
package=$(echo "$line" | cut -d" " -f2)
echo "Downloading package '$package' from '$repo'"
# Download HTML page and discover the correct link
echo "Downloading and updating package '$package' from '$repo'"
url=$(wget --quiet -O - "https://mirror.netcologne.de/archlinux/$repo/os/x86_64/" |
grep "\"$package-[0-9][^\"]*\.pkg\.tar\.xz[^.]" |
sed -e "s,.*<a href=\"\($package-[^\"]*\).*,\1,")
url="https://mirror.netcologne.de/archlinux/$repo/os/x86_64/$url"
wget --quiet --directory-prefix=downloads "$url"
done < packages.txt
wget --quiet --directory-prefix=tmp/downloads "$url"
# Extract manpages
while read line; do
repo=$(echo "$line" | cut -d" " -f1)
package=$(echo "$line" | cut -d" " -f2)
echo "Updating package '$package' from '$repo'"
latest_pkg=$(ls downloads/$package-*.pkg.tar.xz 2>/dev/null | tail -n1)
# Update the manpages from the package
latest_pkg=$(ls tmp/downloads/$package-*.pkg.tar.xz)
if [ -z $latest_pkg ]; then
echo "Warning: Could not find .pkg.tar.xz for package '$package'"
else
mkdir -p tmp/$package
tar xaf $latest_pkg --directory=tmp/$package
for mandir in tmp/$package/usr/share/man/man*/; do
section=$(echo $mandir | cut -d/ -f6)
# Only copy directories with files
files=$(ls $mandir)
if [ -n "$files" ]; then
mkdir -p tmp/$package/$section
# Remove manpages which are links
for manpage in $mandir/*; do
existing=$(readlink $manpage)
if [ -n "$existing" ]; then
linked_section=$(basename $existing .gz | sed -e "s/.\+\.//")
echo man$linked_section/$(basename $existing) $section/$(basename $manpage) >> tmp.links
rm $manpage
fi
done
cp $mandir/* tmp/$package/$section
gzip -d tmp/$package/$section/*
# Remove manpages which contain only .so links
for manpage in tmp/$package/$section/*; do
existing=$(grep "^\.so" $manpage | sed -e "s/^\.so //")
if [ -n "$existing" ]; then
echo $existing.gz $section/$(basename $manpage).gz >> tmp.links
rm $manpage
fi
done
# Copy remaining manpages
cp tmp/$package/$section/* $section
fi
done
if [ -e tmp.links ]; then
cat tmp.links >> links.txt
fi
rm -rf tmp.links
tar xaf $latest_pkg --directory=tmp 2>/dev/null
../move-manpages.sh
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.txt
rm -rf tmp downloads
if [ -f links.txt ]; then
LC_ALL=C sort links.txt > tmp.links
mv tmp.links links.txt
fi
#!/bin/sh
#
# Copyright © 2010-2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2010-2019 Dr. Tobias Quathamer <toddy@debian.org>
#
# 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
......@@ -15,64 +15,46 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
mkdir downloads
# Start with clean directories and no leftover links.txt
rm -rf man* links.txt
mkdir man1 man2 man3 man4 man5 man6 man7 man8
# Download packages
# Process packages
while read package; do
echo "Downloading package '$package'"
mkdir tmp
# Download HTML page and discover the correct link
echo "Downloading and updating package '$package'"
url=$(wget --quiet -O - "http://packages.debian.org/sid/amd64/$package/download" |
grep "http://ftp.de.debian.org/debian/pool/" |
sed -e "s,.*\(http://ftp.de.debian.org/debian/pool/[^\"]*\).*,\1,")
wget --quiet --directory-prefix=downloads "$url"
done < packages.txt
wget --quiet --directory-prefix=tmp/downloads "$url"
# Extract manpages
while read package; do
echo "Updating package '$package'"
latest_deb=$(ls downloads/$package\_*.deb 2>/dev/null | tail -n1)
# Update the manpages from the package
latest_deb=$(ls tmp/downloads/$package\_*.deb)
if [ -z $latest_deb ]; then
echo "Warning: Could not find .deb for package '$package'"
else
data_tar=$(ar t $latest_deb | grep data.tar)
ar x $latest_deb $data_tar
mkdir -p tmp/$package
tar xaf $data_tar --directory=tmp/$package
for mandir in tmp/$package/usr/share/man/man*/; do
section=$(echo $mandir | cut -d/ -f6)
# Only copy directories with files
files=$(ls $mandir)
if [ -n "$files" ]; then
mkdir -p tmp/$package/$section
# Remove manpages which are links
for manpage in $mandir/*; do
existing=$(readlink $manpage)
if [ -n "$existing" ]; then
linked_section=$(basename $existing .gz | sed -e "s/.\+\.//")
echo man$linked_section/$(basename $existing) $section/$(basename $manpage) >> tmp.links
rm $manpage
fi
done
cp $mandir/* tmp/$package/$section
gzip -d tmp/$package/$section/*
# Remove manpages which contain only .so links
for manpage in tmp/$package/$section/*; do
existing=$(grep "^\.so" $manpage | sed -e "s/^\.so //")
if [ -n "$existing" ]; then
echo $existing.gz $section/$(basename $manpage).gz >> tmp.links
rm $manpage
fi
done
# Copy remaining manpages
cp tmp/$package/$section/* $section
fi
done
if [ -e tmp.links ]; then
cat tmp.links >> links.txt
fi
rm -rf $data_tar tmp.links
tar xaf $data_tar --directory=tmp 2>/dev/null
../move-manpages.sh
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 data.tar.*
done < packages.txt
rm -rf tmp downloads
if [ -f links.txt ]; then
LC_ALL=C sort links.txt > tmp.links
mv tmp.links links.txt
fi
# Special case for init.8, because the manpage contains
# a syntax error, so that the manpage cannot be translated
# with po4a. The bug has been reported upstream.
# https://savannah.nongnu.org/bugs/?55678
sed -i -e "s|\\\fB/run/initctl\\\f\\\P, closed. This may be used to make sure init is not|\\\fB/run/initctl\\\fP, closed. This may be used to make sure init is not|" man8/init.8
#!/bin/sh
#
# Copyright © 2018 Dr. Tobias Quathamer <toddy@debian.org>
#
# 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/>.
for mandir in tmp/usr/share/man/man*; do
section=$(echo $mandir | cut -d/ -f5)
# Only copy directories with files
files=$(ls $mandir)
if [ -n "$files" ]; then
# Remove manpages which are links, add them to links.txt
for manpage in $mandir/*; do
existing=$(readlink $manpage)
if [ -n "$existing" ]; then
linked_section=$(basename $existing .gz | sed -e "s/.\+\.//")
echo man$linked_section/$(basename $existing) $section/$(basename $manpage) >> links.txt
rm $manpage
fi
done
# See if there are regular files left
files=$(ls $mandir)
if [ -n "$files" ]; then
mkdir tmp/$section
# Copy remaining manpages
cp $mandir/* tmp/$section
gzip -d tmp/$section/*
# Remove manpages which contain only .so links
for manpage in tmp/$section/*; do
existing=$(grep "^\.so" $manpage | sed -e "s/^\.so //")
if [ -n "$existing" ]; then
echo $existing.gz $section/$(basename $manpage).gz >> links.txt
rm $manpage
fi
done
# Copy remaining manpages
cp tmp/$section/* $section
fi
fi
done
#!/bin/sh
#
# Copyright © 2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2017-2019 Dr. Tobias Quathamer <toddy@debian.org>
#
# 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
......@@ -24,18 +24,9 @@ for directory in $directories; do
echo "Processing directory '$directory'"
cd $directory
# Start with clean directories and no leftover links.txt
rm -rf man* links.txt
# Call the script inside the directory for handling
# the needed instructions for the given distribution.
./update-manpages.sh
# Sort the file links.txt
if [ -f links.txt ]; then
LC_ALL=C sort links.txt > tmp.links
mv tmp.links links.txt
fi
cd ..
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment