#!/usr/bin/env bash # # Copyright © 2026 Zayed Al-Saidi # Adapted from no-upstream.sh to fit pot files # # 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 . # Check if there is a .pot file without the corresponding # upstream manpage, e.g. when a package has been removed. if [ "$1" == "-h" ]; then echo "Usage: ./`basename $0`" echo "This script detects *.pot files in man*/ directories which have no corresponding upstream man page" echo "in upstream/*/man*. You should consider to remove such orphan *.pot files." echo "" echo "Note: Only checks man1/, man2/, man3/, man4/, man5/, man6/, man7/, man8/ directories" echo "Ignores common/ directory and other special files" exit 0 fi # Get the directory where the script is being run from script_dir="$(pwd)" # Set directory paths relative to the script location templatesdir="$script_dir/templates" upstreamdir="$script_dir/upstream" # Verify directories exist if [ ! -d "$templatesdir" ]; then echo "Error: Templates directory $templatesdir not found" exit 1 fi if [ ! -d "$upstreamdir" ]; then echo "Error: Upstream directory $upstreamdir not found" exit 1 fi # Get all distribution directories from upstream (excluding _archive) distributions=$(find "$upstreamdir" -maxdepth 1 -type d ! -name "_archive" ! -path "$upstreamdir" | sort) # Find all .pot files ONLY in man* directories under templates pot_files=$(find "$templatesdir" -type d -name "man?" -exec find {} -name "*.pot" \; 2>/dev/null | LC_ALL=C sort) if [ -z "$pot_files" ]; then echo "No .pot files found in man* directories under $templatesdir" exit 0 fi echo "Checking .pot files in man* directories against upstream manpages..." echo "Templates directory: $templatesdir" echo "Upstream directory: $upstreamdir" echo "" for pot_file in $pot_files; do found_upstream="no" # Get the relative path from templates directory relative_path="${pot_file#$templatesdir/}" # Remove .pot extension to get the manpage name manpage="${relative_path%.pot}" # Check each distribution for the manpage for distribution in $distributions; do dist_name=$(basename "$distribution") upstream_manpage="$upstreamdir/$dist_name/$manpage" if [ -f "$upstream_manpage" ]; then found_upstream="yes" break fi done if [ "$found_upstream" = "no" ]; then echo "No upstream found for: $relative_path" fi done