Files
rocky-man/old_scripts/extract_man.sh
Stephen Simpson 2287678798 Init
2025-01-09 15:39:20 -06:00

28 lines
705 B
Bash
Executable File

#! /bin/bash
ROCKY_VERSION=8.10
MAN_OUTPUT=./export/${ROCKY_VERSION}/
DIRECTORY=$1
if [ -z "$DIRECTORY" ]; then
echo "Please provide the directory containing the RPM files"
exit 1
fi
mkdir -p "$MAN_OUTPUT"
extract_man_pages() {
local rpm=$1
local man_output=$2
MANCOUNT=$(rpm2cpio "$rpm" | cpio -itv --quiet | grep -c "/man/")
RPMNAME=$(rpm -qp --qf "%{NAME}\n" "$rpm")
if [ "$MANCOUNT" -ne 0 ]; then
mkdir -p "${man_output}/${RPMNAME}"
rpm2cpio "$rpm" | cpio -idmv --quiet -D "${man_output}/${RPMNAME}/" '*/man/*'
fi
}
export -f extract_man_pages
find "$DIRECTORY" -type f -name "*.rpm" | parallel --will-cite -j+0 extract_man_pages {} "$MAN_OUTPUT"